diff --git a/BuildToolsVersion.txt b/BuildToolsVersion.txt index 103fd2c9d09d..6bb13bc2318b 100644 --- a/BuildToolsVersion.txt +++ b/BuildToolsVersion.txt @@ -1 +1 @@ -2.2.0-preview1-02829-01 +2.2.0-preview1-03013-03 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e408a4912f9..64a65e362dab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set(VM_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/vm) set(GENERATED_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/src/inc) set(GENERATED_EVENTING_DIR ${CMAKE_CURRENT_BINARY_DIR}/eventing) set(VERSION_FILE_PATH "${CMAKE_BINARY_DIR}/version.cpp") +set(PAL_REDEFINES_FILE ${CMAKE_CURRENT_SOURCE_DIR}/src/dlls/mscordac/palredefines.S) set(CORECLR_SET_RPATH ON) if(CORECLR_SET_RPATH) diff --git a/Documentation/botr/clr-abi.md b/Documentation/botr/clr-abi.md index 6f37357742de..ea5a49ed97fb 100644 --- a/Documentation/botr/clr-abi.md +++ b/Documentation/botr/clr-abi.md @@ -603,7 +603,7 @@ JIT32 only generates one epilog (and causes all returns to branch to it) when th # Synchronized Methods -JIT32/RyuJIT only generates one epilog (and causes all returns to branch to it) when a method is synchronized. See `Compiler::fgAddSyncMethodEnterExit()`. The user code is wrapped in a try/finally. Outside/before the try body, the code initializes a boolean to false. `CORINFO_HELP_MON_ENTER` or `CORINFO_HELP_MON_ENTER_STATIC` are called, passing the lock object (the "this" pointer for instance methods or the Type object for static methods) and the address of the boolean. If the lock is acquired, the boolean is set to true (as an 'atomic' operation in the sense that a Thread.Abort/EH/GC/etc. cannot interrupt the Thread when the boolean does not match the arquired state of the lock). JIT32/RyuJIT follows the exact same logic and arguments for placing the call to `CORINFO_HELP_MON_EXIT` / `CORINFO_HELP_MON_EXIT_STATIC` in the finally. +JIT32/RyuJIT only generates one epilog (and causes all returns to branch to it) when a method is synchronized. See `Compiler::fgAddSyncMethodEnterExit()`. The user code is wrapped in a try/finally. Outside/before the try body, the code initializes a boolean to false. `CORINFO_HELP_MON_ENTER` or `CORINFO_HELP_MON_ENTER_STATIC` are called, passing the lock object (the "this" pointer for instance methods or the Type object for static methods) and the address of the boolean. If the lock is acquired, the boolean is set to true (as an 'atomic' operation in the sense that a Thread.Abort/EH/GC/etc. cannot interrupt the Thread when the boolean does not match the acquired state of the lock). JIT32/RyuJIT follows the exact same logic and arguments for placing the call to `CORINFO_HELP_MON_EXIT` / `CORINFO_HELP_MON_EXIT_STATIC` in the finally. # Rejit diff --git a/Documentation/botr/dac-notes.md b/Documentation/botr/dac-notes.md index adeb9a8cee51..bd2aec315eb7 100644 --- a/Documentation/botr/dac-notes.md +++ b/Documentation/botr/dac-notes.md @@ -152,7 +152,7 @@ In addition to pointer types, the DAC must also marshal static and global values The TADDR and PCODE types we introduced in the example of DAC operation are pure target addresses. These are actually integer types, rather than pointers. This prevents code in the host from incorrectly dereferencing them. The DAC does not treat them as pointers either. Specifically, because we have no type or size information no dereferencing or marshalling can occur. We use these primarily in two situations: when we are treating a target address as pure data and when we need to do pointer arithmetic with target addresses (although we can also do pointer arithmetic with PTR types). Of course, because TADDRs have no type information for the target locations they specify, when we perform address arithmetic, we need to factor in the size explicitly. -We also have one special class of PTRs that don't involve marshaling: PTR\_VOID and PTR\_CVOID. These are the target equivalents of void \* and const void \*, respectively. Because TADDRs are simply numbers, they don't have pointer semantics, which means that if we DACize code by converting void \* to TADDR (as was often the case in the past), we often need extra casts and other changes, even in code that does not compile for the DAC. Using PTR\_VOID makes it easier and cleaner to DACize code that uses void \* by preserving the semantics expected for void \*. If we DACize a function that uses PTR\_VOID or PTR\_CVOID, we can't directly marshal data from these addresses, since we have no idea how much data we would need to read. This means we can't dereference them (or even do pointer aritmetic), but this is identical to the semantics of void \*. As is the case for void \*, we generally cast them to a more specific PTR type when we need to use them. We also have a PTR\_BYTE type, which is a standard marshaled target pointer (that supports pointer arithmetic, etc.). In general, when we DACize code, void \* becomes PTR\_VOID and BYTE \* becomes PTR\_BYTE, just as you would expect. [daccess.h][daccess.h] has explanatory comments that provide more details about the use and semantics of the PTR\_VOID type. +We also have one special class of PTRs that don't involve marshaling: PTR\_VOID and PTR\_CVOID. These are the target equivalents of void \* and const void \*, respectively. Because TADDRs are simply numbers, they don't have pointer semantics, which means that if we DACize code by converting void \* to TADDR (as was often the case in the past), we often need extra casts and other changes, even in code that does not compile for the DAC. Using PTR\_VOID makes it easier and cleaner to DACize code that uses void \* by preserving the semantics expected for void \*. If we DACize a function that uses PTR\_VOID or PTR\_CVOID, we can't directly marshal data from these addresses, since we have no idea how much data we would need to read. This means we can't dereference them (or even do pointer arithmetic), but this is identical to the semantics of void \*. As is the case for void \*, we generally cast them to a more specific PTR type when we need to use them. We also have a PTR\_BYTE type, which is a standard marshaled target pointer (that supports pointer arithmetic, etc.). In general, when we DACize code, void \* becomes PTR\_VOID and BYTE \* becomes PTR\_BYTE, just as you would expect. [daccess.h][daccess.h] has explanatory comments that provide more details about the use and semantics of the PTR\_VOID type. Occasionally, legacy code stores a target address in a host pointer type such as void \*. This is always a bug and makes it extremely difficult to reason about the code. It will also break when we support cross-platform, where the pointer types are different sizes). In DAC builds, the void \* type is a host pointer which should never contain a target address. Using PTR\_VOID instead allows us to indicate that a void pointer type is a target address. We are trying to eliminate all such uses, but some are quite pervasive in the code and will take a while to eliminate entirely. diff --git a/Documentation/botr/intro-to-clr.md b/Documentation/botr/intro-to-clr.md index 097f2e30fd49..f713b414d86d 100644 --- a/Documentation/botr/intro-to-clr.md +++ b/Documentation/botr/intro-to-clr.md @@ -53,19 +53,17 @@ It is this dedication to ease of use (which goes hand in hand with simplicity of The runtime has many features, so it is useful to categorize them as follows: -1. Fundamental features – Features that have broad impact on the design of other features. These include: - a. Garbage Collection - b. Memory Safety and Type Safety - c. High level support for programming languages. - -2. Secondary features – Features enabled by the fundamental features that may not be required by many useful programs: - a. Program isolation with AppDomains - b. Program Security and sandboxing - -3. Other Features – Features that all runtime environments need but that do not leverage the fundamental features of the CLR. Instead, they are the result of the desire to create a complete programming environment. Among them are: - a. Versioning - b. Debugging/Profiling - c. Interoperation +1. **Fundamental features** – Features that have broad impact on the design of other features. These include: + 1. Garbage Collection + 2. Memory Safety and Type Safety + 3. High level support for programming languages. +2. **Secondary features** – Features enabled by the fundamental features that may not be required by many useful programs: + 1. Program isolation with AppDomains + 2. Program Security and sandboxing +3. **Other Features** – Features that all runtime environments need but that do not leverage the fundamental features of the CLR. Instead, they are the result of the desire to create a complete programming environment. Among them are: + 1. Versioning + 2. Debugging/Profiling + 3. Interoperation ## The CLR Garbage Collector (GC) diff --git a/Documentation/building/crossgen.md b/Documentation/building/crossgen.md index ff26094214de..cc825b4dde94 100644 --- a/Documentation/building/crossgen.md +++ b/Documentation/building/crossgen.md @@ -55,7 +55,7 @@ Using native images ------------------- Running CrossGen on an assembly creates a "native image" file, with the extension of `.ni.dll` or `.ni.exe`. -You should include the native images in your app, either by replacing the original MSIL assmblies with the native images, or by putting the native images next to the MSIL assemblies. +You should include the native images in your app, either by replacing the original MSIL assemblies with the native images, or by putting the native images next to the MSIL assemblies. When the native images are present, CoreCLR runtime will automatically use it instead of the original MSIL assemblies. Common errors diff --git a/Documentation/building/linux-instructions.md b/Documentation/building/linux-instructions.md index 98222c520d18..86713c198fa0 100644 --- a/Documentation/building/linux-instructions.md +++ b/Documentation/building/linux-instructions.md @@ -38,8 +38,19 @@ In order to get clang-3.9, llvm-3.9 and lldb-3.9 on Ubuntu 14.04, we need to add ~$ wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add - ~$ sudo apt-get update -Note: arm clang has a known issue with CompareExchange (#15074), so for arm you have to use clang-4.0 or higher, the official build uses clang-5.0. - +Note: ARM clang has a known issue with CompareExchange +([#15074](https://github.com/dotnet/coreclr/issues/15074)), so for ARM you must +use clang-4.0 or higher. Moreover, when building with clang-5.0, the +following errors occur: + +``` +coreclr/src/debug/inc/arm/primitives.h:66:1: error: __declspec attribute 'selectany' is + not supported [-Werror,-Wignored-attributes] +``` + +This is fixed in clang-5.0.2, which can be installed from the apt +repository listed below. + For other version of Debian/Ubuntu, please visit http://apt.llvm.org/. Then install the packages you need: @@ -98,9 +109,32 @@ After the build is complete you will be able to find the output in the `bin` fol Build for ARM/Linux =================== -Libunwind-arm requires fixes that are not included in Ubuntu 14.04, yet. The fix allows libunwind-arm not to break when it is ordered to access unaccessible memory locations. +The CI system and official builds use Docker to build ARM for Linux (for example, see the latest build [here](https://ci.dot.net/job/dotnet_coreclr/job/master/job/arm_cross_checked_ubuntu/lastSuccessfulBuild/consoleText)). The Docker container has pre-built rootfs directories containing the required tools. To build this way, do the following: + +* Install Docker, probably Community Edition, on Windows, Mac, or Linux, from https://www.docker.com/. Some useful post-install setup is: + * Linux: add your user to the docker group, this will avoid running docker with `sudo`: + + `sudo usermod -a -G docker` + + * Windows: switch to Linux containers. This can be done by right clicking on the Docker icon in the lower right corner and clicking "Switch to Linux containers". +* Build using the Docker container (this is a `bash` script, for simplicity): + +``` +ROOT=/Users/me/git/coreclr +DOCKER_ARGS="run -i --rm -v ${ROOT}:/mnt/coreclr -w /mnt/coreclr -e ROOTFS_DIR=/crossrootfs/arm -e CAC_ROOTFS_DIR=/crossrootfs/x86 microsoft/dotnet-buildtools-prereqs:ubuntu-14.04-cross-e435274-20180426002420" +docker ${DOCKER_ARGS} /mnt/coreclr/build.sh arm checked cross crosscomponent +docker ${DOCKER_ARGS} /mnt/coreclr/build-test.sh arm checked cross generatelayoutonly +``` + +Make sure you update the `ROOT` environment to point to your git clone of the coreclr repo. + +The current Docker tag being used by the CI can be found in the `getDockerImageName` function in the [netci.groovy](https://github.com/dotnet/coreclr/blob/master/netci.groovy) file. + +Libunwind issue +--------------- +ARM libunwind versions before 1.3 require a fix. The fix allows libunwind not to break when it is ordered to access unaccessible memory locations. See [this](https://github.com/dotnet/coreclr/pull/3923) issue for history. -First, import the patch from the libunwind upstream: http://git.savannah.gnu.org/gitweb/?p=libunwind.git;a=commit;h=770152268807e460184b4152e23aba9c86601090 +If required, first import the patch from the libunwind upstream: http://git.savannah.gnu.org/gitweb/?p=libunwind.git;a=commit;h=770152268807e460184b4152e23aba9c86601090. Then, expand the coverage of the upstream patch by: @@ -124,7 +158,7 @@ index 1ed3dbf..c643032 100644 ``` Additional optimization levels for ARM/Linux: -Oz and -Ofast -============================================================ +------------------------------------------------------------ This instruction is to enable additional optimization levels such as -Oz and -Ofast on ARM/Linux. The below table shows what we have to enable for the code optimization of the CoreCLR run-time either the size or speed on embedded devices. diff --git a/Documentation/building/test-configuration.md b/Documentation/building/test-configuration.md index 931a540adbc6..127495978e6c 100644 --- a/Documentation/building/test-configuration.md +++ b/Documentation/building/test-configuration.md @@ -1,41 +1,54 @@ -## General Test Infrastructure Notes ## +# General Test Infrastructure -### Kinds of Build Properties ### -* Build Only -> `BuildOnly` - - * Builds an executable. - * Will not execute it. +## Test "Kind" +* Build Only + * Builds an executable. + * Will not execute. + * e.g. `BuildOnly` * Run Only -> `RunOnly` + * Can use output of `BuildOnly` or `BuildAndRun` projects with different command line arguments. + * e.g. `RunOnly` +* Build And Run + * Builds an executable. + * Will execute said executable. + * e.g. `BuildAndRun` +* Shared Libraries + * For building libraries common to zero or more tests. + * e.g. `SharedLibrary` - * Can use Ouput of Build and Run Project with different command line arguments. -* Build and Run -> `BuildAndRun` +By default (i.e. if not specified explicitly), test "Kind" is `BuildAndRun`. - * Builds an executable. - * Will execute said executable. -* Shared Libraries -> `SharedLibrary` +## Priority + +Test cases are categorized by priority level. The most important subset should be and is the smallest subset. This subset is called priority 0. - * For building libraries common to zero or more tests. +* By default, a test case is priority 0. Tests must be explicitly de-prioritized. +* Set the priority of a test by setting the property `` in the test's project file. + * e.g. `2` +* Lower priority values are always run in conjunction when running higher priority value tests. + * i.e. if a developer elects to do a priority 2 test run, then all priority 0, 1 and 2 tests are run. +## Adding Test Guidelines -By default (i.e. if not specified explicitly) a project file is BuildAndRun. +* All test source files should include the following banner: +``` + // 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. +``` +* Disable building of a test by conditionally setting the `` property. + * e.g. `true` +* Add NuGet/MyGet references by updating the following [project file](https://github.com/dotnet/coreclr/blob/master/tests/src/Common/test_dependencies/test_dependencies.csproj). +* Build against the `mscorlib` facade by adding `true` to the test project. -### Priority ### -Testcases are categorized by their priority levels. The most important subset should be and is the smallest subset. This subset is called priority 0. - * By default, a testcase is priority 0. You must elect to de-prioritize a test. - * To de-prioritize a test, add a property _CLRTestPriority_ to the test's project file. -> `2` - * Lower priority values are always run in conjunction when running higher priority value tests. I.e. if a developer elects to do a priority 2 test run, then all priority 0, 1 and 2 tests are run. +### Creating a new C# test project -### Adding Tests ### -#### Converting an existing C# project #### - * Remove AssemblyName - * Swap in dir.props - * Swap in dir.targets - * Assign a CLRTestKind - * (optional) Assign a priority value +**TODO** +### Converting an existing C# project + * Remove the `` property + * Import `dir.props` + * Import `dir.targets` + * Assign a `` + * (optional) Assign a priority value \ No newline at end of file diff --git a/Documentation/building/testing-with-corefx.md b/Documentation/building/testing-with-corefx.md index a400d1426f24..b9a98cf01528 100644 --- a/Documentation/building/testing-with-corefx.md +++ b/Documentation/building/testing-with-corefx.md @@ -3,6 +3,7 @@ Testing with CoreFX It may be valuable to use CoreFX tests to validate your changes to CoreCLR or mscorlib. +## Building CoreFX against CoreCLR **NOTE:** The `BUILDTOOLS_OVERRIDE_RUNTIME` property no longer works. To run CoreFX tests with an updated System.Private.Corelib.dll, [use these instructions](https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md#testing-with-private-coreclr-bits). @@ -27,3 +28,108 @@ Use the following instructions to test a change to the dotnet/coreclr repo using [run-corefx-tests.py](https://github.com/dotnet/coreclr/blob/master/tests/scripts/run-corefx-tests.py) will clone dotnet/corefx and run steps 2-4 above automatically. It is primarily intended to be run by the dotnet/coreclr CI system, but it might provide a useful reference or shortcut for individuals running the tests locally. +## Using the built CoreCLR testhost + +Instead of copying CoreCLR binaries you can also test your changes with an existing CoreFX build or CoreCLR's CI assemblies + +### Locally-built CoreFX + +Once you have finished steps 1, 2. and 4. above execute the following instructions to test your local CLR changes with the built-CoreFX changes. + +1. From `` run +`build-test.cmd buildtesthostonly` + +-or- + +`build-test.sh generatetesthostonly` + +to generate the test host. +2. Navigate to `\bin\tests\` and then the test you would like to run +3. Run + +```cmd +\bin\..\testhost\dotnet.exe \bin\tests\\xunit.console.netcore.exe .dll +``` +-or- + +```sh +/bin/../testhost/dotnet /bin/tests//xunit.console.netcore.exe .dll +``` + +followed by any extra command-line arguments. + +For example to run .NET Core Windows tests from System.Collections.Tests with an x64 Release build of CoreCLR. +``` +cd C:\corefx\bin\tests\System.Collections.Tests +C:\coreclr\bin\tests\Windows_NT.x64.Release\testhost\dotnet.exe .\xunit.console.netcore.exe .\System.Collections.Tests.dll -notrait category=nonnetcoretests -notrait category=nonwindowstests +``` + +-or- + +``` +cd ~/corefx/bin/tests/System.Collections.Tests +~/coreclr/bin/tests/Linux.x64.Release/testhost/dotnet .\xunit.console.netcore.exe .\System.Collections.Tests.dll -notrait category=nonnetcoretests -notrait category=nonlinuxtests +``` + +### CI Script +CoreCLR has an alternative way to run CoreFX tests, built for PR CI jobs. + +To run tests against pre-built binaries you can execute the following from the CoreCLR repo root: + +#### Windows +1. `.\build.cmd skiptests` +2. `.\build-test.cmd buildtesthostonly` - generates the test host +3. `.\tests\runtest.cmd corefxtests|corefxtestsall` - runs CoreFX tests + +#### Linux and OSX +1. `./build.sh skiptests` +2. `./build-test.sh generatetesthostonly` +3. `./tests/runtest.sh --corefxtests|--corefxtestsall --testHostDir= --coreclr-src` + +CoreFXTests - runs all tests defined in TopN.Windows.CoreFX.issues.json or the test list specified with the argument `CoreFXTestList` +CoreFXTestsAll - runs all tests available in the test list found at the URL in `.\coreclr\tests\CoreFX\CoreFXTestListURL.txt`. +#### Linux - specific +<path_to_testhost> - path to the coreclr test host built in step 2. +<path_to_coreclr> - path to coreclr source + +### Helix Testing +To use Helix-built binaries, substitute the URL in `.\coreclr\tests\CoreFX\CoreFXTestListURL.txt` with one acquired from a Helix test run and run the commands above. + +#### Workflow +The CoreFX tests CI jobs run against cached test binaries in blob storage. This means that tests might need to be disabled until the test binaries are refreshed as breaking changes are merged in both CoreCLR and CoreFX. If you suspect a test is not failing because of a functional regression, but rather because it's stale you can add it to either the [Windows](https://github.com/dotnet/coreclr/blob/master/tests/CoreFX/TopN.CoreFX.x64.Windows.issues.json) or [Unix](https://github.com/dotnet/coreclr/blob/master/tests/CoreFX/TopN.CoreFX.x64.Unix.issues.json) test exclusion lists. + +#### Test List Format +The tests defined in TopN.Windows.CoreFX.issues.json or the test list specified with the argument `CoreFXTestList` should conform to the following format - +```json + { + "name": "", //e.g. System.Collections.Concurrent.Tests + "enabled": true|false, // Defines whether a test assembly should be run. If set to false any tests with the same name will not be run even if corefxtestsall is specified + "exclusions": { + "namespaces": // Can be null + [ + { + "name": "System.Collections.Concurrent.Tests", // All test methods under this namespace will be skipped + "reason": "" // This should be a link to the GitHub issue describing the problem + } + ] + "classes": // Can be null + [ + { + "name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests", // All test methods in this class will be skipped + "reason": "" + } + ] + "methods": // Can be null + [ + { + "name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests.TestAddNullValue_IDictionary_ReferenceType_null", + "reason": "" + }, + { + "name": "System.Collections.Concurrent.Tests.ConcurrentDictionaryTests.TestAddNullValue_IDictionary_ValueType_null_add", + "reason": "" + } + ] + } + } +``` \ No newline at end of file diff --git a/Documentation/coding-guidelines/clr-jit-coding-conventions.md b/Documentation/coding-guidelines/clr-jit-coding-conventions.md index 0bab27616aae..4873e1f27488 100644 --- a/Documentation/coding-guidelines/clr-jit-coding-conventions.md +++ b/Documentation/coding-guidelines/clr-jit-coding-conventions.md @@ -125,7 +125,8 @@ Note that these conventions are different from the CLR C++ Coding Conventions, d * [15.5.9 Global class objects](#15.5.9) * [15.6 Exceptions](#15.6) * [15.7 Code tuning for performance optimization](#15.7) - * [15.8 Obsoleting functions, classes and macros](#15.8) + * [15.8 Memory allocation](#15.8) + * [15.9 Obsoleting functions, classes and macros](#15.9) # 4 Principles @@ -1938,7 +1939,45 @@ In general, code should be written to be readable first, and optimized for perfo In the case of tight loops and code that has been analyzed to be a performance bottleneck, performance optimizations take a higher priority. Talk to the performance team if in doubt. -## 15.8 Obsoleting functions, classes and macros +## 15.8 Memory allocation + +All memory required during the compilation of a method must be allocated using the `Compiler`'s arena allocator. This allocator takes care of deallocating all the memory when compilation ends, avoiding memory leaks and simplifying memory management. + +However, the use of an arena allocator can increase memory usage and it's worth considering its impact when writing JIT code. Simple code changes can have a significant impact on memory usage, such as hoisting a `std::vector` variable out of a loop: +```c++ +std::vector outer; // same memory gets used for all iterations +for (...) +{ + std::vector inner; // this will allocate memory on every iteration + // and previously allocated memory is simply wasted +} +``` +Node based data structures (e.g linked lists) may benefit from retaining and reusing removed nodes, provided that maintaining free lists doesn't add significant cost. + +The arena allocator should not be used directly. `Compiler::getAllocator(CompMemKind)` returns a `CompAllocator` object that wraps the arena allocator and supports memory usage tracking when `MEASURE_MEM_ALLOC` is enabled. It's best to use a meaningful memory kind (e.g. not `CMK_Generic`) but exceptions can be made for small allocations. `CompAllocator` objects are always pointer sized and can be freely copied and stored (useful to avoid repeated `CompMemKind` references). + +The `new (CompAllocator)` operator should be preferred over `CompAllocator::allocate(size_t)`. The later is intended to be used only when constructors must not be run, such as when allocating arrays for containers like `std::vector`. +```c++ +// typical object allocation +RangeCheck* p = new (compiler->getAllocator(CMK_RangeCheck)) RangeCheck(compiler); +// slightly shorter alternative +RangeCheck* p = new (compiler, CMK_RangeCheck) RangeCheck(compiler); +// allocate an array with default initialized elements +LclVarDsc* p = new (compiler->getAllocator(CMK_LvaTable)) LclVarDsc[lvaCount]; +// use list initialization to zero out an array +unsigned* p = new (compiler->getAllocator(CMK_LvaTable)) unsigned[lvaTrackedCount] { }; +// use CompAllocator::allocate to allocate memory without doing any initialization... +LclVarDsc* p = compiler->getAllocator(CMK_LvaTable).allocate(lvaCount); +// ... and construct elements in place as needed +new (&p[i], jitstd::placement_t()) LclVarDsc(compiler) +``` +Note that certain classes (e.g. `GenTree`) provide their own `new` operator overloads, those should be used instead of the general purpose `new (CompAllocator)` operator. + +`jitstd` container classes accept a `CompAllocator` object by implicit conversion from `CompAllocator` to `jitstd::allocator`. + +Debug/checked code that needs to allocate memory outside of method compilation can use the `HostAllocator` class and the associated `new` operator. This is a normal memory allocator that requires manual memory deallocation. + +## 15.9 Obsoleting functions, classes and macros The Visual C++ compiler has support built in for marking various user defined constructs as deprecated. This functionality is accessed via one of two mechanisms: diff --git a/Documentation/design-docs/code-versioning.md b/Documentation/design-docs/code-versioning.md index 2542c77cb42b..fdf84138718e 100644 --- a/Documentation/design-docs/code-versioning.md +++ b/Documentation/design-docs/code-versioning.md @@ -381,5 +381,5 @@ A few (completely uncommited) thoughts on how this area of the code might evolve - On stack replacement requires that publication not only redirect new method invocations to a new version, but also continued execution of existing method invocations must redirect to a new version. - Performance improvements that utilize more memory / cpu efficient data structures. - Add new build pipeline stage accessible from managed code APIs to do self-modifying code. -- Add new build pipeline stage accesible from out-of-process or maybe runtime managed that could handle hot-patching app deployment scenarios. +- Add new build pipeline stage accessible from out-of-process or maybe runtime managed that could handle hot-patching app deployment scenarios. - Allow for an extensible set of stages rather than the current hard-coded set, perhaps to allow N profilers to all collaboratively edit. Some form of multi-profiler collaboration has long been requested and this seems a fairly powerful (and potentially way too complicated) form. diff --git a/Documentation/design-docs/eh-writethru.md b/Documentation/design-docs/eh-writethru.md index 966a80f1639f..602ac0ba2344 100644 --- a/Documentation/design-docs/eh-writethru.md +++ b/Documentation/design-docs/eh-writethru.md @@ -61,7 +61,7 @@ There are a number of wrinkles informing this design based on how the JIT models - The jit does not model which handlers are reachable from a given protected region, so considers a variable live into a handler if it is live into any handler in the method. -It is posible to do better than the "store every definition" approch outlined +It is posible to do better than the "store every definition" approach outlined in the design, but the expectation is that this would require posibly modifying the model in the JIT and staging more throughput intensive analyses. With these considerations this design was selected and further improvements diff --git a/Documentation/design-docs/first-class-structs.md b/Documentation/design-docs/first-class-structs.md index a461ba572b2b..039db9406a3c 100644 --- a/Documentation/design-docs/first-class-structs.md +++ b/Documentation/design-docs/first-class-structs.md @@ -360,7 +360,7 @@ And Here is the resulting code just prior to code generation: │ ┌──▌ const struct4 0 REG rax $81 └──▌ return struct4 REG NA $140 ``` -Finally, here is the resulting code that we were hoping to acheive: +Finally, here is the resulting code that we were hoping to achieve: ``` xor eax, eax ``` diff --git a/Documentation/design-docs/inline-size-estimates.md b/Documentation/design-docs/inline-size-estimates.md index 12286c7f5d1f..b7a2f16bf924 100644 --- a/Documentation/design-docs/inline-size-estimates.md +++ b/Documentation/design-docs/inline-size-estimates.md @@ -27,7 +27,7 @@ sort of size estimate `CallerSize'`. The simplest estimate is that (1) `CallerSize'` = `CallerSize + CalleeSize` ``` -However, calling conventions impose some addtional code overhead on +However, calling conventions impose some additional code overhead on both the caller and callee. The caller must set up arguments in registers or on the stack, and if there is a return value, might need to move it or store it somewhere. It also might need to spill values @@ -47,7 +47,7 @@ the number and kind of arguments passed from caller to callee. Note that it's entirely possible that `Overhead > CalleeSize`, so that `CallerSize' < CallerSize`, that is the inline not only results -in faster code but also in smaller code. Indeed this state of affars +in faster code but also in smaller code. Indeed this state of affairs is increasingly common with that advent of modern programming styles that emphasize building functionality out of lots of small procedures. @@ -198,7 +198,7 @@ to be practical. Second, even if we could obtain the actual size of prospective inline candidates, we might not want to use this data. The final code sequence emitted by the compiler depends intimately on details of the -target archtecture, runtime conventions (ABIs), and capabilites of the +target architecture, runtime conventions (ABIs), and capabilites of the compiler phases that run after inlining. If we allow feedback into hey heuristics by incorporating data from these "downstream" sources, we introduce various forms of coupling that have important diff --git a/Documentation/project-docs/jit-testing.md b/Documentation/project-docs/jit-testing.md index 63c6a63dd971..bebcf2106eec 100644 --- a/Documentation/project-docs/jit-testing.md +++ b/Documentation/project-docs/jit-testing.md @@ -43,7 +43,7 @@ It seems sensible for Microsoft to focus on opening up the JIT self-host (aka JITSH) tests first. A few other tasks are also Microsoft specific and are marked with (MS) below. -Other than that the priority, task list, and possibly assigments are open to +Other than that the priority, task list, and possibly assignments are open to discussion. ### (MS) Bring up equivalent of the JITSH tests diff --git a/Documentation/workflow/IssuesFeedbackEngagement.md b/Documentation/workflow/IssuesFeedbackEngagement.md index 4346ed90f325..4cd084520078 100644 --- a/Documentation/workflow/IssuesFeedbackEngagement.md +++ b/Documentation/workflow/IssuesFeedbackEngagement.md @@ -20,7 +20,7 @@ in the [.NET Foundation forums](http://forums.dotnetfoundation.org/). For more real-time feedback you can also start a chat session by clicking on the icons below. -[![.NET Slack Status](https://aspnetcoreslack.herokuapp.com/badge.svg?2)](http://tattoocoder.com/aspnet-slack-sign-up/) [![Join the chat at https://gitter.im/dotnet/coreclr](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dotnet/coreclr?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Join the chat at https://gitter.im/dotnet/coreclr](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dotnet/coreclr?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ### Security issues diff --git a/Documentation/workflow/RunningTests.md b/Documentation/workflow/RunningTests.md index 65957f476d95..b7d4d5d16b1a 100644 --- a/Documentation/workflow/RunningTests.md +++ b/Documentation/workflow/RunningTests.md @@ -1,10 +1,42 @@ - # Running .NET Core Tests -TODO - Incomplete. +Details on test metadata can be found in [test-configuration.md](https://github.com/dotnet/coreclr/blob/master/Documentation/building/test-configuration.md). + +## Build All Tests + +1) Build the CoreCLR product + * [Unix](https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md) + * [OSX](https://github.com/dotnet/coreclr/blob/master/Documentation/building/osx-instructions.md) + * [Windows](https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md) +1) From the root directory run the following command: + * Non-Windows - `./build-test.sh` + * Windows - `build-test.cmd` + * Supply `-h` for usage flags + +### Examples + +* Build all tests priority `2` and higher + * `build-test.cmd -priority=2` + +## Build Individual Test + +Note: The CoreCLR must be built prior to building an individual test. See first step for building all tests. + +* Native Test: Build the generated CMake projects + * Projects are auto-generated when the `build-test.sh`/`build-test.cmd` script is run +* Managed Test: Invoke MSBuild on the project directly + * Non-Windows - All of the necessary tools to build are under `coreclr/Tools`. It is possible to use `coreclr/Tools/MSBuild.dll` as you would normally use MSBuild with a few caveats. The `coreclr/Tools/msbuild.sh` script exists to make the call shorter. + * **Note:** Passing `/p:__BuildOs=`[`OSX`|`Linux`] is required. Otherwise the following error will occur: `error MSB4801: The task factory "CodeTaskFactory" could not be loaded because this version of MSBuild does not support it.` + * Windows - Use Visual Studio Developer command prompt -See [Windows Instructions](../building/windows-test-instructions.md) -See [Unix Instructions](../building/unix-test-instructions.md) +### Examples +* Using the `msbuild.sh` script + * `coreclr/Tools/msbuild.sh /maxcpucount coreclr/tests/src/JIT/CodeGenBringUpTests/Array1.csproj /p:__BuildType=Release /p:__BuildOS=OSX` +* Calling `MSBuild.dll` directly + * `coreclr/Tools/dotnetcli/dotnet coreclr/Tools/MSBuild.dll /maxcpucount coreclr/tests/src/JIT/CodeGenBringUpTests/Array1.csproj /p:__BuildType=Release /p:__BuildOS=OSX` +## Additional Documents +* [Windows](https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-test-instructions.md) +* [Non-Windows](https://github.com/dotnet/coreclr/blob/master/Documentation/building/unix-test-instructions.md) \ No newline at end of file diff --git a/DotnetCLIVersion.txt b/DotnetCLIVersion.txt index 56826f464739..5e908d682fad 100644 --- a/DotnetCLIVersion.txt +++ b/DotnetCLIVersion.txt @@ -1 +1 @@ -2.1.300-rtm-008820 +2.1.301 diff --git a/ILAsmVersion.txt b/ILAsmVersion.txt index 08d8e428f9c5..c3a3b91e625d 100644 --- a/ILAsmVersion.txt +++ b/ILAsmVersion.txt @@ -1 +1 @@ -2.2.0-preview1-26529-04 +3.0.0-preview1-26719-01 diff --git a/build-test.cmd b/build-test.cmd index e65cbcacff97..31c5ad385795 100644 --- a/build-test.cmd +++ b/build-test.cmd @@ -46,6 +46,10 @@ set processedArgs= set __unprocessedBuildArgs= set __RunArgs= set __BuildAgainstPackagesArg= +set __BuildAgainstPackagesMsbuildArg= +set __SkipRestorePackages= +set __SkipManaged= +set __SkipNative= set __RuntimeId= set __ZipTests= set __TargetsWindows=1 @@ -56,6 +60,8 @@ set __DoCrossgen= @REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems, @REM and allow the "-priority=1" syntax. set __Priority=0 +set __PriorityArg= +set __PassThroughArg= :Arg_Loop if "%1" == "" goto ArgsDone @@ -74,14 +80,18 @@ if /i "%1" == "release" (set __BuildType=Release&set processedArgs if /i "%1" == "checked" (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) -if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set __BuildAgainstPackagesMsbuildArg=/p:BuildTestsAgainstPackages=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop) if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop) +if /i "%1" == "--" (set __PassThroughArg=%1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if [!processedArgs!]==[] ( set __UnprocessedBuildArgs=%__args% @@ -95,7 +105,7 @@ if [!processedArgs!]==[] ( :ArgsDone @REM Special handling for -priority=N argument. -if %__Priority% GTR 0 (set "__UnprocessedBuildArgs=!__UnprocessedBuildArgs! -priority=%__Priority%") +if %__Priority% GTR 0 (set "__PriorityArg=-priority=%__Priority%") if defined __BuildAgainstPackagesArg ( if not defined __RuntimeID ( @@ -107,6 +117,8 @@ if defined __BuildAgainstPackagesArg ( @if defined _echo @echo on set __RunArgs=-BuildOS=%__BuildOS% -BuildType=%__BuildType% -BuildArch=%__BuildArch% +REM As we move from buildtools to arcade, __RunArgs should be replaced with __msbuildArgs +set __msbuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch% if defined __ToolsetDir ( rem arm64 builds currently use private toolset which has not been released yet @@ -150,6 +162,12 @@ REM === REM ========================================================================================= call "%__ProjectDir%\init-tools.cmd" @if defined _echo @echo on +set "__ToolsDir=%__ProjectDir%\Tools" +set "__DotnetHost=%__ToolsDir%\dotnetcli\dotnet.exe" +if not exist "%__DotnetHost%" ( + echo %__DotnetHost% not found after init-tools. + exit /b 1 +) REM ========================================================================================= REM === @@ -160,6 +178,8 @@ REM ============================================================================ call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir% @if defined _echo @echo on +if defined __SkipNative goto skipnative + REM ========================================================================================= REM === REM === Native test build section @@ -212,7 +232,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% @@ -224,8 +244,7 @@ if errorlevel 1 ( :skipnative set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%" - -if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct +if "%__SkipRestorePackages%" == 1 goto SkipRestoreProduct REM ========================================================================================= REM === REM === Restore product binaries from packages @@ -243,8 +262,9 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% +if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct set __BuildLogRootName=Tests_GenerateRuntimeLayout set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn @@ -253,7 +273,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% +call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo BinPlace of mscorlib.dll failed exit /b 1 @@ -263,7 +283,7 @@ echo %__MsgPrefix% Restored CoreCLR product from packages :SkipRestoreProduct -if defined __SkipManaged exit /b 0 +if defined __SkipManaged goto SkipManagedBuild REM ========================================================================================= REM === @@ -301,7 +321,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do ( set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%";Append=!__AppendToLog! set TestBuildSlice=%%G - call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs% + call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: @@ -316,6 +336,7 @@ for /l %%G in (1, 1, %__BuildLoopCount%) do ( set __AppendToLog=true ) +:SkipManagedBuild REM Prepare the Test Drop REM Cleans any NI from the last run powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force" @@ -344,22 +365,30 @@ if defined __BuildAgainstPackagesArg ( ) ) -echo %__MsgPrefix%Creating test wrappers... +REM ========================================================================================= +REM === +REM === Create the test overlay +REM === +REM ========================================================================================= set RuntimeIdArg= -set TargetsWindowsArg= - if defined __RuntimeId ( set RuntimeIdArg=-RuntimeID="%__RuntimeId%" ) +set TargetsWindowsArg= +set TargetsWindowsMsbuildArg= if "%__TargetsWindows%"=="1" ( set TargetsWindowsArg=-TargetsWindows=true + set TargetsWindowsMsbuildArg=/p:TargetsWindows=true ) else if "%__TargetsWindows%"=="0" ( set TargetsWindowsArg=-TargetsWindows=false + set TargetsWindowsMsbuildArg=/p:TargetsWindows=false ) -set __BuildLogRootName=Tests_XunitWrapper +echo %__MsgPrefix%Creating test overlay... + +set __BuildLogRootName=Tests_Overlay_Managed set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err @@ -367,15 +396,21 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( - echo Xunit Wrapper build failed + echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: + echo %__BuildLog% + echo %__BuildWrn% + echo %__BuildErr% exit /b 1 ) -echo %__MsgPrefix%Creating test overlay... +xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%" -set __BuildLogRootName=Tests_Overlay_Managed +REM Create the test host necessary for running CoreFX tests +REM The test host includes a dotnet executable, system libraries and CoreCLR assemblies found in CoreRoot + +set __BuildLogRootName=Tests_CoreFX_Testhost set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err @@ -383,7 +418,7 @@ set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testHost -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% @@ -392,7 +427,25 @@ if errorlevel 1 ( exit /b 1 ) -xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%" +if defined __SkipManaged goto SkipBuildingWrappers + +echo %__MsgPrefix%Creating test wrappers... + +set __BuildLogRootName=Tests_XunitWrapper +set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log +set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn +set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err +set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%" +set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%" +set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%" + +REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well. +call %__DotnetHost% msbuild %__ProjectDir%\tests\runtest.proj /p:BuildWrappers=true !__msbuildLog! !__msbuildWrn! !__msbuildErr! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesMsbuildArg% %__unprocessedBuildArgs% +if errorlevel 1 ( + echo Xunit Wrapper build failed + exit /b 1 +) +:SkipBuildingWrappers set __CrossgenArg = "" if defined __DoCrossgen ( @@ -422,7 +475,7 @@ REM === Prep test binaries for Helix publishing REM === REM ========================================================================================= -call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs% +call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__PriorityArg% %__PassThroughArg% %__unprocessedBuildArgs% if errorlevel 1 ( echo %__MsgPrefix%Error: build failed. Refer to the build log files for details: echo %__BuildLog% diff --git a/build-test.sh b/build-test.sh index 5339dc1116c7..fd2d8af3d99f 100755 --- a/build-test.sh +++ b/build-test.sh @@ -152,7 +152,7 @@ generate_layout() # === # ========================================================================================= - build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)" + build_Tests_internal "Restore_Packages" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages" if [ -n "$__UpdateInvalidPackagesArg" ]; then __up=-updateinvalidpackageversion @@ -172,7 +172,7 @@ generate_layout() mkdir -p $CORE_ROOT - build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "-testOverlay" "Creating test overlay" + build_Tests_internal "Tests_Overlay_Managed" "${__ProjectDir}/tests/runtest.proj" "Creating test overlay" "-testOverlay" chmod +x $__BinDir/corerun chmod +x $__BinDir/crossgen @@ -180,15 +180,23 @@ generate_layout() # Make sure to copy over the pulled down packages cp -r $__BinDir/* $CORE_ROOT/ > /dev/null - # Work hardcoded path around - if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" ]; then - ln -s "${__BuildToolsDir}/Microsoft.CSharp.Core.targets" "${__BuildToolsDir}/Microsoft.CSharp.Core.Targets" - fi - if [ ! -f "${__BuildToolsDir}/Microsoft.CSharp.targets" ]; then - ln -s "${__BuildToolsDir}/Microsoft.CSharp.Targets" "${__BuildToolsDir}/Microsoft.CSharp.targets" +} + +generate_testhost() +{ + export TEST_HOST=$xUnitTestBinBase/testhost + + if [ -d "${TEST_HOST}" ]; then + rm -rf $TEST_HOST fi + + echo "${__MsgPrefix}Creating test overlay..." + mkdir -p $TEST_HOST + + build_Tests_internal "Tests_Generate_TestHost" "${__ProjectDir}/tests/runtest.proj" "Creating test host" "-testHost" } + build_Tests() { __TestDir=$__ProjectDir/tests @@ -230,15 +238,15 @@ build_Tests() # === # ========================================================================================= - build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" " -BatchRestorePackages" "Restore product binaries (build tests)" + build_Tests_internal "Restore_Product" "${__ProjectDir}/tests/build.proj" "Restore product binaries (build tests)" "-BatchRestorePackages" if [ -n "$__BuildAgainstPackagesArg" ]; then - build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "-BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct" "Restore product binaries (run tests)" + build_Tests_internal "Tests_GenerateRuntimeLayout" "${__ProjectDir}/tests/runtest.proj" "Restore product binaries (run tests)" "-BinPlaceRef" "-BinPlaceProduct" "-CopyCrossgenToProduct" fi echo "Starting the Managed Tests Build..." - build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "$__up" "Managed tests build (build tests)" + build_Tests_internal "Tests_Managed" "$__ProjectDir/tests/build.proj" "Managed tests build (build tests)" "$__up" if [ $? -ne 0 ]; then echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)" @@ -254,7 +262,7 @@ build_Tests() if [ ! -f $__XUnitWrapperBuiltMarker ]; then - build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "-BuildWrappers -MsBuildEventLogging=\" \" " "Test Xunit Wrapper" + build_Tests_internal "Tests_XunitWrapper" "$__ProjectDir/tests/runtest.proj" "Test Xunit Wrapper" "-BuildWrappers" "-MsBuildEventLogging= " "-TargetsWindows=false" if [ $? -ne 0 ]; then echo "${__MsgPrefix}Error: build failed. Refer to the build log files for details (above)" @@ -279,16 +287,19 @@ build_Tests() if [ $__ZipTests -ne 0 ]; then echo "${__MsgPrefix}ZIP tests packages..." - build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" " " "Prep test binaries for Helix publishing" + build_Tests_internal "Helix_Prep" "$__ProjectDir/tests/helixprep.proj" "Prep test binaries for Helix publishing" " " fi } build_Tests_internal() { subDirectoryName=$1 - projectName=$2 - extraBuildParameters=$3 - stepName="$4" + shift + projectName=$1 + shift + stepName="$1" + shift + extraBuildParameters=("$@") # Set up directories and file names __BuildLogRootName=$subDirectoryName @@ -296,6 +307,13 @@ build_Tests_internal() __BuildWrn="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.wrn" __BuildErr="$__LogsDir/${__BuildLogRootName}.${__BuildOS}.${__BuildArch}.${__BuildType}.err" + # Use binclashlogger by default if no other logger is specified + if [[ "${extraBuildParameters[*]}" == *"-MsBuildEventLogging"* ]]; then + msbuildEventLogging="" + else + msbuildEventLogging="-MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\"" + fi + if [[ "$subDirectoryName" == "Tests_Managed" ]]; then # Execute msbuild managed test build in stages - workaround for excessive data retention in MSBuild ConfigCache # See https://github.com/Microsoft/msbuild/issues/2993 @@ -321,12 +339,16 @@ build_Tests_internal() export TestBuildSlice=$slice # Generate build command - buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs" + buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}") + buildArgs+=("$msbuildEventLogging") + buildArgs+=("${extraBuildParameters[@]}") + buildArgs+=("${__RunArgs[@]}") + buildArgs+=("${__UnprocessedBuildArgs[@]}") echo "Building step '$stepName' slice=$slice via $buildCommand" # Invoke MSBuild - eval $buildCommand + "$__ProjectRoot/run.sh" build "${buildArgs[@]}" # Make sure everything is OK if [ $? -ne 0 ]; then @@ -346,15 +368,16 @@ build_Tests_internal() __msbuildErr="\"/flp2:ErrorsOnly;LogFile=${__BuildErr}\"" # Generate build command - buildCommand="$__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog=${__msbuildLog} -MsBuildWrn=${__msbuildWrn} -MsBuildErr=${__msbuildErr} -MsBuildEventLogging=\"/l:BinClashLogger,Tools/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log\" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs" + buildArgs=("-Project=$projectName" "-MsBuildLog=${__msbuildLog}" "-MsBuildWrn=${__msbuildWrn}" "-MsBuildErr=${__msbuildErr}") + buildArgs+=("$msbuildEventLogging") + buildArgs+=("${extraBuildParameters[@]}") + buildArgs+=("${__RunArgs[@]}") + buildArgs+=("${__UnprocessedBuildArgs[@]}") echo "Building step '$stepName' via $buildCommand" # Invoke MSBuild - eval $buildCommand - - # Invoke MSBuild - # $__ProjectRoot/run.sh build -Project=$projectName -MsBuildLog="$__msbuildLog" -MsBuildWrn="$__msbuildWrn" -MsBuildErr="$__msbuildErr" $extraBuildParameters $__RunArgs $__UnprocessedBuildArgs + "$__ProjectRoot/run.sh" build "${buildArgs[@]}" # Make sure everything is OK if [ $? -ne 0 ]; then @@ -384,6 +407,7 @@ usage() echo "verbose - optional argument to enable verbose build output." echo "rebuild - if tests have already been built - rebuild them" echo "generatelayoutonly - only pull down dependencies and build coreroot" + echo "generatetesthostonly - only pull down dependencies and build coreroot and the CoreFX testhost" echo "buildagainstpackages - pull down and build using packages." echo "runtests - run tests after building them" echo "ziptests - zips CoreCLR tests & Core_Root for a Helix run" @@ -507,8 +531,9 @@ __ZipTests=0 __NativeTestIntermediatesDir= __RunTests=0 __RebuildTests=0 -__BuildTestWrappers=0 +__BuildTestWrappers=1 __GenerateLayoutOnly= +__GenerateTestHostOnly= __priority1= CORE_ROOT= @@ -640,7 +665,9 @@ while :; do generatelayoutonly) __GenerateLayoutOnly=1 ;; - + generatetesthostonly) + __GenerateTestHostOnly=1 + ;; buildagainstpackages) __BuildAgainstPackagesArg=1 ;; @@ -666,10 +693,10 @@ while :; do ;; priority1) __priority1=1 - __UnprocessedBuildArgs="$__UnprocessedBuildArgs -priority=1" + __UnprocessedBuildArgs+=("-priority=1") ;; *) - __UnprocessedBuildArgs="$__UnprocessedBuildArgs $1" + __UnprocessedBuildArgs+=("$1") ;; esac @@ -677,12 +704,12 @@ while :; do done -__RunArgs="-BuildArch=$__BuildArch -BuildType=$__BuildType -BuildOS=$__BuildOS" +__RunArgs=("-BuildArch=$__BuildArch" "-BuildType=$__BuildType" "-BuildOS=$__BuildOS") # Configure environment if we are doing a verbose build if [ $__VerboseBuild == 1 ]; then export VERBOSE=1 - __RunArgs="$__RunArgs -verbose" + __RunArgs+=("-verbose") fi # Set default clang version @@ -727,7 +754,7 @@ __CrossgenExe="$__CrossComponentBinDir/crossgen" isMSBuildOnNETCoreSupported -# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to set. +# CI_SPECIFIC - On CI machines, $HOME may not be set. In such a case, create a subfolder and set the variable to it. # This is needed by CLI to function. if [ -z "$HOME" ]; then if [ ! -d "$__ProjectDir/temp_home" ]; then @@ -740,15 +767,22 @@ fi # Specify path to be set for CMAKE_INSTALL_PREFIX. # This is where all built CoreClr libraries will copied to. export __CMakeBinDir="$__BinDir" +if [ [ ! -d "$__BinDir" ] || [ ! -d "$__BinDir/bin" ] ]; then + if [ [ -z "$__GenerateLayoutOnly" ] && [ -z "$__GenerateTestHostOnly" ] ]; then -if [ ! -d "$__BinDir" ] || [ ! -d "$__BinDir/bin" ]; then - - echo "Cannot find build directory for the CoreCLR Product or native tests." - echo "Please make sure CoreCLR and native tests are built before building managed tests." - echo "Example use: './build.sh $__BuildArch $__BuildType' without -skiptests switch" + echo "Cannot find build directory for the CoreCLR native tests." + echo "Please make sure native tests are built before building managed tests." + echo "Example use: './build.sh $__BuildArch $__BuildType' without -skiptests switch" + else + echo "Cannot find build directory for the CoreCLR Product." + echo "Please make sure CoreCLR and native tests are built before building managed tests." + echo "Example use: './build.sh $__BuildArch $__BuildType' " + fi exit 1 fi + + # Configure environment if we are doing a cross compile. if [ $__CrossBuild == 1 ]; then export CROSSCOMPILE=1 @@ -765,12 +799,17 @@ initTargetDistroRid __CoreClrVersion=1.1.0 __sharedFxDir=$__BuildToolsDir/dotnetcli/shared/Microsoft.NETCore.App/$__CoreClrVersion/ -echo "Building Tests..." -if [ -z "$__GenerateLayoutOnly" ]; then +if [[ (-z "$__GenerateLayoutOnly") && (-z "$__GenerateTestHostOnly") ]]; then + echo "Building Tests..." build_Tests else + echo "Generating test layout..." generate_layout + if [ ! -z "$__GenerateTestHostOnly" ]; then + echo "Generating test host..." + generate_testhost + fi fi if [ $? -ne 0 ]; then diff --git a/build.cmd b/build.cmd index bdeebc5875bf..ebc789bcc2fd 100644 --- a/build.cmd +++ b/build.cmd @@ -92,6 +92,7 @@ set __BuildNative=1 set __BuildTests=1 set __BuildPackages=1 set __BuildNativeCoreLib=1 +set __BuildManagedTools=1 set __RestoreOptData=1 set __GenerateLayout=0 set __CrossgenAltJit= @@ -154,12 +155,12 @@ if [!__PassThroughArgs!]==[] ( set __PassThroughArgs=%__PassThroughArgs% %1 ) -if /i "%1" == "-freebsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=FreeBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-linuxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=Linux&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-netbsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=NetBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-osxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=OSX&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-windowsmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=Windows_NT&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "-nativemscorlib" (set __BuildNativeCoreLib=1&set __BuildCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-freebsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=FreeBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-linuxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=Linux&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-netbsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=NetBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-osxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=OSX&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-windowsmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=Windows_NT&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "-nativemscorlib" (set __BuildNativeCoreLib=1&set __BuildCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-configureonly" (set __ConfigureOnly=1&set __BuildNative=1&set __BuildNativeCoreLib=0&set __BuildCoreLib=0&set __BuildTests=0&set __BuildPackages=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "-skipmscorlib" (set __BuildCoreLib=0&set __BuildNativeCoreLib=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -177,12 +178,12 @@ if /i "%1" == "-crossgenaltjit" (set __CrossgenAltJit=%2&set processedArgs= REM TODO these are deprecated remove them eventually REM don't add more, use the - syntax instead -if /i "%1" == "freebsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=FreeBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "linuxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=Linux&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "netbsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=NetBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "osxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=OSX&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "windowsmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildOS=Windows_NT&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) -if /i "%1" == "nativemscorlib" (set __BuildNativeCoreLib=1&set __BuildCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "freebsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=FreeBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "linuxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=Linux&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "netbsdmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=NetBSD&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "osxmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=OSX&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "windowsmscorlib" (set __BuildSOS=0&set __BuildNativeCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set __BuildOS=Windows_NT&set __SkipNugetPackage=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) +if /i "%1" == "nativemscorlib" (set __BuildNativeCoreLib=1&set __BuildCoreLib=0&set __BuildNative=0&set __BuildTests=0&set __BuildPackages=0&set __BuildManagedTools=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __BuildNative=1&set __BuildNativeCoreLib=0&set __BuildCoreLib=0&set __BuildTests=0&set __BuildPackages=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "skipconfigure" (set __SkipConfigure=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) if /i "%1" == "skipmscorlib" (set __BuildCoreLib=0&set __BuildNativeCoreLib=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop) @@ -593,6 +594,10 @@ if %__BuildCoreLib% EQU 1 ( set __ExtraBuildArgs=!__ExtraBuildArgs! -SkipSOS=true ) + if "%__BuildManagedTools%" == "1" ( + set __ExtraBuildArgs=!__ExtraBuildArgs! -BuildManagedTools=true + ) + if /i "%__BuildArch%" == "arm64" ( set __nugetBuildArgs=-buildNugetPackage=false ) else if "%__SkipNugetPackage%" == "1" ( diff --git a/build.proj b/build.proj index 1a633a65b46e..3af8010944aa 100644 --- a/build.proj +++ b/build.proj @@ -24,6 +24,7 @@ + - 2.2.0 + 3.0.0 false @@ -23,20 +23,19 @@ - cf1dffdd938ec543cdfcdebedddc67d7eb1eb3a5 - cf1dffdd938ec543cdfcdebedddc67d7eb1eb3a5 - 8f0c0873424c5a15f04a0d36f68aae89eba38093 - cf1dffdd938ec543cdfcdebedddc67d7eb1eb3a5 + 300cfdc6d48406c1e70032cfd6754e81a1e31b1d + cd6277062ffecc4b34f590d29dfeac5004e9b58f + d60645ab29d840336360335dfc84e3b055dd6d9d + cfff11f63cd6c206d533dcd5714de8cebfdc3886 - 4.6.0-preview1-26529-04 - 2.2.0-preview1-26529-04 - 99.99.99-master-20180529-0053 - 2.2.0-preview1-26529-04 - 2.2.0-beta2-build3300 - 1.0.2-prerelease-00177 + 4.6.0-preview1-26717-04 + 3.0.0-preview1-26717-04 + 99.99.99-master-20180718-0214 + 3.0.0-preview1-26719-01 + 2.4.0-beta.2.build4010 1.0.0-beta-build0015 2.0.4 2.2.0 @@ -51,7 +50,7 @@ Microsoft.DotNet.Build.Tasks.Feed - 2.2.0-preview1-02829-01 + 2.2.0-preview1-03013-03 @@ -137,6 +136,7 @@ + @@ -163,10 +163,6 @@ $(XunitPerformanceApiPackageVersion) - - $(XunitConsoleNetcorePackageVersion) - - %(Identity) true diff --git a/dir.common.props b/dir.common.props new file mode 100644 index 000000000000..f94528972e90 --- /dev/null +++ b/dir.common.props @@ -0,0 +1,36 @@ + + + + + + $(MSBuildThisFileDirectory) + $(CoreclrDir)/packages + + + + + $(__BuildArch) + x64 + x64 + + $(__BuildType) + Debug + Debug + Release + Checked + + $(__BuildOS) + Windows_NT + + $(BuildType) + $(BuildArch) + + + + $(PackagesDir) + + + + diff --git a/dir.props b/dir.props index 1b3329f8e173..ad66a0b8fa42 100644 --- a/dir.props +++ b/dir.props @@ -2,6 +2,8 @@ + + @@ -42,18 +44,6 @@ - - $(__BuildArch) - x64 - x64 - - Debug - Debug - Release - Checked - - $(__BuildOS) - Windows_NT $(__ProjectDir)\ $(MSBuildThisFileDirectory) diff --git a/functions.cmake b/functions.cmake index c2286839dd3f..d86844591078 100644 --- a/functions.cmake +++ b/functions.cmake @@ -107,6 +107,27 @@ function(generate_exports_file) PROPERTIES GENERATED TRUE) endfunction() +function(generate_exports_file_prefix inputFilename outputFilename prefix) + + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(AWK_SCRIPT generateexportedsymbols.awk) + else() + set(AWK_SCRIPT generateversionscript.awk) + if (NOT ${prefix} STREQUAL "") + set(AWK_VARS ${AWK_VARS} -v prefix=${prefix}) + endif() + endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) + + add_custom_command( + OUTPUT ${outputFilename} + COMMAND ${AWK} -f ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} ${AWK_VARS} ${inputFilename} >${outputFilename} + DEPENDS ${inputFilename} ${CMAKE_SOURCE_DIR}/${AWK_SCRIPT} + COMMENT "Generating exports file ${outputFilename}" + ) + set_source_files_properties(${outputFilename} + PROPERTIES GENERATED TRUE) +endfunction() + function(add_precompiled_header header cppFile targetSources) if(MSVC) set(precompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/stdafx.pch") diff --git a/generateexportedsymbols.awk b/generateexportedsymbols.awk index 1d9b200d2361..120897fa378d 100644 --- a/generateexportedsymbols.awk +++ b/generateexportedsymbols.awk @@ -1,11 +1,12 @@ { - # Remove the CR character in case the sources are mapped from - # a Windows share and contain CRLF line endings - gsub(/\r/,"", $0); + # Remove the CR character in case the sources are mapped from + # a Windows share and contain CRLF line endings + gsub(/\r/,"", $0); - # Skip empty lines and comment lines starting with semicolon - if (NF && !match($0, /^[:space:]*;/)) - { - print "_" $0; - } + # Skip empty lines and comment lines starting with semicolon + if (NF && !match($0, /^[:space:]*;/)) + { + gsub(/^#/,"", $0); + print "_" $0; + } } diff --git a/generateredefinesfile.awk b/generateredefinesfile.awk new file mode 100644 index 000000000000..592c19a5dd8a --- /dev/null +++ b/generateredefinesfile.awk @@ -0,0 +1,22 @@ +# "jump" is the jump instruction for the platform +# "prefix1" is the prefix of what is being mapped from +# "prefix2" is the prefix of what is being mapped to +{ + # Remove the CR character in case the sources are mapped from + # a Windows share and contain CRLF line endings + gsub(/\r/,"", $0); + + # Skip empty lines and comment lines starting with semicolon + if (NF && !match($0, /^[:space:]*;/)) + { + # Only process the entries that begin with "#" + if (match($0, /^#.*/)) + { + gsub(/^#/,"", $0); + print "LEAF_ENTRY " prefix1 $0 ", _TEXT" + print " " jump " EXTERNAL_C_FUNC(" prefix2 $0 ")" + print "LEAF_END " prefix1 $0 ", _TEXT" + print "" + } + } +} diff --git a/generateversionscript.awk b/generateversionscript.awk index 226c6a545fb7..7efc537325aa 100644 --- a/generateversionscript.awk +++ b/generateversionscript.awk @@ -1,19 +1,28 @@ BEGIN { - print "V1.0 {"; - print " global:"; + print "V1.0 {"; + print " global:"; } { - # Remove the CR character in case the sources are mapped from - # a Windows share and contain CRLF line endings - gsub(/\r/,"", $0); + # Remove the CR character in case the sources are mapped from + # a Windows share and contain CRLF line endings + gsub(/\r/,"", $0); - # Skip empty lines and comment lines starting with semicolon - if (NF && !match($0, /^[ \t]*;/)) + # Skip empty lines and comment lines starting with semicolon + if (NF && !match($0, /^[ \t]*;/)) + { + # Only prefix the entries that start with "#" + if (match($0, /^#.*/)) { - print " " $0 ";"; + gsub(/^#/,"", $0); + print " "prefix $0 ";"; } + else + { + print " "$0 ";"; + } + } } END { - print " local: *;" - print "};"; + print " local: *;" + print "};"; } diff --git a/init-tools.sh b/init-tools.sh index 16c202cf2fff..2adec1a64b0b 100755 --- a/init-tools.sh +++ b/init-tools.sh @@ -111,8 +111,8 @@ if [ ! -e "$__DOTNET_PATH" ]; then __PKG_RID=linux ;; esac - - __DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-$__PKG_RID-$__PKG_ARCH + __PKG_RID=$__PKG_RID-$__PKG_ARCH + __DOTNET_PKG=dotnet-sdk-${__DOTNET_TOOLS_VERSION}-$__PKG_RID fi mkdir -p "$__DOTNET_PATH" @@ -152,7 +152,7 @@ if [ ! -e "$__BUILD_TOOLS_PATH" ]; then fi if [ -z "${__ILASM_RID-}" ]; then - __ILASM_RID=$__PKG_RID-$__PKG_ARCH + __ILASM_RID=$__PKG_RID fi echo "Using RID $__ILASM_RID for BuildTools native tools" @@ -182,7 +182,7 @@ echo "Making all .sh files executable under Tools." ls "$__scriptpath/Tools/"*.sh | xargs chmod +x ls "$__scriptpath/Tools/scripts/docker/"*.sh | xargs chmod +x -"$__scriptpath/Tools/crossgen.sh" "$__scriptpath/Tools" +"$__scriptpath/Tools/crossgen.sh" "$__scriptpath/Tools" $__PKG_RID mkdir -p "$(dirname "$__BUILD_TOOLS_SEMAPHORE")" && touch "$__BUILD_TOOLS_SEMAPHORE" diff --git a/netci.groovy b/netci.groovy index 47b3b6f52b83..5ec6b4c16930 100755 --- a/netci.groovy +++ b/netci.groovy @@ -68,75 +68,82 @@ class Constants { // need to be set to actually enable that stress mode. The key of the map is the stress mode and // the values are the environment variables def static jitStressModeScenarios = [ - 'minopts' : ['COMPlus_JITMinOpts' : '1'], - 'tieredcompilation' : ['COMPlus_EXPERIMENTAL_TieredCompilation' : '1'], - 'forcerelocs' : ['COMPlus_ForceRelocs' : '1'], - 'jitstress1' : ['COMPlus_JitStress' : '1'], - 'jitstress2' : ['COMPlus_JitStress' : '2'], - 'jitstressregs1' : ['COMPlus_JitStressRegs' : '1'], - 'jitstressregs2' : ['COMPlus_JitStressRegs' : '2'], - 'jitstressregs3' : ['COMPlus_JitStressRegs' : '3'], - 'jitstressregs4' : ['COMPlus_JitStressRegs' : '4'], - 'jitstressregs8' : ['COMPlus_JitStressRegs' : '8'], - 'jitstressregs0x10' : ['COMPlus_JitStressRegs' : '0x10'], - 'jitstressregs0x80' : ['COMPlus_JitStressRegs' : '0x80'], - 'jitstressregs0x1000' : ['COMPlus_JitStressRegs' : '0x1000'], - 'jitstress2_jitstressregs1' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '1'], - 'jitstress2_jitstressregs2' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '2'], - 'jitstress2_jitstressregs3' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '3'], - 'jitstress2_jitstressregs4' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '4'], - 'jitstress2_jitstressregs8' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '8'], - 'jitstress2_jitstressregs0x10' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x10'], - 'jitstress2_jitstressregs0x80' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x80'], - 'jitstress2_jitstressregs0x1000' : ['COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x1000'], - 'tailcallstress' : ['COMPlus_TailcallStress' : '1'], - 'jitsse2only' : ['COMPlus_EnableAVX' : '0', 'COMPlus_EnableSSE3_4' : '0'], - 'jitnosimd' : ['COMPlus_FeatureSIMD' : '0'], - 'jitincompletehwintrinsic' : ['COMPlus_EnableIncompleteISAClass' : '1'], - 'jitx86hwintrinsicnoavx' : ['COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX' : '0'], // testing the legacy SSE encoding - 'jitx86hwintrinsicnoavx2' : ['COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX2' : '0'], // testing SNB/IVB - 'jitx86hwintrinsicnosimd' : ['COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_FeatureSIMD' : '0'], // match "jitnosimd", may need to remove after decoupling HW intrinsic from FeatureSIMD - 'jitnox86hwintrinsic' : ['COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableSSE' : '0' , 'COMPlus_EnableSSE2' : '0' , 'COMPlus_EnableSSE3' : '0' , 'COMPlus_EnableSSSE3' : '0' , 'COMPlus_EnableSSE41' : '0' , 'COMPlus_EnableSSE42' : '0' , 'COMPlus_EnableAVX' : '0' , 'COMPlus_EnableAVX2' : '0' , 'COMPlus_EnableAES' : '0' , 'COMPlus_EnableBMI1' : '0' , 'COMPlus_EnableBMI2' : '0' , 'COMPlus_EnableFMA' : '0' , 'COMPlus_EnableLZCNT' : '0' , 'COMPlus_EnablePCLMULQDQ' : '0' , 'COMPlus_EnablePOPCNT' : '0'], - 'corefx_baseline' : [ : ], // corefx baseline - 'corefx_minopts' : ['COMPlus_JITMinOpts' : '1'], - 'corefx_tieredcompilation' : ['COMPlus_EXPERIMENTAL_TieredCompilation' : '1'], - 'corefx_jitstress1' : ['COMPlus_JitStress' : '1'], - 'corefx_jitstress2' : ['COMPlus_JitStress' : '2'], - 'corefx_jitstressregs1' : ['COMPlus_JitStressRegs' : '1'], - 'corefx_jitstressregs2' : ['COMPlus_JitStressRegs' : '2'], - 'corefx_jitstressregs3' : ['COMPlus_JitStressRegs' : '3'], - 'corefx_jitstressregs4' : ['COMPlus_JitStressRegs' : '4'], - 'corefx_jitstressregs8' : ['COMPlus_JitStressRegs' : '8'], - 'corefx_jitstressregs0x10' : ['COMPlus_JitStressRegs' : '0x10'], - 'corefx_jitstressregs0x80' : ['COMPlus_JitStressRegs' : '0x80'], - 'corefx_jitstressregs0x1000' : ['COMPlus_JitStressRegs' : '0x1000'], - 'gcstress0x3' : ['COMPlus_GCStress' : '0x3'], - 'gcstress0xc' : ['COMPlus_GCStress' : '0xC'], - 'zapdisable' : ['COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'], - 'heapverify1' : ['COMPlus_HeapVerify' : '1'], - 'gcstress0xc_zapdisable' : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'], - 'gcstress0xc_zapdisable_jitstress2' : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_JitStress' : '2'], - 'gcstress0xc_zapdisable_heapverify1' : ['COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_HeapVerify' : '1'], - 'gcstress0xc_jitstress1' : ['COMPlus_GCStress' : '0xC', 'COMPlus_JitStress' : '1'], - 'gcstress0xc_jitstress2' : ['COMPlus_GCStress' : '0xC', 'COMPlus_JitStress' : '2'], - 'gcstress0xc_minopts_heapverify1' : ['COMPlus_GCStress' : '0xC', 'COMPlus_JITMinOpts' : '1', 'COMPlus_HeapVerify' : '1'] + 'minopts' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JITMinOpts' : '1'], + 'tieredcompilation' : ['COMPlus_TieredCompilation' : '1'], // this can be removed once tiered compilation is on by default + 'no_tiered_compilation' : ['COMPlus_TieredCompilation' : '0'], + 'no_tiered_compilation_innerloop': ['COMPlus_TieredCompilation' : '0'], + 'forcerelocs' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_ForceRelocs' : '1'], + 'jitstress1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '1'], + 'jitstress2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2'], + 'jitstress1_tiered' : ['COMPlus_TieredCompilation' : '1', 'COMPlus_JitStress' : '1'], + 'jitstress2_tiered' : ['COMPlus_TieredCompilation' : '1', 'COMPlus_JitStress' : '2'], + 'jitstressregs1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '1'], + 'jitstressregs2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '2'], + 'jitstressregs3' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '3'], + 'jitstressregs4' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '4'], + 'jitstressregs8' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '8'], + 'jitstressregs0x10' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x10'], + 'jitstressregs0x80' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x80'], + 'jitstressregs0x1000' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x1000'], + 'jitstress2_jitstressregs1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '1'], + 'jitstress2_jitstressregs2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '2'], + 'jitstress2_jitstressregs3' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '3'], + 'jitstress2_jitstressregs4' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '4'], + 'jitstress2_jitstressregs8' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '8'], + 'jitstress2_jitstressregs0x10' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x10'], + 'jitstress2_jitstressregs0x80' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x80'], + 'jitstress2_jitstressregs0x1000' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2', 'COMPlus_JitStressRegs' : '0x1000'], + 'tailcallstress' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_TailcallStress' : '1'], + 'jitsse2only' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableAVX' : '0', 'COMPlus_EnableSSE3_4' : '0'], + 'jitnosimd' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_FeatureSIMD' : '0'], + 'jitincompletehwintrinsic' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1'], + 'jitx86hwintrinsicnoavx' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX' : '0'], // testing the legacy SSE encoding + 'jitx86hwintrinsicnoavx2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableAVX2' : '0'], // testing SNB/IVB + 'jitx86hwintrinsicnosimd' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_FeatureSIMD' : '0'], // match "jitnosimd", may need to remove after decoupling HW intrinsic from FeatureSIMD + 'jitnox86hwintrinsic' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_EnableIncompleteISAClass' : '1', 'COMPlus_EnableSSE' : '0' , 'COMPlus_EnableSSE2' : '0' , 'COMPlus_EnableSSE3' : '0' , 'COMPlus_EnableSSSE3' : '0' , 'COMPlus_EnableSSE41' : '0' , 'COMPlus_EnableSSE42' : '0' , 'COMPlus_EnableAVX' : '0' , 'COMPlus_EnableAVX2' : '0' , 'COMPlus_EnableAES' : '0' , 'COMPlus_EnableBMI1' : '0' , 'COMPlus_EnableBMI2' : '0' , 'COMPlus_EnableFMA' : '0' , 'COMPlus_EnableLZCNT' : '0' , 'COMPlus_EnablePCLMULQDQ' : '0' , 'COMPlus_EnablePOPCNT' : '0'], + 'corefx_baseline' : ['COMPlus_TieredCompilation' : '0'], // corefx baseline + 'corefx_minopts' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JITMinOpts' : '1'], + 'corefx_tieredcompilation' : ['COMPlus_TieredCompilation' : '1'], // this can be removed once tiered compilation is on by default + 'corefx_jitstress1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '1'], + 'corefx_jitstress2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStress' : '2'], + 'corefx_jitstressregs1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '1'], + 'corefx_jitstressregs2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '2'], + 'corefx_jitstressregs3' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '3'], + 'corefx_jitstressregs4' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '4'], + 'corefx_jitstressregs8' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '8'], + 'corefx_jitstressregs0x10' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x10'], + 'corefx_jitstressregs0x80' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x80'], + 'corefx_jitstressregs0x1000' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_JitStressRegs' : '0x1000'], + 'gcstress0x3' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0x3'], + 'gcstress0xc' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC'], + 'zapdisable' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'], + 'heapverify1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_HeapVerify' : '1'], + 'gcstress0xc_zapdisable' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0'], + 'gcstress0xc_zapdisable_jitstress2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_JitStress' : '2'], + 'gcstress0xc_zapdisable_heapverify1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_ZapDisable' : '1', 'COMPlus_ReadyToRun' : '0', 'COMPlus_HeapVerify' : '1'], + 'gcstress0xc_jitstress1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JitStress' : '1'], + 'gcstress0xc_jitstress2' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JitStress' : '2'], + 'gcstress0xc_minopts_heapverify1' : ['COMPlus_TieredCompilation' : '0', 'COMPlus_GCStress' : '0xC', 'COMPlus_JITMinOpts' : '1', 'COMPlus_HeapVerify' : '1'] ] // This is a set of ReadyToRun stress scenarios def static r2rStressScenarios = [ - 'r2r_jitstress1' : ["COMPlus_JitStress": "1"], - 'r2r_jitstress2' : ["COMPlus_JitStress": "2"], - 'r2r_jitstressregs1' : ["COMPlus_JitStressRegs": "1"], - 'r2r_jitstressregs2' : ["COMPlus_JitStressRegs": "2"], - 'r2r_jitstressregs3' : ["COMPlus_JitStressRegs": "3"], - 'r2r_jitstressregs4' : ["COMPlus_JitStressRegs": "4"], - 'r2r_jitstressregs8' : ["COMPlus_JitStressRegs": "8"], - 'r2r_jitstressregs0x10' : ["COMPlus_JitStressRegs": "0x10"], - 'r2r_jitstressregs0x80' : ["COMPlus_JitStressRegs": "0x80"], - 'r2r_jitstressregs0x1000' : ["COMPlus_JitStressRegs": "0x1000"], - 'r2r_jitminopts' : ["COMPlus_JITMinOpts": "1"], - 'r2r_jitforcerelocs' : ["COMPlus_ForceRelocs": "1"], - 'r2r_gcstress15' : ["COMPlus_GCStress": "0xF"] + 'r2r_jitstress1' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStress": "1"], + 'r2r_jitstress2' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStress": "2"], + 'r2r_jitstress1_tiered' : ['COMPlus_TieredCompilation' : '1', "COMPlus_JitStress": "1"], + 'r2r_jitstress2_tiered' : ['COMPlus_TieredCompilation' : '1', "COMPlus_JitStress": "2"], + 'r2r_jitstressregs1' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "1"], + 'r2r_jitstressregs2' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "2"], + 'r2r_jitstressregs3' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "3"], + 'r2r_jitstressregs4' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "4"], + 'r2r_jitstressregs8' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "8"], + 'r2r_jitstressregs0x10' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x10"], + 'r2r_jitstressregs0x80' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x80"], + 'r2r_jitstressregs0x1000' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JitStressRegs": "0x1000"], + 'r2r_jitminopts' : ['COMPlus_TieredCompilation' : '0', "COMPlus_JITMinOpts": "1"], + 'r2r_jitforcerelocs' : ['COMPlus_TieredCompilation' : '0', "COMPlus_ForceRelocs": "1"], + 'r2r_gcstress15' : ['COMPlus_TieredCompilation' : '0', "COMPlus_GCStress": "0xF"], + 'r2r_no_tiered_compilation' : ['COMPlus_TieredCompilation' : '0'], ] // This is the basic set of scenarios @@ -151,7 +158,8 @@ class Constants { // 'jitdiff', // jitdiff is currently disabled, until someone spends the effort to make it fully work 'standalone_gc', 'gc_reliability_framework', - 'illink'] + 'illink', + 'corefx_innerloop'] def static allScenarios = basicScenarios + r2rStressScenarios.keySet() + jitStressModeScenarios.keySet() @@ -236,6 +244,8 @@ class Constants { // 'illink' 'r2r_jitstress1': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'r2r_jitstress2': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], + 'r2r_jitstress1_tiered': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], + 'r2r_jitstress2_tiered': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'r2r_jitstressregs1': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'r2r_jitstressregs2': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'r2r_jitstressregs3': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], @@ -247,11 +257,16 @@ class Constants { 'r2r_jitminopts': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE", "MINOPTS_FAIL", "MINOPTS_EXCLUDE"], 'r2r_jitforcerelocs': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'r2r_gcstress15': ["R2R_FAIL", "R2R_EXCLUDE", "JITSTRESS_FAIL", "JITSTRESS_EXCLUDE", "GCSTRESS_FAIL", "GCSTRESS_EXCLUDE"], + 'r2r_no_tiered_compilation': ["R2R_FAIL", "R2R_EXCLUDE"], 'minopts': ["MINOPTS_FAIL", "MINOPTS_EXCLUDE"], 'tieredcompilation': [], + 'no_tiered_compilation': [], + 'no_tiered_compilation_innerloop': [], 'forcerelocs': [], 'jitstress1': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'jitstress2': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], + 'jitstress1_tiered': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], + 'jitstress2_tiered': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'jitstressregs1': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'jitstressregs2': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], 'jitstressregs3': ["JITSTRESS_FAIL", "JITSTRESS_EXCLUDE"], @@ -339,6 +354,8 @@ class Constants { // 'illink' 'r2r_jitstress1', 'r2r_jitstress2', + 'r2r_jitstress1_tiered', + 'r2r_jitstress2_tiered', 'r2r_jitstressregs1', 'r2r_jitstressregs2', 'r2r_jitstressregs3', @@ -350,11 +367,16 @@ class Constants { 'r2r_jitminopts', 'r2r_jitforcerelocs', 'r2r_gcstress15', + 'r2r_no_tiered_compilation', 'minopts', 'tieredcompilation', + 'no_tiered_compilation', + 'no_tiered_compilation_innerloop', 'forcerelocs', 'jitstress1', 'jitstress2', + 'jitstress1_tiered', + 'jitstress2_tiered', 'jitstressregs1', 'jitstressregs2', 'jitstressregs3', @@ -373,7 +395,90 @@ class Constants { 'jitstress2_jitstressregs0x1000', 'tailcallstress', // 'jitsse2only' // Only relevant to xarch - // 'jitnosimd' + // 'jitnosimd' // Only interesting on platforms where SIMD support exists. + // 'jitincompletehwintrinsic' + // 'jitx86hwintrinsicnoavx' + // 'jitx86hwintrinsicnoavx2' + // 'jitx86hwintrinsicnosimd' + // 'jitnox86hwintrinsic' + 'corefx_baseline', + 'corefx_minopts', + 'corefx_tieredcompilation', + 'corefx_jitstress1', + 'corefx_jitstress2', + 'corefx_jitstressregs1', + 'corefx_jitstressregs2', + 'corefx_jitstressregs3', + 'corefx_jitstressregs4', + 'corefx_jitstressregs8', + 'corefx_jitstressregs0x10', + 'corefx_jitstressregs0x80', + 'corefx_jitstressregs0x1000', + 'gcstress0x3', + 'gcstress0xc', + 'zapdisable', + 'heapverify1', + 'gcstress0xc_zapdisable', + 'gcstress0xc_zapdisable_jitstress2', + 'gcstress0xc_zapdisable_heapverify1', + 'gcstress0xc_jitstress1', + 'gcstress0xc_jitstress2', + 'gcstress0xc_minopts_heapverify1' + ] + + def static validLinuxArm64Scenarios = [ + 'innerloop', + 'normal', + // 'ilrt' + 'r2r', + // 'longgc' + // 'formatting' + // 'gcsimulator' + // 'jitdiff' + // 'standalone_gc' + // 'gc_reliability_framework' + // 'illink' + 'r2r_jitstress1', + 'r2r_jitstress2', + 'r2r_jitstress1_tiered', + 'r2r_jitstress2_tiered', + 'r2r_jitstressregs1', + 'r2r_jitstressregs2', + 'r2r_jitstressregs3', + 'r2r_jitstressregs4', + 'r2r_jitstressregs8', + 'r2r_jitstressregs0x10', + 'r2r_jitstressregs0x80', + 'r2r_jitstressregs0x1000', + 'r2r_jitminopts', + 'r2r_jitforcerelocs', + 'r2r_gcstress15', + 'minopts', + 'tieredcompilation', + 'forcerelocs', + 'jitstress1', + 'jitstress2', + 'jitstress1_tiered', + 'jitstress2_tiered', + 'jitstressregs1', + 'jitstressregs2', + 'jitstressregs3', + 'jitstressregs4', + 'jitstressregs8', + 'jitstressregs0x10', + 'jitstressregs0x80', + 'jitstressregs0x1000', + 'jitstress2_jitstressregs1', + 'jitstress2_jitstressregs2', + 'jitstress2_jitstressregs3', + 'jitstress2_jitstressregs4', + 'jitstress2_jitstressregs8', + 'jitstress2_jitstressregs0x10', + 'jitstress2_jitstressregs0x80', + 'jitstress2_jitstressregs0x1000', + 'tailcallstress', + // 'jitsse2only' // Only relevant to xarch + 'jitnosimd', // Only interesting on platforms where SIMD support exists. // 'jitincompletehwintrinsic' // 'jitx86hwintrinsicnoavx' // 'jitx86hwintrinsicnoavx2' @@ -408,7 +513,7 @@ class Constants { // This is the set of architectures // Some of these are pseudo-architectures: - // armem -- ARM builds/runs using an emulator. Used for Ubuntu/Ubuntu16.04/Tizen runs. + // armem -- ARM builds/runs using an emulator. Used for Tizen runs. // x86_arm_altjit -- ARM runs on x86 using the ARM altjit // x64_arm64_altjit -- ARM64 runs on x64 using the ARM64 altjit def static architectureList = ['arm', 'armem', 'x86_arm_altjit', 'x64_arm64_altjit', 'arm64', 'x64', 'x86'] @@ -553,7 +658,6 @@ def static setMachineAffinity(def job, def os, def architecture, def options = n assert architecture instanceof String def armArches = ['arm', 'armem', 'arm64'] - def supportedArmLinuxOs = ['Ubuntu', 'Ubuntu16.04', 'Tizen'] if (!(architecture in armArches)) { assert options == null @@ -581,7 +685,7 @@ def static setMachineAffinity(def job, def os, def architecture, def options = n // Ubuntu // // Arm32 emulator (Build, Test) -> arm-cross-latest - // |-> os in supportedArmLinuxOs && (architecture == "armem") + // |-> os == "Tizen" && (architecture == "armem") // // Arm32 hardware (Flow) -> Ubuntu 16.04 latest-or-auto (don't use limited arm hardware) // |-> os == "Ubuntu" && (architecture == "arm") && options['is_flow_job'] == true @@ -610,10 +714,9 @@ def static setMachineAffinity(def job, def os, def architecture, def options = n } } else { assert os != 'Windows_NT' - assert os in supportedArmLinuxOs if (architecture == 'arm64') { - assert (architecture == 'arm64') && (os == 'Ubuntu') + assert os == 'Ubuntu' def isFlow = (options != null) && (options['is_flow_job'] == true) def isBuild = (options != null) && (options['is_build_job'] == true) if (isFlow || isBuild) { @@ -631,13 +734,15 @@ def static setMachineAffinity(def job, def os, def architecture, def options = n } } else if (architecture == 'armem') { - // arm emulator (Ubuntu/Ubuntu16.04/Tizen). Build and test on same machine, + // arm emulator (Tizen). Build and test on same machine, // using Docker. + assert os == 'Tizen' Utilities.setMachineAffinity(job, 'Ubuntu', 'arm-cross-latest') } else { // arm Ubuntu on hardware. - assert (architecture == 'arm') && (os == 'Ubuntu') + assert architecture == 'arm' + assert os == 'Ubuntu' def isFlow = (options != null) && (options['is_flow_job'] == true) def isBuild = (options != null) && (options['is_build_job'] == true) if (isFlow || isBuild) { @@ -786,6 +891,12 @@ def static isValidPrTriggeredInnerLoopJob(os, architecture, configuration, isBui return true } +// This means the job builds and runs the 'Pri0' test set. This does not mean the job is +// scheduled with a default PR trigger despite the correlation being true at the moment. +def static isPri0TestScenario(def scenario) { + return (scenario == 'innerloop' || scenario == 'no_tiered_compilation_innerloop') +} + def static getFxBranch(def branch) { def fxBranch = branch // Map 'dev/unix_test_workflow' to 'master' so we can test CoreFX jobs in the CoreCLR dev/unix_test_workflow @@ -799,11 +910,9 @@ def static getFxBranch(def branch) { def static setJobTimeout(newJob, isPR, architecture, configuration, scenario, isBuildOnly) { // 2 hours (120 minutes) is the default timeout def timeout = 120 - def innerLoop = (scenario == "innerloop") - if (!innerLoop) { - // Pri-1 test builds take a long time. Default PR jobs are Pri-0; everything else is Pri-1 - // (see calculateBuildCommands()). So up the Pri-1 build jobs timeout. + if (!isPri0TestScenario(scenario)) { + // Pri-1 test builds take a long time (see calculateBuildCommands()). So up the Pri-1 build jobs timeout. timeout = 240 } @@ -1011,14 +1120,8 @@ def static getDockerImageName(def architecture, def os, def isBuild) { return "hseok82/dotnet-buildtools-prereqs:ubuntu-16.04-crossx86-ef0ac75-20175511035548" } else if (architecture == 'armem') { - if (os == 'Ubuntu') { - return "microsoft/dotnet-buildtools-prereqs:ubuntu-14.04-cross-e435274-20180405193556" - } - else if (os == 'Ubuntu16.04') { - return "microsoft/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180404203310" - } - else if (os == 'Tizen') { - return "gbalykov/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-4.0m2" + if (os == 'Tizen') { + return "tizendotnet/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-5.0m1" } } else if (architecture == 'arm') { @@ -1100,13 +1203,8 @@ def static getJobName(def configuration, def architecture, def os, def scenario, break case 'armem': // These are cross builds - if (os == 'Tizen') { - // ABI: softfp - baseName = 'armel_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase() - } - else { - baseName = architecture.toLowerCase() + '_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase() - } + assert os == 'Tizen' + baseName = 'armel_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase() break case 'arm': baseName = architecture.toLowerCase() + '_cross_' + configuration.toLowerCase() + '_' + os.toLowerCase() @@ -1137,9 +1235,16 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def return } + // Ubuntu x86 CI jobs are failing. Disable non-PR triggered jobs to avoid these constant failures + // until this is fixed. Tracked by https://github.com/dotnet/coreclr/issues/19003. + if (architecture == 'x86' && os == 'Ubuntu') { + return + } + // Check scenario. switch (scenario) { case 'innerloop': + case 'no_tiered_compilation_innerloop': break case 'normal': switch (architecture) { @@ -1244,6 +1349,8 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def break case 'r2r_jitstress1': case 'r2r_jitstress2': + case 'r2r_jitstress1_tiered': + case 'r2r_jitstress2_tiered': case 'r2r_jitstressregs1': case 'r2r_jitstressregs2': case 'r2r_jitstressregs3': @@ -1255,6 +1362,7 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def case 'r2r_jitminopts': case 'r2r_jitforcerelocs': case 'r2r_gcstress15': + case 'r2r_no_tiered_compilation': assert !(os in bidailyCrossList) // GCStress=C is currently not supported on OS X @@ -1352,9 +1460,13 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def case 'jitstressregs0x80': case 'jitstressregs0x1000': case 'minopts': + case 'tieredcompilation': + case 'no_tiered_compilation': case 'forcerelocs': case 'jitstress1': case 'jitstress2': + case 'jitstress1_tiered': + case 'jitstress2_tiered': case 'jitstress2_jitstressregs1': case 'jitstress2_jitstressregs2': case 'jitstress2_jitstressregs3': @@ -1373,6 +1485,7 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def case 'jitx86hwintrinsicnosimd': case 'corefx_baseline': case 'corefx_minopts': + case 'corefx_tieredcompilation': case 'corefx_jitstress1': case 'corefx_jitstress2': case 'corefx_jitstressregs1': @@ -1457,11 +1570,6 @@ def static addNonPRTriggers(def job, def branch, def isPR, def architecture, def } } break - - case 'tieredcompilation': - case 'corefx_tieredcompilation': - // No periodic jobs just yet, still testing - break default: println("Unknown scenario: ${scenario}"); @@ -1564,6 +1672,16 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} via ILLink", "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*") break } + else if (scenario == 'corefx_innerloop') { + if (configuration == 'Checked') { + Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} CoreFX Tests") + } + else { + Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} CoreFX Tests", "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+CoreFX Tests.*") + } + break + } + // fall through case 'OSX10.12': @@ -1625,6 +1743,12 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, } break + case 'corefx_innerloop': + if (configuration == 'Checked') { + Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} CoreFX Tests") + } + break + default: if (isJitStressScenario(scenario)) { def displayStr = getStressModeDisplayName(scenario) @@ -1695,6 +1819,14 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Innerloop Build and Test") } break + //no_tiered_compilation_innerloop will be added as default once it is confirmed working + //case 'no_tiered_compilation_innerloop': + // // Default trigger + // if (configuration == 'Checked') { + // def displayStr = getStressModeDisplayName(scenario) + // Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})") + // } + // break case 'normal': if (configuration == 'Checked') { @@ -1741,6 +1873,11 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, case 'illink': Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} via ILLink", "(?i).*test\\W+${os}\\W+${architecture}\\W+${configuration}\\W+${scenario}.*") break + case 'corefx_innerloop': + if (configuration == 'Checked') { + Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} CoreFX Tests") + } + break default: if (isJitStressScenario(scenario)) { @@ -1785,16 +1922,8 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, } switch (os) { - case 'Ubuntu': - case 'Ubuntu16.04': - assert scenario != 'innerloop' - Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Build", - "(?i).*test\\W+${os}\\W+${architecture}\\W+Cross\\W+${configuration}\\W+Build.*") - break - case 'Tizen': architecture = 'armel' - if (scenario == 'innerloop') { if (configuration == 'Checked') { Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} Cross ${configuration} Innerloop Build and Test") @@ -1841,7 +1970,8 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, switch (os) { case 'Ubuntu': - if (scenario == 'innerloop') { + //no_tiered_compilation_innerloop will be added as default once it is confirmed working + if (scenario == 'innerloop' /*|| scenario == 'no_tiered_compilation_innerloop'*/) { if (configuration == 'Checked') { Utilities.addGithubPRTriggerForBranch(job, branch, contextString) } @@ -1980,6 +2110,14 @@ def static addTriggers(def job, def branch, def isPR, def architecture, def os, } break + //no_tiered_compilation_innerloop will be added as default once it is confirmed working + //case 'no_tiered_compilation_innerloop': + // if (configuration == 'Checked') { + // def displayStr = getStressModeDisplayName(scenario) + // Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test (Jit - ${displayStr})") + // } + // break + case 'normal': if (configuration == 'Checked') { Utilities.addGithubPRTriggerForBranch(job, branch, "${os} ${architecture} ${configuration} Build and Test", @@ -2071,7 +2209,7 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR def lowerConfiguration = configuration.toLowerCase() def priority = '1' - if (scenario == 'innerloop') { + if (isPri0TestScenario(scenario)) { priority = '0' } @@ -2212,19 +2350,30 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR runtestArguments = "${lowerConfiguration} ${arch} ${testOpts}" if (doCoreFxTesting) { - def workspaceRelativeFxRoot = "_/fx" - def absoluteFxRoot = "%WORKSPACE%\\_\\fx" - def fxBranch = getFxBranch(branch) + if (scenario == 'corefx_innerloop') { + // Create CORE_ROOT and testhost + buildCommands += "build-test.cmd ${lowerConfiguration} ${arch} buildtesthostonly" + buildCommands += "tests\\runtest.cmd ${runtestArguments} CoreFXTestsAll" + + // Archive and process (only) the test results + Utilities.addArchival(newJob, "bin/Logs/**/testResults.xml") + Utilities.addXUnitDotNETResults(newJob, "bin/Logs/**/testResults.xml") + } + else { + def workspaceRelativeFxRoot = "_/fx" + def absoluteFxRoot = "%WORKSPACE%\\_\\fx" + def fxBranch = getFxBranch(branch) - buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath}" + buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${arch} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath}" - // Archive and process (only) the test results - Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") - Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") + // 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) + //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" @@ -2269,32 +2418,26 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR } break case 'arm': + case 'arm64': assert isArmWindowsScenario(scenario) - def buildArchitecture = 'arm' def buildOpts = '' + if (architecture == 'arm64') { + buildOpts += " toolset_dir C:\\ats2" + } + if (doCoreFxTesting) { - // We shouldn't need to build the tests. However, run-corefx-tests.py currently depends on having the restored corefx - // package available, to determine the correct corefx version git commit hash, and we need to build the tests before - // running "tests\\runtest.cmd GenerateLayoutOnly". So build the pri-0 tests to make this happen. - // - // buildOpts += ' skiptests'; - buildOpts += " -priority=0" + buildOpts += ' skiptests' } else { buildOpts += " -priority=${priority}" } // This is now a build only job. Do not run tests. Use the flow job. - buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${buildArchitecture} ${buildOpts}" + buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} ${buildOpts}" if (doCoreFxTesting) { assert isBuildOnly - assert architecture == 'arm' - - // Generate the test layout because it restores the corefx package which allows run-corefx-tests.py - // to determine the correct matching corefx version git commit hash. - buildCommands += "tests\\runtest.cmd ${lowerConfiguration} ${architecture} GenerateLayoutOnly" // Set the stress mode variables; this is incorporated into the generated CoreFx RunTests.cmd files. def envScriptPath = '' @@ -2310,10 +2453,15 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR def absoluteFxRoot = "%WORKSPACE%\\_\\fx" def fxBranch = getFxBranch(branch) - buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath} -no_run_tests" + def toolsetDirOpt = '' + if (architecture == 'arm64') { + toolsetDirOpt = "-toolset_dir C:\\ats2" + } + + buildCommands += "python -u %WORKSPACE%\\tests\\scripts\\run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${envScriptPath} -no_run_tests ${toolsetDirOpt}" // Zip up the CoreFx runtime and tests. We don't need the CoreCLR binaries; they have been copied to the CoreFX tree. - buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('${workspaceRelativeFxRootWin}\\bin\\testhost\\netcoreapp-Windows_NT-Release-arm', '${workspaceRelativeFxRootWin}\\fxruntime.zip')\""; + buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('${workspaceRelativeFxRootWin}\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}', '${workspaceRelativeFxRootWin}\\fxruntime.zip')\""; buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('${workspaceRelativeFxRootWin}\\bin\\tests', '${workspaceRelativeFxRootWin}\\fxtests.zip')\""; Utilities.addArchival(newJob, "${workspaceRelativeFxRootLinux}/fxruntime.zip") @@ -2321,25 +2469,12 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR } else { // Zip up the tests directory so that we don't use so much space/time copying // 10s of thousands of files around. - buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${buildArchitecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; + buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; // Add archival. Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**") } break - case 'arm64': - assert isArmWindowsScenario(scenario) - - // This is now a build only job. Do not run tests. Use the flow job. - buildCommands += "set __TestIntermediateDir=int&&build.cmd ${lowerConfiguration} ${architecture} toolset_dir C:\\ats2 -priority=${priority}" - - // Zip up the tests directory so that we don't use so much space/time copying - // 10s of thousands of files around. - buildCommands += "powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('.\\bin\\tests\\${osGroup}.${architecture}.${configuration}', '.\\bin\\tests\\tests.zip')\""; - - // Add archival. - Utilities.addArchival(newJob, "bin/Product/**,bin/tests/tests.zip", "bin/Product/**/.nuget/**") - break default: println("Unknown architecture: ${architecture}"); assert false @@ -2396,48 +2531,55 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml') } else { - // Corefx stress testing - assert os == 'Ubuntu' - assert architecture == 'x64' - assert lowerConfiguration == 'checked' - assert isJitStressScenario(scenario) + if (scenario == 'corefx_innerloop') { + assert os == 'Ubuntu' || 'OSX10.12' + assert architecture == 'x64' - // Build coreclr - buildCommands += "./build.sh ${lowerConfiguration} ${architecture}" + buildCommands += "./build.sh ${lowerConfiguration} ${architecture} skiptests" + buildCommands += "./build-test.sh ${lowerConfiguration} ${architecture} generatetesthostonly" + buildCommands += "./tests/runtest.sh --corefxtestsall --testHostDir=\${WORKSPACE}/bin/tests/${osGroup}.${architecture}.${configuration}/testhost/ --coreclr-src=\${WORKSPACE}" + + break + // Archive and process (only) the test results + Utilities.addArchival(newJob, "bin/Logs/**/testResults.xml") + Utilities.addXUnitDotNETResults(newJob, "bin/Logs/**/testResults.xml") + } + else { + // Corefx stress testing + assert os == 'Ubuntu' + assert architecture == 'x64' + assert lowerConfiguration == 'checked' + assert isJitStressScenario(scenario) - def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh" + // Build coreclr + buildCommands += "./build.sh ${lowerConfiguration} ${architecture}" - def envScriptCmds = envScriptCreate(os, scriptFileName) - envScriptCmds += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], scriptFileName) - envScriptCmds += envScriptFinalize(os, scriptFileName) - buildCommands += envScriptCmds + def scriptFileName = "\$WORKSPACE/set_stress_test_env.sh" - // Build and text corefx - def workspaceRelativeFxRoot = "_/fx" - def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRoot}" - def fxBranch = getFxBranch(branch) + def envScriptCmds = envScriptCreate(os, scriptFileName) + envScriptCmds += envScriptSetStressModeVariables(os, Constants.jitStressModeScenarios[scenario], scriptFileName) + envScriptCmds += envScriptFinalize(os, scriptFileName) + buildCommands += envScriptCmds - buildCommands += "python -u \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${scriptFileName}" + // Build and text corefx + def workspaceRelativeFxRoot = "_/fx" + def absoluteFxRoot = "\$WORKSPACE/${workspaceRelativeFxRoot}" + def fxBranch = getFxBranch(branch) + + buildCommands += "python -u \$WORKSPACE/tests/scripts/run-corefx-tests.py -arch ${architecture} -ci_arch ${architecture} -build_type ${configuration} -fx_root ${absoluteFxRoot} -fx_branch ${fxBranch} -env_script ${scriptFileName}" - // Archive and process (only) the test results - Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") - Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") + // Archive and process (only) the test results + Utilities.addArchival(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") + Utilities.addXUnitDotNETResults(newJob, "${workspaceRelativeFxRoot}/bin/**/testResults.xml") + } } break case 'armem': - // Emulator cross builds for ARM runs on Ubuntu, Ubuntu16.04 and Tizen currently - assert (os == 'Ubuntu') || (os == 'Ubuntu16.04') || (os == 'Tizen') + // Emulator cross builds for ARM runs on Tizen currently + assert os == 'Tizen' - // default values for Ubuntu - def arm_abi = "arm" - def linuxCodeName = "trusty" - if (os == 'Ubuntu16.04') { - linuxCodeName = "xenial" - } - else if (os == 'Tizen') { - arm_abi = "armel" - linuxCodeName = "tizen" - } + def arm_abi = "armel" + def linuxCodeName = "tizen" // Unzip the Windows test binaries first. Exit with 0 buildCommands += "unzip -q -o ./bin/tests/tests.zip -d ./bin/tests/Windows_NT.x64.${configuration} || exit 0" @@ -2445,14 +2587,6 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR // Unpack the corefx binaries buildCommands += "mkdir ./bin/CoreFxBinDir" buildCommands += "tar -xf ./bin/build.tar.gz -C ./bin/CoreFxBinDir" - if (os != 'Tizen') { - buildCommands += "chmod a+x ./bin/CoreFxBinDir/corerun" - } - // Test environment emulation using docker and qemu has some problem to use lttng library. - // We should remove libcoreclrtraceptprovider.so to avoid test hang. - if (os == 'Ubuntu') { - buildCommands += "rm -f -v ./bin/CoreFxBinDir/libcoreclrtraceptprovider.so" - } // Call the ARM CI script to cross build and test using docker buildCommands += """./tests/scripts/arm32_ci_script.sh \\ @@ -2566,11 +2700,16 @@ def static calculateBuildCommands(def newJob, def scenario, def branch, def isPR def static shouldGenerateJob(def scenario, def isPR, def architecture, def configuration, def os, def isBuildOnly) { // The "innerloop" (Pri-0 testing) scenario is only available as PR triggered. - // All other scenarios do Pri-1 testing. if (scenario == 'innerloop' && !isPR) { return false } + // Run basic corefx tests only on PR-triggered jobs + // Runs under Release and Checked + if (scenario == 'corefx_innerloop' && !isPR) { + return false + } + // Tizen is only supported for armem architecture if (os == 'Tizen' && architecture != 'armem') { return false @@ -2586,7 +2725,7 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi } break case 'armem': - if ((os != 'Ubuntu') && (os != 'Ubuntu16.04') && (os != 'Tizen')) { + if (os != 'Tizen') { return false } break @@ -2617,7 +2756,8 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi if (isBuildOnly) { switch (architecture) { case 'arm': - // We use build only jobs for Windows arm cross-compilation corefx testing, so we need to generate builds for that. + case 'arm64': + // We use build only jobs for Windows arm/arm64 cross-compilation corefx testing, so we need to generate builds for that. if (!isCoreFxScenario(scenario)) { return false } @@ -2659,7 +2799,7 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi break case 'arm': - // We use build only jobs for Windows arm cross-compilation corefx testing, so we need to generate builds for that. + // We use build only jobs for Windows arm/arm64 cross-compilation corefx testing, so we need to generate builds for that. // No "regular" Windows arm corefx jobs, e.g. // For Ubuntu arm corefx testing, we use regular jobs (not "build only" since only Windows has "build only", and // the Ubuntu arm "regular" jobs don't run tests anyway). @@ -2677,7 +2817,9 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi case 'arm64': if (os == 'Windows_NT') { - return false + if (! (isBuildOnly && isCoreFxScenario(scenario)) ) { + return false + } } else { if (!isCoreFxScenario(scenario)) { @@ -2696,9 +2838,28 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi if (os != 'Windows_NT') { return false } - // Stress scenarios only run with Checked builds, not Release (they would work with Debug, but be slow). - if ((configuration != 'Checked') && isR2RStressScenario(scenario)) { - return false + + if (isR2RBaselineScenario(scenario)) { + // no need for Debug scenario; Checked is sufficient + if (configuration != 'Checked' && configuration != 'Release') { + return false + } + } + else if (isR2RStressScenario(scenario)) { + // Stress scenarios only run with Checked builds, not Release (they would work with Debug, but be slow). + if (configuration != 'Checked') { + return false + } + } + + switch (architecture) { + case 'arm': + case 'arm64': + // Windows arm/arm64 ready-to-run jobs use flow jobs and test jobs, but depend on "normal" (not R2R specific) build jobs. + return false + + default: + break } } else { @@ -2784,6 +2945,14 @@ def static shouldGenerateJob(def scenario, def isPR, def architecture, def confi return false } break + case 'corefx_innerloop': + if (os != 'Windows_NT' && os != 'Ubuntu' && os != 'OSX10.12') { + return false + } + if (architecture != 'x64') { + return false + } + break default: println("Unknown scenario: ${scenario}") assert false @@ -2831,7 +3000,13 @@ Constants.allScenarios.each { scenario -> // Create the new job def newJob = job(Utilities.getFullJobName(project, jobName, isPR, folderName)) {} - addToViews(newJob, isPR, architecture, os) + + // We don't want to include in view any job that is only used by a flow job (because we want the views to have only the + // "top-level" jobs. Build only jobs are such jobs. + if (!isBuildOnly) + { + addToViews(newJob, isPR, architecture, os) + } setJobMachineAffinity(architecture, os, true, false, false, newJob) // isBuildJob = true, isTestJob = false, isFlowJob = false @@ -2842,7 +3017,7 @@ Constants.allScenarios.each { scenario -> // Copy Windows build test binaries and corefx build artifacts for Linux cross build for armem. // We don't use a flow job for this, but we do depend on there being existing builds with these // artifacts produced. - if (architecture == 'armem' && (os == 'Ubuntu' || os == 'Ubuntu16.04' || os == 'Tizen')) { + if ((architecture == 'armem') && (os == 'Tizen')) { // Define the Windows Tests and Corefx build job names def lowerConfiguration = configuration.toLowerCase() def WindowsTestsName = projectFolder + '/' + @@ -2853,12 +3028,8 @@ Constants.allScenarios.each { scenario -> def corefxFolder = Utilities.getFolderName('dotnet/corefx') + '/' + Utilities.getFolderName(fxBranch) - def arm_abi = 'arm' - def corefx_os = 'linux' - if (os == 'Tizen') { - arm_abi = 'armel' - corefx_os = 'tizen' - } + def arm_abi = 'armel' + def corefx_os = 'tizen' // Let's use release CoreFX to test checked CoreCLR, // because we do not generate checked CoreFX in CoreFX CI yet. @@ -2938,20 +3109,20 @@ def static CreateWindowsArmTestJob(def dslFactory, def project, def architecture if (isCoreFxScenario(scenario)) { - // Only arm supported for corefx testing now. - assert architecture == 'arm' + // Only arm/arm64 supported for corefx testing now. + assert architecture == 'arm' || architecture == 'arm64' // Unzip CoreFx runtime - batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('_\\fx\\fxruntime.zip', '_\\fx\\bin\\testhost\\netcoreapp-Windows_NT-Release-arm')\"") + batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('_\\fx\\fxruntime.zip', '_\\fx\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}')\"") // Unzip CoreFx tests. batchFile("powershell -NoProfile -Command \"Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::ExtractToDirectory('_\\fx\\fxtests.zip', '_\\fx\\bin\\tests')\"") // Add the script to run the corefx tests - def corefx_runtime_path = "%WORKSPACE%\\_\\fx\\bin\\testhost\\netcoreapp-Windows_NT-Release-arm" + def corefx_runtime_path = "%WORKSPACE%\\_\\fx\\bin\\testhost\\netcoreapp-Windows_NT-Release-${architecture}" def corefx_tests_dir = "%WORKSPACE%\\_\\fx\\bin\\tests" - def corefx_exclusion_file = "%WORKSPACE%\\tests\\arm\\corefx_test_exclusions.txt" - batchFile("call %WORKSPACE%\\tests\\scripts\\run-corefx-tests.bat ${corefx_runtime_path} ${corefx_tests_dir} ${corefx_exclusion_file}") + def corefx_exclusion_file = "%WORKSPACE%\\tests\\${architecture}\\corefx_test_exclusions.txt" + batchFile("call %WORKSPACE%\\tests\\scripts\\run-corefx-tests.bat ${corefx_runtime_path} ${corefx_tests_dir} ${corefx_exclusion_file} ${architecture}") } else { // !isCoreFxScenario(scenario) @@ -3029,8 +3200,7 @@ def static CreateWindowsArmTestJob(def dslFactory, def project, def architecture addArchSpecificExclude(architecture, excludeTag) } - // Innerloop jobs run Pri-0 tests; everyone else runs Pri-1. - if (scenario == 'innerloop') { + if (isPri0TestScenario(scenario)) { addExclude("pri1") } @@ -3125,6 +3295,12 @@ def static CreateOtherTestJob(def dslFactory, def project, def branch, def archi else if (scenario == 'r2r_jitstress2') { testOpts += ' --jitstress=2' } + else if (scenario == 'r2r_jitstress1_tiered') { + testOpts += ' --jitstress=1' + } + else if (scenario == 'r2r_jitstress2_tiered') { + testOpts += ' --jitstress=2' + } else if (scenario == 'r2r_jitstressregs1') { testOpts += ' --jitstressregs=1' } @@ -3257,6 +3433,7 @@ def static CreateOtherTestJob(def dslFactory, def project, def branch, def archi } } + shell("mkdir ./bin/CoreFxBinDir") shell("tar -xf ./bin/CoreFxNative/bin/build.tar.gz -C ./bin/CoreFxBinDir") } @@ -3370,6 +3547,8 @@ ${runScript} \\ // Create a test job that will be used by a flow job. // Returns the newly created job. +// Note that we don't add tests jobs to the various views, since they are always used by a flow job, which is in the views, +// and we want the views to be the minimal set of "top-level" jobs that represent all work. def static CreateTestJob(def dslFactory, def project, def branch, def architecture, def os, def configuration, def scenario, def isPR, def inputCoreCLRBuildName, def inputTestsBuildName) { def windowsArmJob = ((os == "Windows_NT") && (architecture in Constants.armWindowsCrossArchitectureList)) @@ -3384,8 +3563,6 @@ def static CreateTestJob(def dslFactory, def project, def branch, def architectu setJobMachineAffinity(architecture, os, false, true, false, newJob) // isBuildJob = false, isTestJob = true, isFlowJob = false - addToViews(newJob, isPR, architecture, os) - if (scenario == 'jitdiff') { def osGroup = getOSGroup(os) Utilities.addArchival(newJob, "bin/tests/${osGroup}.${architecture}.${configuration}/dasm/**") @@ -3455,10 +3632,13 @@ build(params + [CORECLR_BUILD: coreclrBuildJob.build.number, def static shouldGenerateFlowJob(def scenario, def isPR, def architecture, def configuration, def os) { // The "innerloop" (Pri-0 testing) scenario is only available as PR triggered. - // All other scenarios do Pri-1 testing. if (scenario == 'innerloop' && !isPR) { return false } + + if (scenario == 'corefx_innerloop') { + return false + } // Filter based on OS and architecture. @@ -3509,7 +3689,7 @@ def static shouldGenerateFlowJob(def scenario, def isPR, def architecture, def c else { // Non-Windows if (architecture == 'arm64') { - if (!(scenario in Constants.validLinuxArmScenarios)) { + if (!(scenario in Constants.validLinuxArm64Scenarios)) { return false } } @@ -3524,6 +3704,14 @@ def static shouldGenerateFlowJob(def scenario, def isPR, def architecture, def c return false } } + else if (architecture == 'x64') { + // Linux/x64 corefx testing doesn't need a flow job; the "build" job runs run-corefx-tests.py which + // builds and runs the corefx tests. Other Linux/x64 flow jobs are required to get the test + // build from a Windows machine. + if (isCoreFxScenario(scenario)) { + return false + } + } } // For CentOS, we only want Checked/Release builds. @@ -3552,11 +3740,6 @@ def static shouldGenerateFlowJob(def scenario, def isPR, def architecture, def c if (configuration != 'Checked') { return false } - - // On Windows, CoreFx tests currently not implemented for ARM64. - if (isCoreFxScenario(scenario) && (os == 'Windows_NT') && (architecture == 'arm64')) { - return false - } } else if (isR2RBaselineScenario(scenario)) { if (configuration != 'Checked' && configuration != 'Release') { @@ -3640,7 +3823,7 @@ Constants.allScenarios.each { scenario -> // Figure out the job name of the CoreCLR build the test will depend on. - def inputCoreCLRBuildScenario = scenario == 'innerloop' ? 'innerloop' : 'normal' + def inputCoreCLRBuildScenario = isPri0TestScenario(scenario) ? 'innerloop' : 'normal' def inputCoreCLRBuildIsBuildOnly = false if (doCoreFxTesting) { // Every CoreFx test depends on its own unique build. @@ -3663,7 +3846,7 @@ Constants.allScenarios.each { scenario -> def inputTestsBuildName = null if (!windowsArmJob && !doCoreFxTesting) { - def testBuildScenario = scenario == 'innerloop' ? 'innerloop' : 'normal' + def testBuildScenario = isPri0TestScenario(scenario) ? 'innerloop' : 'normal' def inputTestsBuildArch = architecture if (architecture == "arm64") { diff --git a/run.sh b/run.sh index 2d037e91e557..cc6a1846bbeb 100755 --- a/run.sh +++ b/run.sh @@ -9,7 +9,7 @@ toolRuntime=$working_tree_root/Tools dotnet=$toolRuntime/dotnetcli/dotnet echo "Running: $dotnet $toolRuntime/run.exe $working_tree_root/config.json $*" -$dotnet $toolRuntime/run.exe $working_tree_root/config.json $* +$dotnet $toolRuntime/run.exe $working_tree_root/config.json "$@" if [ $? -ne 0 ] then echo "ERROR: An error occured in $dotnet $toolRuntime/run $#. Check $# logs under $working_tree_root." diff --git a/src/.nuget/Microsoft.NETCore.ILAsm/runtime.FreeBSD.Microsoft.NETCore.ILAsm.props b/src/.nuget/Microsoft.NETCore.ILAsm/runtime.FreeBSD.Microsoft.NETCore.ILAsm.props new file mode 100644 index 000000000000..a8019b21e638 --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.ILAsm/runtime.FreeBSD.Microsoft.NETCore.ILAsm.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/.nuget/Microsoft.NETCore.ILDAsm/runtime.FreeBSD.Microsoft.NETCore.ILDAsm.props b/src/.nuget/Microsoft.NETCore.ILDAsm/runtime.FreeBSD.Microsoft.NETCore.ILDAsm.props new file mode 100644 index 000000000000..f7ab15b66417 --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.ILDAsm/runtime.FreeBSD.Microsoft.NETCore.ILDAsm.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/.nuget/Microsoft.NETCore.Jit/runtime.FreeBSD.Microsoft.NETCore.Jit.props b/src/.nuget/Microsoft.NETCore.Jit/runtime.FreeBSD.Microsoft.NETCore.Jit.props new file mode 100644 index 000000000000..b92d11ae597f --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.Jit/runtime.FreeBSD.Microsoft.NETCore.Jit.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.props b/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.props index ff2f587a1c25..a46a1bee5563 100644 --- a/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.props +++ b/src/.nuget/Microsoft.NETCore.Native/Microsoft.NETCore.Native.props @@ -1,6 +1,6 @@ - Linux;OSX + Linux;OSX;FreeBSD - \ No newline at end of file + diff --git a/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props b/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props new file mode 100644 index 000000000000..dea614a67d91 --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.Native/runtime.FreeBSD.Microsoft.NETCore.Native.props @@ -0,0 +1,7 @@ + + + + + + + diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props new file mode 100644 index 000000000000..fcf0d78a0b9a --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.FreeBSD.Microsoft.NETCore.Runtime.CoreCLR.props @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + 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 952e64550b47..f618a4f815b3 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 @@ -21,8 +21,8 @@ - + diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props index ffb1c2d3f4c2..9a641975ff44 100644 --- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.OSX.Microsoft.NETCore.Runtime.CoreCLR.props @@ -8,7 +8,7 @@ - + diff --git a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props index d01c38f3bc80..200ca18fcf11 100644 --- a/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props +++ b/src/.nuget/Microsoft.NETCore.Runtime.CoreCLR/runtime.Windows_NT.Microsoft.NETCore.Runtime.CoreCLR.props @@ -20,7 +20,7 @@ - + diff --git a/src/.nuget/Microsoft.NETCore.TestHost/runtime.FreeBSD.Microsoft.NETCore.TestHost.props b/src/.nuget/Microsoft.NETCore.TestHost/runtime.FreeBSD.Microsoft.NETCore.TestHost.props new file mode 100644 index 000000000000..ce004bdac4db --- /dev/null +++ b/src/.nuget/Microsoft.NETCore.TestHost/runtime.FreeBSD.Microsoft.NETCore.TestHost.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/.nuget/dir.props b/src/.nuget/dir.props index 4163f1430046..03d06753daac 100644 --- a/src/.nuget/dir.props +++ b/src/.nuget/dir.props @@ -23,7 +23,7 @@ $(OSRid) - Windows_NT;OSX;Android;Linux + Windows_NT;OSX;Android;Linux;FreeBSD ;$(SupportedPackageOSGroups); @@ -39,9 +39,16 @@ + + + + runtimes/$(PackageTargetRuntime)/il + + + - + true diff --git a/src/System.Private.CoreLib/ILLinkTrim.xml b/src/System.Private.CoreLib/ILLinkTrim.xml index e4e83e37166a..5445899b064f 100644 --- a/src/System.Private.CoreLib/ILLinkTrim.xml +++ b/src/System.Private.CoreLib/ILLinkTrim.xml @@ -37,5 +37,7 @@ + + diff --git a/src/System.Private.CoreLib/Resources/Strings.resx b/src/System.Private.CoreLib/Resources/Strings.resx index a21c2bc9f043..b1cba1672d4a 100644 --- a/src/System.Private.CoreLib/Resources/Strings.resx +++ b/src/System.Private.CoreLib/Resources/Strings.resx @@ -266,7 +266,7 @@ Delegate to an instance method cannot have null 'this'. - Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type. + Cannot bind to the target method because its signature is not compatible with that of the delegate type. Delegates must be of the same type. @@ -1577,7 +1577,7 @@ The unmanaged Version information is too large to persist. - The name '{0}' can be no more than {1} characters in length. + The length of the name exceeds the maximum limit. Cannot marshal type '{0}' to Windows Runtime. Only 'System.RuntimeType' is supported. @@ -1993,69 +1993,6 @@ The SyncRoot property may not be used for the synchronization of concurrent collections. - - The array is multidimensional, or the type parameter for the set cannot be cast automatically to the type of the destination array. - - - The index is equal to or greater than the length of the array, or the number of elements in the dictionary is greater than the available space from index to the end of the destination array. - - - The capacity argument must be greater than or equal to zero. - - - The concurrencyLevel argument must be positive. - - - The index argument is less than zero. - - - TKey is a reference type and item.Key is null. - - - The key already existed in the dictionary. - - - The key was of an incorrect type for this dictionary. - - - The value was of an incorrect type for this dictionary. - - - Barrier finishing phase {1}. - - - ConcurrentBag stealing in TryPeek. - - - ConcurrentBag stealing in TryTake. - - - ConcurrentDictionary acquiring all locks on {0} bucket(s). - - - Pop from ConcurrentStack spun {0} time(s). - - - Push to ConcurrentStack spun {0} time(s). - - - Task {1} entering fork/join {2}. - - - Beginning ParallelInvoke {2} from Task {1} for {4} actions. - - - Ending ParallelInvoke {2}. - - - Task {1} leaving fork/join {2}. - - - Beginning {3} loop {2} from Task {1}. - - - Ending loop {2} after {3} iterations. - SpinLock beginning to spin. @@ -2554,9 +2491,6 @@ Interface cannot have constructors. - - SecurityTransparent and SecurityCritical attributes cannot be applied to the assembly scope at the same time. - Internal Error in DateTime and Calendar operations. @@ -3691,9 +3625,6 @@ The startIndex argument must be greater than or equal to zero. - - The source argument contains duplicate keys. - This method is not supported on signature types. @@ -3739,4 +3670,16 @@ The string must be null-terminated. + + The week parameter must be in the range 1 through 53. + + + PInvoke methods must be static and native and cannot be abstract. + + + PInvoke methods cannot exist on interfaces. + + + Method has been already defined. + diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj index dd29c084afb1..9a2fc6817030 100644 --- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj @@ -5,12 +5,9 @@ - amd64,x86,arm,armel,arm64 + x64,x86,arm,armel,arm64 $(BuildType) $(BuildArch) - - amd64 arm {3DA06C3A-2E7B-4CB7-80ED-9B12916013F9} Library @@ -49,7 +46,7 @@ - + x64 false 0x180000000 @@ -75,7 +72,7 @@ true full _LOGGING;DEBUG;TRACE;$(DefineConstants) - CODE_ANALYSIS;$(DefineConstants) + CODE_ANALYSIS;$(DefineConstants) true @@ -244,65 +241,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -329,8 +267,6 @@ - - @@ -341,7 +277,6 @@ - @@ -364,6 +299,10 @@ + + + + @@ -396,7 +335,6 @@ - @@ -407,7 +345,6 @@ - @@ -417,13 +354,6 @@ - - - - - - - @@ -456,12 +386,9 @@ - - - @@ -469,11 +396,8 @@ - - - @@ -493,7 +417,6 @@ - @@ -511,10 +434,14 @@ + + + - + + @@ -556,11 +483,8 @@ - - - @@ -606,11 +530,8 @@ - - - diff --git a/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs b/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs index aeff3ce2ca0a..03d3f8521176 100644 --- a/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs +++ b/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs @@ -357,6 +357,17 @@ public static ref T AsRef(void* source) return ref Unsafe.As(ref *(byte*)source); } + /// + /// Reinterprets the given location as a reference to a value of type . + /// + [Intrinsic] + [NonVersionable] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T AsRef(in T source) + { + throw new PlatformNotSupportedException(); + } + /// /// Determines the byte offset from origin to target from the given references. /// diff --git a/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs b/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs index 9942882f1a14..aeeb60ff775b 100644 --- a/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs +++ b/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Collation.cs @@ -20,13 +20,11 @@ internal static partial class Globalization [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")] internal static extern unsafe int CompareString(SafeSortHandle sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options); - [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")] - internal static extern unsafe int IndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")] internal static extern unsafe int IndexOf(SafeSortHandle sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")] - internal static extern unsafe int LastIndexOf(SafeSortHandle sortHandle, string target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); + internal static extern unsafe int LastIndexOf(SafeSortHandle sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOfOrdinalIgnoreCase")] internal static extern unsafe int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast); diff --git a/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Locale.cs b/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Locale.cs index 9ef41dedf2ee..b6f5fbec1cab 100644 --- a/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Locale.cs +++ b/src/System.Private.CoreLib/shared/Interop/Unix/System.Globalization.Native/Interop.Locale.cs @@ -35,6 +35,6 @@ internal static partial class Globalization internal static extern unsafe bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize); [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocales")] - internal static extern unsafe int GetLocales([Out] Char[] value, int valueLength); + internal static extern unsafe int GetLocales([Out] char[] value, int valueLength); } } diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CloseHandle.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CloseHandle.cs index 96ed922a846d..ff41f939f1c6 100644 --- a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CloseHandle.cs +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.CloseHandle.cs @@ -10,7 +10,6 @@ internal partial class Interop internal partial class Kernel32 { [DllImport(Libraries.Kernel32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool CloseHandle(IntPtr handle); } } diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Constants.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Constants.cs new file mode 100644 index 000000000000..b13cdfd03fed --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Constants.cs @@ -0,0 +1,15 @@ +// 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. + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + internal const int MAXIMUM_ALLOWED = 0x02000000; + internal const int SYNCHRONIZE = 0x00100000; + internal const int MUTEX_MODIFY_STATE = 0x00000001; + internal const int SEMAPHORE_MODIFY_STATE = 0x00000002; + internal const int EVENT_MODIFY_STATE = 0x00000002; + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs new file mode 100644 index 000000000000..b562e527e719 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs @@ -0,0 +1,28 @@ +// 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.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + internal const uint CREATE_EVENT_INITIAL_SET = 0x2; + internal const uint CREATE_EVENT_MANUAL_RESET = 0x1; + + [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] + internal static extern bool SetEvent(SafeWaitHandle handle); + + [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] + internal static extern bool ResetEvent(SafeWaitHandle handle); + + [DllImport(Interop.Libraries.Kernel32, EntryPoint = "CreateEventExW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle CreateEventEx(IntPtr lpSecurityAttributes, string name, uint flags, uint desiredAccess); + + [DllImport(Interop.Libraries.Kernel32, EntryPoint = "OpenEventW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle OpenEvent(uint desiredAccess, bool inheritHandle, string name); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.MUI.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.MUI.cs index 6ed7aa2dc41c..8d97c03546ab 100644 --- a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.MUI.cs +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.MUI.cs @@ -13,6 +13,6 @@ internal static partial class Kernel32 internal const uint MUI_PREFERRED_UI_LANGUAGES = 0x10; [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)] - internal static extern bool GetFileMUIPath(uint flags, String filePath, [Out] StringBuilder language, ref int languageLength, [Out] StringBuilder fileMuiPath, ref int fileMuiPathLength, ref Int64 enumerator); + internal static extern bool GetFileMUIPath(uint flags, string filePath, [Out] StringBuilder language, ref int languageLength, [Out] StringBuilder fileMuiPath, ref int fileMuiPathLength, ref long enumerator); } } diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Mutex.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Mutex.cs new file mode 100644 index 000000000000..cbb306e4f71f --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Mutex.cs @@ -0,0 +1,24 @@ +// 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.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + internal const uint CREATE_MUTEX_INITIAL_OWNER = 0x1; + + [DllImport(Interop.Libraries.Kernel32, EntryPoint = "OpenMutexW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name); + + [DllImport(Interop.Libraries.Kernel32, EntryPoint = "CreateMutexExW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle CreateMutexEx(IntPtr lpMutexAttributes, string name, uint flags, uint desiredAccess); + + [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] + internal static extern bool ReleaseMutex(SafeWaitHandle handle); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryValues.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryValues.cs index 8a4b84dccd20..3c02c4976ba1 100644 --- a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryValues.cs +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.RegistryValues.cs @@ -14,6 +14,9 @@ internal partial class RegistryValues // (with environment variable references) internal const int REG_BINARY = 3; // Free form binary internal const int REG_DWORD = 4; // 32-bit number + internal const int REG_DWORD_LITTLE_ENDIAN = 4; // 32-bit number (same as REG_DWORD) + internal const int REG_DWORD_BIG_ENDIAN = 5; // 32-bit number + internal const int REG_LINK = 6; // Symbolic Link (Unicode) internal const int REG_MULTI_SZ = 7; // Multiple Unicode strings internal const int REG_QWORD = 11; // 64-bit number } diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Semaphore.cs b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Semaphore.cs new file mode 100644 index 000000000000..94648a707799 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Interop/Windows/Kernel32/Interop.Semaphore.cs @@ -0,0 +1,22 @@ +// 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.Win32.SafeHandles; +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class Kernel32 + { + [DllImport(Interop.Libraries.Kernel32, EntryPoint = "OpenSemaphoreW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle OpenSemaphore(uint desiredAccess, bool inheritHandle, string name); + + [DllImport(Libraries.Kernel32, EntryPoint = "CreateSemaphoreExW", SetLastError = true, CharSet = CharSet.Unicode)] + internal static extern SafeWaitHandle CreateSemaphoreEx(IntPtr lpSecurityAttributes, int initialCount, int maximumCount, string name, uint flags, uint desiredAccess); + + [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] + internal static extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount); + } +} diff --git a/src/System.Private.CoreLib/shared/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs b/src/System.Private.CoreLib/shared/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs index 1af2b3fce964..be902b0c5820 100644 --- a/src/System.Private.CoreLib/shared/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs +++ b/src/System.Private.CoreLib/shared/Interop/Windows/OleAut32/Interop.SysAllocStringLen.cs @@ -14,6 +14,6 @@ internal partial class OleAut32 internal static extern SafeBSTRHandle SysAllocStringLen(IntPtr src, uint len); [DllImport(Libraries.OleAut32, CharSet = CharSet.Unicode)] - internal static extern IntPtr SysAllocStringLen(String src, int len); + internal static extern IntPtr SysAllocStringLen(string src, int len); } } diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs index 1d8d561a7960..5395abe067ab 100644 --- a/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.cs +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/RegistryValueKind.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. - namespace Microsoft.Win32 { #if REGISTRY_ASSEMBLY diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.Windows.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.Windows.cs new file mode 100644 index 000000000000..66f17f0af709 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.Windows.cs @@ -0,0 +1,11 @@ +// 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. + +namespace Microsoft.Win32.SafeHandles +{ + public sealed partial class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid + { + protected override bool ReleaseHandle() => Interop.Kernel32.CloseHandle(handle); + } +} diff --git a/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs new file mode 100644 index 000000000000..edb0cdfcafe7 --- /dev/null +++ b/src/System.Private.CoreLib/shared/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs @@ -0,0 +1,21 @@ +// 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 Microsoft.Win32.SafeHandles +{ + public sealed partial class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid + { + // Called by P/Invoke marshaler + private SafeWaitHandle() : base(true) + { + } + + public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) + { + SetHandle(existingHandle); + } + } +} diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems index 98f9d1ebefa4..743a70361f4d 100644 --- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems +++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems @@ -26,6 +26,7 @@ + @@ -115,6 +116,8 @@ + + @@ -174,6 +177,7 @@ + @@ -215,6 +219,7 @@ + @@ -321,6 +326,16 @@ + + + + + + + + + + @@ -393,6 +408,7 @@ + @@ -476,6 +492,14 @@ + + + + + + + + @@ -561,16 +585,23 @@ + + + + + + + @@ -701,7 +732,6 @@ - @@ -746,8 +776,8 @@ - + @@ -787,9 +817,18 @@ + + + + + + + + + @@ -848,4 +887,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/System.Private.CoreLib/shared/System/AccessViolationException.cs b/src/System.Private.CoreLib/shared/System/AccessViolationException.cs index 280d9b8a9795..a66f2a892e79 100644 --- a/src/System.Private.CoreLib/shared/System/AccessViolationException.cs +++ b/src/System.Private.CoreLib/shared/System/AccessViolationException.cs @@ -26,13 +26,13 @@ public AccessViolationException() HResult = HResults.E_POINTER; } - public AccessViolationException(String message) + public AccessViolationException(string message) : base(message) { HResult = HResults.E_POINTER; } - public AccessViolationException(String message, Exception innerException) + public AccessViolationException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.E_POINTER; diff --git a/src/System.Private.CoreLib/shared/System/ApplicationException.cs b/src/System.Private.CoreLib/shared/System/ApplicationException.cs index f36e2c1274e5..cac29196bfff 100644 --- a/src/System.Private.CoreLib/shared/System/ApplicationException.cs +++ b/src/System.Private.CoreLib/shared/System/ApplicationException.cs @@ -39,13 +39,13 @@ public ApplicationException() // message, its HRESULT set to COR_E_APPLICATION, // and its ExceptionInfo reference set to null. // - public ApplicationException(String message) + public ApplicationException(string message) : base(message) { HResult = HResults.COR_E_APPLICATION; } - public ApplicationException(String message, Exception innerException) + public ApplicationException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_APPLICATION; diff --git a/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs b/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs index 80e43cc26598..edc38f2a4c56 100644 --- a/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs +++ b/src/System.Private.CoreLib/shared/System/ArgumentNullException.cs @@ -30,19 +30,19 @@ public ArgumentNullException() HResult = HResults.E_POINTER; } - public ArgumentNullException(String paramName) + public ArgumentNullException(string paramName) : base(SR.ArgumentNull_Generic, paramName) { HResult = HResults.E_POINTER; } - public ArgumentNullException(String message, Exception innerException) + public ArgumentNullException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.E_POINTER; } - public ArgumentNullException(String paramName, String message) + public ArgumentNullException(string paramName, string message) : base(message, paramName) { HResult = HResults.E_POINTER; diff --git a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs index 604caa8ee87e..8d91561ce462 100644 --- a/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs +++ b/src/System.Private.CoreLib/shared/System/ArgumentOutOfRangeException.cs @@ -22,7 +22,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class ArgumentOutOfRangeException : ArgumentException { - private Object _actualValue; + private object _actualValue; // Creates a new ArgumentOutOfRangeException with its message // string set to a default message explaining an argument was out of range. @@ -32,19 +32,19 @@ public ArgumentOutOfRangeException() HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } - public ArgumentOutOfRangeException(String paramName) + public ArgumentOutOfRangeException(string paramName) : base(SR.Arg_ArgumentOutOfRangeException, paramName) { HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } - public ArgumentOutOfRangeException(String paramName, String message) + public ArgumentOutOfRangeException(string paramName, string message) : base(message, paramName) { HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; } - public ArgumentOutOfRangeException(String message, Exception innerException) + public ArgumentOutOfRangeException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENTOUTOFRANGE; @@ -53,7 +53,7 @@ public ArgumentOutOfRangeException(String message, Exception innerException) // We will not use this in the classlibs, but we'll provide it for // anyone that's really interested so they don't have to stick a bunch // of printf's in their code. - public ArgumentOutOfRangeException(String paramName, Object actualValue, String message) + public ArgumentOutOfRangeException(string paramName, object actualValue, string message) : base(message, paramName) { _actualValue = actualValue; @@ -72,14 +72,14 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("ActualValue", _actualValue, typeof(object)); } - public override String Message + public override string Message { get { - String s = base.Message; + string s = base.Message; if (_actualValue != null) { - String valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, _actualValue.ToString()); + string valueMessage = SR.Format(SR.ArgumentOutOfRange_ActualValue, _actualValue.ToString()); if (s == null) return valueMessage; return s + Environment.NewLine + valueMessage; @@ -92,7 +92,7 @@ public override String Message // Note - we don't set this anywhere in the class libraries in // version 1, but it might come in handy for other developers who // want to avoid sticking printf's in their code. - public virtual Object ActualValue + public virtual object ActualValue { get { return _actualValue; } } diff --git a/src/System.Private.CoreLib/shared/System/ArithmeticException.cs b/src/System.Private.CoreLib/shared/System/ArithmeticException.cs index 606f1debfd8a..46492cab5665 100644 --- a/src/System.Private.CoreLib/shared/System/ArithmeticException.cs +++ b/src/System.Private.CoreLib/shared/System/ArithmeticException.cs @@ -34,13 +34,13 @@ public ArithmeticException() // message, its HRESULT set to COR_E_ARITHMETIC, // and its ExceptionInfo reference set to null. // - public ArithmeticException(String message) + public ArithmeticException(string message) : base(message) { HResult = HResults.COR_E_ARITHMETIC; } - public ArithmeticException(String message, Exception innerException) + public ArithmeticException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARITHMETIC; diff --git a/src/System.Private.CoreLib/shared/System/ArraySegment.cs b/src/System.Private.CoreLib/shared/System/ArraySegment.cs index 81cf7706756a..b2bd41780614 100644 --- a/src/System.Private.CoreLib/shared/System/ArraySegment.cs +++ b/src/System.Private.CoreLib/shared/System/ArraySegment.cs @@ -131,7 +131,7 @@ public void CopyTo(ArraySegment destination) System.Array.Copy(_array, _offset, destination._array, destination._offset, _count); } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is ArraySegment) return Equals((ArraySegment)obj); diff --git a/src/System.Private.CoreLib/shared/System/ArrayTypeMismatchException.cs b/src/System.Private.CoreLib/shared/System/ArrayTypeMismatchException.cs index 49820f58f57a..2f60fd4ea514 100644 --- a/src/System.Private.CoreLib/shared/System/ArrayTypeMismatchException.cs +++ b/src/System.Private.CoreLib/shared/System/ArrayTypeMismatchException.cs @@ -34,13 +34,13 @@ public ArrayTypeMismatchException() // message, its HRESULT set to COR_E_ARRAYTYPEMISMATCH, // and its ExceptionInfo reference set to null. // - public ArrayTypeMismatchException(String message) + public ArrayTypeMismatchException(string message) : base(message) { HResult = HResults.COR_E_ARRAYTYPEMISMATCH; } - public ArrayTypeMismatchException(String message, Exception innerException) + public ArrayTypeMismatchException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARRAYTYPEMISMATCH; diff --git a/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs b/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs index 1743075a6fd6..c8cb65c64a3e 100644 --- a/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs +++ b/src/System.Private.CoreLib/shared/System/BadImageFormatException.cs @@ -21,8 +21,8 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public partial class BadImageFormatException : SystemException { - private String _fileName; // The name of the corrupt PE file. - private String _fusionLog = null; // fusion log (when applicable) + private string _fileName; // The name of the corrupt PE file. + private string _fusionLog = null; // fusion log (when applicable) public BadImageFormatException() : base(SR.Arg_BadImageFormatException) @@ -30,25 +30,25 @@ public BadImageFormatException() HResult = HResults.COR_E_BADIMAGEFORMAT; } - public BadImageFormatException(String message) + public BadImageFormatException(string message) : base(message) { HResult = HResults.COR_E_BADIMAGEFORMAT; } - public BadImageFormatException(String message, Exception inner) + public BadImageFormatException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_BADIMAGEFORMAT; } - public BadImageFormatException(String message, String fileName) : base(message) + public BadImageFormatException(string message, string fileName) : base(message) { HResult = HResults.COR_E_BADIMAGEFORMAT; _fileName = fileName; } - public BadImageFormatException(String message, String fileName, Exception inner) + public BadImageFormatException(string message, string fileName, Exception inner) : base(message, inner) { HResult = HResults.COR_E_BADIMAGEFORMAT; @@ -69,7 +69,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont info.AddValue("BadImageFormat_FusionLog", _fusionLog, typeof(string)); } - public override String Message + public override string Message { get { @@ -91,14 +91,14 @@ private void SetMessageField() } } - public String FileName + public string FileName { get { return _fileName; } } - public override String ToString() + public override string ToString() { - String s = GetType().ToString() + ": " + Message; + string s = GetType().ToString() + ": " + Message; if (_fileName != null && _fileName.Length != 0) s += Environment.NewLine + SR.Format(SR.IO_FileName_Name, _fileName); @@ -121,7 +121,7 @@ public override String ToString() return s; } - public String FusionLog + public string FusionLog { get { return _fusionLog; } } diff --git a/src/System.Private.CoreLib/shared/System/BitConverter.cs b/src/System.Private.CoreLib/shared/System/BitConverter.cs index e3cf20eb6a88..8a8101ddce2a 100644 --- a/src/System.Private.CoreLib/shared/System/BitConverter.cs +++ b/src/System.Private.CoreLib/shared/System/BitConverter.cs @@ -376,7 +376,7 @@ public static string ToString(byte[] value, int startIndex, int length) if (length > (int.MaxValue / 3)) { - // (Int32.MaxValue / 3) == 715,827,882 Bytes == 699 MB + // (int.MaxValue / 3) == 715,827,882 Bytes == 699 MB throw new ArgumentOutOfRangeException(nameof(length), SR.Format(SR.ArgumentOutOfRange_LengthTooLarge, (int.MaxValue / 3))); } diff --git a/src/System.Private.CoreLib/shared/System/Boolean.cs b/src/System.Private.CoreLib/shared/System/Boolean.cs index c55fc65ccbc4..4daf6f3f96b8 100644 --- a/src/System.Private.CoreLib/shared/System/Boolean.cs +++ b/src/System.Private.CoreLib/shared/System/Boolean.cs @@ -19,12 +19,12 @@ namespace System { [Serializable] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Boolean : IComparable, IConvertible, IComparable, IEquatable + public readonly struct Boolean : IComparable, IConvertible, IComparable, IEquatable { // // Member Variables // - private bool m_value; // Do not rename (binary serialization) + private readonly bool m_value; // Do not rename (binary serialization) // The true value. // @@ -41,11 +41,11 @@ public struct Boolean : IComparable, IConvertible, IComparable, IEquata // The internal string representation of true. // - internal const String TrueLiteral = "True"; + internal const string TrueLiteral = "True"; // The internal string representation of false. // - internal const String FalseLiteral = "False"; + internal const string FalseLiteral = "False"; // @@ -54,11 +54,11 @@ public struct Boolean : IComparable, IConvertible, IComparable, IEquata // The public string representation of true. // - public static readonly String TrueString = TrueLiteral; + public static readonly string TrueString = TrueLiteral; // The public string representation of false. // - public static readonly String FalseString = FalseLiteral; + public static readonly string FalseString = FalseLiteral; // // Overriden Instance Methods @@ -81,7 +81,7 @@ public override int GetHashCode() **Exceptions: None. ==============================================================================*/ // Converts the boolean value of this instance to a String. - public override String ToString() + public override string ToString() { if (false == m_value) { @@ -90,41 +90,57 @@ public override String ToString() return TrueLiteral; } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return ToString(); } public bool TryFormat(Span destination, out int charsWritten) { - string s = m_value ? TrueLiteral : FalseLiteral; - - if (s.AsSpan().TryCopyTo(destination)) + if (m_value) { - charsWritten = s.Length; - return true; + if ((uint)destination.Length > 3) // uint cast, per https://github.com/dotnet/coreclr/issues/18688 + { + destination[0] = 'T'; + destination[1] = 'r'; + destination[2] = 'u'; + destination[3] = 'e'; + charsWritten = 4; + return true; + } } else { - charsWritten = 0; - return false; + if ((uint)destination.Length > 4) + { + destination[0] = 'F'; + destination[1] = 'a'; + destination[2] = 'l'; + destination[3] = 's'; + destination[4] = 'e'; + charsWritten = 5; + return true; + } } + + charsWritten = 0; + return false; } // Determines whether two Boolean objects are equal. - public override bool Equals(Object obj) + public override bool Equals(object obj) { //If it's not a boolean, we're definitely not equal - if (!(obj is Boolean)) + if (!(obj is bool)) { return false; } - return (m_value == ((Boolean)obj).m_value); + return (m_value == ((bool)obj).m_value); } [NonVersionable] - public bool Equals(Boolean obj) + public bool Equals(bool obj) { return m_value == obj; } @@ -136,18 +152,18 @@ public bool Equals(Boolean obj) // // Returns a value less than zero if this object // - public int CompareTo(Object obj) + public int CompareTo(object obj) { if (obj == null) { return 1; } - if (!(obj is Boolean)) + if (!(obj is bool)) { throw new ArgumentException(SR.Arg_MustBeBoolean); } - if (m_value == ((Boolean)obj).m_value) + if (m_value == ((bool)obj).m_value) { return 0; } @@ -158,7 +174,7 @@ public int CompareTo(Object obj) return 1; } - public int CompareTo(Boolean value) + public int CompareTo(bool value) { if (m_value == value) { @@ -198,7 +214,7 @@ internal static bool IsFalseStringIgnoreCase(ReadOnlySpan value) // Determines whether a String represents true or false. // - public static Boolean Parse(String value) + public static bool Parse(string value) { if (value == null) throw new ArgumentNullException(nameof(value)); return Parse(value.AsSpan()); @@ -209,7 +225,7 @@ public static bool Parse(ReadOnlySpan value) => // Determines whether a String represents true or false. // - public static Boolean TryParse(String value, out Boolean result) + public static bool TryParse(string value, out bool result) { if (value == null) { @@ -260,7 +276,7 @@ private static ReadOnlySpan TrimWhiteSpaceAndNull(ReadOnlySpan value int start = 0; while (start < value.Length) { - if (!Char.IsWhiteSpace(value[start]) && value[start] != nullChar) + if (!char.IsWhiteSpace(value[start]) && value[start] != nullChar) { break; } @@ -270,7 +286,7 @@ private static ReadOnlySpan TrimWhiteSpaceAndNull(ReadOnlySpan value int end = value.Length - 1; while (end >= start) { - if (!Char.IsWhiteSpace(value[end]) && value[end] != nullChar) + if (!char.IsWhiteSpace(value[end]) && value[end] != nullChar) { break; } @@ -350,7 +366,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -360,7 +376,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Boolean", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Byte.cs b/src/System.Private.CoreLib/shared/System/Byte.cs index 31185f0ed028..5e8580642b0b 100644 --- a/src/System.Private.CoreLib/shared/System/Byte.cs +++ b/src/System.Private.CoreLib/shared/System/Byte.cs @@ -12,9 +12,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Byte : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct Byte : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private byte m_value; // Do not rename (binary serialization) + private readonly byte m_value; // Do not rename (binary serialization) // The maximum value that a Byte may represent: 255. public const byte MaxValue = (byte)0xFF; @@ -29,37 +29,37 @@ public struct Byte : IComparable, IConvertible, IFormattable, IComparable, // null is considered to be less than any instance. // If object is not of type byte, this method throws an ArgumentException. // - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) { return 1; } - if (!(value is Byte)) + if (!(value is byte)) { throw new ArgumentException(SR.Arg_MustBeByte); } - return m_value - (((Byte)value).m_value); + return m_value - (((byte)value).m_value); } - public int CompareTo(Byte value) + public int CompareTo(byte value) { return m_value - value; } // Determines whether two Byte objects are equal. - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (!(obj is Byte)) + if (!(obj is byte)) { return false; } - return m_value == ((Byte)obj).m_value; + return m_value == ((byte)obj).m_value; } [NonVersionable] - public bool Equals(Byte obj) + public bool Equals(byte obj) { return m_value == obj; } @@ -70,20 +70,20 @@ public override int GetHashCode() return m_value; } - public static byte Parse(String s) + public static byte Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } - public static byte Parse(String s, NumberStyles style) + public static byte Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, style, NumberFormatInfo.CurrentInfo); } - public static byte Parse(String s, IFormatProvider provider) + public static byte Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); @@ -92,7 +92,7 @@ public static byte Parse(String s, IFormatProvider provider) // Parses an unsigned byte from a String in the given style. If // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. - public static byte Parse(String s, NumberStyles style, IFormatProvider provider) + public static byte Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -121,7 +121,7 @@ private static byte Parse(ReadOnlySpan s, NumberStyles style, NumberFormat return (byte)i; } - public static bool TryParse(String s, out Byte result) + public static bool TryParse(string s, out byte result) { if (s == null) { @@ -137,7 +137,7 @@ public static bool TryParse(ReadOnlySpan s, out byte result) return TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result); } - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Byte result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out byte result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -156,7 +156,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro return TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result); } - private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out Byte result) + private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out byte result) { result = 0; int i; @@ -172,22 +172,22 @@ private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFor return true; } - public override String ToString() + public override string ToString() { return Number.FormatInt32(m_value, null, null); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatInt32(m_value, format, null); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatInt32(m_value, null, provider); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatInt32(m_value, format, provider); } @@ -266,7 +266,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -276,7 +276,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Byte", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Char.cs b/src/System.Private.CoreLib/shared/System/Char.cs index d3ed1f5b6830..8c743369b1ec 100644 --- a/src/System.Private.CoreLib/shared/System/Char.cs +++ b/src/System.Private.CoreLib/shared/System/Char.cs @@ -21,12 +21,12 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Char : IComparable, IComparable, IEquatable, IConvertible + public readonly struct Char : IComparable, IComparable, IEquatable, IConvertible { // // Member Variables // - private char m_value; // Do not rename (binary serialization) + private readonly char m_value; // Do not rename (binary serialization) // // Public Constants @@ -87,7 +87,7 @@ private static bool IsAscii(char ch) // Return the Unicode category for Unicode character <= 0x00ff. private static UnicodeCategory GetLatin1UnicodeCategory(char ch) { - Debug.Assert(IsLatin1(ch), "Char.GetLatin1UnicodeCategory(): ch should be <= 007f"); + Debug.Assert(IsLatin1(ch), "char.GetLatin1UnicodeCategory(): ch should be <= 007f"); return (UnicodeCategory)(s_categoryForLatin1[(int)ch]); } @@ -107,17 +107,17 @@ public override int GetHashCode() // Used for comparing two boxed Char objects. // - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (!(obj is Char)) + if (!(obj is char)) { return false; } - return (m_value == ((Char)obj).m_value); + return (m_value == ((char)obj).m_value); } [System.Runtime.Versioning.NonVersionable] - public bool Equals(Char obj) + public bool Equals(char obj) { return m_value == obj; } @@ -128,34 +128,34 @@ public bool Equals(Char obj) // null is considered to be less than any instance. // If object is not of type Char, this method throws an ArgumentException. // - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) { return 1; } - if (!(value is Char)) + if (!(value is char)) { throw new ArgumentException(SR.Arg_MustBeChar); } - return (m_value - ((Char)value).m_value); + return (m_value - ((char)value).m_value); } - public int CompareTo(Char value) + public int CompareTo(char value) { return (m_value - value); } // Overrides System.Object.ToString. - public override String ToString() + public override string ToString() { - return Char.ToString(m_value); + return char.ToString(m_value); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { - return Char.ToString(m_value); + return char.ToString(m_value); } // @@ -168,7 +168,7 @@ public String ToString(IFormatProvider provider) // Provides a string representation of a character. public static string ToString(char c) => string.CreateFromChar(c); - public static char Parse(String s) + public static char Parse(string s) { if (s == null) { @@ -182,7 +182,7 @@ public static char Parse(String s) return s[0]; } - public static bool TryParse(String s, out Char result) + public static bool TryParse(string s, out char result) { result = '\0'; if (s == null) @@ -201,7 +201,7 @@ public static bool TryParse(String s, out Char result) // Static Methods // /*=================================ISDIGIT====================================== - **A wrapper for Char. Returns a boolean indicating whether ** + **A wrapper for char. Returns a boolean indicating whether ** **character c is considered to be a digit. ** ==============================================================================*/ // Determines whether a character is a digit. @@ -233,7 +233,7 @@ internal static bool CheckLetter(UnicodeCategory uc) } /*=================================ISLETTER===================================== - **A wrapper for Char. Returns a boolean indicating whether ** + **A wrapper for char. Returns a boolean indicating whether ** **character c is considered to be a letter. ** ==============================================================================*/ // Determines whether a character is a letter. @@ -271,7 +271,7 @@ private static bool IsWhiteSpaceLatin1(char c) } /*===============================ISWHITESPACE=================================== - **A wrapper for Char. Returns a boolean indicating whether ** + **A wrapper for char. Returns a boolean indicating whether ** **character c is considered to be a whitespace character. ** ==============================================================================*/ // Determines whether a character is whitespace. @@ -393,7 +393,7 @@ public static char ToUpper(char c, CultureInfo culture) } /*=================================TOUPPER====================================== - **A wrapper for Char.toUpperCase. Converts character c to its ** + **A wrapper for char.ToUpperCase. Converts character c to its ** **uppercase equivalent. If c is already an uppercase character or is not an ** **alphabetic, nothing happens. ** ==============================================================================*/ @@ -425,7 +425,7 @@ public static char ToLower(char c, CultureInfo culture) } /*=================================TOLOWER====================================== - **A wrapper for Char.toLowerCase. Converts character c to its ** + **A wrapper for char.ToLowerCase. Converts character c to its ** **lowercase equivalent. If c is already a lowercase character or is not an ** **alphabetic, nothing happens. ** ==============================================================================*/ @@ -512,7 +512,7 @@ double IConvertible.ToDouble(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Double")); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "Decimal")); } @@ -522,7 +522,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Char", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } @@ -535,7 +535,7 @@ public static bool IsControl(char c) return (CharUnicodeInfo.GetUnicodeCategory(c) == UnicodeCategory.Control); } - public static bool IsControl(String s, int index) + public static bool IsControl(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -552,7 +552,7 @@ public static bool IsControl(String s, int index) } - public static bool IsDigit(String s, int index) + public static bool IsDigit(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -568,7 +568,7 @@ public static bool IsDigit(String s, int index) return (CharUnicodeInfo.GetUnicodeCategory(s, index) == UnicodeCategory.DecimalDigitNumber); } - public static bool IsLetter(String s, int index) + public static bool IsLetter(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -589,7 +589,7 @@ public static bool IsLetter(String s, int index) return (CheckLetter(CharUnicodeInfo.GetUnicodeCategory(s, index))); } - public static bool IsLetterOrDigit(String s, int index) + public static bool IsLetterOrDigit(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -605,7 +605,7 @@ public static bool IsLetterOrDigit(String s, int index) return CheckLetterOrDigit(CharUnicodeInfo.GetUnicodeCategory(s, index)); } - public static bool IsLower(String s, int index) + public static bool IsLower(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -655,7 +655,7 @@ public static bool IsNumber(char c) return (CheckNumber(CharUnicodeInfo.GetUnicodeCategory(c))); } - public static bool IsNumber(String s, int index) + public static bool IsNumber(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -683,7 +683,7 @@ public static bool IsNumber(String s, int index) // //////////////////////////////////////////////////////////////////////// - public static bool IsPunctuation(String s, int index) + public static bool IsPunctuation(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -732,7 +732,7 @@ public static bool IsSeparator(char c) return (CheckSeparator(CharUnicodeInfo.GetUnicodeCategory(c))); } - public static bool IsSeparator(String s, int index) + public static bool IsSeparator(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -753,7 +753,7 @@ public static bool IsSurrogate(char c) return (c >= HIGH_SURROGATE_START && c <= LOW_SURROGATE_END); } - public static bool IsSurrogate(String s, int index) + public static bool IsSurrogate(string s, int index) { if (s == null) { @@ -792,7 +792,7 @@ public static bool IsSymbol(char c) return (CheckSymbol(CharUnicodeInfo.GetUnicodeCategory(c))); } - public static bool IsSymbol(String s, int index) + public static bool IsSymbol(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -809,7 +809,7 @@ public static bool IsSymbol(String s, int index) } - public static bool IsUpper(String s, int index) + public static bool IsUpper(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -830,7 +830,7 @@ public static bool IsUpper(String s, int index) return (CharUnicodeInfo.GetUnicodeCategory(s, index) == UnicodeCategory.UppercaseLetter); } - public static bool IsWhiteSpace(String s, int index) + public static bool IsWhiteSpace(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -856,7 +856,7 @@ public static UnicodeCategory GetUnicodeCategory(char c) return CharUnicodeInfo.GetUnicodeCategory((int)c); } - public static UnicodeCategory GetUnicodeCategory(String s, int index) + public static UnicodeCategory GetUnicodeCategory(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -876,7 +876,7 @@ public static double GetNumericValue(char c) return CharUnicodeInfo.GetNumericValue(c); } - public static double GetNumericValue(String s, int index) + public static double GetNumericValue(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -896,7 +896,7 @@ public static bool IsHighSurrogate(char c) return ((c >= CharUnicodeInfo.HIGH_SURROGATE_START) && (c <= CharUnicodeInfo.HIGH_SURROGATE_END)); } - public static bool IsHighSurrogate(String s, int index) + public static bool IsHighSurrogate(string s, int index) { if (s == null) { @@ -917,7 +917,7 @@ public static bool IsLowSurrogate(char c) return ((c >= CharUnicodeInfo.LOW_SURROGATE_START) && (c <= CharUnicodeInfo.LOW_SURROGATE_END)); } - public static bool IsLowSurrogate(String s, int index) + public static bool IsLowSurrogate(string s, int index) { if (s == null) { @@ -933,7 +933,7 @@ public static bool IsLowSurrogate(String s, int index) /*================================= IsSurrogatePair ============================ ** Check if the string specified by the index starts with a surrogate pair. ==============================================================================*/ - public static bool IsSurrogatePair(String s, int index) + public static bool IsSurrogatePair(string s, int index) { if (s == null) { @@ -972,7 +972,7 @@ public static bool IsSurrogatePair(char highSurrogate, char lowSurrogate) ** Convert an UTF32 value into a surrogate pair. ==============================================================================*/ - public static String ConvertFromUtf32(int utf32) + public static string ConvertFromUtf32(int utf32) { // For UTF32 values from U+00D800 ~ U+00DFFF, we should throw. They // are considered as irregular code unit sequence, but they are not illegal. @@ -984,7 +984,7 @@ public static String ConvertFromUtf32(int utf32) if (utf32 < UNICODE_PLANE01_START) { // This is a BMP character. - return (Char.ToString((char)utf32)); + return (char.ToString((char)utf32)); } unsafe @@ -1025,7 +1025,7 @@ public static int ConvertToUtf32(char highSurrogate, char lowSurrogate) ** This method throws if a low surrogate is seen without preceding a high-surrogate. ==============================================================================*/ - public static int ConvertToUtf32(String s, int index) + public static int ConvertToUtf32(string s, int index) { if (s == null) { diff --git a/src/System.Private.CoreLib/shared/System/CharEnumerator.cs b/src/System.Private.CoreLib/shared/System/CharEnumerator.cs index ea9915a7c4f3..ca60705d9912 100644 --- a/src/System.Private.CoreLib/shared/System/CharEnumerator.cs +++ b/src/System.Private.CoreLib/shared/System/CharEnumerator.cs @@ -19,11 +19,11 @@ namespace System { public sealed class CharEnumerator : IEnumerator, IEnumerator, IDisposable, ICloneable { - private String _str; + private string _str; private int _index; private char _currentElement; - internal CharEnumerator(String str) + internal CharEnumerator(string str) { _str = str; _index = -1; @@ -54,7 +54,7 @@ public void Dispose() _str = null; } - Object IEnumerator.Current + object IEnumerator.Current { get { return Current; } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/Comparer.cs b/src/System.Private.CoreLib/shared/System/Collections/Comparer.cs index 6fcedc09ab09..e22fb5bb91bf 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Comparer.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Comparer.cs @@ -52,7 +52,7 @@ public void GetObjectData(SerializationInfo info, StreamingContext context) // If a doesn't implement IComparable and b does, -(b.CompareTo(a)) is returned. // Otherwise an exception is thrown. // - public int Compare(Object a, Object b) + public int Compare(object a, object b) { if (a == b) return 0; if (a == null) return -1; diff --git a/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs b/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs index 3c1c0befa395..187301a08f49 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/DictionaryEntry.cs @@ -12,18 +12,18 @@ namespace System.Collections [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public struct DictionaryEntry { - private Object _key; // Do not rename (binary serialization) - private Object _value; // Do not rename (binary serialization) + private object _key; // Do not rename (binary serialization) + private object _value; // Do not rename (binary serialization) // Constructs a new DictionaryEnumerator by setting the Key // and Value fields appropriately. - public DictionaryEntry(Object key, Object value) + public DictionaryEntry(object key, object value) { _key = key; _value = value; } - public Object Key + public object Key { get { @@ -36,7 +36,7 @@ public Object Key } } - public Object Value + public object Value { get { diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs index 8ee3004f2efa..03b9865044f6 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/ArraySortHelper.cs @@ -38,7 +38,7 @@ internal static int FloorLog2PlusOne(int n) return result; } - internal static void ThrowOrIgnoreBadComparer(Object comparer) + internal static void ThrowOrIgnoreBadComparer(object comparer) { throw new ArgumentException(SR.Format(SR.Arg_BogusIComparer, comparer)); } @@ -654,10 +654,10 @@ public void Sort(TKey[] keys, TValue[] values, int index, int length, IComparer< private static void SwapIfGreaterWithItems(TKey[] keys, TValue[] values, IComparer comparer, int a, int b) { Debug.Assert(keys != null); - Debug.Assert(values != null && values.Length >= keys.Length); + Debug.Assert(values != null); Debug.Assert(comparer != null); - Debug.Assert(0 <= a && a < keys.Length); - Debug.Assert(0 <= b && b < keys.Length); + Debug.Assert(0 <= a && a < keys.Length && a < values.Length); + Debug.Assert(0 <= b && b < keys.Length && b < values.Length); if (a != b) { diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs index da5d8bb86b24..8f7ad70e29ab 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/Dictionary.cs @@ -758,27 +758,30 @@ public bool Remove(TKey key) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); } - if (_buckets != null) + int[] buckets = _buckets; + Entry[] entries = _entries; + int collisionCount = 0; + if (buckets != null) { int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF; - int bucket = hashCode % _buckets.Length; + int bucket = hashCode % buckets.Length; int last = -1; - // Value in _buckets is 1-based - int i = _buckets[bucket] - 1; + // Value in buckets is 1-based + int i = buckets[bucket] - 1; while (i >= 0) { - ref Entry entry = ref _entries[i]; + ref Entry entry = ref entries[i]; if (entry.hashCode == hashCode && (_comparer?.Equals(entry.key, key) ?? EqualityComparer.Default.Equals(entry.key, key))) { if (last < 0) { - // Value in _buckets is 1-based - _buckets[bucket] = entry.next + 1; + // Value in buckets is 1-based + buckets[bucket] = entry.next + 1; } else { - _entries[last].next = entry.next; + entries[last].next = entry.next; } entry.hashCode = -1; entry.next = _freeList; @@ -793,12 +796,18 @@ public bool Remove(TKey key) } _freeList = i; _freeCount++; - _version++; return true; } last = i; i = entry.next; + if (collisionCount >= entries.Length) + { + // The chain of entries forms a loop; which means a concurrent update has happened. + // Break out of the loop and throw, rather than looping forever. + ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported(); + } + collisionCount++; } } return false; @@ -814,27 +823,30 @@ public bool Remove(TKey key, out TValue value) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key); } - if (_buckets != null) + int[] buckets = _buckets; + Entry[] entries = _entries; + int collisionCount = 0; + if (buckets != null) { int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF; - int bucket = hashCode % _buckets.Length; + int bucket = hashCode % buckets.Length; int last = -1; - // Value in _buckets is 1-based - int i = _buckets[bucket] - 1; + // Value in buckets is 1-based + int i = buckets[bucket] - 1; while (i >= 0) { - ref Entry entry = ref _entries[i]; + ref Entry entry = ref entries[i]; if (entry.hashCode == hashCode && (_comparer?.Equals(entry.key, key) ?? EqualityComparer.Default.Equals(entry.key, key))) { if (last < 0) { - // Value in _buckets is 1-based - _buckets[bucket] = entry.next + 1; + // Value in buckets is 1-based + buckets[bucket] = entry.next + 1; } else { - _entries[last].next = entry.next; + entries[last].next = entry.next; } value = entry.value; @@ -852,12 +864,18 @@ public bool Remove(TKey key, out TValue value) } _freeList = i; _freeCount++; - _version++; return true; } last = i; i = entry.next; + if (collisionCount >= entries.Length) + { + // The chain of entries forms a loop; which means a concurrent update has happened. + // Break out of the loop and throw, rather than looping forever. + ThrowHelper.ThrowInvalidOperationException_ConcurrentOperationsNotSupported(); + } + collisionCount++; } } value = default; @@ -1163,7 +1181,7 @@ public bool MoveNext() } // Use unsigned comparison since we set index to dictionary.count+1 when the enumeration ends. - // dictionary.count+1 could be negative if dictionary.count is Int32.MaxValue + // dictionary.count+1 could be negative if dictionary.count is int.MaxValue while ((uint)_index < (uint)_dictionary._count) { ref Entry entry = ref _dictionary._entries[_index++]; diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyNotFoundException.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyNotFoundException.cs index 48eddb87454c..3990e13784b9 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/KeyNotFoundException.cs @@ -17,13 +17,13 @@ public KeyNotFoundException() HResult = HResults.COR_E_KEYNOTFOUND; } - public KeyNotFoundException(String message) + public KeyNotFoundException(string message) : base(message) { HResult = HResults.COR_E_KEYNOTFOUND; } - public KeyNotFoundException(String message, Exception innerException) + public KeyNotFoundException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_KEYNOTFOUND; diff --git a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs index 72da4a9e197f..aea6052f030a 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Generic/ValueListBuilder.cs @@ -21,7 +21,16 @@ public ValueListBuilder(Span initialSpan) _pos = 0; } - public int Length => _pos; + public int Length + { + get => _pos; + set + { + Debug.Assert(value >= 0); + Debug.Assert(value <= _span.Length); + _pos = value; + } + } public ref T this[int index] { diff --git a/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs b/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs index 1ee12138f879..1c3139d27189 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/Hashtable.cs @@ -110,16 +110,16 @@ the hash table. -- */ - private const Int32 InitialSize = 3; + private const int InitialSize = 3; - private const String LoadFactorName = "LoadFactor"; // Do not rename (binary serialization) - private const String VersionName = "Version"; // Do not rename (binary serialization) - private const String ComparerName = "Comparer"; // Do not rename (binary serialization) - private const String HashCodeProviderName = "HashCodeProvider"; // Do not rename (binary serialization) - private const String HashSizeName = "HashSize"; // Must save buckets.Length. Do not rename (binary serialization) - private const String KeysName = "Keys"; // Do not rename (binary serialization) - private const String ValuesName = "Values"; // Do not rename (binary serialization) - private const String KeyComparerName = "KeyComparer"; // Do not rename (binary serialization) + private const string LoadFactorName = "LoadFactor"; // Do not rename (binary serialization) + private const string VersionName = "Version"; // Do not rename (binary serialization) + private const string ComparerName = "Comparer"; // Do not rename (binary serialization) + private const string HashCodeProviderName = "HashCodeProvider"; // Do not rename (binary serialization) + private const string HashSizeName = "HashSize"; // Must save buckets.Length. Do not rename (binary serialization) + private const string KeysName = "Keys"; // Do not rename (binary serialization) + private const string ValuesName = "Values"; // Do not rename (binary serialization) + private const string KeyComparerName = "KeyComparer"; // Do not rename (binary serialization) // Deleted entries have their key set to buckets @@ -127,8 +127,8 @@ the hash table. // This cannot be serialized private struct bucket { - public Object key; - public Object val; + public object key; + public object val; public int hash_coll; // Store hash code; sign bit means there was a collision. } @@ -150,7 +150,7 @@ private struct bucket private ICollection _values; private IEqualityComparer _keycomparer; - private Object _syncRoot; + private object _syncRoot; [Obsolete("Please use EqualityComparer property.")] protected IHashCodeProvider hcp @@ -278,7 +278,7 @@ public Hashtable(int capacity, float loadFactor) _loadFactor = 0.72f * loadFactor; double rawsize = capacity / _loadFactor; - if (rawsize > Int32.MaxValue) + if (rawsize > int.MaxValue) throw new ArgumentException(SR.Arg_HTCapacityOverflow, nameof(capacity)); // Avoid awfully small sizes @@ -404,7 +404,7 @@ protected Hashtable(SerializationInfo info, StreamingContext context) // The out parameter seed is h1(key), while the out parameter // incr is h2(key, hashSize). Callers of this function should // add incr each time through a loop. - private uint InitHash(Object key, int hashsize, out uint seed, out uint incr) + private uint InitHash(object key, int hashsize, out uint seed, out uint incr) { // Hashcode must be positive. Also, we must not use the sign bit, since // that is used for the collision bit. @@ -423,7 +423,7 @@ private uint InitHash(Object key, int hashsize, out uint seed, out uint incr) // ArgumentException is thrown if the key is null or if the key is already // present in the hashtable. // - public virtual void Add(Object key, Object value) + public virtual void Add(object key, object value) { Insert(key, value, true); } @@ -453,7 +453,7 @@ public virtual void Clear() // Clone returns a virtually identical copy of this hash table. This does // a shallow copy - the Objects in the table aren't cloned, only the references // to those Objects. - public virtual Object Clone() + public virtual object Clone() { bucket[] lbuckets = _buckets; Hashtable ht = new Hashtable(_count, _keycomparer); @@ -465,7 +465,7 @@ public virtual Object Clone() while (bucket > 0) { bucket--; - Object keyv = lbuckets[bucket].key; + object keyv = lbuckets[bucket].key; if ((keyv != null) && (keyv != lbuckets)) { ht[keyv] = lbuckets[bucket].val; @@ -476,7 +476,7 @@ public virtual Object Clone() } // Checks if this hashtable contains the given key. - public virtual bool Contains(Object key) + public virtual bool Contains(object key) { return ContainsKey(key); } @@ -484,7 +484,7 @@ public virtual bool Contains(Object key) // Checks if this hashtable contains an entry with the given key. This is // an O(1) operation. // - public virtual bool ContainsKey(Object key) + public virtual bool ContainsKey(object key) { if (key == null) { @@ -523,7 +523,7 @@ public virtual bool ContainsKey(Object key) // search and is thus be substantially slower than the ContainsKey // method. // - public virtual bool ContainsValue(Object value) + public virtual bool ContainsValue(object value) { if (value == null) { @@ -537,7 +537,7 @@ public virtual bool ContainsValue(Object value) { for (int i = _buckets.Length; --i >= 0;) { - Object val = _buckets[i].val; + object val = _buckets[i].val; if (val != null && val.Equals(value)) return true; } @@ -556,7 +556,7 @@ private void CopyKeys(Array array, int arrayIndex) bucket[] lbuckets = _buckets; for (int i = lbuckets.Length; --i >= 0;) { - Object keyv = lbuckets[i].key; + object keyv = lbuckets[i].key; if ((keyv != null) && (keyv != _buckets)) { array.SetValue(keyv, arrayIndex++); @@ -575,7 +575,7 @@ private void CopyEntries(Array array, int arrayIndex) bucket[] lbuckets = _buckets; for (int i = lbuckets.Length; --i >= 0;) { - Object keyv = lbuckets[i].key; + object keyv = lbuckets[i].key; if ((keyv != null) && (keyv != _buckets)) { DictionaryEntry entry = new DictionaryEntry(keyv, lbuckets[i].val); @@ -611,7 +611,7 @@ internal virtual KeyValuePairs[] ToKeyValuePairsArray() bucket[] lbuckets = _buckets; for (int i = lbuckets.Length; --i >= 0;) { - Object keyv = lbuckets[i].key; + object keyv = lbuckets[i].key; if ((keyv != null) && (keyv != _buckets)) { array[index++] = new KeyValuePairs(keyv, lbuckets[i].val); @@ -633,7 +633,7 @@ private void CopyValues(Array array, int arrayIndex) bucket[] lbuckets = _buckets; for (int i = lbuckets.Length; --i >= 0;) { - Object keyv = lbuckets[i].key; + object keyv = lbuckets[i].key; if ((keyv != null) && (keyv != _buckets)) { array.SetValue(lbuckets[i].val, arrayIndex++); @@ -644,7 +644,7 @@ private void CopyValues(Array array, int arrayIndex) // Returns the value associated with the given key. If an entry with the // given key is not found, the returned value is null. // - public virtual Object this[Object key] + public virtual object this[object key] { get { @@ -736,7 +736,7 @@ private void rehash() private void UpdateVersion() { - // Version might become negative when version is Int32.MaxValue, but the oddity will be still be correct. + // Version might become negative when version is int.MaxValue, but the oddity will be still be correct. // So we don't need to special case this. _version++; } @@ -799,7 +799,7 @@ public virtual IDictionaryEnumerator GetEnumerator() // Internal method to get the hash code for an Object. This will call // GetHashCode() on each object if you haven't provided an IHashCodeProvider // instance. Otherwise, it calls hcp.GetHashCode(obj). - protected virtual int GetHash(Object key) + protected virtual int GetHash(object key) { if (_keycomparer != null) return _keycomparer.GetHashCode(key); @@ -827,15 +827,15 @@ public virtual bool IsSynchronized // instance in the constructor, this method will call comparer.Compare(item, key). // Otherwise, it will call item.Equals(key). // - protected virtual bool KeyEquals(Object item, Object key) + protected virtual bool KeyEquals(object item, object key) { Debug.Assert(key != null, "key can't be null here!"); - if (Object.ReferenceEquals(_buckets, item)) + if (object.ReferenceEquals(_buckets, item)) { return false; } - if (Object.ReferenceEquals(item, key)) + if (object.ReferenceEquals(item, key)) return true; if (_keycomparer != null) @@ -885,7 +885,7 @@ public virtual ICollection Values // Inserts an entry into this hashtable. This method is called from the Set // and Add methods. If the add parameter is true and the given key already // exists in the hashtable, an exception is thrown. - private void Insert(Object key, Object nvalue, bool add) + private void Insert(object key, object nvalue, bool add) { if (key == null) { @@ -998,7 +998,7 @@ private void Insert(Object key, Object nvalue, bool add) throw new InvalidOperationException(SR.InvalidOperation_HashInsertFailed); } - private void putEntry(bucket[] newBuckets, Object key, Object nvalue, int hashcode) + private void putEntry(bucket[] newBuckets, object key, object nvalue, int hashcode) { Debug.Assert(hashcode >= 0, "hashcode >= 0"); // make sure collision bit (sign bit) wasn't set. @@ -1028,7 +1028,7 @@ private void putEntry(bucket[] newBuckets, Object key, Object nvalue, int hashco // key exists in the hashtable, it is removed. An ArgumentException is // thrown if the key is null. // - public virtual void Remove(Object key) + public virtual void Remove(object key) { if (key == null) { @@ -1073,13 +1073,13 @@ public virtual void Remove(Object key) } // Returns the object to synchronize on for this hash table. - public virtual Object SyncRoot + public virtual object SyncRoot { get { if (_syncRoot == null) { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref _syncRoot, new object(), null); } return _syncRoot; } @@ -1145,12 +1145,12 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte #pragma warning restore 618 info.AddValue(HashSizeName, _buckets.Length); //This is the length of the bucket array. - Object[] serKeys = new Object[_count]; - Object[] serValues = new Object[_count]; + object[] serKeys = new object[_count]; + object[] serValues = new object[_count]; CopyKeys(serKeys, 0); CopyValues(serValues, 0); - info.AddValue(KeysName, serKeys, typeof(Object[])); - info.AddValue(ValuesName, serValues, typeof(Object[])); + info.AddValue(KeysName, serKeys, typeof(object[])); + info.AddValue(ValuesName, serValues, typeof(object[])); // Explicitly check to see if anyone changed the Hashtable while we // were serializing it. That's a race in their code. @@ -1164,7 +1164,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte // // DeserializationEvent Listener // - public virtual void OnDeserialization(Object sender) + public virtual void OnDeserialization(object sender) { if (_buckets != null) { @@ -1187,8 +1187,8 @@ public virtual void OnDeserialization(Object sender) IHashCodeProvider hcp = null; #pragma warning restore 618 - Object[] serKeys = null; - Object[] serValues = null; + object[] serKeys = null; + object[] serValues = null; SerializationInfoEnumerator enumerator = siInfo.GetEnumerator(); @@ -1214,10 +1214,10 @@ public virtual void OnDeserialization(Object sender) #pragma warning restore 618 break; case KeysName: - serKeys = (Object[])siInfo.GetValue(KeysName, typeof(Object[])); + serKeys = (object[])siInfo.GetValue(KeysName, typeof(object[])); break; case ValuesName: - serValues = (Object[])siInfo.GetValue(ValuesName, typeof(Object[])); + serValues = (object[])siInfo.GetValue(ValuesName, typeof(object[])); break; } } @@ -1292,7 +1292,7 @@ public virtual bool IsSynchronized get { return _hashtable.IsSynchronized; } } - public virtual Object SyncRoot + public virtual object SyncRoot { get { return _hashtable.SyncRoot; } } @@ -1337,7 +1337,7 @@ public virtual bool IsSynchronized get { return _hashtable.IsSynchronized; } } - public virtual Object SyncRoot + public virtual object SyncRoot { get { return _hashtable.SyncRoot; } } @@ -1388,7 +1388,7 @@ public override bool IsSynchronized get { return true; } } - public override Object this[Object key] + public override object this[object key] { get { @@ -1403,12 +1403,12 @@ public override Object this[Object key] } } - public override Object SyncRoot + public override object SyncRoot { get { return _table.SyncRoot; } } - public override void Add(Object key, Object value) + public override void Add(object key, object value) { lock (_table.SyncRoot) { @@ -1424,12 +1424,12 @@ public override void Clear() } } - public override bool Contains(Object key) + public override bool Contains(object key) { return _table.Contains(key); } - public override bool ContainsKey(Object key) + public override bool ContainsKey(object key) { if (key == null) { @@ -1438,7 +1438,7 @@ public override bool ContainsKey(Object key) return _table.ContainsKey(key); } - public override bool ContainsValue(Object key) + public override bool ContainsValue(object key) { lock (_table.SyncRoot) { @@ -1454,7 +1454,7 @@ public override void CopyTo(Array array, int arrayIndex) } } - public override Object Clone() + public override object Clone() { lock (_table.SyncRoot) { @@ -1494,7 +1494,7 @@ public override ICollection Values } } - public override void Remove(Object key) + public override void Remove(object key) { lock (_table.SyncRoot) { @@ -1502,7 +1502,7 @@ public override void Remove(Object key) } } - public override void OnDeserialization(Object sender) + public override void OnDeserialization(object sender) { // Does nothing. We have to implement this because our parent HT implements it, // but it doesn't do anything meaningful. The real work will be done when we @@ -1526,8 +1526,8 @@ private class HashtableEnumerator : IDictionaryEnumerator, ICloneable private int _version; private bool _current; private int _getObjectRetType; // What should GetObject return? - private Object _currentKey; - private Object _currentValue; + private object _currentKey; + private object _currentValue; internal const int Keys = 1; internal const int Values = 2; @@ -1544,7 +1544,7 @@ internal HashtableEnumerator(Hashtable hashtable, int getObjRetType) public object Clone() => MemberwiseClone(); - public virtual Object Key + public virtual object Key { get { @@ -1561,7 +1561,7 @@ public virtual bool MoveNext() while (_bucket > 0) { _bucket--; - Object keyv = _hashtable._buckets[_bucket].key; + object keyv = _hashtable._buckets[_bucket].key; if ((keyv != null) && (keyv != _hashtable._buckets)) { _currentKey = keyv; @@ -1585,7 +1585,7 @@ public virtual DictionaryEntry Entry } - public virtual Object Current + public virtual object Current { get { @@ -1601,7 +1601,7 @@ public virtual Object Current } } - public virtual Object Value + public virtual object Value { get { diff --git a/src/System.Private.CoreLib/shared/System/Collections/ICollection.cs b/src/System.Private.CoreLib/shared/System/Collections/ICollection.cs index b8eba71c240f..65e37c73813b 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/ICollection.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/ICollection.cs @@ -54,7 +54,7 @@ int Count // that the this pointer may not be sufficient for collections that // wrap other collections; those should return the underlying // collection's SyncRoot property. - Object SyncRoot + object SyncRoot { get; } // Is this collection synchronized (i.e., thread-safe)? If you want a diff --git a/src/System.Private.CoreLib/shared/System/Collections/IComparer.cs b/src/System.Private.CoreLib/shared/System/Collections/IComparer.cs index cef91c3ffa28..38bab78b3c48 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IComparer.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IComparer.cs @@ -17,6 +17,6 @@ public interface IComparer // value less than zero if x is less than y, zero if x is equal to y, or a // value greater than zero if x is greater than y. // - int Compare(Object x, Object y); + int Compare(object x, object y); } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IDictionary.cs b/src/System.Private.CoreLib/shared/System/Collections/IDictionary.cs index b934c2399cf2..b077c9192754 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IDictionary.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IDictionary.cs @@ -15,7 +15,7 @@ public interface IDictionary : ICollection // Interfaces are not serializable // The Item property provides methods to read and edit entries // in the Dictionary. - Object this[Object key] + object this[object key] { get; set; @@ -35,11 +35,11 @@ ICollection Values // Returns whether this dictionary contains a particular key. // - bool Contains(Object key); + bool Contains(object key); // Adds a key-value pair to the dictionary. // - void Add(Object key, Object value); + void Add(object key, object value); // Removes all pairs from the dictionary. void Clear(); @@ -55,6 +55,6 @@ bool IsFixedSize // Removes a particular key from the dictionary. // - void Remove(Object key); + void Remove(object key); } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IDictionaryEnumerator.cs b/src/System.Private.CoreLib/shared/System/Collections/IDictionaryEnumerator.cs index 451cf68976ec..0cf6aaa1545d 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IDictionaryEnumerator.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IDictionaryEnumerator.cs @@ -39,7 +39,7 @@ public interface IDictionaryEnumerator : IEnumerator // GetKey with no intervening calls to GetNext will return // the same object. // - Object Key + object Key { get; } @@ -50,7 +50,7 @@ Object Key // to GetValue with no intervening calls to GetNext will // return the same object. // - Object Value + object Value { get; } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IEnumerator.cs b/src/System.Private.CoreLib/shared/System/Collections/IEnumerator.cs index 2c2c2e4a97da..29a6f475bfe2 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IEnumerator.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IEnumerator.cs @@ -25,7 +25,7 @@ public interface IEnumerator // GetCurrent with no intervening calls to MoveNext // will return the same object. // - Object Current + object Current { get; } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IEqualityComparer.cs b/src/System.Private.CoreLib/shared/System/Collections/IEqualityComparer.cs index 35513f577d85..9b5476896ce6 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IEqualityComparer.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IEqualityComparer.cs @@ -10,7 +10,7 @@ namespace System.Collections // that can be consumed by some of the common collections. public interface IEqualityComparer { - bool Equals(Object x, Object y); - int GetHashCode(Object obj); + bool Equals(object x, object y); + int GetHashCode(object obj); } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IList.cs b/src/System.Private.CoreLib/shared/System/Collections/IList.cs index 0110eca1f5eb..25d3b1922690 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IList.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IList.cs @@ -12,7 +12,7 @@ namespace System.Collections public interface IList : ICollection { // The Item property provides methods to read and edit entries in the List. - Object this[int index] + object this[int index] { get; set; @@ -22,10 +22,10 @@ Object this[int index] // implementation-dependent, so while ArrayList may always insert // in the last available location, a SortedList most likely would not. // The return value is the position the new element was inserted in. - int Add(Object value); + int Add(object value); // Returns whether the list contains a particular item. - bool Contains(Object value); + bool Contains(object value); // Removes all items from the list. void Clear(); @@ -42,16 +42,16 @@ bool IsFixedSize // Returns the index of a particular item, if it is in the list. // Returns -1 if the item isn't in the list. - int IndexOf(Object value); + int IndexOf(object value); // Inserts value into the list at position index. // index must be non-negative and less than or equal to the // number of elements in the list. If index equals the number // of items in the list, then value is appended to the end. - void Insert(int index, Object value); + void Insert(int index, object value); // Removes an item from the list. - void Remove(Object value); + void Remove(object value); // Removes the item at position index. void RemoveAt(int index); diff --git a/src/System.Private.CoreLib/shared/System/Collections/IStructuralComparable.cs b/src/System.Private.CoreLib/shared/System/Collections/IStructuralComparable.cs index a5e4834b9bb2..9041e0d5ff2e 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IStructuralComparable.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IStructuralComparable.cs @@ -8,6 +8,6 @@ namespace System.Collections { public interface IStructuralComparable { - Int32 CompareTo(Object other, IComparer comparer); + int CompareTo(object other, IComparer comparer); } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/IStructuralEquatable.cs b/src/System.Private.CoreLib/shared/System/Collections/IStructuralEquatable.cs index 4e61d5e75f6a..1784da58cb06 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/IStructuralEquatable.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/IStructuralEquatable.cs @@ -6,7 +6,7 @@ namespace System.Collections { public interface IStructuralEquatable { - Boolean Equals(Object other, IEqualityComparer comparer); + bool Equals(object other, IEqualityComparer comparer); int GetHashCode(IEqualityComparer comparer); } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/ListDictionaryInternal.cs b/src/System.Private.CoreLib/shared/System/Collections/ListDictionaryInternal.cs index eccb9f034709..6045778abfeb 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/ListDictionaryInternal.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/ListDictionaryInternal.cs @@ -27,13 +27,13 @@ public class ListDictionaryInternal : IDictionary private int version; // Do not rename (binary serialization) private int count; // Do not rename (binary serialization) [NonSerialized] - private Object _syncRoot; + private object _syncRoot; public ListDictionaryInternal() { } - public Object this[Object key] + public object this[object key] { get { @@ -134,13 +134,13 @@ public bool IsSynchronized } } - public Object SyncRoot + public object SyncRoot { get { if (_syncRoot == null) { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref _syncRoot, new object(), null); } return _syncRoot; } @@ -154,7 +154,7 @@ public ICollection Values } } - public void Add(Object key, Object value) + public void Add(object key, object value) { if (key == null) { @@ -201,7 +201,7 @@ public void Clear() version++; } - public bool Contains(Object key) + public bool Contains(object key) { if (key == null) { @@ -248,7 +248,7 @@ IEnumerator IEnumerable.GetEnumerator() return new NodeEnumerator(this); } - public void Remove(Object key) + public void Remove(object key) { if (key == null) { @@ -296,7 +296,7 @@ public NodeEnumerator(ListDictionaryInternal list) current = null; } - public Object Current + public object Current { get { @@ -316,7 +316,7 @@ public DictionaryEntry Entry } } - public Object Key + public object Key { get { @@ -328,7 +328,7 @@ public Object Key } } - public Object Value + public object Value { get { @@ -422,7 +422,7 @@ bool ICollection.IsSynchronized } } - Object ICollection.SyncRoot + object ICollection.SyncRoot { get { @@ -453,7 +453,7 @@ public NodeKeyValueEnumerator(ListDictionaryInternal list, bool isKeys) current = null; } - public Object Current + public object Current { get { @@ -501,8 +501,8 @@ public void Reset() [Serializable] private class DictionaryNode { - public Object key; - public Object value; + public object key; + public object value; public DictionaryNode next; } } diff --git a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs index 1e1b2c7959b9..53272b386a49 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/Collection.cs @@ -15,7 +15,7 @@ public class Collection : IList, IList, IReadOnlyList { private IList items; // Do not rename (binary serialization) [NonSerialized] - private Object _syncRoot; + private object _syncRoot; public Collection() { @@ -195,7 +195,7 @@ object ICollection.SyncRoot } else { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref _syncRoot, new object(), null); } } return _syncRoot; diff --git a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs index dbf88d8b8d86..3c4eda20484f 100644 --- a/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs +++ b/src/System.Private.CoreLib/shared/System/Collections/ObjectModel/ReadOnlyCollection.cs @@ -15,7 +15,7 @@ public class ReadOnlyCollection : IList, IList, IReadOnlyList { private IList list; // Do not rename (binary serialization) [NonSerialized] - private Object _syncRoot; + private object _syncRoot; public ReadOnlyCollection(IList list) { @@ -127,7 +127,7 @@ object ICollection.SyncRoot } else { - System.Threading.Interlocked.CompareExchange(ref _syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref _syncRoot, new object(), null); } } return _syncRoot; diff --git a/src/System.Private.CoreLib/shared/System/Convert.cs b/src/System.Private.CoreLib/shared/System/Convert.cs index c72b5401c7a3..1c303d248108 100644 --- a/src/System.Private.CoreLib/shared/System/Convert.cs +++ b/src/System.Private.CoreLib/shared/System/Convert.cs @@ -100,27 +100,27 @@ public static partial class Convert { //A typeof operation is fairly expensive (does a system call), so we'll cache these here //statically. These are exactly lined up with the TypeCode, eg. ConvertType[TypeCode.Int16] - //will give you the type of an Int16. + //will give you the type of an short. internal static readonly Type[] ConvertTypes = { typeof(System.Empty), - typeof(Object), + typeof(object), typeof(System.DBNull), - typeof(Boolean), - typeof(Char), - typeof(SByte), - typeof(Byte), - typeof(Int16), - typeof(UInt16), - typeof(Int32), - typeof(UInt32), - typeof(Int64), - typeof(UInt64), - typeof(Single), - typeof(Double), - typeof(Decimal), + typeof(bool), + typeof(char), + typeof(sbyte), + typeof(byte), + typeof(short), + typeof(ushort), + typeof(int), + typeof(uint), + typeof(long), + typeof(ulong), + typeof(float), + typeof(double), + typeof(decimal), typeof(DateTime), - typeof(Object), //TypeCode is discontinuous so we need a placeholder. - typeof(String) + typeof(object), //TypeCode is discontinuous so we need a placeholder. + typeof(string) }; // Need to special case Enum because typecode will be underlying type, e.g. Int32 @@ -132,7 +132,7 @@ public static partial class Convert 't','u','v','w','x','y','z','0','1','2','3','4','5','6','7', '8','9','+','/','=' }; - private const Int32 base64LineBreakPosition = 76; + private const int base64LineBreakPosition = 76; #if DEBUG private static bool TriggerAsserts = DoAsserts(); @@ -142,7 +142,7 @@ private static bool DoAsserts() Debug.Assert(ConvertTypes.Length == ((int)TypeCode.String + 1), "[Convert.cctor]ConvertTypes.Length == ((int)TypeCode.String + 1)"); Debug.Assert(ConvertTypes[(int)TypeCode.Empty] == typeof(System.Empty), "[Convert.cctor]ConvertTypes[(int)TypeCode.Empty]==typeof(System.Empty)"); - Debug.Assert(ConvertTypes[(int)TypeCode.String] == typeof(String), + Debug.Assert(ConvertTypes[(int)TypeCode.String] == typeof(string), "[Convert.cctor]ConvertTypes[(int)TypeCode.String]==typeof(System.String)"); Debug.Assert(ConvertTypes[(int)TypeCode.Int32] == typeof(int), "[Convert.cctor]ConvertTypes[(int)TypeCode.Int32]==typeof(int)"); @@ -150,7 +150,7 @@ private static bool DoAsserts() } #endif - public static readonly Object DBNull = System.DBNull.Value; + public static readonly object DBNull = System.DBNull.Value; // Returns the type code for the given object. If the argument is null, // the result is TypeCode.Empty. If the argument is not a value (i.e. if @@ -189,12 +189,12 @@ public static bool IsDBNull(object value) // object already has the given type code, in which case the object is // simply returned. Otherwise, the appropriate ToXXX() is invoked on the // object's implementation of IConvertible. - public static Object ChangeType(Object value, TypeCode typeCode) + public static object ChangeType(object value, TypeCode typeCode) { return ChangeType(value, typeCode, CultureInfo.CurrentCulture); } - public static Object ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) + public static object ChangeType(object value, TypeCode typeCode, IFormatProvider provider) { if (value == null && (typeCode == TypeCode.Empty || typeCode == TypeCode.String || typeCode == TypeCode.Object)) { @@ -208,7 +208,7 @@ public static Object ChangeType(Object value, TypeCode typeCode, IFormatProvider } // This line is invalid for things like Enums that return a TypeCode - // of Int32, but the object can't actually be cast to an Int32. + // of int, but the object can't actually be cast to an int. // if (v.GetTypeCode() == typeCode) return value; switch (typeCode) { @@ -253,7 +253,7 @@ public static Object ChangeType(Object value, TypeCode typeCode, IFormatProvider } } - internal static Object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) + internal static object DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) { Debug.Assert(value != null, "[Convert.DefaultToType]value!=null"); if (targetType == null) @@ -297,7 +297,7 @@ internal static Object DefaultToType(IConvertible value, Type targetType, IForma if (ReferenceEquals(targetType, ConvertTypes[(int)TypeCode.String])) return value.ToString(provider); if (ReferenceEquals(targetType, ConvertTypes[(int)TypeCode.Object])) - return (Object)value; + return (object)value; // Need to special case Enum because typecode will be underlying type, e.g. Int32 if (ReferenceEquals(targetType, EnumType)) return (Enum)value; @@ -309,12 +309,12 @@ internal static Object DefaultToType(IConvertible value, Type targetType, IForma throw new InvalidCastException(string.Format(SR.InvalidCast_FromTo, value.GetType().FullName, targetType.FullName)); } - public static Object ChangeType(Object value, Type conversionType) + public static object ChangeType(object value, Type conversionType) { return ChangeType(value, conversionType, CultureInfo.CurrentCulture); } - public static Object ChangeType(Object value, Type conversionType, IFormatProvider provider) + public static object ChangeType(object value, Type conversionType, IFormatProvider provider) { if (conversionType is null) { @@ -371,7 +371,7 @@ public static Object ChangeType(Object value, Type conversionType, IFormatProvid if (ReferenceEquals(conversionType, ConvertTypes[(int)TypeCode.String])) return ic.ToString(provider); if (ReferenceEquals(conversionType, ConvertTypes[(int)TypeCode.Object])) - return (Object)value; + return (object)value; return ic.ToType(conversionType, provider); } @@ -395,12 +395,12 @@ public static Object ChangeType(Object value, Type conversionType, IFormatProvid private static void ThrowUInt64OverflowException() { throw new OverflowException(SR.Overflow_UInt64); } // Conversions to Boolean - public static bool ToBoolean(Object value) + public static bool ToBoolean(object value) { return value == null ? false : ((IConvertible)value).ToBoolean(null); } - public static bool ToBoolean(Object value, IFormatProvider provider) + public static bool ToBoolean(object value, IFormatProvider provider) { return value == null ? false : ((IConvertible)value).ToBoolean(provider); } @@ -463,18 +463,18 @@ public static bool ToBoolean(ulong value) return value != 0; } - public static bool ToBoolean(String value) + public static bool ToBoolean(string value) { if (value == null) return false; - return Boolean.Parse(value); + return bool.Parse(value); } - public static bool ToBoolean(String value, IFormatProvider provider) + public static bool ToBoolean(string value, IFormatProvider provider) { if (value == null) return false; - return Boolean.Parse(value); + return bool.Parse(value); } public static bool ToBoolean(float value) @@ -549,27 +549,27 @@ public static char ToChar(ushort value) public static char ToChar(int value) { - if (value < 0 || value > Char.MaxValue) ThrowCharOverflowException(); + if (value < 0 || value > char.MaxValue) ThrowCharOverflowException(); return (char)value; } [CLSCompliant(false)] public static char ToChar(uint value) { - if (value > Char.MaxValue) ThrowCharOverflowException(); + if (value > char.MaxValue) ThrowCharOverflowException(); return (char)value; } public static char ToChar(long value) { - if (value < 0 || value > Char.MaxValue) ThrowCharOverflowException(); + if (value < 0 || value > char.MaxValue) ThrowCharOverflowException(); return (char)value; } [CLSCompliant(false)] public static char ToChar(ulong value) { - if (value > Char.MaxValue) ThrowCharOverflowException(); + if (value > char.MaxValue) ThrowCharOverflowException(); return (char)value; } @@ -577,12 +577,12 @@ public static char ToChar(ulong value) // @VariantSwitch // Remove FormatExceptions; // - public static char ToChar(String value) + public static char ToChar(string value) { return ToChar(value, null); } - public static char ToChar(String value, IFormatProvider provider) + public static char ToChar(string value, IFormatProvider provider) { if (value == null) throw new ArgumentNullException(nameof(value)); @@ -640,7 +640,7 @@ public static sbyte ToSByte(object value, IFormatProvider provider) [CLSCompliant(false)] public static sbyte ToSByte(bool value) { - return value ? (sbyte)Boolean.True : (sbyte)Boolean.False; + return value ? (sbyte)bool.True : (sbyte)bool.False; } [CLSCompliant(false)] @@ -652,56 +652,56 @@ public static sbyte ToSByte(sbyte value) [CLSCompliant(false)] public static sbyte ToSByte(char value) { - if (value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(byte value) { - if (value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(short value) { - if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value < sbyte.MinValue || value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(ushort value) { - if (value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(int value) { - if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value < sbyte.MinValue || value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(uint value) { - if (value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(long value) { - if (value < SByte.MinValue || value > SByte.MaxValue) ThrowSByteOverflowException(); + if (value < sbyte.MinValue || value > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } [CLSCompliant(false)] public static sbyte ToSByte(ulong value) { - if (value > (ulong)SByte.MaxValue) ThrowSByteOverflowException(); + if (value > (ulong)sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)value; } @@ -720,21 +720,21 @@ public static sbyte ToSByte(double value) [CLSCompliant(false)] public static sbyte ToSByte(decimal value) { - return Decimal.ToSByte(Decimal.Round(value, 0)); + return decimal.ToSByte(decimal.Round(value, 0)); } [CLSCompliant(false)] - public static sbyte ToSByte(String value) + public static sbyte ToSByte(string value) { if (value == null) return 0; - return SByte.Parse(value, CultureInfo.CurrentCulture); + return sbyte.Parse(value, CultureInfo.CurrentCulture); } [CLSCompliant(false)] - public static sbyte ToSByte(String value, IFormatProvider provider) + public static sbyte ToSByte(string value, IFormatProvider provider) { - return SByte.Parse(value, NumberStyles.Integer, provider); + return sbyte.Parse(value, NumberStyles.Integer, provider); } [CLSCompliant(false)] @@ -760,7 +760,7 @@ public static byte ToByte(object value, IFormatProvider provider) public static byte ToByte(bool value) { - return value ? (byte)Boolean.True : (byte)Boolean.False; + return value ? (byte)bool.True : (byte)bool.False; } public static byte ToByte(byte value) @@ -770,53 +770,53 @@ public static byte ToByte(byte value) public static byte ToByte(char value) { - if (value > Byte.MaxValue) ThrowByteOverflowException(); + if (value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } [CLSCompliant(false)] public static byte ToByte(sbyte value) { - if (value < Byte.MinValue) ThrowByteOverflowException(); + if (value < byte.MinValue) ThrowByteOverflowException(); return (byte)value; } public static byte ToByte(short value) { - if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException(); + if (value < byte.MinValue || value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } [CLSCompliant(false)] public static byte ToByte(ushort value) { - if (value > Byte.MaxValue) ThrowByteOverflowException(); + if (value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } public static byte ToByte(int value) { - if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException(); + if (value < byte.MinValue || value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } [CLSCompliant(false)] public static byte ToByte(uint value) { - if (value > Byte.MaxValue) ThrowByteOverflowException(); + if (value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } public static byte ToByte(long value) { - if (value < Byte.MinValue || value > Byte.MaxValue) ThrowByteOverflowException(); + if (value < byte.MinValue || value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } [CLSCompliant(false)] public static byte ToByte(ulong value) { - if (value > Byte.MaxValue) ThrowByteOverflowException(); + if (value > byte.MaxValue) ThrowByteOverflowException(); return (byte)value; } @@ -832,21 +832,21 @@ public static byte ToByte(double value) public static byte ToByte(decimal value) { - return Decimal.ToByte(Decimal.Round(value, 0)); + return decimal.ToByte(decimal.Round(value, 0)); } - public static byte ToByte(String value) + public static byte ToByte(string value) { if (value == null) return 0; - return Byte.Parse(value, CultureInfo.CurrentCulture); + return byte.Parse(value, CultureInfo.CurrentCulture); } - public static byte ToByte(String value, IFormatProvider provider) + public static byte ToByte(string value, IFormatProvider provider) { if (value == null) return 0; - return Byte.Parse(value, NumberStyles.Integer, provider); + return byte.Parse(value, NumberStyles.Integer, provider); } public static byte ToByte(DateTime value) @@ -872,12 +872,12 @@ public static short ToInt16(object value, IFormatProvider provider) public static short ToInt16(bool value) { - return value ? (short)Boolean.True : (short)Boolean.False; + return value ? (short)bool.True : (short)bool.False; } public static short ToInt16(char value) { - if (value > Int16.MaxValue) ThrowInt16OverflowException(); + if (value > short.MaxValue) ThrowInt16OverflowException(); return (short)value; } @@ -895,20 +895,20 @@ public static short ToInt16(byte value) [CLSCompliant(false)] public static short ToInt16(ushort value) { - if (value > Int16.MaxValue) ThrowInt16OverflowException(); + if (value > short.MaxValue) ThrowInt16OverflowException(); return (short)value; } public static short ToInt16(int value) { - if (value < Int16.MinValue || value > Int16.MaxValue) ThrowInt16OverflowException(); + if (value < short.MinValue || value > short.MaxValue) ThrowInt16OverflowException(); return (short)value; } [CLSCompliant(false)] public static short ToInt16(uint value) { - if (value > Int16.MaxValue) ThrowInt16OverflowException(); + if (value > short.MaxValue) ThrowInt16OverflowException(); return (short)value; } @@ -919,14 +919,14 @@ public static short ToInt16(short value) public static short ToInt16(long value) { - if (value < Int16.MinValue || value > Int16.MaxValue) ThrowInt16OverflowException(); + if (value < short.MinValue || value > short.MaxValue) ThrowInt16OverflowException(); return (short)value; } [CLSCompliant(false)] public static short ToInt16(ulong value) { - if (value > (ulong)Int16.MaxValue) ThrowInt16OverflowException(); + if (value > (ulong)short.MaxValue) ThrowInt16OverflowException(); return (short)value; } @@ -942,21 +942,21 @@ public static short ToInt16(double value) public static short ToInt16(decimal value) { - return Decimal.ToInt16(Decimal.Round(value, 0)); + return decimal.ToInt16(decimal.Round(value, 0)); } - public static short ToInt16(String value) + public static short ToInt16(string value) { if (value == null) return 0; - return Int16.Parse(value, CultureInfo.CurrentCulture); + return short.Parse(value, CultureInfo.CurrentCulture); } - public static short ToInt16(String value, IFormatProvider provider) + public static short ToInt16(string value, IFormatProvider provider) { if (value == null) return 0; - return Int16.Parse(value, NumberStyles.Integer, provider); + return short.Parse(value, NumberStyles.Integer, provider); } public static short ToInt16(DateTime value) @@ -986,7 +986,7 @@ public static ushort ToUInt16(object value, IFormatProvider provider) [CLSCompliant(false)] public static ushort ToUInt16(bool value) { - return value ? (ushort)Boolean.True : (ushort)Boolean.False; + return value ? (ushort)bool.True : (ushort)bool.False; } [CLSCompliant(false)] @@ -1018,7 +1018,7 @@ public static ushort ToUInt16(short value) [CLSCompliant(false)] public static ushort ToUInt16(int value) { - if (value < 0 || value > UInt16.MaxValue) ThrowUInt16OverflowException(); + if (value < 0 || value > ushort.MaxValue) ThrowUInt16OverflowException(); return (ushort)value; } @@ -1031,7 +1031,7 @@ public static ushort ToUInt16(ushort value) [CLSCompliant(false)] public static ushort ToUInt16(uint value) { - if (value > UInt16.MaxValue) ThrowUInt16OverflowException(); + if (value > ushort.MaxValue) ThrowUInt16OverflowException(); return (ushort)value; } @@ -1039,14 +1039,14 @@ public static ushort ToUInt16(uint value) [CLSCompliant(false)] public static ushort ToUInt16(long value) { - if (value < 0 || value > UInt16.MaxValue) ThrowUInt16OverflowException(); + if (value < 0 || value > ushort.MaxValue) ThrowUInt16OverflowException(); return (ushort)value; } [CLSCompliant(false)] public static ushort ToUInt16(ulong value) { - if (value > UInt16.MaxValue) ThrowUInt16OverflowException(); + if (value > ushort.MaxValue) ThrowUInt16OverflowException(); return (ushort)value; } @@ -1065,23 +1065,23 @@ public static ushort ToUInt16(double value) [CLSCompliant(false)] public static ushort ToUInt16(decimal value) { - return Decimal.ToUInt16(Decimal.Round(value, 0)); + return decimal.ToUInt16(decimal.Round(value, 0)); } [CLSCompliant(false)] - public static ushort ToUInt16(String value) + public static ushort ToUInt16(string value) { if (value == null) return 0; - return UInt16.Parse(value, CultureInfo.CurrentCulture); + return ushort.Parse(value, CultureInfo.CurrentCulture); } [CLSCompliant(false)] - public static ushort ToUInt16(String value, IFormatProvider provider) + public static ushort ToUInt16(string value, IFormatProvider provider) { if (value == null) return 0; - return UInt16.Parse(value, NumberStyles.Integer, provider); + return ushort.Parse(value, NumberStyles.Integer, provider); } [CLSCompliant(false)] @@ -1108,7 +1108,7 @@ public static int ToInt32(object value, IFormatProvider provider) public static int ToInt32(bool value) { - return value ? Boolean.True : Boolean.False; + return value ? bool.True : bool.False; } public static int ToInt32(char value) @@ -1141,7 +1141,7 @@ public static int ToInt32(ushort value) [CLSCompliant(false)] public static int ToInt32(uint value) { - if (value > Int32.MaxValue) ThrowInt32OverflowException(); + if (value > int.MaxValue) ThrowInt32OverflowException(); return (int)value; } @@ -1152,14 +1152,14 @@ public static int ToInt32(int value) public static int ToInt32(long value) { - if (value < Int32.MinValue || value > Int32.MaxValue) ThrowInt32OverflowException(); + if (value < int.MinValue || value > int.MaxValue) ThrowInt32OverflowException(); return (int)value; } [CLSCompliant(false)] public static int ToInt32(ulong value) { - if (value > Int32.MaxValue) ThrowInt32OverflowException(); + if (value > int.MaxValue) ThrowInt32OverflowException(); return (int)value; } @@ -1195,21 +1195,21 @@ public static int ToInt32(double value) public static int ToInt32(decimal value) { - return Decimal.ToInt32(Decimal.Round(value, 0)); + return decimal.ToInt32(decimal.Round(value, 0)); } - public static int ToInt32(String value) + public static int ToInt32(string value) { if (value == null) return 0; - return Int32.Parse(value, CultureInfo.CurrentCulture); + return int.Parse(value, CultureInfo.CurrentCulture); } - public static int ToInt32(String value, IFormatProvider provider) + public static int ToInt32(string value, IFormatProvider provider) { if (value == null) return 0; - return Int32.Parse(value, NumberStyles.Integer, provider); + return int.Parse(value, NumberStyles.Integer, provider); } public static int ToInt32(DateTime value) @@ -1239,7 +1239,7 @@ public static uint ToUInt32(object value, IFormatProvider provider) [CLSCompliant(false)] public static uint ToUInt32(bool value) { - return value ? (uint)Boolean.True : (uint)Boolean.False; + return value ? (uint)bool.True : (uint)bool.False; } [CLSCompliant(false)] @@ -1290,14 +1290,14 @@ public static uint ToUInt32(uint value) [CLSCompliant(false)] public static uint ToUInt32(long value) { - if (value < 0 || value > UInt32.MaxValue) ThrowUInt32OverflowException(); + if (value < 0 || value > uint.MaxValue) ThrowUInt32OverflowException(); return (uint)value; } [CLSCompliant(false)] public static uint ToUInt32(ulong value) { - if (value > UInt32.MaxValue) ThrowUInt32OverflowException(); + if (value > uint.MaxValue) ThrowUInt32OverflowException(); return (uint)value; } @@ -1323,23 +1323,23 @@ public static uint ToUInt32(double value) [CLSCompliant(false)] public static uint ToUInt32(decimal value) { - return Decimal.ToUInt32(Decimal.Round(value, 0)); + return decimal.ToUInt32(decimal.Round(value, 0)); } [CLSCompliant(false)] - public static uint ToUInt32(String value) + public static uint ToUInt32(string value) { if (value == null) return 0; - return UInt32.Parse(value, CultureInfo.CurrentCulture); + return uint.Parse(value, CultureInfo.CurrentCulture); } [CLSCompliant(false)] - public static uint ToUInt32(String value, IFormatProvider provider) + public static uint ToUInt32(string value, IFormatProvider provider) { if (value == null) return 0; - return UInt32.Parse(value, NumberStyles.Integer, provider); + return uint.Parse(value, NumberStyles.Integer, provider); } [CLSCompliant(false)] @@ -1366,7 +1366,7 @@ public static long ToInt64(object value, IFormatProvider provider) public static long ToInt64(bool value) { - return value ? Boolean.True : Boolean.False; + return value ? bool.True : bool.False; } public static long ToInt64(char value) @@ -1410,7 +1410,7 @@ public static long ToInt64(uint value) [CLSCompliant(false)] public static long ToInt64(ulong value) { - if (value > Int64.MaxValue) ThrowInt64OverflowException(); + if (value > long.MaxValue) ThrowInt64OverflowException(); return (long)value; } @@ -1432,21 +1432,21 @@ public static long ToInt64(double value) public static long ToInt64(decimal value) { - return Decimal.ToInt64(Decimal.Round(value, 0)); + return decimal.ToInt64(decimal.Round(value, 0)); } public static long ToInt64(string value) { if (value == null) return 0; - return Int64.Parse(value, CultureInfo.CurrentCulture); + return long.Parse(value, CultureInfo.CurrentCulture); } - public static long ToInt64(String value, IFormatProvider provider) + public static long ToInt64(string value, IFormatProvider provider) { if (value == null) return 0; - return Int64.Parse(value, NumberStyles.Integer, provider); + return long.Parse(value, NumberStyles.Integer, provider); } public static long ToInt64(DateTime value) @@ -1474,7 +1474,7 @@ public static ulong ToUInt64(object value, IFormatProvider provider) [CLSCompliant(false)] public static ulong ToUInt64(bool value) { - return value ? (ulong)Boolean.True : (ulong)Boolean.False; + return value ? (ulong)bool.True : (ulong)bool.False; } [CLSCompliant(false)] @@ -1531,7 +1531,7 @@ public static ulong ToUInt64(long value) } [CLSCompliant(false)] - public static ulong ToUInt64(UInt64 value) + public static ulong ToUInt64(ulong value) { return value; } @@ -1551,23 +1551,23 @@ public static ulong ToUInt64(double value) [CLSCompliant(false)] public static ulong ToUInt64(decimal value) { - return Decimal.ToUInt64(Decimal.Round(value, 0)); + return decimal.ToUInt64(decimal.Round(value, 0)); } [CLSCompliant(false)] - public static ulong ToUInt64(String value) + public static ulong ToUInt64(string value) { if (value == null) return 0; - return UInt64.Parse(value, CultureInfo.CurrentCulture); + return ulong.Parse(value, CultureInfo.CurrentCulture); } [CLSCompliant(false)] - public static ulong ToUInt64(String value, IFormatProvider provider) + public static ulong ToUInt64(string value, IFormatProvider provider) { if (value == null) return 0; - return UInt64.Parse(value, NumberStyles.Integer, provider); + return ulong.Parse(value, NumberStyles.Integer, provider); } [CLSCompliant(false)] @@ -1655,24 +1655,24 @@ public static float ToSingle(decimal value) return (float)value; } - public static float ToSingle(String value) + public static float ToSingle(string value) { if (value == null) return 0; - return Single.Parse(value, CultureInfo.CurrentCulture); + return float.Parse(value, CultureInfo.CurrentCulture); } - public static float ToSingle(String value, IFormatProvider provider) + public static float ToSingle(string value, IFormatProvider provider) { if (value == null) return 0; - return Single.Parse(value, NumberStyles.Float | NumberStyles.AllowThousands, provider); + return float.Parse(value, NumberStyles.Float | NumberStyles.AllowThousands, provider); } public static float ToSingle(bool value) { - return value ? Boolean.True : Boolean.False; + return value ? bool.True : bool.False; } public static float ToSingle(DateTime value) @@ -1760,23 +1760,23 @@ public static double ToDouble(decimal value) return (double)value; } - public static double ToDouble(String value) + public static double ToDouble(string value) { if (value == null) return 0; - return Double.Parse(value, CultureInfo.CurrentCulture); + return double.Parse(value, CultureInfo.CurrentCulture); } - public static double ToDouble(String value, IFormatProvider provider) + public static double ToDouble(string value, IFormatProvider provider) { if (value == null) return 0; - return Double.Parse(value, NumberStyles.Float | NumberStyles.AllowThousands, provider); + return double.Parse(value, NumberStyles.Float | NumberStyles.AllowThousands, provider); } public static double ToDouble(bool value) { - return value ? Boolean.True : Boolean.False; + return value ? bool.True : bool.False; } public static double ToDouble(DateTime value) @@ -1858,18 +1858,18 @@ public static decimal ToDecimal(double value) return (decimal)value; } - public static decimal ToDecimal(String value) + public static decimal ToDecimal(string value) { if (value == null) return 0m; - return Decimal.Parse(value, CultureInfo.CurrentCulture); + return decimal.Parse(value, CultureInfo.CurrentCulture); } - public static Decimal ToDecimal(String value, IFormatProvider provider) + public static decimal ToDecimal(string value, IFormatProvider provider) { if (value == null) return 0m; - return Decimal.Parse(value, NumberStyles.Number, provider); + return decimal.Parse(value, NumberStyles.Number, provider); } public static decimal ToDecimal(decimal value) @@ -1879,7 +1879,7 @@ public static decimal ToDecimal(decimal value) public static decimal ToDecimal(bool value) { - return value ? Boolean.True : Boolean.False; + return value ? bool.True : bool.False; } public static decimal ToDecimal(DateTime value) @@ -1907,14 +1907,14 @@ public static DateTime ToDateTime(object value, IFormatProvider provider) return value == null ? DateTime.MinValue : ((IConvertible)value).ToDateTime(provider); } - public static DateTime ToDateTime(String value) + public static DateTime ToDateTime(string value) { if (value == null) return new DateTime(0); return DateTime.Parse(value, CultureInfo.CurrentCulture); } - public static DateTime ToDateTime(String value, IFormatProvider provider) + public static DateTime ToDateTime(string value, IFormatProvider provider) { if (value == null) return new DateTime(0); @@ -1995,12 +1995,12 @@ public static DateTime ToDateTime(decimal value) // Conversions to String - public static string ToString(Object value) + public static string ToString(object value) { return ToString(value, null); } - public static string ToString(Object value, IFormatProvider provider) + public static string ToString(object value, IFormatProvider provider) { IConvertible ic = value as IConvertible; if (ic != null) @@ -2023,7 +2023,7 @@ public static string ToString(bool value, IFormatProvider provider) public static string ToString(char value) { - return Char.ToString(value); + return char.ToString(value); } public static string ToString(char value, IFormatProvider provider) @@ -2144,7 +2144,7 @@ public static string ToString(decimal value) return value.ToString(CultureInfo.CurrentCulture); } - public static string ToString(Decimal value, IFormatProvider provider) + public static string ToString(decimal value, IFormatProvider provider) { return value.ToString(provider); } @@ -2159,12 +2159,12 @@ public static string ToString(DateTime value, IFormatProvider provider) return value.ToString(provider); } - public static String ToString(String value) + public static string ToString(string value) { return value; } - public static String ToString(String value, IFormatProvider provider) + public static string ToString(string value, IFormatProvider provider) { return value; // avoid the null check } @@ -2177,7 +2177,7 @@ public static String ToString(String value, IFormatProvider provider) // be 2, 8, 10, or 16. If base is 16, the number may be preceded // by 0x; any other leading or trailing characters cause an error. // - public static byte ToByte(String value, int fromBase) + public static byte ToByte(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2190,7 +2190,7 @@ public static byte ToByte(String value, int fromBase) } int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); - if (r < Byte.MinValue || r > Byte.MaxValue) + if (r < byte.MinValue || r > byte.MaxValue) ThrowByteOverflowException(); return (byte)r; } @@ -2200,7 +2200,7 @@ public static byte ToByte(String value, int fromBase) // by 0x; any other leading or trailing characters cause an error. // [CLSCompliant(false)] - public static sbyte ToSByte(String value, int fromBase) + public static sbyte ToSByte(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2213,10 +2213,10 @@ public static sbyte ToSByte(String value, int fromBase) } int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI1); - if (fromBase != 10 && r <= Byte.MaxValue) + if (fromBase != 10 && r <= byte.MaxValue) return (sbyte)r; - if (r < SByte.MinValue || r > SByte.MaxValue) + if (r < sbyte.MinValue || r > sbyte.MaxValue) ThrowSByteOverflowException(); return (sbyte)r; } @@ -2225,7 +2225,7 @@ public static sbyte ToSByte(String value, int fromBase) // be 2, 8, 10, or 16. If fromBase is 16, the number may be preceded // by 0x; any other leading or trailing characters cause an error. // - public static short ToInt16(String value, int fromBase) + public static short ToInt16(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2238,10 +2238,10 @@ public static short ToInt16(String value, int fromBase) } int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsI2); - if (fromBase != 10 && r <= UInt16.MaxValue) + if (fromBase != 10 && r <= ushort.MaxValue) return (short)r; - if (r < Int16.MinValue || r > Int16.MaxValue) + if (r < short.MinValue || r > short.MaxValue) ThrowInt16OverflowException(); return (short)r; } @@ -2251,7 +2251,7 @@ public static short ToInt16(String value, int fromBase) // by 0x; any other leading or trailing characters cause an error. // [CLSCompliant(false)] - public static ushort ToUInt16(String value, int fromBase) + public static ushort ToUInt16(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2264,7 +2264,7 @@ public static ushort ToUInt16(String value, int fromBase) } int r = ParseNumbers.StringToInt(value.AsSpan(), fromBase, ParseNumbers.IsTight | ParseNumbers.TreatAsUnsigned); - if (r < UInt16.MinValue || r > UInt16.MaxValue) + if (r < ushort.MinValue || r > ushort.MaxValue) ThrowUInt16OverflowException(); return (ushort)r; } @@ -2273,7 +2273,7 @@ public static ushort ToUInt16(String value, int fromBase) // be 2, 8, 10, or 16. If fromBase is 16, the number may be preceded // by 0x; any other leading or trailing characters cause an error. // - public static int ToInt32(String value, int fromBase) + public static int ToInt32(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2289,7 +2289,7 @@ public static int ToInt32(String value, int fromBase) // by 0x; any other leading or trailing characters cause an error. // [CLSCompliant(false)] - public static uint ToUInt32(String value, int fromBase) + public static uint ToUInt32(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2304,7 +2304,7 @@ public static uint ToUInt32(String value, int fromBase) // be 2, 8, 10, or 16. If fromBase is 16, the number may be preceded // by 0x; any other leading or trailing characters cause an error. // - public static long ToInt64(String value, int fromBase) + public static long ToInt64(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2320,7 +2320,7 @@ public static long ToInt64(String value, int fromBase) // by 0x; any other leading or trailing characters cause an error. // [CLSCompliant(false)] - public static ulong ToUInt64(String value, int fromBase) + public static ulong ToUInt64(string value, int fromBase) { if (fromBase != 2 && fromBase != 8 && fromBase != 10 && fromBase != 16) { @@ -2332,7 +2332,7 @@ public static ulong ToUInt64(String value, int fromBase) } // Convert the byte value to a string in base fromBase - public static String ToString(byte value, int toBase) + public static string ToString(byte value, int toBase) { if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16) { @@ -2342,7 +2342,7 @@ public static String ToString(byte value, int toBase) } // Convert the Int16 value to a string in base fromBase - public static String ToString(short value, int toBase) + public static string ToString(short value, int toBase) { if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16) { @@ -2352,7 +2352,7 @@ public static String ToString(short value, int toBase) } // Convert the Int32 value to a string in base toBase - public static String ToString(int value, int toBase) + public static string ToString(int value, int toBase) { if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16) { @@ -2362,7 +2362,7 @@ public static String ToString(int value, int toBase) } // Convert the Int64 value to a string in base toBase - public static String ToString(long value, int toBase) + public static string ToString(long value, int toBase) { if (toBase != 2 && toBase != 8 && toBase != 10 && toBase != 16) { @@ -2371,7 +2371,7 @@ public static String ToString(long value, int toBase) return ParseNumbers.LongToString(value, toBase, -1, ' ', 0); } - public static String ToBase64String(byte[] inArray) + public static string ToBase64String(byte[] inArray) { if (inArray == null) { @@ -2380,7 +2380,7 @@ public static String ToBase64String(byte[] inArray) return ToBase64String(new ReadOnlySpan(inArray), Base64FormattingOptions.None); } - public static String ToBase64String(byte[] inArray, Base64FormattingOptions options) + public static string ToBase64String(byte[] inArray, Base64FormattingOptions options) { if (inArray == null) { @@ -2389,12 +2389,12 @@ public static String ToBase64String(byte[] inArray, Base64FormattingOptions opti return ToBase64String(new ReadOnlySpan(inArray), options); } - public static String ToBase64String(byte[] inArray, int offset, int length) + public static string ToBase64String(byte[] inArray, int offset, int length) { return ToBase64String(inArray, offset, length, Base64FormattingOptions.None); } - public static String ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options) + public static string ToBase64String(byte[] inArray, int offset, int length, Base64FormattingOptions options) { if (inArray == null) throw new ArgumentNullException(nameof(inArray)); @@ -2620,7 +2620,7 @@ private static int ToBase64_CalculateAndValidateOutputLength(int inputLength, bo /// /// The string to convert /// The array of bytes represented by the specified Base64 string. - public static Byte[] FromBase64String(String s) + public static byte[] FromBase64String(string s) { // "s" is an unfortunate parameter name, but we need to keep it for backward compat. @@ -2630,7 +2630,7 @@ public static Byte[] FromBase64String(String s) unsafe { - fixed (Char* sPtr = s) + fixed (char* sPtr = s) { return FromBase64CharPtr(sPtr, s.Length); } @@ -2772,7 +2772,7 @@ private static void CopyToTempBufferWithoutWhiteSpace(ReadOnlySpan chars, /// A position within the input array. /// Number of element to convert. /// The array of bytes represented by the specified Base64 encoding characters. - public static Byte[] FromBase64CharArray(Char[] inArray, Int32 offset, Int32 length) + public static byte[] FromBase64CharArray(char[] inArray, int offset, int length) { if (inArray == null) throw new ArgumentNullException(nameof(inArray)); @@ -2794,7 +2794,7 @@ public static Byte[] FromBase64CharArray(Char[] inArray, Int32 offset, Int32 len unsafe { - fixed (Char* inArrayPtr = &inArray[0]) + fixed (char* inArrayPtr = &inArray[0]) { return FromBase64CharPtr(inArrayPtr + offset, length); } @@ -2810,7 +2810,7 @@ public static Byte[] FromBase64CharArray(Char[] inArray, Int32 offset, Int32 len /// Pointer to the first input char /// Number of input chars /// - private static unsafe Byte[] FromBase64CharPtr(Char* inputPtr, Int32 inputLength) + private static unsafe byte[] FromBase64CharPtr(char* inputPtr, int inputLength) { // The validity of parameters much be checked by callers, thus we are Critical here. @@ -2820,14 +2820,14 @@ private static unsafe Byte[] FromBase64CharPtr(Char* inputPtr, Int32 inputLength // Otherwise we would be rejecting input such as "abc= ": while (inputLength > 0) { - Int32 lastChar = inputPtr[inputLength - 1]; - if (lastChar != (Int32)' ' && lastChar != (Int32)'\n' && lastChar != (Int32)'\r' && lastChar != (Int32)'\t') + int lastChar = inputPtr[inputLength - 1]; + if (lastChar != (int)' ' && lastChar != (int)'\n' && lastChar != (int)'\r' && lastChar != (int)'\t') break; inputLength--; } // Compute the output length: - Int32 resultLength = FromBase64_ComputeResultLength(inputPtr, inputLength); + int resultLength = FromBase64_ComputeResultLength(inputPtr, inputLength); Debug.Assert(0 <= resultLength); @@ -2835,7 +2835,7 @@ private static unsafe Byte[] FromBase64CharPtr(Char* inputPtr, Int32 inputLength // It may either simply write no bytes (e.g. input = " ") or throw (e.g. input = "ab"). // Create result byte blob: - Byte[] decodedBytes = new Byte[resultLength]; + byte[] decodedBytes = new byte[resultLength]; // Convert Base64 chars into bytes: if (!TryFromBase64Chars(new ReadOnlySpan(inputPtr, inputLength), decodedBytes, out int _)) @@ -2854,20 +2854,20 @@ private static unsafe Byte[] FromBase64CharPtr(Char* inputPtr, Int32 inputLength /// Walk the entire input counting white spaces and padding chars, then compute result length /// based on 3 bytes per 4 chars. /// - private static unsafe Int32 FromBase64_ComputeResultLength(Char* inputPtr, Int32 inputLength) + private static unsafe int FromBase64_ComputeResultLength(char* inputPtr, int inputLength) { - const UInt32 intEq = (UInt32)'='; - const UInt32 intSpace = (UInt32)' '; + const uint intEq = (uint)'='; + const uint intSpace = (uint)' '; Debug.Assert(0 <= inputLength); - Char* inputEndPtr = inputPtr + inputLength; - Int32 usefulInputLength = inputLength; - Int32 padding = 0; + char* inputEndPtr = inputPtr + inputLength; + int usefulInputLength = inputLength; + int padding = 0; while (inputPtr < inputEndPtr) { - UInt32 c = (UInt32)(*inputPtr); + uint c = (uint)(*inputPtr); inputPtr++; // We want to be as fast as possible and filter out spaces with as few comparisons as possible. diff --git a/src/System.Private.CoreLib/shared/System/CurrentSystemTimeZone.cs b/src/System.Private.CoreLib/shared/System/CurrentSystemTimeZone.cs index 8327bd2f4a63..0112c81abfa6 100644 --- a/src/System.Private.CoreLib/shared/System/CurrentSystemTimeZone.cs +++ b/src/System.Private.CoreLib/shared/System/CurrentSystemTimeZone.cs @@ -23,15 +23,15 @@ namespace System { [Obsolete("System.CurrentSystemTimeZone has been deprecated. Please investigate the use of System.TimeZoneInfo.Local instead.")] - internal partial class CurrentSystemTimeZone : TimeZone + internal class CurrentSystemTimeZone : TimeZone { // Standard offset in ticks to the Universal time if // no daylight saving is in used. // E.g. the offset for PST (Pacific Standard time) should be -8 * 60 * 60 * 1000 * 10000. // (1 millisecond = 10000 ticks) private long m_ticksOffset; - private String m_standardName; - private String m_daylightName; + private string m_standardName; + private string m_daylightName; internal CurrentSystemTimeZone() { @@ -42,7 +42,7 @@ internal CurrentSystemTimeZone() m_daylightName = local.DaylightName; } - public override String StandardName + public override string StandardName { get { @@ -50,7 +50,7 @@ public override String StandardName } } - public override String DaylightName + public override string DaylightName { get { @@ -58,7 +58,7 @@ public override String DaylightName } } - internal long GetUtcOffsetFromUniversalTime(DateTime time, ref Boolean isAmbiguousLocalDst) + internal long GetUtcOffsetFromUniversalTime(DateTime time, ref bool isAmbiguousLocalDst) { // Get the daylight changes for the year of the specified time. TimeSpan offset = new TimeSpan(m_ticksOffset); @@ -89,7 +89,7 @@ internal long GetUtcOffsetFromUniversalTime(DateTime time, ref Boolean isAmbiguo ambiguousEnd = startTime - daylightTime.Delta; } - Boolean isDst = false; + bool isDst = false; if (startTime > endTime) { // In southern hemisphere, the daylight saving time starts later in the year, and ends in the beginning of next year. @@ -122,8 +122,8 @@ public override DateTime ToLocalTime(DateTime time) { return time; } - Boolean isAmbiguousLocalDst = false; - Int64 offset = GetUtcOffsetFromUniversalTime(time, ref isAmbiguousLocalDst); + bool isAmbiguousLocalDst = false; + long offset = GetUtcOffsetFromUniversalTime(time, ref isAmbiguousLocalDst); long tick = time.Ticks + offset; if (tick > DateTime.MaxTicks) { @@ -192,7 +192,7 @@ public override TimeSpan GetUtcOffset(DateTime time) private DaylightTime GetCachedDaylightChanges(int year) { - Object objYear = (Object)year; + object objYear = (object)year; if (!m_CachedDaylightChanges.Contains(objYear)) { diff --git a/src/System.Private.CoreLib/shared/System/DataMisalignedException.cs b/src/System.Private.CoreLib/shared/System/DataMisalignedException.cs index 2a245b6ef781..940407fc5796 100644 --- a/src/System.Private.CoreLib/shared/System/DataMisalignedException.cs +++ b/src/System.Private.CoreLib/shared/System/DataMisalignedException.cs @@ -23,13 +23,13 @@ public DataMisalignedException() HResult = HResults.COR_E_DATAMISALIGNED; } - public DataMisalignedException(String message) + public DataMisalignedException(string message) : base(message) { HResult = HResults.COR_E_DATAMISALIGNED; } - public DataMisalignedException(String message, Exception innerException) + public DataMisalignedException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_DATAMISALIGNED; diff --git a/src/System.Private.CoreLib/shared/System/DateTime.cs b/src/System.Private.CoreLib/shared/System/DateTime.cs index 9c3b3989e4a6..5b76f6092536 100644 --- a/src/System.Private.CoreLib/shared/System/DateTime.cs +++ b/src/System.Private.CoreLib/shared/System/DateTime.cs @@ -115,18 +115,18 @@ namespace System public static readonly DateTime MaxValue = new DateTime(MaxTicks, DateTimeKind.Unspecified); public static readonly DateTime UnixEpoch = new DateTime(UnixEpochTicks, DateTimeKind.Utc); - private const UInt64 TicksMask = 0x3FFFFFFFFFFFFFFF; - private const UInt64 FlagsMask = 0xC000000000000000; - private const UInt64 LocalMask = 0x8000000000000000; - private const Int64 TicksCeiling = 0x4000000000000000; - private const UInt64 KindUnspecified = 0x0000000000000000; - private const UInt64 KindUtc = 0x4000000000000000; - private const UInt64 KindLocal = 0x8000000000000000; - private const UInt64 KindLocalAmbiguousDst = 0xC000000000000000; - private const Int32 KindShift = 62; - - private const String TicksField = "ticks"; // Do not rename (binary serialization) - private const String DateDataField = "dateData"; // Do not rename (binary serialization) + private const ulong TicksMask = 0x3FFFFFFFFFFFFFFF; + private const ulong FlagsMask = 0xC000000000000000; + private const ulong LocalMask = 0x8000000000000000; + private const long TicksCeiling = 0x4000000000000000; + private const ulong KindUnspecified = 0x0000000000000000; + private const ulong KindUtc = 0x4000000000000000; + private const ulong KindLocal = 0x8000000000000000; + private const ulong KindLocalAmbiguousDst = 0xC000000000000000; + private const int KindShift = 62; + + private const string TicksField = "ticks"; // Do not rename (binary serialization) + private const string DateDataField = "dateData"; // Do not rename (binary serialization) // The data is stored as an unsigned 64-bit integer // Bits 01-62: The value of 100-nanosecond ticks where 0 represents 1/1/0001 12:00am, up until the value @@ -136,7 +136,7 @@ namespace System // savings time hour and it is in daylight savings time. This allows distinction of these // otherwise ambiguous local times and prevents data loss when round tripping from Local to // UTC time. - private readonly UInt64 _dateData; + private readonly ulong _dateData; // Constructs a DateTime from a tick count. The ticks // argument specifies the date as the number of 100-nanosecond intervals @@ -146,10 +146,10 @@ public DateTime(long ticks) { if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks); - _dateData = (UInt64)ticks; + _dateData = (ulong)ticks; } - private DateTime(UInt64 dateData) + private DateTime(ulong dateData) { this._dateData = dateData; } @@ -164,17 +164,17 @@ public DateTime(long ticks, DateTimeKind kind) { throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } - _dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); + _dateData = ((ulong)ticks | ((ulong)kind << KindShift)); } - internal DateTime(long ticks, DateTimeKind kind, Boolean isAmbiguousDst) + internal DateTime(long ticks, DateTimeKind kind, bool isAmbiguousDst) { if (ticks < MinTicks || ticks > MaxTicks) { throw new ArgumentOutOfRangeException(nameof(ticks), SR.ArgumentOutOfRange_DateTimeBadTicks); } Debug.Assert(kind == DateTimeKind.Local, "Internal Constructor is for local times only"); - _dateData = ((UInt64)ticks | (isAmbiguousDst ? KindLocalAmbiguousDst : KindLocal)); + _dateData = ((ulong)ticks | (isAmbiguousDst ? KindLocalAmbiguousDst : KindLocal)); } // Constructs a DateTime from a given year, month, and day. The @@ -182,7 +182,7 @@ internal DateTime(long ticks, DateTimeKind kind, Boolean isAmbiguousDst) // public DateTime(int year, int month, int day) { - _dateData = (UInt64)DateToTicks(year, month, day); + _dateData = (ulong)DateToTicks(year, month, day); } // Constructs a DateTime from a given year, month, and day for @@ -199,7 +199,7 @@ public DateTime(int year, int month, int day, Calendar calendar) // public DateTime(int year, int month, int day, int hour, int minute, int second) { - _dateData = (UInt64)(DateToTicks(year, month, day) + TimeToTicks(hour, minute, second)); + _dateData = (ulong)(DateToTicks(year, month, day) + TimeToTicks(hour, minute, second)); } public DateTime(int year, int month, int day, int hour, int minute, int second, DateTimeKind kind) @@ -208,8 +208,8 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } - Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); - _dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); + long ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); + _dateData = ((ulong)ticks | ((ulong)kind << KindShift)); } // Constructs a DateTime from a given year, month, day, hour, @@ -219,7 +219,7 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { if (calendar == null) throw new ArgumentNullException(nameof(calendar)); - _dateData = (UInt64)calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; + _dateData = (ulong)calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; } // Constructs a DateTime from a given year, month, day, hour, @@ -231,11 +231,11 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } - Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); + long ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentException(SR.Arg_DateTimeRange); - _dateData = (UInt64)ticks; + _dateData = (ulong)ticks; } public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, DateTimeKind kind) @@ -248,11 +248,11 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } - Int64 ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); + long ticks = DateToTicks(year, month, day) + TimeToTicks(hour, minute, second); ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentException(SR.Arg_DateTimeRange); - _dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); + _dateData = ((ulong)ticks | ((ulong)kind << KindShift)); } // Constructs a DateTime from a given year, month, day, hour, @@ -266,11 +266,11 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { throw new ArgumentOutOfRangeException(nameof(millisecond), SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)); } - Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; + long ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentException(SR.Arg_DateTimeRange); - _dateData = (UInt64)ticks; + _dateData = (ulong)ticks; } public DateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, Calendar calendar, DateTimeKind kind) @@ -285,11 +285,11 @@ public DateTime(int year, int month, int day, int hour, int minute, int second, { throw new ArgumentException(SR.Argument_InvalidDateTimeKind, nameof(kind)); } - Int64 ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; + long ticks = calendar.ToDateTime(year, month, day, hour, minute, second, 0).Ticks; ticks += millisecond * TicksPerMillisecond; if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentException(SR.Arg_DateTimeRange); - _dateData = ((UInt64)ticks | ((UInt64)kind << KindShift)); + _dateData = ((ulong)ticks | ((ulong)kind << KindShift)); } private DateTime(SerializationInfo info, StreamingContext context) @@ -297,10 +297,10 @@ private DateTime(SerializationInfo info, StreamingContext context) if (info == null) throw new ArgumentNullException(nameof(info)); - Boolean foundTicks = false; - Boolean foundDateData = false; - Int64 serializedTicks = 0; - UInt64 serializedDateData = 0; + bool foundTicks = false; + bool foundDateData = false; + long serializedTicks = 0; + ulong serializedDateData = 0; // Get the data @@ -328,13 +328,13 @@ private DateTime(SerializationInfo info, StreamingContext context) } else if (foundTicks) { - _dateData = (UInt64)serializedTicks; + _dateData = (ulong)serializedTicks; } else { throw new SerializationException(SR.Serialization_MissingDateTimeData); } - Int64 ticks = InternalTicks; + long ticks = InternalTicks; if (ticks < MinTicks || ticks > MaxTicks) { throw new SerializationException(SR.Serialization_DateTimeTicksOutOfRange); @@ -343,15 +343,15 @@ private DateTime(SerializationInfo info, StreamingContext context) - internal Int64 InternalTicks + internal long InternalTicks { get { - return (Int64)(_dateData & TicksMask); + return (long)(_dateData & TicksMask); } } - private UInt64 InternalKind + private ulong InternalKind { get { @@ -459,7 +459,7 @@ public DateTime AddMonths(int months) } int days = DaysInMonth(y, m); if (d > days) d = days; - return new DateTime((UInt64)(DateToTicks(y, m, d) + InternalTicks % TicksPerDay) | InternalKind); + return new DateTime((ulong)(DateToTicks(y, m, d) + InternalTicks % TicksPerDay) | InternalKind); } // Returns the DateTime resulting from adding a fractional number of @@ -484,7 +484,7 @@ public DateTime AddTicks(long value) { throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_DateArithmetic); } - return new DateTime((UInt64)(ticks + value) | InternalKind); + return new DateTime((ulong)(ticks + value) | InternalKind); } // Returns the DateTime resulting from adding the given number of @@ -511,8 +511,8 @@ public DateTime AddYears(int value) // public static int Compare(DateTime t1, DateTime t2) { - Int64 ticks1 = t1.InternalTicks; - Int64 ticks2 = t2.InternalTicks; + long ticks1 = t1.InternalTicks; + long ticks2 = t2.InternalTicks; if (ticks1 > ticks2) return 1; if (ticks1 < ticks2) return -1; return 0; @@ -524,7 +524,7 @@ public static int Compare(DateTime t1, DateTime t2) // occurs. Null is considered less than any instance. // // Returns a value less than zero if this object - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) return 1; if (!(value is DateTime)) @@ -610,7 +610,7 @@ internal static long DoubleDateToTicks(double value) // is equal to the value of this DateTime. Returns false // otherwise. // - public override bool Equals(Object value) + public override bool Equals(object value) { if (value is DateTime) { @@ -633,15 +633,15 @@ public static bool Equals(DateTime t1, DateTime t2) return t1.InternalTicks == t2.InternalTicks; } - public static DateTime FromBinary(Int64 dateData) + public static DateTime FromBinary(long dateData) { - if ((dateData & (unchecked((Int64)LocalMask))) != 0) + if ((dateData & (unchecked((long)LocalMask))) != 0) { // Local times need to be adjusted as you move from one time zone to another, // just as they are when serializing in text. As such the format for local times // changes to store the ticks of the UTC time, but with flags that look like a // local date. - Int64 ticks = dateData & (unchecked((Int64)TicksMask)); + long ticks = dateData & (unchecked((long)TicksMask)); // Negative ticks are stored in the top part of the range and should be converted back into a negative number if (ticks > TicksCeiling - TicksPerDay) { @@ -649,8 +649,8 @@ public static DateTime FromBinary(Int64 dateData) } // Convert the ticks back to local. If the UTC ticks are out of range, we need to default to // the UTC offset from MinValue and MaxValue to be consistent with Parse. - Boolean isAmbiguousLocalDst = false; - Int64 offsetTicks; + bool isAmbiguousLocalDst = false; + long offsetTicks; if (ticks < MinTicks) { offsetTicks = TimeZoneInfo.GetLocalUtcOffset(DateTime.MinValue, TimeZoneInfoOptions.NoThrowOnInvalidTime).Ticks; @@ -664,7 +664,7 @@ public static DateTime FromBinary(Int64 dateData) // Because the ticks conversion between UTC and local is lossy, we need to capture whether the // time is in a repeated hour so that it can be passed to the DateTime constructor. DateTime utcDt = new DateTime(ticks, DateTimeKind.Utc); - Boolean isDaylightSavings = false; + bool isDaylightSavings = false; offsetTicks = TimeZoneInfo.GetUtcOffsetFromUtc(utcDt, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; } ticks += offsetTicks; @@ -688,12 +688,12 @@ public static DateTime FromBinary(Int64 dateData) // A version of ToBinary that uses the real representation and does not adjust local times. This is needed for // scenarios where the serialized data must maintain compatibility - internal static DateTime FromBinaryRaw(Int64 dateData) + internal static DateTime FromBinaryRaw(long dateData) { - Int64 ticks = dateData & (Int64)TicksMask; + long ticks = dateData & (long)TicksMask; if (ticks < MinTicks || ticks > MaxTicks) throw new ArgumentException(SR.Argument_DateTimeBadBinaryData, nameof(dateData)); - return new DateTime((UInt64)dateData); + return new DateTime((ulong)dateData); } // Creates a DateTime from a Windows filetime. A Windows filetime is @@ -736,7 +736,7 @@ void ISerializable.GetObjectData(SerializationInfo info, StreamingContext contex info.AddValue(DateDataField, _dateData); } - public Boolean IsDaylightSavingTime() + public bool IsDaylightSavingTime() { if (Kind == DateTimeKind.Utc) { @@ -750,7 +750,7 @@ public static DateTime SpecifyKind(DateTime value, DateTimeKind kind) return new DateTime(value.InternalTicks, kind); } - public Int64 ToBinary() + public long ToBinary() { if (Kind == DateTimeKind.Local) { @@ -765,17 +765,17 @@ public Int64 ToBinary() // end of the maximum range, and values just below minimum value are stored // at the end of the ticks area, just below 2^62. TimeSpan offset = TimeZoneInfo.GetLocalUtcOffset(this, TimeZoneInfoOptions.NoThrowOnInvalidTime); - Int64 ticks = Ticks; - Int64 storedTicks = ticks - offset.Ticks; + long ticks = Ticks; + long storedTicks = ticks - offset.Ticks; if (storedTicks < 0) { storedTicks = TicksCeiling + storedTicks; } - return storedTicks | (unchecked((Int64)LocalMask)); + return storedTicks | (unchecked((long)LocalMask)); } else { - return (Int64)_dateData; + return (long)_dateData; } } @@ -787,8 +787,8 @@ public DateTime Date { get { - Int64 ticks = InternalTicks; - return new DateTime((UInt64)(ticks - ticks % TicksPerDay) | InternalKind); + long ticks = InternalTicks; + return new DateTime((ulong)(ticks - ticks % TicksPerDay) | InternalKind); } } @@ -796,7 +796,7 @@ public DateTime Date // to compute the year, day-of-year, month, or day part. private int GetDatePart(int part) { - Int64 ticks = InternalTicks; + long ticks = InternalTicks; // n = number of days since 1/1/0001 int n = (int)(ticks / TicksPerDay); // y400 = number of whole 400-year periods since 1/1/0001 @@ -846,7 +846,7 @@ private int GetDatePart(int part) // are needed rather than redoing the computations for each. internal void GetDatePart(out int year, out int month, out int day) { - Int64 ticks = InternalTicks; + long ticks = InternalTicks; // n = number of days since 1/1/0001 int n = (int)(ticks / TicksPerDay); // y400 = number of whole 400-year periods since 1/1/0001 @@ -925,7 +925,7 @@ public int DayOfYear // public override int GetHashCode() { - Int64 ticks = InternalTicks; + long ticks = InternalTicks; return unchecked((int)ticks) ^ (int)(ticks >> 32); } @@ -940,7 +940,7 @@ public int Hour } } - internal Boolean IsAmbiguousDaylightSavingTime() + internal bool IsAmbiguousDaylightSavingTime() { return (InternalKind == KindLocalAmbiguousDst); } @@ -1001,8 +1001,8 @@ public static DateTime Now get { DateTime utc = UtcNow; - Boolean isAmbiguousLocalDst = false; - Int64 offset = TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc(utc, out isAmbiguousLocalDst).Ticks; + bool isAmbiguousLocalDst = false; + long offset = TimeZoneInfo.GetDateTimeNowUtcOffsetFromUtc(utc, out isAmbiguousLocalDst).Ticks; long tick = utc.Ticks + offset; if (tick > DateTime.MaxTicks) { @@ -1089,7 +1089,7 @@ public static bool IsLeapYear(int year) // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTime Parse(String s) + public static DateTime Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return (DateTimeParse.Parse(s, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None)); @@ -1099,13 +1099,13 @@ public static DateTime Parse(String s) // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTime Parse(String s, IFormatProvider provider) + public static DateTime Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return (DateTimeParse.Parse(s, DateTimeFormatInfo.GetInstance(provider), DateTimeStyles.None)); } - public static DateTime Parse(String s, IFormatProvider provider, DateTimeStyles styles) + public static DateTime Parse(string s, IFormatProvider provider, DateTimeStyles styles) { DateTimeFormatInfo.ValidateStyles(styles, nameof(styles)); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -1122,7 +1122,7 @@ public static DateTime Parse(ReadOnlySpan s, IFormatProvider provider = nu // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTime ParseExact(String s, String format, IFormatProvider provider) + public static DateTime ParseExact(string s, string format, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); if (format == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.format); @@ -1133,7 +1133,7 @@ public static DateTime ParseExact(String s, String format, IFormatProvider provi // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTime ParseExact(String s, String format, IFormatProvider provider, DateTimeStyles style) + public static DateTime ParseExact(string s, string format, IFormatProvider provider, DateTimeStyles style) { DateTimeFormatInfo.ValidateStyles(style, nameof(style)); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -1147,7 +1147,7 @@ public static DateTime ParseExact(ReadOnlySpan s, ReadOnlySpan forma return DateTimeParse.ParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style); } - public static DateTime ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style) + public static DateTime ParseExact(string s, string[] formats, IFormatProvider provider, DateTimeStyles style) { DateTimeFormatInfo.ValidateStyles(style, nameof(style)); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -1173,7 +1173,7 @@ public DateTime Subtract(TimeSpan value) { throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_DateArithmetic); } - return new DateTime((UInt64)(ticks - valueTicks) | InternalKind); + return new DateTime((ulong)(ticks - valueTicks) | InternalKind); } // This function is duplicated in COMDateTime.cpp @@ -1232,9 +1232,9 @@ internal DateTime ToLocalTime(bool throwOnOverflow) { return this; } - Boolean isDaylightSavings = false; - Boolean isAmbiguousLocalDst = false; - Int64 offset = TimeZoneInfo.GetUtcOffsetFromUtc(this, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; + bool isDaylightSavings = false; + bool isAmbiguousLocalDst = false; + long offset = TimeZoneInfo.GetUtcOffsetFromUtc(this, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; long tick = Ticks + offset; if (tick > DateTime.MaxTicks) { @@ -1253,42 +1253,42 @@ internal DateTime ToLocalTime(bool throwOnOverflow) return new DateTime(tick, DateTimeKind.Local, isAmbiguousLocalDst); } - public String ToLongDateString() + public string ToLongDateString() { return DateTimeFormat.Format(this, "D", null); } - public String ToLongTimeString() + public string ToLongTimeString() { return DateTimeFormat.Format(this, "T", null); } - public String ToShortDateString() + public string ToShortDateString() { return DateTimeFormat.Format(this, "d", null); } - public String ToShortTimeString() + public string ToShortTimeString() { return DateTimeFormat.Format(this, "t", null); } - public override String ToString() + public override string ToString() { return DateTimeFormat.Format(this, null, null); } - public String ToString(String format) + public string ToString(string format) { return DateTimeFormat.Format(this, format, null); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return DateTimeFormat.Format(this, null, provider); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return DateTimeFormat.Format(this, format, provider); } @@ -1301,7 +1301,7 @@ public DateTime ToUniversalTime() return TimeZoneInfo.ConvertTimeToUtc(this, TimeZoneInfoOptions.NoThrowOnInvalidTime); } - public static Boolean TryParse(String s, out DateTime result) + public static bool TryParse(string s, out DateTime result) { if (s == null) { @@ -1316,7 +1316,7 @@ public static bool TryParse(ReadOnlySpan s, out DateTime result) return DateTimeParse.TryParse(s, DateTimeFormatInfo.CurrentInfo, DateTimeStyles.None, out result); } - public static Boolean TryParse(String s, IFormatProvider provider, DateTimeStyles styles, out DateTime result) + public static bool TryParse(string s, IFormatProvider provider, DateTimeStyles styles, out DateTime result) { DateTimeFormatInfo.ValidateStyles(styles, nameof(styles)); @@ -1335,7 +1335,7 @@ public static bool TryParse(ReadOnlySpan s, IFormatProvider provider, Date return DateTimeParse.TryParse(s, DateTimeFormatInfo.GetInstance(provider), styles, out result); } - public static Boolean TryParseExact(String s, String format, IFormatProvider provider, DateTimeStyles style, out DateTime result) + public static bool TryParseExact(string s, string format, IFormatProvider provider, DateTimeStyles style, out DateTime result) { DateTimeFormatInfo.ValidateStyles(style, nameof(style)); @@ -1354,7 +1354,7 @@ public static bool TryParseExact(ReadOnlySpan s, ReadOnlySpan format return DateTimeParse.TryParseExact(s, format, DateTimeFormatInfo.GetInstance(provider), style, out result); } - public static Boolean TryParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style, out DateTime result) + public static bool TryParseExact(string s, string[] formats, IFormatProvider provider, DateTimeStyles style, out DateTime result) { DateTimeFormatInfo.ValidateStyles(style, nameof(style)); @@ -1381,7 +1381,7 @@ public static bool TryParseExact(ReadOnlySpan s, string[] formats, IFormat { throw new ArgumentOutOfRangeException(nameof(t), SR.ArgumentOutOfRange_DateArithmetic); } - return new DateTime((UInt64)(ticks + valueTicks) | d.InternalKind); + return new DateTime((ulong)(ticks + valueTicks) | d.InternalKind); } public static DateTime operator -(DateTime d, TimeSpan t) @@ -1392,7 +1392,7 @@ public static bool TryParseExact(ReadOnlySpan s, string[] formats, IFormat { throw new ArgumentOutOfRangeException(nameof(t), SR.ArgumentOutOfRange_DateArithmetic); } - return new DateTime((UInt64)(ticks - valueTicks) | d.InternalKind); + return new DateTime((ulong)(ticks - valueTicks) | d.InternalKind); } public static TimeSpan operator -(DateTime d1, DateTime d2) @@ -1434,7 +1434,7 @@ public static bool TryParseExact(ReadOnlySpan s, string[] formats, IFormat // Returns a string array containing all of the known date and time options for the // current culture. The strings returned are properly formatted date and // time strings for the current instance of DateTime. - public String[] GetDateTimeFormats() + public string[] GetDateTimeFormats() { return (GetDateTimeFormats(CultureInfo.CurrentCulture)); } @@ -1442,7 +1442,7 @@ public String[] GetDateTimeFormats() // Returns a string array containing all of the known date and time options for the // using the information provided by IFormatProvider. The strings returned are properly formatted date and // time strings for the current instance of DateTime. - public String[] GetDateTimeFormats(IFormatProvider provider) + public string[] GetDateTimeFormats(IFormatProvider provider) { return (DateTimeFormat.GetAllDateTimes(this, DateTimeFormatInfo.GetInstance(provider))); } @@ -1451,7 +1451,7 @@ public String[] GetDateTimeFormats(IFormatProvider provider) // Returns a string array containing all of the date and time options for the // given format format and current culture. The strings returned are properly formatted date and // time strings for the current instance of DateTime. - public String[] GetDateTimeFormats(char format) + public string[] GetDateTimeFormats(char format) { return (GetDateTimeFormats(format, CultureInfo.CurrentCulture)); } @@ -1459,7 +1459,7 @@ public String[] GetDateTimeFormats(char format) // Returns a string array containing all of the date and time options for the // given format format and given culture. The strings returned are properly formatted date and // time strings for the current instance of DateTime. - public String[] GetDateTimeFormats(char format, IFormatProvider provider) + public string[] GetDateTimeFormats(char format, IFormatProvider provider) { return (DateTimeFormat.GetAllDateTimes(this, format, DateTimeFormatInfo.GetInstance(provider))); } @@ -1534,7 +1534,7 @@ double IConvertible.ToDouble(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Double")); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Decimal")); } @@ -1544,7 +1544,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) return this; } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } @@ -1552,7 +1552,7 @@ Object IConvertible.ToType(Type type, IFormatProvider provider) // Tries to construct a DateTime from a given year, month, day, hour, // minute, second and millisecond. // - internal static Boolean TryCreate(int year, int month, int day, int hour, int minute, int second, int millisecond, out DateTime result) + internal static bool TryCreate(int year, int month, int day, int hour, int minute, int second, int millisecond, out DateTime result) { result = DateTime.MinValue; if (year < 1 || year > 9999 || month < 1 || month > 12) diff --git a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs index da5705c8aa92..fd86132a17aa 100644 --- a/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs +++ b/src/System.Private.CoreLib/shared/System/DateTimeOffset.cs @@ -34,8 +34,8 @@ namespace System public struct DateTimeOffset : IComparable, IFormattable, IComparable, IEquatable, ISerializable, IDeserializationCallback, ISpanFormattable { // Constants - internal const Int64 MaxOffset = TimeSpan.TicksPerHour * 14; - internal const Int64 MinOffset = -MaxOffset; + internal const long MaxOffset = TimeSpan.TicksPerHour * 14; + internal const long MinOffset = -MaxOffset; private const long UnixEpochSeconds = DateTime.UnixEpochTicks / TimeSpan.TicksPerSecond; // 62,135,596,800 private const long UnixEpochMilliseconds = DateTime.UnixEpochTicks / TimeSpan.TicksPerMillisecond; // 62,135,596,800,000 @@ -50,7 +50,7 @@ public struct DateTimeOffset : IComparable, IFormattable, IComparable input, IFormatProvider for // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTimeOffset ParseExact(String input, String format, IFormatProvider formatProvider) + public static DateTimeOffset ParseExact(string input, string format, IFormatProvider formatProvider) { if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); if (format == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.format); @@ -654,7 +654,7 @@ public static DateTimeOffset ParseExact(String input, String format, IFormatProv // date and optionally a time in a culture-specific or universal format. // Leading and trailing whitespace characters are allowed. // - public static DateTimeOffset ParseExact(String input, String format, IFormatProvider formatProvider, DateTimeStyles styles) + public static DateTimeOffset ParseExact(string input, string format, IFormatProvider formatProvider, DateTimeStyles styles) { styles = ValidateStyles(styles, nameof(styles)); if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); @@ -676,7 +676,7 @@ public static DateTimeOffset ParseExact(ReadOnlySpan input, ReadOnlySpan input, out DateTimeOffset result) return parsed; } - public static Boolean TryParse(String input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result) + public static bool TryParse(string input, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result) { styles = ValidateStyles(styles, nameof(styles)); if (input == null) @@ -812,7 +812,7 @@ public static Boolean TryParse(String input, IFormatProvider formatProvider, Dat TimeSpan offset; DateTime dateResult; - Boolean parsed = DateTimeParse.TryParse(input, + bool parsed = DateTimeParse.TryParse(input, DateTimeFormatInfo.GetInstance(formatProvider), styles, out dateResult, @@ -829,7 +829,7 @@ public static bool TryParse(ReadOnlySpan input, IFormatProvider formatProv return parsed; } - public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, DateTimeStyles styles, + public static bool TryParseExact(string input, string format, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result) { styles = ValidateStyles(styles, nameof(styles)); @@ -841,7 +841,7 @@ public static Boolean TryParseExact(String input, String format, IFormatProvider TimeSpan offset; DateTime dateResult; - Boolean parsed = DateTimeParse.TryParseExact(input, + bool parsed = DateTimeParse.TryParseExact(input, format, DateTimeFormatInfo.GetInstance(formatProvider), styles, @@ -860,7 +860,7 @@ public static bool TryParseExact( return parsed; } - public static Boolean TryParseExact(String input, String[] formats, IFormatProvider formatProvider, DateTimeStyles styles, + public static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, DateTimeStyles styles, out DateTimeOffset result) { styles = ValidateStyles(styles, nameof(styles)); @@ -872,7 +872,7 @@ public static Boolean TryParseExact(String input, String[] formats, IFormatProvi TimeSpan offset; DateTime dateResult; - Boolean parsed = DateTimeParse.TryParseExactMultiple(input, + bool parsed = DateTimeParse.TryParseExactMultiple(input, formats, DateTimeFormatInfo.GetInstance(formatProvider), styles, @@ -892,9 +892,9 @@ public static bool TryParseExact( } // Ensures the TimeSpan is valid to go in a DateTimeOffset. - private static Int16 ValidateOffset(TimeSpan offset) + private static short ValidateOffset(TimeSpan offset) { - Int64 ticks = offset.Ticks; + long ticks = offset.Ticks; if (ticks % TimeSpan.TicksPerMinute != 0) { throw new ArgumentException(SR.Argument_OffsetPrecision, nameof(offset)); @@ -903,7 +903,7 @@ private static Int16 ValidateOffset(TimeSpan offset) { throw new ArgumentOutOfRangeException(nameof(offset), SR.Argument_OffsetOutOfRange); } - return (Int16)(offset.Ticks / TimeSpan.TicksPerMinute); + return (short)(offset.Ticks / TimeSpan.TicksPerMinute); } // Ensures that the time and offset are in range. @@ -914,8 +914,8 @@ private static DateTime ValidateDate(DateTime dateTime, TimeSpan offset) Debug.Assert(offset.Ticks >= MinOffset && offset.Ticks <= MaxOffset, "Offset not validated."); // This operation cannot overflow because offset should have already been validated to be within - // 14 hours and the DateTime instance is more than that distance from the boundaries of Int64. - Int64 utcTicks = dateTime.Ticks - offset.Ticks; + // 14 hours and the DateTime instance is more than that distance from the boundaries of long. + long utcTicks = dateTime.Ticks - offset.Ticks; if (utcTicks < DateTime.MinTicks || utcTicks > DateTime.MaxTicks) { throw new ArgumentOutOfRangeException(nameof(offset), SR.Argument_UTCOutOfRange); @@ -925,7 +925,7 @@ private static DateTime ValidateDate(DateTime dateTime, TimeSpan offset) return new DateTime(utcTicks, DateTimeKind.Unspecified); } - private static DateTimeStyles ValidateStyles(DateTimeStyles style, String parameterName) + private static DateTimeStyles ValidateStyles(DateTimeStyles style, string parameterName) { if ((style & DateTimeFormatInfo.InvalidDateTimeStyles) != 0) { diff --git a/src/System.Private.CoreLib/shared/System/Decimal.DecCalc.cs b/src/System.Private.CoreLib/shared/System/Decimal.DecCalc.cs new file mode 100644 index 000000000000..75ddbfc231ba --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Decimal.DecCalc.cs @@ -0,0 +1,2711 @@ +// 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; +using System.Runtime.InteropServices; +using Internal.Runtime.CompilerServices; +using X86 = System.Runtime.Intrinsics.X86; + +namespace System +{ + public partial struct Decimal + { + // Low level accessors used by a DecCalc and formatting + internal uint High => (uint)hi; + internal uint Low => (uint)lo; + internal uint Mid => (uint)mid; + + internal bool IsNegative => flags < 0; + + internal int Scale => (byte)(flags >> ScaleShift); + +#if BIGENDIAN + private ulong Low64 => ((ulong)Mid << 32) | Low; +#else + private ulong Low64 => Unsafe.As(ref Unsafe.AsRef(in lo)); +#endif + + private static ref DecCalc AsMutable(ref decimal d) => ref Unsafe.As(ref d); + + #region APIs need by number formatting. + + internal static uint DecDivMod1E9(ref decimal value) + { + return DecCalc.DecDivMod1E9(ref AsMutable(ref value)); + } + + internal static void DecAddInt32(ref decimal value, uint i) + { + DecCalc.DecAddInt32(ref AsMutable(ref value), i); + } + + internal static void DecMul10(ref decimal value) + { + DecCalc.DecMul10(ref AsMutable(ref value)); + } + + #endregion + + /// + /// Class that contains all the mathematical calculations for decimal. Most of which have been ported from oleaut32. + /// + [StructLayout(LayoutKind.Explicit)] + private struct DecCalc + { + // NOTE: Do not change the offsets of these fields. This structure must have the same layout as Decimal. + [FieldOffset(0)] + private uint uflags; + [FieldOffset(4)] + private uint uhi; + [FieldOffset(8)] + private uint ulo; + [FieldOffset(12)] + private uint umid; + + /// + /// The low and mid fields combined in little-endian order + /// + [FieldOffset(8)] + private ulong ulomidLE; + + private uint High + { + get => uhi; + set => uhi = value; + } + + private uint Low + { + get => ulo; + set => ulo = value; + } + + private uint Mid + { + get => umid; + set => umid = value; + } + + private bool IsNegative => (int)uflags < 0; + + private int Scale => (byte)(uflags >> ScaleShift); + + private ulong Low64 + { +#if BIGENDIAN + get { return ((ulong)umid << 32) | ulo; } + set { umid = (uint)(value >> 32); ulo = (uint)value; } +#else + get => ulomidLE; + set => ulomidLE = value; +#endif + } + + private const uint SignMask = 0x80000000; + private const uint ScaleMask = 0x00FF0000; + + private const int DEC_SCALE_MAX = 28; + + private const uint TenToPowerNine = 1000000000; + private const ulong TenToPowerEighteen = 1000000000000000000; + + // The maximum power of 10 that a 32 bit integer can store + private const int MaxInt32Scale = 9; + // The maximum power of 10 that a 64 bit integer can store + private const int MaxInt64Scale = 19; + + // Fast access for 10^n where n is 0-9 + private static readonly uint[] s_powers10 = new uint[] { + 1, + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000 + }; + + // Fast access for 10^n where n is 1-19 + private static readonly ulong[] s_ulongPowers10 = new ulong[] { + 10, + 100, + 1000, + 10000, + 100000, + 1000000, + 10000000, + 100000000, + 1000000000, + 10000000000, + 100000000000, + 1000000000000, + 10000000000000, + 100000000000000, + 1000000000000000, + 10000000000000000, + 100000000000000000, + 1000000000000000000, + 10000000000000000000, + }; + + private static readonly double[] s_doublePowers10 = new double[] { + 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, + 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39, + 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49, + 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, + 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69, + 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79, + 1e80 + }; + + #region Decimal Math Helpers + + private static unsafe uint GetExponent(float f) + { + // Based on pulling out the exp from this single struct layout + //typedef struct { + // ULONG mant:23; + // ULONG exp:8; + // ULONG sign:1; + //} SNGSTRUCT; + + return (byte)(*(uint*)&f >> 23); + } + + private static unsafe uint GetExponent(double d) + { + // Based on pulling out the exp from this double struct layout + //typedef struct { + // DWORDLONG mant:52; + // DWORDLONG signexp:12; + // } DBLSTRUCT; + + return (uint)(*(ulong*)&d >> 52) & 0x7FFu; + } + + private static ulong UInt32x32To64(uint a, uint b) + { + return (ulong)a * (ulong)b; + } + + private static void UInt64x64To128(ulong a, ulong b, ref DecCalc pdecOut) + { + ulong low = UInt32x32To64((uint)a, (uint)b); // lo partial prod + ulong mid = UInt32x32To64((uint)a, (uint)(b >> 32)); // mid 1 partial prod + ulong high = UInt32x32To64((uint)(a >> 32), (uint)(b >> 32)); + high += mid >> 32; + low += mid <<= 32; + if (low < mid) // test for carry + high++; + + mid = UInt32x32To64((uint)(a >> 32), (uint)b); + high += mid >> 32; + low += mid <<= 32; + if (low < mid) // test for carry + high++; + + if (high > uint.MaxValue) + throw new OverflowException(SR.Overflow_Decimal); + pdecOut.Low64 = low; + pdecOut.High = (uint)high; + } + + /*** + * Div96By32 + * + * Entry: + * bufNum - 96-bit dividend as array of ULONGs, least-sig first + * ulDen - 32-bit divisor. + * + * Purpose: + * Do full divide, yielding 96-bit result and 32-bit remainder. + * + * Exit: + * Quotient overwrites dividend. + * Returns remainder. + * + * Exceptions: + * None. + * + ***********************************************************************/ + private static uint Div96By32(ref Buf12 bufNum, uint ulDen) + { + // TODO: https://github.com/dotnet/coreclr/issues/3439 + ulong tmp, div; + if (bufNum.U2 != 0) + { + tmp = bufNum.High64; + div = tmp / ulDen; + bufNum.High64 = div; + tmp = ((tmp - (uint)div * ulDen) << 32) | bufNum.U0; + if (tmp == 0) + return 0; + uint div32 = (uint)(tmp / ulDen); + bufNum.U0 = div32; + return (uint)tmp - div32 * ulDen; + } + + tmp = bufNum.Low64; + if (tmp == 0) + return 0; + div = tmp / ulDen; + bufNum.Low64 = div; + return (uint)(tmp - div * ulDen); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool Div96ByConst(ref ulong high64, ref uint low, uint pow) + { +#if BIT64 + ulong div64 = high64 / pow; + uint div = (uint)((((high64 - div64 * pow) << 32) + low) / pow); + if (low == div * pow) + { + high64 = div64; + low = div; + return true; + } +#else + // 32-bit RyuJIT doesn't convert 64-bit division by constant into multiplication by reciprocal. Do half-width divisions instead. + Debug.Assert(pow <= ushort.MaxValue); + uint num, mid32, low16, div; + if (high64 <= uint.MaxValue) + { + num = (uint)high64; + mid32 = num / pow; + num = (num - mid32 * pow) << 16; + + num += low >> 16; + low16 = num / pow; + num = (num - low16 * pow) << 16; + + num += (ushort)low; + div = num / pow; + if (num == div * pow) + { + high64 = mid32; + low = (low16 << 16) + div; + return true; + } + } + else + { + num = (uint)(high64 >> 32); + uint high32 = num / pow; + num = (num - high32 * pow) << 16; + + num += (uint)high64 >> 16; + mid32 = num / pow; + num = (num - mid32 * pow) << 16; + + num += (ushort)high64; + div = num / pow; + num = (num - div * pow) << 16; + mid32 = div + (mid32 << 16); + + num += low >> 16; + low16 = num / pow; + num = (num - low16 * pow) << 16; + + num += (ushort)low; + div = num / pow; + if (num == div * pow) + { + high64 = ((ulong)high32 << 32) | mid32; + low = (low16 << 16) + div; + return true; + } + } +#endif + return false; + } + + // Normalize (unscale) the number by trying to divide out 10^8, 10^4, 10^2, and 10^1. + // If a division by one of these powers returns a zero remainder, then we keep the quotient. + // + // Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 we can extract. + // We use this as a quick test on whether to try a given power. + // + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void Unscale(ref uint low, ref ulong high64, ref int scale) + { +#if BIT64 + while ((byte)low == 0 && scale >= 8 && Div96ByConst(ref high64, ref low, 100000000)) + scale -= 8; + + if ((low & 0xF) == 0 && scale >= 4 && Div96ByConst(ref high64, ref low, 10000)) + scale -= 4; +#else + while ((low & 0xF) == 0 && scale >= 4 && Div96ByConst(ref high64, ref low, 10000)) + scale -= 4; +#endif + + if ((low & 3) == 0 && scale >= 2 && Div96ByConst(ref high64, ref low, 100)) + scale -= 2; + + if ((low & 1) == 0 && scale >= 1 && Div96ByConst(ref high64, ref low, 10)) + scale--; + } + + /*** + * Div96By64 + * + * Entry: + * bufNum - 96-bit dividend as array of ULONGs, least-sig first + * sdlDen - 64-bit divisor. + * + * Purpose: + * Do partial divide, yielding 32-bit result and 64-bit remainder. + * Divisor must be larger than upper 64 bits of dividend. + * + * Exit: + * Remainder overwrites lower 64-bits of dividend. + * Returns quotient. + * + * Exceptions: + * None. + * + ***********************************************************************/ + private static uint Div96By64(ref Buf12 bufNum, ulong den) + { + uint quo; + ulong num; + uint num2 = bufNum.U2; + if (num2 == 0) + { + num = bufNum.Low64; + if (num < den) + // Result is zero. Entire dividend is remainder. + return 0; + + // TODO: https://github.com/dotnet/coreclr/issues/3439 + quo = (uint)(num / den); + num -= quo * den; // remainder + bufNum.Low64 = num; + return quo; + } + + uint denHigh32 = (uint)(den >> 32); + if (num2 >= denHigh32) + { + // Divide would overflow. Assume a quotient of 2^32, and set + // up remainder accordingly. + // + num = bufNum.Low64; + num -= den << 32; + quo = 0; + + // Remainder went negative. Add divisor back in until it's positive, + // a max of 2 times. + // + do + { + quo--; + num += den; + } while (num >= den); + + bufNum.Low64 = num; + return quo; + } + + // Hardware divide won't overflow + // + ulong num64 = bufNum.High64; + if (num64 < denHigh32) + // Result is zero. Entire dividend is remainder. + // + return 0; + + // TODO: https://github.com/dotnet/coreclr/issues/3439 + quo = (uint)(num64 / denHigh32); + num = bufNum.U0 | ((num64 - quo * denHigh32) << 32); // remainder + + // Compute full remainder, rem = dividend - (quo * divisor). + // + ulong prod = UInt32x32To64(quo, (uint)den); // quo * lo divisor + num -= prod; + + if (num > ~prod) + { + // Remainder went negative. Add divisor back in until it's positive, + // a max of 2 times. + // + do + { + quo--; + num += den; + } while (num >= den); + } + + bufNum.Low64 = num; + return quo; + } + + /*** + * Div128By96 + * + * Entry: + * bufNum - 128-bit dividend as array of ULONGs, least-sig first + * bufDen - 96-bit divisor. + * + * Purpose: + * Do partial divide, yielding 32-bit result and 96-bit remainder. + * Top divisor ULONG must be larger than top dividend ULONG. This is + * assured in the initial call because the divisor is normalized + * and the dividend can't be. In subsequent calls, the remainder + * is multiplied by 10^9 (max), so it can be no more than 1/4 of + * the divisor which is effectively multiplied by 2^32 (4 * 10^9). + * + * Exit: + * Remainder overwrites lower 96-bits of dividend. + * Returns quotient. + * + * Exceptions: + * None. + * + ***********************************************************************/ + private static uint Div128By96(ref Buf16 bufNum, ref Buf12 bufDen) + { + ulong dividend = bufNum.High64; + uint den = bufDen.U2; + if (dividend < den) + // Result is zero. Entire dividend is remainder. + // + return 0; + + // TODO: https://github.com/dotnet/coreclr/issues/3439 + uint quo = (uint)(dividend / den); + uint remainder = (uint)dividend - quo * den; + + // Compute full remainder, rem = dividend - (quo * divisor). + // + ulong prod1 = UInt32x32To64(quo, bufDen.U0); // quo * lo divisor + ulong prod2 = UInt32x32To64(quo, bufDen.U1); // quo * mid divisor + prod2 += prod1 >> 32; + prod1 = (uint)prod1 | (prod2 << 32); + prod2 >>= 32; + + ulong num = bufNum.Low64; + num -= prod1; + remainder -= (uint)prod2; + + // Propagate carries + // + if (num > ~prod1) + { + remainder--; + if (remainder < ~(uint)prod2) + goto PosRem; + } + else if (remainder <= ~(uint)prod2) + goto PosRem; + { + // Remainder went negative. Add divisor back in until it's positive, + // a max of 2 times. + // + prod1 = bufDen.Low64; + + for (;;) + { + quo--; + num += prod1; + remainder += den; + + if (num < prod1) + { + // Detected carry. Check for carry out of top + // before adding it in. + // + if (remainder++ < den) + break; + } + if (remainder < den) + break; // detected carry + } + } +PosRem: + + bufNum.Low64 = num; + bufNum.U2 = remainder; + return quo; + } + + /*** + * IncreaseScale + * + * Entry: + * bufNum - 96-bit number as array of ULONGs, least-sig first + * ulPwr - Scale factor to multiply by + * + * Purpose: + * Multiply the two numbers. The low 96 bits of the result overwrite + * the input. The last 32 bits of the product are the return value. + * + * Exit: + * Returns highest 32 bits of product. + * + * Exceptions: + * None. + * + ***********************************************************************/ + private static uint IncreaseScale(ref Buf12 bufNum, uint ulPwr) + { + ulong tmp = UInt32x32To64(bufNum.U0, ulPwr); + bufNum.U0 = (uint)tmp; + tmp >>= 32; + tmp += UInt32x32To64(bufNum.U1, ulPwr); + bufNum.U1 = (uint)tmp; + tmp >>= 32; + tmp += UInt32x32To64(bufNum.U2, ulPwr); + bufNum.U2 = (uint)tmp; + return (uint)(tmp >> 32); + } + + private static void IncreaseScale64(ref Buf12 bufNum, uint ulPwr) + { + ulong tmp = UInt32x32To64(bufNum.U0, ulPwr); + bufNum.U0 = (uint)tmp; + tmp >>= 32; + tmp += UInt32x32To64(bufNum.U1, ulPwr); + bufNum.High64 = tmp; + } + + /*** + * ScaleResult + * + * Entry: + * bufRes - Array of ULONGs with value, least-significant first. + * iHiRes - Index of last non-zero value in bufRes. + * iScale - Scale factor for this value, range 0 - 2 * DEC_SCALE_MAX + * + * Purpose: + * See if we need to scale the result to fit it in 96 bits. + * Perform needed scaling. Adjust scale factor accordingly. + * + * Exit: + * bufRes updated in place, always 3 ULONGs. + * New scale factor returned. + * + ***********************************************************************/ + private static unsafe int ScaleResult(Buf24* bufRes, uint iHiRes, int iScale) + { + Debug.Assert(iHiRes < bufRes->Length); + uint* rgulRes = (uint*)bufRes; + + // See if we need to scale the result. The combined scale must + // be <= DEC_SCALE_MAX and the upper 96 bits must be zero. + // + // Start by figuring a lower bound on the scaling needed to make + // the upper 96 bits zero. iHiRes is the index into rgulRes[] + // of the highest non-zero ULONG. + // + int iNewScale = 0; + if (iHiRes > 2) + { + iNewScale = (int)iHiRes * 32 - 64 - 1; + iNewScale -= X86.Lzcnt.IsSupported ? (int)X86.Lzcnt.LeadingZeroCount(rgulRes[iHiRes]) : LeadingZeroCount(rgulRes[iHiRes]); + + // Multiply bit position by log10(2) to figure it's power of 10. + // We scale the log by 256. log(2) = .30103, * 256 = 77. Doing this + // with a multiply saves a 96-byte lookup table. The power returned + // is <= the power of the number, so we must add one power of 10 + // to make it's integer part zero after dividing by 256. + // + // Note: the result of this multiplication by an approximation of + // log10(2) have been exhaustively checked to verify it gives the + // correct result. (There were only 95 to check...) + // + iNewScale = ((iNewScale * 77) >> 8) + 1; + + // iNewScale = min scale factor to make high 96 bits zero, 0 - 29. + // This reduces the scale factor of the result. If it exceeds the + // current scale of the result, we'll overflow. + // + if (iNewScale > iScale) + goto ThrowOverflow; + } + + // Make sure we scale by enough to bring the current scale factor + // into valid range. + // + if (iNewScale < iScale - DEC_SCALE_MAX) + iNewScale = iScale - DEC_SCALE_MAX; + + if (iNewScale != 0) + { + // Scale by the power of 10 given by iNewScale. Note that this is + // NOT guaranteed to bring the number within 96 bits -- it could + // be 1 power of 10 short. + // + iScale -= iNewScale; + uint ulSticky = 0; + uint quotient, remainder = 0; + + for (;;) + { + ulSticky |= remainder; // record remainder as sticky bit + + uint ulPwr; + // Scaling loop specialized for each power of 10 because division by constant is an order of magnitude faster (especially for 64-bit division that's actually done by 128bit DIV on x64) + switch (iNewScale) + { + case 1: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 10); + break; + case 2: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 100); + break; + case 3: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 1000); + break; + case 4: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 10000); + break; +#if BIT64 + case 5: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 100000); + break; + case 6: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 1000000); + break; + case 7: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 10000000); + break; + case 8: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, 100000000); + break; + default: + ulPwr = DivByConst(rgulRes, iHiRes, out quotient, out remainder, TenToPowerNine); + break; +#else + default: + goto case 4; +#endif + } + rgulRes[iHiRes] = quotient; + // If first quotient was 0, update iHiRes. + // + if (quotient == 0 && iHiRes != 0) + iHiRes--; + +#if BIT64 + iNewScale -= MaxInt32Scale; +#else + iNewScale -= 4; +#endif + if (iNewScale > 0) + continue; // scale some more + + // If we scaled enough, iHiRes would be 2 or less. If not, + // divide by 10 more. + // + if (iHiRes > 2) + { + if (iScale == 0) + goto ThrowOverflow; + iNewScale = 1; + iScale--; + continue; // scale by 10 + } + + // Round final result. See if remainder >= 1/2 of divisor. + // If remainder == 1/2 divisor, round up if odd or sticky bit set. + // + ulPwr >>= 1; // power of 10 always even + if (ulPwr <= remainder && (ulPwr < remainder || ((rgulRes[0] & 1) | ulSticky) != 0) && ++rgulRes[0] == 0) + { + uint iCur = 0; + do + { + Debug.Assert(iCur + 1 < bufRes->Length); + } + while (++rgulRes[++iCur] == 0); + + if (iCur > 2) + { + // The rounding caused us to carry beyond 96 bits. + // Scale by 10 more. + // + if (iScale == 0) + goto ThrowOverflow; + iHiRes = iCur; + ulSticky = 0; // no sticky bit + remainder = 0; // or remainder + iNewScale = 1; + iScale--; + continue; // scale by 10 + } + } + + break; + } // for(;;) + } + return iScale; + +ThrowOverflow: + throw new OverflowException(SR.Overflow_Decimal); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static unsafe uint DivByConst(uint* rgulRes, uint iHiRes, out uint quotient, out uint remainder, uint power) + { + uint high = rgulRes[iHiRes]; + remainder = high - (quotient = high / power) * power; + for (uint i = iHiRes - 1; (int)i >= 0; i--) + { +#if BIT64 + ulong num = rgulRes[i] + ((ulong)remainder << 32); + remainder = (uint)num - (rgulRes[i] = (uint)(num / power)) * power; +#else + // 32-bit RyuJIT doesn't convert 64-bit division by constant into multiplication by reciprocal. Do half-width divisions instead. + Debug.Assert(power <= ushort.MaxValue); +#if BIGENDIAN + const int low16 = 2, high16 = 0; +#else + const int low16 = 0, high16 = 2; +#endif + // byte* is used here because Roslyn doesn't do constant propagation for pointer arithmetic + uint num = *(ushort*)((byte*)rgulRes + i * 4 + high16) + (remainder << 16); + uint div = num / power; + remainder = num - div * power; + *(ushort*)((byte*)rgulRes + i * 4 + high16) = (ushort)div; + + num = *(ushort*)((byte*)rgulRes + i * 4 + low16) + (remainder << 16); + div = num / power; + remainder = num - div * power; + *(ushort*)((byte*)rgulRes + i * 4 + low16) = (ushort)div; +#endif + } + return power; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static int LeadingZeroCount(uint value) + { + Debug.Assert(value > 0); + int c = 1; + if ((value & 0xFFFF0000) == 0) + { + value <<= 16; + c += 16; + } + if ((value & 0xFF000000) == 0) + { + value <<= 8; + c += 8; + } + if ((value & 0xF0000000) == 0) + { + value <<= 4; + c += 4; + } + if ((value & 0xC0000000) == 0) + { + value <<= 2; + c += 2; + } + return c + ((int)value >> 31); + } + + // Adjust the quotient to deal with an overflow. We need to divide by 10, + // feed in the high bit to undo the overflow and then round as required, + private static int OverflowUnscale(ref Buf12 bufQuo, int iScale, bool fRemainder) + { + if (--iScale < 0) + throw new OverflowException(SR.Overflow_Decimal); + + Debug.Assert(bufQuo.U2 == 0); + + // We have overflown, so load the high bit with a one. + const ulong highbit = 1UL << 32; + bufQuo.U2 = (uint)(highbit / 10); + ulong tmp = ((highbit % 10) << 32) + bufQuo.U1; + uint div = (uint)(tmp / 10); + bufQuo.U1 = div; + tmp = ((tmp - div * 10) << 32) + bufQuo.U0; + div = (uint)(tmp / 10); + bufQuo.U0 = div; + uint remainder = (uint)(tmp - div * 10); + // The remainder is the last digit that does not fit, so we can use it to work out if we need to round up + if (remainder > 5 || remainder == 5 && (fRemainder || (bufQuo.U0 & 1) != 0)) + Add32To96(ref bufQuo, 1); + return iScale; + } + + /*** + * SearchScale + * + * Entry: + * bufQuo - 96-bit quotient + * iScale - Scale factor of quotient, range -DEC_SCALE_MAX to DEC_SCALE_MAX-1 + * + * Purpose: + * Determine the max power of 10, <= 9, that the quotient can be scaled + * up by and still fit in 96 bits. + * + * Exit: + * Returns power of 10 to scale by. + * + ***********************************************************************/ + private static int SearchScale(ref Buf12 bufQuo, int iScale) + { + const uint OVFL_MAX_9_HI = 4; + const uint OVFL_MAX_8_HI = 42; + const uint OVFL_MAX_7_HI = 429; + const uint OVFL_MAX_6_HI = 4294; + const uint OVFL_MAX_5_HI = 42949; + const uint OVFL_MAX_4_HI = 429496; + const uint OVFL_MAX_3_HI = 4294967; + const uint OVFL_MAX_2_HI = 42949672; + const uint OVFL_MAX_1_HI = 429496729; + const ulong OVFL_MAX_9_MIDLO = 5441186219426131129; + + uint ulResHi = bufQuo.U2; + ulong ulResMidLo = bufQuo.Low64; + int iCurScale = 0; + + // Quick check to stop us from trying to scale any more. + // + if (ulResHi > OVFL_MAX_1_HI) + { + goto HaveScale; + } + + var powerOvfl = PowerOvflValues; + if (iScale > DEC_SCALE_MAX - 9) + { + // We can't scale by 10^9 without exceeding the max scale factor. + // See if we can scale to the max. If not, we'll fall into + // standard search for scale factor. + // + iCurScale = DEC_SCALE_MAX - iScale; + if (ulResHi < powerOvfl[iCurScale - 1].Hi) + goto HaveScale; + } + else if (ulResHi < OVFL_MAX_9_HI || ulResHi == OVFL_MAX_9_HI && ulResMidLo <= OVFL_MAX_9_MIDLO) + return 9; + + // Search for a power to scale by < 9. Do a binary search. + // + if (ulResHi > OVFL_MAX_5_HI) + { + if (ulResHi > OVFL_MAX_3_HI) + { + iCurScale = 2; + if (ulResHi > OVFL_MAX_2_HI) + iCurScale--; + } + else + { + iCurScale = 4; + if (ulResHi > OVFL_MAX_4_HI) + iCurScale--; + } + } + else + { + if (ulResHi > OVFL_MAX_7_HI) + { + iCurScale = 6; + if (ulResHi > OVFL_MAX_6_HI) + iCurScale--; + } + else + { + iCurScale = 8; + if (ulResHi > OVFL_MAX_8_HI) + iCurScale--; + } + } + + // In all cases, we already found we could not use the power one larger. + // So if we can use this power, it is the biggest, and we're done. If + // we can't use this power, the one below it is correct for all cases + // unless it's 10^1 -- we might have to go to 10^0 (no scaling). + // + if (ulResHi == powerOvfl[iCurScale - 1].Hi && ulResMidLo > powerOvfl[iCurScale - 1].MidLo) + iCurScale--; + + HaveScale: + // iCurScale = largest power of 10 we can scale by without overflow, + // iCurScale < 9. See if this is enough to make scale factor + // positive if it isn't already. + // + if (iCurScale + iScale < 0) + throw new OverflowException(SR.Overflow_Decimal); + + return iCurScale; + } + + // Add a 32 bit unsigned long to an array of 3 unsigned longs representing a 96 integer + // Returns false if there is an overflow + private static bool Add32To96(ref Buf12 bufNum, uint ulValue) + { + if ((bufNum.Low64 += ulValue) < ulValue) + { + if (++bufNum.U2 == 0) + return false; + } + return true; + } + + // DecAddSub adds or subtracts two decimal values. + // On return, d1 contains the result of the operation and d2 is trashed. + // Passing in true for bSign means subtract and false means add. + internal static unsafe void DecAddSub(ref DecCalc d1, ref DecCalc d2, bool bSign) + { + ulong low64 = d1.Low64; + uint high = d1.High, flags = d1.uflags, d2flags = d2.uflags; + + uint xorflags = d2flags ^ flags; + bSign ^= (xorflags & SignMask) != 0; + + if ((xorflags & ScaleMask) == 0) + { + // Scale factors are equal, no alignment necessary. + // + goto AlignedAdd; + } + else + { + // Scale factors are not equal. Assume that a larger scale + // factor (more decimal places) is likely to mean that number + // is smaller. Start by guessing that the right operand has + // the larger scale factor. The result will have the larger + // scale factor. + // + uint d1flags = flags; + flags = d2flags & ScaleMask | flags & SignMask; // scale factor of "smaller", but sign of "larger" + int iScale = (int)(flags - d1flags) >> ScaleShift; + + if (iScale < 0) + { + // Guessed scale factor wrong. Swap operands. + // + iScale = -iScale; + flags = d1flags; + if (bSign) + flags ^= SignMask; + low64 = d2.Low64; + high = d2.High; + d2 = d1; + } + + uint ulPwr; + ulong tmp64, tmpLow; + + // d1 will need to be multiplied by 10^iScale so + // it will have the same scale as d2. We could be + // extending it to up to 192 bits of precision. + + // Scan for zeros in the upper words. + // + if (high == 0) + { + if (low64 <= uint.MaxValue) + { + if ((uint)low64 == 0) + { + // Left arg is zero, return right. + // + uint signFlags = flags & SignMask; + if (bSign) + signFlags ^= SignMask; + d1 = d2; + d1.uflags = d2.uflags & ScaleMask | signFlags; + return; + } + + do + { + if (iScale <= MaxInt32Scale) + { + low64 = UInt32x32To64((uint)low64, s_powers10[iScale]); + goto AlignedAdd; + } + iScale -= MaxInt32Scale; + low64 = UInt32x32To64((uint)low64, TenToPowerNine); + } while (low64 <= uint.MaxValue); + } + + do + { + ulPwr = TenToPowerNine; + if (iScale < MaxInt32Scale) + ulPwr = s_powers10[iScale]; + tmpLow = UInt32x32To64((uint)low64, ulPwr); + tmp64 = UInt32x32To64((uint)(low64 >> 32), ulPwr) + (tmpLow >> 32); + low64 = (uint)tmpLow + (tmp64 << 32); + high = (uint)(tmp64 >> 32); + if ((iScale -= MaxInt32Scale) <= 0) + goto AlignedAdd; + } while (high == 0); + } + + while (true) + { + // Scaling won't make it larger than 4 ULONGs + // + ulPwr = TenToPowerNine; + if (iScale < MaxInt32Scale) + ulPwr = s_powers10[iScale]; + tmpLow = UInt32x32To64((uint)low64, ulPwr); + tmp64 = UInt32x32To64((uint)(low64 >> 32), ulPwr) + (tmpLow >> 32); + low64 = (uint)tmpLow + (tmp64 << 32); + tmp64 >>= 32; + tmp64 += UInt32x32To64(high, ulPwr); + + iScale -= MaxInt32Scale; + if (tmp64 > uint.MaxValue) + break; + + high = (uint)tmp64; + // Result fits in 96 bits. Use standard aligned add. + if (iScale <= 0) + goto AlignedAdd; + } + + // Have to scale by a bunch. Move the number to a buffer where it has room to grow as it's scaled. + // + Buf24 bufNum; + _ = &bufNum; // workaround for CS0165 + bufNum.Low64 = low64; + bufNum.Mid64 = tmp64; + uint iHiProd = 3; + + // Scaling loop, up to 10^9 at a time. iHiProd stays updated with index of highest non-zero ULONG. + // + for (; iScale > 0; iScale -= MaxInt32Scale) + { + ulPwr = TenToPowerNine; + if (iScale < MaxInt32Scale) + ulPwr = s_powers10[iScale]; + tmp64 = 0; + uint* rgulNum = (uint*)&bufNum; + for (uint iCur = 0; ;) + { + Debug.Assert(iCur < bufNum.Length); + tmp64 += UInt32x32To64(rgulNum[iCur], ulPwr); + rgulNum[iCur] = (uint)tmp64; + iCur++; + tmp64 >>= 32; + if (iCur > iHiProd) + break; + } + + if ((uint)tmp64 != 0) + { + // We're extending the result by another ULONG. + Debug.Assert(iHiProd + 1 < bufNum.Length); + rgulNum[++iHiProd] = (uint)tmp64; + } + } + + // Scaling complete, do the add. Could be subtract if signs differ. + // + tmp64 = bufNum.Low64; + low64 = d2.Low64; + uint tmpHigh = bufNum.U2; + high = d2.High; + + if (bSign) + { + // Signs differ, subtract. + // + low64 = tmp64 - low64; + high = tmpHigh - high; + + // Propagate carry + // + if (low64 > tmp64) + { + high--; + if (high < tmpHigh) + goto NoCarry; + } + else if (high <= tmpHigh) + goto NoCarry; + + // Carry the subtraction into the higher bits. + // + uint* rgulNum = (uint*)&bufNum; + uint iCur = 3; + do + { + Debug.Assert(iCur < bufNum.Length); + } while (rgulNum[iCur++]-- == 0); + Debug.Assert(iHiProd < bufNum.Length); + if (rgulNum[iHiProd] == 0 && --iHiProd <= 2) + goto ReturnResult; + } + else + { + // Signs the same, add. + // + low64 += tmp64; + high += tmpHigh; + + // Propagate carry + // + if (low64 < tmp64) + { + high++; + if (high > tmpHigh) + goto NoCarry; + } + else if (high >= tmpHigh) + goto NoCarry; + + uint* rgulNum = (uint*)&bufNum; + for (uint iCur = 3; ++rgulNum[iCur++] == 0;) + { + Debug.Assert(iCur < bufNum.Length); + if (iHiProd < iCur) + { + rgulNum[iCur] = 1; + iHiProd = iCur; + break; + } + } + } +NoCarry: + + bufNum.Low64 = low64; + bufNum.U2 = high; + int scale = ScaleResult(&bufNum, iHiProd, (byte)(flags >> ScaleShift)); + flags = (flags & ~ScaleMask) | ((uint)scale << ScaleShift); + low64 = bufNum.Low64; + high = bufNum.U2; + goto ReturnResult; + } + +SignFlip: + { + // Got negative result. Flip its sign. + flags ^= SignMask; + high = ~high; + low64 = (ulong)-(long)low64; + if (low64 == 0) + high++; + goto ReturnResult; + } + +AlignedScale: + { + // The addition carried above 96 bits. + // Divide the value by 10, dropping the scale factor. + // + if ((flags & ScaleMask) == 0) + throw new OverflowException(SR.Overflow_Decimal); + flags -= 1 << ScaleShift; + + const uint den = 10; + ulong num = high + (1UL << 32); + high = (uint)(num / den); + num = ((num - high * den) << 32) + (low64 >> 32); + uint div = (uint)(num / den); + num = ((num - div * den) << 32) + (uint)low64; + low64 = div; + low64 <<= 32; + div = (uint)(num / den); + low64 += div; + div = (uint)num - div * den; + + // See if we need to round up. + // + if (div >= 5 && (div > 5 || (low64 & 1) != 0)) + { + if (++low64 == 0) + high++; + } + goto ReturnResult; + } + +AlignedAdd: + { + ulong d1Low64 = low64; + uint d1High = high; + if (bSign) + { + // Signs differ - subtract + // + low64 = d1Low64 - d2.Low64; + high = d1High - d2.High; + + // Propagate carry + // + if (low64 > d1Low64) + { + high--; + if (high >= d1High) + goto SignFlip; + } + else if (high > d1High) + goto SignFlip; + } + else + { + // Signs are the same - add + // + low64 = d1Low64 + d2.Low64; + high = d1High + d2.High; + + // Propagate carry + // + if (low64 < d1Low64) + { + high++; + if (high <= d1High) + goto AlignedScale; + } + else if (high < d1High) + goto AlignedScale; + } + goto ReturnResult; + } + +ReturnResult: + d1.uflags = flags; + d1.High = high; + d1.Low64 = low64; + return; + } + +#endregion + + //********************************************************************** + // VarCyFromDec - Convert Currency to Decimal (similar to OleAut32 api.) + //********************************************************************** + internal static long VarCyFromDec(ref DecCalc pdecIn) + { + long value; + + int scale = pdecIn.Scale - 4; + // Need to scale to get 4 decimal places. -4 <= scale <= 24. + // + if (scale < 0) + { + if (pdecIn.High != 0) + goto ThrowOverflow; + uint pwr = s_powers10[-scale]; + ulong high = UInt32x32To64(pwr, pdecIn.Mid); + if (high > uint.MaxValue) + goto ThrowOverflow; + ulong low = UInt32x32To64(pwr, pdecIn.Low); + low += high <<= 32; + if (low < high) + goto ThrowOverflow; + value = (long)low; + } + else + { + if (scale != 0) + InternalRound(ref pdecIn, (uint)scale, RoundingMode.ToEven); + if (pdecIn.High != 0) + goto ThrowOverflow; + value = (long)pdecIn.Low64; + } + + if (value < 0 && (value != long.MinValue || !pdecIn.IsNegative)) + goto ThrowOverflow; + + if (pdecIn.IsNegative) + value = -value; + + return value; + +ThrowOverflow: + throw new OverflowException(SR.Overflow_Currency); + } + + //********************************************************************** + // VarDecCmp - Decimal Compare updated to return values similar to ICompareTo + //********************************************************************** + internal static int VarDecCmp(in decimal pdecL, in decimal pdecR) + { + if ((pdecR.Low | pdecR.Mid | pdecR.High) == 0) + { + if ((pdecL.Low | pdecL.Mid | pdecL.High) == 0) + return 0; + return (pdecL.flags >> 31) | 1; + } + if ((pdecL.Low | pdecL.Mid | pdecL.High) == 0) + return -((pdecR.flags >> 31) | 1); + + int sign = (pdecL.flags >> 31) - (pdecR.flags >> 31); + if (sign != 0) + return sign; + return VarDecCmpSub(in pdecL, in pdecR); + } + + private static int VarDecCmpSub(in decimal d1, in decimal d2) + { + int flags = d2.flags; + int sign = (flags >> 31) | 1; + int iScale = flags - d1.flags; + + ulong low64 = d1.Low64; + uint high = d1.High; + + ulong d2Low64 = d2.Low64; + uint d2High = d2.High; + + if (iScale != 0) + { + iScale >>= ScaleShift; + + // Scale factors are not equal. Assume that a larger scale factor (more decimal places) is likely to mean that number is smaller. + // Start by guessing that the right operand has the larger scale factor. + if (iScale < 0) + { + // Guessed scale factor wrong. Swap operands. + iScale = -iScale; + sign = -sign; + + ulong tmp64 = low64; + low64 = d2Low64; + d2Low64 = tmp64; + + uint tmp = high; + high = d2High; + d2High = tmp; + } + + // d1 will need to be multiplied by 10^iScale so it will have the same scale as d2. + // Scaling loop, up to 10^9 at a time. + do + { + uint ulPwr = iScale >= MaxInt32Scale ? TenToPowerNine : s_powers10[iScale]; + ulong tmpLow = UInt32x32To64((uint)low64, ulPwr); + ulong tmp = UInt32x32To64((uint)(low64 >> 32), ulPwr) + (tmpLow >> 32); + low64 = (uint)tmpLow + (tmp << 32); + tmp >>= 32; + tmp += UInt32x32To64(high, ulPwr); + // If the scaled value has more than 96 significant bits then it's greater than d2 + if (tmp > uint.MaxValue) + return sign; + high = (uint)tmp; + } while ((iScale -= MaxInt32Scale) > 0); + } + + uint cmpHigh = high - d2High; + if (cmpHigh != 0) + { + // check for overflow + if (cmpHigh > high) + sign = -sign; + return sign; + } + + ulong cmpLow64 = low64 - d2Low64; + if (cmpLow64 == 0) + sign = 0; + // check for overflow + else if (cmpLow64 > low64) + sign = -sign; + return sign; + } + + //********************************************************************** + // VarDecMul - Decimal Multiply + //********************************************************************** + internal static unsafe void VarDecMul(ref DecCalc pdecL, ref DecCalc pdecR) + { + int iScale = (byte)(pdecL.uflags + pdecR.uflags >> ScaleShift); + + ulong tmp; + uint iHiProd; + Buf24 bufProd; + _ = &bufProd; // workaround for CS0165 + + if ((pdecL.High | pdecL.Mid) == 0) + { + if ((pdecR.High | pdecR.Mid) == 0) + { + // Upper 64 bits are zero. + // + ulong low64 = UInt32x32To64(pdecL.Low, pdecR.Low); + if (iScale > DEC_SCALE_MAX) + { + // Result iScale is too big. Divide result by power of 10 to reduce it. + // If the amount to divide by is > 19 the result is guaranteed + // less than 1/2. [max value in 64 bits = 1.84E19] + // + if (iScale > DEC_SCALE_MAX + MaxInt64Scale) + goto ReturnZero; + + iScale -= DEC_SCALE_MAX + 1; + ulong ulPwr = s_ulongPowers10[iScale]; + + // TODO: https://github.com/dotnet/coreclr/issues/3439 + tmp = low64 / ulPwr; + ulong remainder = low64 - tmp * ulPwr; + low64 = tmp; + + // Round result. See if remainder >= 1/2 of divisor. + // Divisor is a power of 10, so it is always even. + // + ulPwr >>= 1; + if (remainder >= ulPwr && (remainder > ulPwr || ((uint)low64 & 1) > 0)) + low64++; + + iScale = DEC_SCALE_MAX; + } + pdecL.Low64 = low64; + pdecL.uflags = ((pdecR.uflags ^ pdecL.uflags) & SignMask) | ((uint)iScale << ScaleShift); + return; + } + else + { + // Left value is 32-bit, result fits in 4 uints + tmp = UInt32x32To64(pdecL.Low, pdecR.Low); + bufProd.U0 = (uint)tmp; + + tmp = UInt32x32To64(pdecL.Low, pdecR.Mid) + (tmp >> 32); + bufProd.U1 = (uint)tmp; + tmp >>= 32; + + if (pdecR.High != 0) + { + tmp += UInt32x32To64(pdecL.Low, pdecR.High); + if (tmp > uint.MaxValue) + { + bufProd.Mid64 = tmp; + iHiProd = 3; + goto SkipScan; + } + } + if ((uint)tmp != 0) + { + bufProd.U2 = (uint)tmp; + iHiProd = 2; + goto SkipScan; + } + iHiProd = 1; + } + } + else if ((pdecR.High | pdecR.Mid) == 0) + { + // Right value is 32-bit, result fits in 4 uints + tmp = UInt32x32To64(pdecR.Low, pdecL.Low); + bufProd.U0 = (uint)tmp; + + tmp = UInt32x32To64(pdecR.Low, pdecL.Mid) + (tmp >> 32); + bufProd.U1 = (uint)tmp; + tmp >>= 32; + + if (pdecL.High != 0) + { + tmp += UInt32x32To64(pdecR.Low, pdecL.High); + if (tmp > uint.MaxValue) + { + bufProd.Mid64 = tmp; + iHiProd = 3; + goto SkipScan; + } + } + if ((uint)tmp != 0) + { + bufProd.U2 = (uint)tmp; + iHiProd = 2; + goto SkipScan; + } + iHiProd = 1; + } + else + { + // Both operands have bits set in the upper 64 bits. + // + // Compute and accumulate the 9 partial products into a + // 192-bit (24-byte) result. + // + // [l-h][l-m][l-l] left high, middle, low + // x [r-h][r-m][r-l] right high, middle, low + // ------------------------------ + // + // [0-h][0-l] l-l * r-l + // [1ah][1al] l-l * r-m + // [1bh][1bl] l-m * r-l + // [2ah][2al] l-m * r-m + // [2bh][2bl] l-l * r-h + // [2ch][2cl] l-h * r-l + // [3ah][3al] l-m * r-h + // [3bh][3bl] l-h * r-m + // [4-h][4-l] l-h * r-h + // ------------------------------ + // [p-5][p-4][p-3][p-2][p-1][p-0] prod[] array + // + + tmp = UInt32x32To64(pdecL.Low, pdecR.Low); + bufProd.U0 = (uint)tmp; + + ulong tmp2 = UInt32x32To64(pdecL.Low, pdecR.Mid) + (tmp >> 32); + + tmp = UInt32x32To64(pdecL.Mid, pdecR.Low); + tmp += tmp2; // this could generate carry + bufProd.U1 = (uint)tmp; + if (tmp < tmp2) // detect carry + tmp2 = (tmp >> 32) | (1UL << 32); + else + tmp2 = tmp >> 32; + + tmp = UInt32x32To64(pdecL.Mid, pdecR.Mid) + tmp2; + + if ((pdecL.High | pdecR.High) > 0) + { + // Highest 32 bits is non-zero. Calculate 5 more partial products. + // + tmp2 = UInt32x32To64(pdecL.Low, pdecR.High); + tmp += tmp2; // this could generate carry + uint tmp3 = 0; + if (tmp < tmp2) // detect carry + tmp3 = 1; + + tmp2 = UInt32x32To64(pdecL.High, pdecR.Low); + tmp += tmp2; // this could generate carry + bufProd.U2 = (uint)tmp; + if (tmp < tmp2) // detect carry + tmp3++; + tmp2 = ((ulong)tmp3 << 32) | (tmp >> 32); + + tmp = UInt32x32To64(pdecL.Mid, pdecR.High); + tmp += tmp2; // this could generate carry + tmp3 = 0; + if (tmp < tmp2) // detect carry + tmp3 = 1; + + tmp2 = UInt32x32To64(pdecL.High, pdecR.Mid); + tmp += tmp2; // this could generate carry + bufProd.U3 = (uint)tmp; + if (tmp < tmp2) // detect carry + tmp3++; + tmp = ((ulong)tmp3 << 32) | (tmp >> 32); + + bufProd.High64 = UInt32x32To64(pdecL.High, pdecR.High) + tmp; + + iHiProd = 5; + } + else if (tmp != 0) + { + bufProd.Mid64 = tmp; + iHiProd = 3; + } + else + iHiProd = 1; + } + + // Check for leading zero ULONGs on the product + // + uint* rgulProd = (uint*)&bufProd; + while (rgulProd[(int)iHiProd] == 0) + { + if (iHiProd == 0) + goto ReturnZero; + iHiProd--; + } + +SkipScan: + if (iHiProd > 2 || iScale > DEC_SCALE_MAX) + { + iScale = ScaleResult(&bufProd, iHiProd, iScale); + } + + pdecL.Low64 = bufProd.Low64; + pdecL.High = bufProd.U2; + pdecL.uflags = ((pdecR.uflags ^ pdecL.uflags) & SignMask) | ((uint)iScale << ScaleShift); + return; + +ReturnZero: + pdecL = default; + } + + //********************************************************************** + // VarDecFromR4 - Convert float to Decimal + //********************************************************************** + internal static void VarDecFromR4(float input, out DecCalc pdecOut) + { + pdecOut = default; + + // The most we can scale by is 10^28, which is just slightly more + // than 2^93. So a float with an exponent of -94 could just + // barely reach 0.5, but smaller exponents will always round to zero. + // + const uint SNGBIAS = 126; + int iExp = (int)(GetExponent(input) - SNGBIAS); + if (iExp < -94) + return; // result should be zeroed out + + if (iExp > 96) + throw new OverflowException(SR.Overflow_Decimal); + + uint flags = 0; + if (input < 0) + { + input = -input; + flags = SignMask; + } + + // Round the input to a 7-digit integer. The R4 format has + // only 7 digits of precision, and we want to keep garbage digits + // out of the Decimal were making. + // + // Calculate max power of 10 input value could have by multiplying + // the exponent by log10(2). Using scaled integer multiplcation, + // log10(2) * 2 ^ 16 = .30103 * 65536 = 19728.3. + // + double dbl = input; + int iPower = 6 - ((iExp * 19728) >> 16); + // iPower is between -22 and 35 + + if (iPower >= 0) + { + // We have less than 7 digits, scale input up. + // + if (iPower > DEC_SCALE_MAX) + iPower = DEC_SCALE_MAX; + + dbl *= s_doublePowers10[iPower]; + } + else + { + if (iPower != -1 || dbl >= 1E7) + dbl /= s_doublePowers10[-iPower]; + else + iPower = 0; // didn't scale it + } + + Debug.Assert(dbl < 1E7); + if (dbl < 1E6 && iPower < DEC_SCALE_MAX) + { + dbl *= 10; + iPower++; + Debug.Assert(dbl >= 1E6); + } + + // Round to integer + // + uint ulMant; + // with SSE4.1 support ROUNDSD can be used + if (X86.Sse41.IsSupported) + ulMant = (uint)(int)Math.Round(dbl); + else + { + ulMant = (uint)(int)dbl; + dbl -= (int)ulMant; // difference between input & integer + if (dbl > 0.5 || dbl == 0.5 && (ulMant & 1) != 0) + ulMant++; + } + + if (ulMant == 0) + return; // result should be zeroed out + + if (iPower < 0) + { + // Add -iPower factors of 10, -iPower <= (29 - 7) = 22. + // + iPower = -iPower; + if (iPower < 10) + { + pdecOut.Low64 = UInt32x32To64(ulMant, s_powers10[iPower]); + } + else + { + // Have a big power of 10. + // + if (iPower > 18) + { + ulong low64 = UInt32x32To64(ulMant, s_powers10[iPower - 18]); + UInt64x64To128(low64, TenToPowerEighteen, ref pdecOut); + } + else + { + ulong low64 = UInt32x32To64(ulMant, s_powers10[iPower - 9]); + ulong hi64 = UInt32x32To64(TenToPowerNine, (uint)(low64 >> 32)); + low64 = UInt32x32To64(TenToPowerNine, (uint)low64); + pdecOut.Low = (uint)low64; + hi64 += low64 >> 32; + pdecOut.Mid = (uint)hi64; + hi64 >>= 32; + pdecOut.High = (uint)hi64; + } + } + } + else + { + // Factor out powers of 10 to reduce the scale, if possible. + // The maximum number we could factor out would be 6. This + // comes from the fact we have a 7-digit number, and the + // MSD must be non-zero -- but the lower 6 digits could be + // zero. Note also the scale factor is never negative, so + // we can't scale by any more than the power we used to + // get the integer. + // + int lmax = iPower; + if (lmax > 6) + lmax = 6; + + if ((ulMant & 0xF) == 0 && lmax >= 4) + { + const uint den = 10000; + uint div = ulMant / den; + if (ulMant == div * den) + { + ulMant = div; + iPower -= 4; + lmax -= 4; + } + } + + if ((ulMant & 3) == 0 && lmax >= 2) + { + const uint den = 100; + uint div = ulMant / den; + if (ulMant == div * den) + { + ulMant = div; + iPower -= 2; + lmax -= 2; + } + } + + if ((ulMant & 1) == 0 && lmax >= 1) + { + const uint den = 10; + uint div = ulMant / den; + if (ulMant == div * den) + { + ulMant = div; + iPower--; + } + } + + flags |= (uint)iPower << ScaleShift; + pdecOut.Low = ulMant; + } + + pdecOut.uflags = flags; + } + + //********************************************************************** + // VarDecFromR8 - Convert double to Decimal + //********************************************************************** + internal static void VarDecFromR8(double input, out DecCalc pdecOut) + { + pdecOut = default; + + // The most we can scale by is 10^28, which is just slightly more + // than 2^93. So a float with an exponent of -94 could just + // barely reach 0.5, but smaller exponents will always round to zero. + // + const uint DBLBIAS = 1022; + int iExp = (int)(GetExponent(input) - DBLBIAS); + if (iExp < -94) + return; // result should be zeroed out + + if (iExp > 96) + throw new OverflowException(SR.Overflow_Decimal); + + uint flags = 0; + if (input < 0) + { + input = -input; + flags = SignMask; + } + + // Round the input to a 15-digit integer. The R8 format has + // only 15 digits of precision, and we want to keep garbage digits + // out of the Decimal were making. + // + // Calculate max power of 10 input value could have by multiplying + // the exponent by log10(2). Using scaled integer multiplcation, + // log10(2) * 2 ^ 16 = .30103 * 65536 = 19728.3. + // + double dbl = input; + int iPower = 14 - ((iExp * 19728) >> 16); + // iPower is between -14 and 43 + + if (iPower >= 0) + { + // We have less than 15 digits, scale input up. + // + if (iPower > DEC_SCALE_MAX) + iPower = DEC_SCALE_MAX; + + dbl *= s_doublePowers10[iPower]; + } + else + { + if (iPower != -1 || dbl >= 1E15) + dbl /= s_doublePowers10[-iPower]; + else + iPower = 0; // didn't scale it + } + + Debug.Assert(dbl < 1E15); + if (dbl < 1E14 && iPower < DEC_SCALE_MAX) + { + dbl *= 10; + iPower++; + Debug.Assert(dbl >= 1E14); + } + + // Round to int64 + // + ulong ulMant; + // with SSE4.1 support ROUNDSD can be used + if (X86.Sse41.IsSupported) + ulMant = (ulong)(long)Math.Round(dbl); + else + { + ulMant = (ulong)(long)dbl; + dbl -= (long)ulMant; // difference between input & integer + if (dbl > 0.5 || dbl == 0.5 && (ulMant & 1) != 0) + ulMant++; + } + + if (ulMant == 0) + return; // result should be zeroed out + + if (iPower < 0) + { + // Add -iPower factors of 10, -iPower <= (29 - 15) = 14. + // + iPower = -iPower; + if (iPower < 10) + { + var pow10 = s_powers10[iPower]; + ulong low64 = UInt32x32To64((uint)ulMant, pow10); + ulong hi64 = UInt32x32To64((uint)(ulMant >> 32), pow10); + pdecOut.Low = (uint)low64; + hi64 += low64 >> 32; + pdecOut.Mid = (uint)hi64; + hi64 >>= 32; + pdecOut.High = (uint)hi64; + } + else + { + // Have a big power of 10. + // + Debug.Assert(iPower <= 14); + UInt64x64To128(ulMant, s_ulongPowers10[iPower - 1], ref pdecOut); + } + } + else + { + // Factor out powers of 10 to reduce the scale, if possible. + // The maximum number we could factor out would be 14. This + // comes from the fact we have a 15-digit number, and the + // MSD must be non-zero -- but the lower 14 digits could be + // zero. Note also the scale factor is never negative, so + // we can't scale by any more than the power we used to + // get the integer. + // + int lmax = iPower; + if (lmax > 14) + lmax = 14; + + if ((byte)ulMant == 0 && lmax >= 8) + { + const uint den = 100000000; + ulong div = ulMant / den; + if ((uint)ulMant == (uint)(div * den)) + { + ulMant = div; + iPower -= 8; + lmax -= 8; + } + } + + if (((uint)ulMant & 0xF) == 0 && lmax >= 4) + { + const uint den = 10000; + ulong div = ulMant / den; + if ((uint)ulMant == (uint)(div * den)) + { + ulMant = div; + iPower -= 4; + lmax -= 4; + } + } + + if (((uint)ulMant & 3) == 0 && lmax >= 2) + { + const uint den = 100; + ulong div = ulMant / den; + if ((uint)ulMant == (uint)(div * den)) + { + ulMant = div; + iPower -= 2; + lmax -= 2; + } + } + + if (((uint)ulMant & 1) == 0 && lmax >= 1) + { + const uint den = 10; + ulong div = ulMant / den; + if ((uint)ulMant == (uint)(div * den)) + { + ulMant = div; + iPower--; + } + } + + flags |= (uint)iPower << ScaleShift; + pdecOut.Low64 = ulMant; + } + + pdecOut.uflags = flags; + } + + //********************************************************************** + // VarR4ToDec - Convert Decimal to float + //********************************************************************** + internal static float VarR4FromDec(ref decimal pdecIn) + { + return (float)VarR8FromDec(ref pdecIn); + } + + //********************************************************************** + // VarR8ToDec - Convert Decimal to double + //********************************************************************** + internal static double VarR8FromDec(ref decimal pdecIn) + { + // Value taken via reverse engineering the double that corresponds to 2^64. (oleaut32 has ds2to64 = DEFDS(0, 0, DBLBIAS + 65, 0)) + const double ds2to64 = 1.8446744073709552e+019; + + double dbl = ((double)pdecIn.Low64 + + (double)pdecIn.High * ds2to64) / s_doublePowers10[pdecIn.Scale]; + + if (pdecIn.IsNegative) + dbl = -dbl; + + return dbl; + } + + internal static int GetHashCode(in decimal d) + { + if ((d.Low | d.Mid | d.High) == 0) + return 0; + + uint flags = (uint)d.flags; + if ((flags & ScaleMask) == 0 || (d.Low & 1) != 0) + return (int)(flags ^ d.High ^ d.Mid ^ d.Low); + + int scale = (byte)(flags >> ScaleShift); + uint low = d.Low; + ulong high64 = ((ulong)d.High << 32) | d.Mid; + + Unscale(ref low, ref high64, ref scale); + + flags = ((flags) & ~ScaleMask) | (uint)scale << ScaleShift; + return (int)(flags ^ (uint)(high64 >> 32) ^ (uint)high64 ^ low); + } + + // VarDecDiv divides two decimal values. On return, d1 contains the result + // of the operation. + internal static unsafe void VarDecDiv(ref DecCalc d1, ref DecCalc d2) + { + Buf12 bufQuo, bufDivisor; + _ = &bufQuo; // workaround for CS0165 + _ = &bufDivisor; // workaround for CS0165 + uint ulPwr; + int iCurScale; + + int iScale = (sbyte)(d1.uflags - d2.uflags >> ScaleShift); + bool fUnscale = false; + uint ulTmp; + + if (d2.High == 0 && d2.Mid == 0) + { + // Divisor is only 32 bits. Easy divide. + // + uint den = d2.Low; + if (den == 0) + throw new DivideByZeroException(); + + bufQuo.Low64 = d1.Low64; + bufQuo.U2 = d1.High; + uint remainder = Div96By32(ref bufQuo, den); + + for (;;) + { + if (remainder == 0) + { + if (iScale < 0) + { + iCurScale = Math.Min(9, -iScale); + goto HaveScale; + } + break; + } + + // We need to unscale if and only if we have a non-zero remainder + fUnscale = true; + + // We have computed a quotient based on the natural scale + // ( - ). We have a non-zero + // remainder, so now we should increase the scale if possible to + // include more quotient bits. + // + // If it doesn't cause overflow, we'll loop scaling by 10^9 and + // computing more quotient bits as long as the remainder stays + // non-zero. If scaling by that much would cause overflow, we'll + // drop out of the loop and scale by as much as we can. + // + // Scaling by 10^9 will overflow if rgulQuo[2].rgulQuo[1] >= 2^32 / 10^9 + // = 4.294 967 296. So the upper limit is rgulQuo[2] == 4 and + // rgulQuo[1] == 0.294 967 296 * 2^32 = 1,266,874,889.7+. Since + // quotient bits in rgulQuo[0] could be all 1's, then 1,266,874,888 + // is the largest value in rgulQuo[1] (when rgulQuo[2] == 4) that is + // assured not to overflow. + // + if (iScale == DEC_SCALE_MAX || (iCurScale = SearchScale(ref bufQuo, iScale)) == 0) + { + // No more scaling to be done, but remainder is non-zero. + // Round quotient. + // + ulTmp = remainder << 1; + if (ulTmp < remainder || ulTmp >= den && (ulTmp > den || (bufQuo.U0 & 1) != 0)) + goto RoundUp; + break; + } + + HaveScale: + ulPwr = s_powers10[iCurScale]; + iScale += iCurScale; + + if (IncreaseScale(ref bufQuo, ulPwr) != 0) + goto ThrowOverflow; + + ulong num = UInt32x32To64(remainder, ulPwr); + // TODO: https://github.com/dotnet/coreclr/issues/3439 + uint div = (uint)(num / den); + remainder = (uint)num - div * den; + + if (!Add32To96(ref bufQuo, div)) + { + iScale = OverflowUnscale(ref bufQuo, iScale, remainder != 0); + break; + } + } // for (;;) + } + else + { + // Divisor has bits set in the upper 64 bits. + // + // Divisor must be fully normalized (shifted so bit 31 of the most + // significant ULONG is 1). Locate the MSB so we know how much to + // normalize by. The dividend will be shifted by the same amount so + // the quotient is not changed. + // + bufDivisor.Low64 = d2.Low64; + ulTmp = d2.High; + bufDivisor.U2 = ulTmp; + if (ulTmp == 0) + ulTmp = d2.Mid; + + iCurScale = X86.Lzcnt.IsSupported ? (int)X86.Lzcnt.LeadingZeroCount(ulTmp) : LeadingZeroCount(ulTmp); + + // Shift both dividend and divisor left by iCurScale. + // + Buf16 bufRem; + _ = &bufRem; // workaround for CS0165 + bufRem.Low64 = d1.Low64 << iCurScale; + bufRem.High64 = (d1.Mid + ((ulong)d1.High << 32)) >> (31 - iCurScale) >> 1; + + ulong divisor = bufDivisor.Low64 << iCurScale; + + if (bufDivisor.U2 == 0) + { + // Have a 64-bit divisor in sdlDivisor. The remainder + // (currently 96 bits spread over 4 ULONGs) will be < divisor. + // + + bufQuo.U1 = Div96By64(ref *(Buf12*)&bufRem.U1, divisor); + bufQuo.U0 = Div96By64(ref *(Buf12*)&bufRem, divisor); + + for (;;) + { + if (bufRem.Low64 == 0) + { + if (iScale < 0) + { + iCurScale = Math.Min(9, -iScale); + goto HaveScale64; + } + break; + } + + // We need to unscale if and only if we have a non-zero remainder + fUnscale = true; + + // Remainder is non-zero. Scale up quotient and remainder by + // powers of 10 so we can compute more significant bits. + // + if (iScale == DEC_SCALE_MAX || (iCurScale = SearchScale(ref bufQuo, iScale)) == 0) + { + // No more scaling to be done, but remainder is non-zero. + // Round quotient. + // + ulong tmp = bufRem.Low64; + if ((long)tmp < 0 || (tmp <<= 1) > divisor || + (tmp == divisor && (bufQuo.U0 & 1) != 0)) + goto RoundUp; + break; + } + + HaveScale64: + ulPwr = s_powers10[iCurScale]; + iScale += iCurScale; + + if (IncreaseScale(ref bufQuo, ulPwr) != 0) + goto ThrowOverflow; + + IncreaseScale64(ref *(Buf12*)&bufRem, ulPwr); + ulTmp = Div96By64(ref *(Buf12*)&bufRem, divisor); + if (!Add32To96(ref bufQuo, ulTmp)) + { + iScale = OverflowUnscale(ref bufQuo, iScale, bufRem.Low64 != 0); + break; + } + } // for (;;) + } + else + { + // Have a 96-bit divisor in rgulDivisor[]. + // + // Start by finishing the shift left by iCurScale. + // + uint tmp = (uint)(bufDivisor.High64 >> (31 - iCurScale) >> 1); + bufDivisor.Low64 = divisor; + bufDivisor.U2 = tmp; + + // The remainder (currently 96 bits spread over 4 ULONGs) + // will be < divisor. + // + bufQuo.Low64 = Div128By96(ref bufRem, ref bufDivisor); + + for (;;) + { + if ((bufRem.Low64 | bufRem.U2) == 0) + { + if (iScale < 0) + { + iCurScale = Math.Min(9, -iScale); + goto HaveScale96; + } + break; + } + + // We need to unscale if and only if we have a non-zero remainder + fUnscale = true; + + // Remainder is non-zero. Scale up quotient and remainder by + // powers of 10 so we can compute more significant bits. + // + if (iScale == DEC_SCALE_MAX || (iCurScale = SearchScale(ref bufQuo, iScale)) == 0) + { + // No more scaling to be done, but remainder is non-zero. + // Round quotient. + // + if ((int)bufRem.U2 < 0) + { + goto RoundUp; + } + + ulTmp = bufRem.U1 >> 31; + bufRem.Low64 <<= 1; + bufRem.U2 = (bufRem.U2 << 1) + ulTmp; + + if (bufRem.U2 > bufDivisor.U2 || bufRem.U2 == bufDivisor.U2 && + (bufRem.Low64 > bufDivisor.Low64 || bufRem.Low64 == bufDivisor.Low64 && + (bufQuo.U0 & 1) != 0)) + goto RoundUp; + break; + } + + HaveScale96: + ulPwr = s_powers10[iCurScale]; + iScale += iCurScale; + + if (IncreaseScale(ref bufQuo, ulPwr) != 0) + goto ThrowOverflow; + + bufRem.U3 = IncreaseScale(ref *(Buf12*)&bufRem, ulPwr); + ulTmp = Div128By96(ref bufRem, ref bufDivisor); + if (!Add32To96(ref bufQuo, ulTmp)) + { + iScale = OverflowUnscale(ref bufQuo, iScale, (bufRem.Low64 | bufRem.High64) != 0); + break; + } + } // for (;;) + } + } + +Unscale: + if (fUnscale) + { + uint low = bufQuo.U0; + ulong high64 = bufQuo.High64; + Unscale(ref low, ref high64, ref iScale); + d1.Low = low; + d1.Mid = (uint)high64; + d1.High = (uint)(high64 >> 32); + } + else + { + d1.Low64 = bufQuo.Low64; + d1.High = bufQuo.U2; + } + + d1.uflags = ((d1.uflags ^ d2.uflags) & SignMask) | ((uint)iScale << ScaleShift); + return; + +RoundUp: + { + if (++bufQuo.Low64 == 0 && ++bufQuo.U2 == 0) + { + iScale = OverflowUnscale(ref bufQuo, iScale, true); + } + goto Unscale; + } + +ThrowOverflow: + throw new OverflowException(SR.Overflow_Decimal); + } + + //********************************************************************** + // VarDecMod - Computes the remainder between two decimals + //********************************************************************** + internal static void VarDecMod(ref DecCalc d1, ref DecCalc d2) + { + if ((d2.ulo | d2.umid | d2.uhi) == 0) + throw new DivideByZeroException(); + + if ((d1.ulo | d1.umid | d1.uhi) == 0) + return; + + // In the operation x % y the sign of y does not matter. Result will have the sign of x. + d2.uflags = (d2.uflags & ~SignMask) | (d1.uflags & SignMask); + + int cmp = VarDecCmpSub(in Unsafe.As(ref d1), in Unsafe.As(ref d2)); + if (cmp == 0) + { + d1.ulo = 0; + d1.umid = 0; + d1.uhi = 0; + if (d2.uflags > d1.uflags) + d1.uflags = d2.uflags; + return; + } + if ((cmp ^ (int)(d1.uflags & SignMask)) < 0) + return; + + // This piece of code is to work around the fact that Dividing a decimal with 28 digits number by decimal which causes + // causes the result to be 28 digits, can cause to be incorrectly rounded up. + // eg. Decimal.MaxValue / 2 * Decimal.MaxValue will overflow since the division by 2 was rounded instead of being truncked. + DecCalc tmp = d2; + DecAddSub(ref d1, ref tmp, true); + + // Formula: d1 - (RoundTowardsZero(d1 / d2) * d2) + tmp = d1; + VarDecDiv(ref tmp, ref d2); + Truncate(ref Unsafe.As(ref tmp)); + VarDecMul(ref tmp, ref d2); + uint flags = d1.uflags; + DecAddSub(ref d1, ref tmp, true); + // See if the result has crossed 0 + if (((flags ^ d1.uflags) & SignMask) != 0) + { + if ((d1.Low | d1.Mid | d1.High) == 0 || d1.Scale == DEC_SCALE_MAX && d1.Low64 == 1 && d1.High == 0) + { + // Certain Remainder operations on decimals with 28 significant digits round + // to [+-]0.0000000000000000000000000001m instead of [+-]0m during the intermediate calculations. + // 'zero' results just need their sign corrected. + d1.uflags ^= SignMask; + } + else + { + // If the division rounds up because it runs out of digits, the multiplied result can end up with a larger + // absolute value and the result of the formula crosses 0. To correct it can add the divisor back. + DecAddSub(ref d1, ref d2, false); + } + } + } + + internal enum RoundingMode + { + ToEven = 0, + AwayFromZero = 1, + Truncate = 2, + Floor = 3, + Ceiling = 4, + } + + // Does an in-place round by the specified scale + internal static void InternalRound(ref DecCalc d, uint scale, RoundingMode mode) + { + // the scale becomes the desired decimal count + d.uflags -= scale << ScaleShift; + + uint remainder, sticky = 0, power; + // First divide the value by constant 10^9 up to three times + while (scale >= MaxInt32Scale) + { + scale -= MaxInt32Scale; + + const uint divisor = TenToPowerNine; + uint n = d.uhi; + if (n == 0) + { + ulong tmp = d.Low64; + ulong div = tmp / divisor; + d.Low64 = div; + remainder = (uint)(tmp - div * divisor); + } + else + { + uint q; + d.uhi = q = n / divisor; + remainder = n - q * divisor; + n = d.umid; + if ((n | remainder) != 0) + { + d.umid = q = (uint)((((ulong)remainder << 32) | n) / divisor); + remainder = n - q * divisor; + } + n = d.ulo; + if ((n | remainder) != 0) + { + d.ulo = q = (uint)((((ulong)remainder << 32) | n) / divisor); + remainder = n - q * divisor; + } + } + power = divisor; + if (scale == 0) + goto checkRemainder; + sticky |= remainder; + } + + { + power = s_powers10[scale]; + // TODO: https://github.com/dotnet/coreclr/issues/3439 + uint n = d.uhi; + if (n == 0) + { + ulong tmp = d.Low64; + if (tmp == 0) + { + if (mode <= RoundingMode.Truncate) + goto done; + remainder = 0; + goto checkRemainder; + } + ulong div = tmp / power; + d.Low64 = div; + remainder = (uint)(tmp - div * power); + } + else + { + uint q; + d.uhi = q = n / power; + remainder = n - q * power; + n = d.umid; + if ((n | remainder) != 0) + { + d.umid = q = (uint)((((ulong)remainder << 32) | n) / power); + remainder = n - q * power; + } + n = d.ulo; + if ((n | remainder) != 0) + { + d.ulo = q = (uint)((((ulong)remainder << 32) | n) / power); + remainder = n - q * power; + } + } + } + +checkRemainder: + if (mode == RoundingMode.Truncate) + goto done; + else if (mode == RoundingMode.ToEven) + { + // To do IEEE rounding, we add LSB of result to sticky bits so either causes round up if remainder * 2 == last divisor. + remainder <<= 1; + if ((sticky | d.ulo & 1) != 0) + remainder++; + if (power >= remainder) + goto done; + } + else if (mode == RoundingMode.AwayFromZero) + { + // Round away from zero at the mid point. + remainder <<= 1; + if (power > remainder) + goto done; + } + else if (mode == RoundingMode.Floor) + { + // Round toward -infinity if we have chopped off a non-zero amount from a negative value. + if ((remainder | sticky) == 0 || !d.IsNegative) + goto done; + } + else + { + Debug.Assert(mode == RoundingMode.Ceiling); + // Round toward infinity if we have chopped off a non-zero amount from a positive value. + if ((remainder | sticky) == 0 || d.IsNegative) + goto done; + } + if (++d.Low64 == 0) + d.uhi++; +done: + return; + } + +#region Number Formatting helpers + + internal static uint DecDivMod1E9(ref DecCalc value) + { + ulong high64 = ((ulong)value.uhi << 32) + value.umid; + ulong div64 = high64 / TenToPowerNine; + value.uhi = (uint)(div64 >> 32); + value.umid = (uint)div64; + + ulong num = ((high64 - (uint)div64 * TenToPowerNine) << 32) + value.ulo; + uint div = (uint)(num / TenToPowerNine); + value.ulo = div; + return (uint)num - div * TenToPowerNine; + } + + internal static void DecAddInt32(ref DecCalc value, uint i) + { + if (D32AddCarry(ref value.ulo, i)) + { + if (D32AddCarry(ref value.umid, 1)) + D32AddCarry(ref value.uhi, 1); + } + } + + private static bool D32AddCarry(ref uint value, uint i) + { + uint v = value; + uint sum = v + i; + value = sum; + return (sum < v) || (sum < i); + } + + internal static void DecMul10(ref DecCalc value) + { + DecCalc d = value; + DecShiftLeft(ref value); + DecShiftLeft(ref value); + DecAdd(ref value, d); + DecShiftLeft(ref value); + } + + private static void DecShiftLeft(ref DecCalc value) + { + uint c0 = (value.Low & 0x80000000) != 0 ? 1u : 0u; + uint c1 = (value.Mid & 0x80000000) != 0 ? 1u : 0u; + value.Low = value.Low << 1; + value.Mid = (value.Mid << 1) | c0; + value.High = (value.High << 1) | c1; + } + + private static void DecAdd(ref DecCalc value, DecCalc d) + { + if (D32AddCarry(ref value.ulo, d.Low)) + { + if (D32AddCarry(ref value.umid, 1)) + D32AddCarry(ref value.uhi, 1); + } + + if (D32AddCarry(ref value.umid, d.Mid)) + D32AddCarry(ref value.uhi, 1); + + D32AddCarry(ref value.uhi, d.High); + } + +#endregion + + struct PowerOvfl + { + public readonly uint Hi; + public readonly ulong MidLo; + + public PowerOvfl(uint hi, uint mid, uint lo) + { + Hi = hi; + MidLo = ((ulong)mid << 32) + lo; + } + } + + static readonly PowerOvfl[] PowerOvflValues = new[] + { + // This is a table of the largest values that can be in the upper two + // ULONGs of a 96-bit number that will not overflow when multiplied + // by a given power. For the upper word, this is a table of + // 2^32 / 10^n for 1 <= n <= 8. For the lower word, this is the + // remaining fraction part * 2^32. 2^32 = 4294967296. + // + new PowerOvfl(429496729, 2576980377, 2576980377), // 10^1 remainder 0.6 + new PowerOvfl(42949672, 4123168604, 687194767), // 10^2 remainder 0.16 + new PowerOvfl(4294967, 1271310319, 2645699854), // 10^3 remainder 0.616 + new PowerOvfl(429496, 3133608139, 694066715), // 10^4 remainder 0.1616 + new PowerOvfl(42949, 2890341191, 2216890319), // 10^5 remainder 0.51616 + new PowerOvfl(4294, 4154504685, 2369172679), // 10^6 remainder 0.551616 + new PowerOvfl(429, 2133437386, 4102387834), // 10^7 remainder 0.9551616 + new PowerOvfl(42, 4078814305, 410238783), // 10^8 remainder 0.09991616 + }; + + [StructLayout(LayoutKind.Explicit)] + private struct Buf12 + { + [FieldOffset(0 * 4)] + public uint U0; + [FieldOffset(1 * 4)] + public uint U1; + [FieldOffset(2 * 4)] + public uint U2; + + [FieldOffset(0)] + private ulong ulo64LE; + [FieldOffset(4)] + private ulong uhigh64LE; + + public ulong Low64 + { +#if BIGENDIAN + get => ((ulong)U1 << 32) | U0; + set { U1 = (uint)(value >> 32); U0 = (uint)value; } +#else + get => ulo64LE; + set => ulo64LE = value; +#endif + } + + /// + /// U1-U2 combined (overlaps with Low64) + /// + public ulong High64 + { +#if BIGENDIAN + get => ((ulong)U2 << 32) | U1; + set { U2 = (uint)(value >> 32); U1 = (uint)value; } +#else + get => uhigh64LE; + set => uhigh64LE = value; +#endif + } + } + + [StructLayout(LayoutKind.Explicit)] + private struct Buf16 + { + [FieldOffset(0 * 4)] + public uint U0; + [FieldOffset(1 * 4)] + public uint U1; + [FieldOffset(2 * 4)] + public uint U2; + [FieldOffset(3 * 4)] + public uint U3; + + [FieldOffset(0 * 8)] + private ulong ulo64LE; + [FieldOffset(1 * 8)] + private ulong uhigh64LE; + + public ulong Low64 + { +#if BIGENDIAN + get => ((ulong)U1 << 32) | U0; + set { U1 = (uint)(value >> 32); U0 = (uint)value; } +#else + get => ulo64LE; + set => ulo64LE = value; +#endif + } + + public ulong High64 + { +#if BIGENDIAN + get => ((ulong)U3 << 32) | U2; + set { U3 = (uint)(value >> 32); U2 = (uint)value; } +#else + get => uhigh64LE; + set => uhigh64LE = value; +#endif + } + } + + [StructLayout(LayoutKind.Explicit)] + private struct Buf24 + { + [FieldOffset(0 * 4)] + public uint U0; + [FieldOffset(1 * 4)] + public uint U1; + [FieldOffset(2 * 4)] + public uint U2; + [FieldOffset(3 * 4)] + public uint U3; + [FieldOffset(4 * 4)] + public uint U4; + [FieldOffset(5 * 4)] + public uint U5; + + [FieldOffset(0 * 8)] + private ulong ulo64LE; + [FieldOffset(1 * 8)] + private ulong umid64LE; + [FieldOffset(2 * 8)] + private ulong uhigh64LE; + + public ulong Low64 + { +#if BIGENDIAN + get => ((ulong)U1 << 32) | U0; + set { U1 = (uint)(value >> 32); U0 = (uint)value; } +#else + get => ulo64LE; + set => ulo64LE = value; +#endif + } + + public ulong Mid64 + { +#if BIGENDIAN + get => ((ulong)U3 << 32) | U2; + set { U3 = (uint)(value >> 32); U2 = (uint)value; } +#else + get => umid64LE; + set => umid64LE = value; +#endif + } + + public ulong High64 + { +#if BIGENDIAN + get => ((ulong)U5 << 32) | U4; + set { U5 = (uint)(value >> 32); U4 = (uint)value; } +#else + get => uhigh64LE; + set => uhigh64LE = value; +#endif + } + + public int Length => 6; + } + } + } +} diff --git a/src/System.Private.CoreLib/src/System/Decimal.cs b/src/System.Private.CoreLib/shared/System/Decimal.cs similarity index 57% rename from src/System.Private.CoreLib/src/System/Decimal.cs rename to src/System.Private.CoreLib/shared/System/Decimal.cs index 18ea74a2b320..a79a7c3e7fa0 100644 --- a/src/System.Private.CoreLib/src/System/Decimal.cs +++ b/src/System.Private.CoreLib/shared/System/Decimal.cs @@ -2,15 +2,11 @@ // 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.Diagnostics; using System.Globalization; -using System.Runtime.InteropServices; using System.Runtime.CompilerServices; -using System.Runtime.ConstrainedExecution; -using System.Runtime.Versioning; +using System.Runtime.InteropServices; using System.Runtime.Serialization; -using System.Diagnostics; namespace System { @@ -60,7 +56,7 @@ namespace System [Serializable] [System.Runtime.Versioning.NonVersionable] // This only applies to field layout [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public partial struct Decimal : IFormattable, IComparable, IConvertible, IComparable, IEquatable, IDeserializationCallback, ISpanFormattable + public readonly partial struct Decimal : IFormattable, IComparable, IConvertible, IComparable, IEquatable, IDeserializationCallback, ISpanFormattable { // Sign mask for the flags field. A value of zero in this bit indicates a // positive Decimal value, and a value of one in this bit indicates a @@ -69,8 +65,6 @@ public partial struct Decimal : IFormattable, IComparable, IConvertible, ICompar // Look at OleAut's DECIMAL_NEG constant to check for negative values // in native code. private const int SignMask = unchecked((int)0x80000000); - private const byte DECIMAL_NEG = 0x80; - private const byte DECIMAL_ADD = 0x00; // Scale mask for the flags field. This byte in the flags field contains // the power of 10 to divide the Decimal value by. The scale byte must @@ -80,48 +74,22 @@ public partial struct Decimal : IFormattable, IComparable, IConvertible, ICompar // Number of bits scale is shifted by. private const int ScaleShift = 16; - // The maximum power of 10 that a 32 bit integer can store - private const Int32 MaxInt32Scale = 9; - - // Fast access for 10^n where n is 0-9 - private static UInt32[] Powers10 = new UInt32[] { - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000 - }; - // Constant representing the Decimal value 0. - public const Decimal Zero = 0m; + public const decimal Zero = 0m; // Constant representing the Decimal value 1. - public const Decimal One = 1m; + public const decimal One = 1m; // Constant representing the Decimal value -1. - public const Decimal MinusOne = -1m; + public const decimal MinusOne = -1m; // Constant representing the largest possible Decimal value. The value of // this constant is 79,228,162,514,264,337,593,543,950,335. - public const Decimal MaxValue = 79228162514264337593543950335m; + public const decimal MaxValue = 79228162514264337593543950335m; // Constant representing the smallest possible Decimal value. The value of // this constant is -79,228,162,514,264,337,593,543,950,335. - public const Decimal MinValue = -79228162514264337593543950335m; - - - // Constant representing the negative number that is the closest possible - // Decimal value to -0m. - private const Decimal NearNegativeZero = -0.000000000000000000000000001m; - - // Constant representing the positive number that is the closest possible - // Decimal value to +0m. - private const Decimal NearPositiveZero = +0.000000000000000000000000001m; + public const decimal MinValue = -79228162514264337593543950335m; // The lo, mid, hi, and flags fields contain the representation of the // Decimal value. The lo, mid, and hi fields contain the 96-bit integer @@ -135,40 +103,25 @@ public partial struct Decimal : IFormattable, IComparable, IConvertible, ICompar // NOTE: Do not change the order in which these fields are declared. The // native methods in this class rely on this particular order. // Do not rename (binary serialization). - private int flags; - private int hi; - private int lo; - private int mid; - - internal uint High => (uint)hi; - internal uint Low => (uint)lo; - internal uint Mid => (uint)mid; - - // Constructs a zero Decimal. - //public Decimal() { - // lo = 0; - // mid = 0; - // hi = 0; - // flags = 0; - //} + private readonly int flags; + private readonly int hi; + private readonly int lo; + private readonly int mid; // Constructs a Decimal from an integer value. // public Decimal(int value) { - // JIT today can't inline methods that contains "starg" opcode. - // For more details, see DevDiv Bugs 81184: x86 JIT CQ: Removing the inline striction of "starg". - int value_copy = value; - if (value_copy >= 0) + if (value >= 0) { flags = 0; } else { flags = SignMask; - value_copy = -value_copy; + value = -value; } - lo = value_copy; + lo = value; mid = 0; hi = 0; } @@ -188,20 +141,17 @@ public Decimal(uint value) // public Decimal(long value) { - // JIT today can't inline methods that contains "starg" opcode. - // For more details, see DevDiv Bugs 81184: x86 JIT CQ: Removing the inline striction of "starg". - long value_copy = value; - if (value_copy >= 0) + if (value >= 0) { flags = 0; } else { flags = SignMask; - value_copy = -value_copy; + value = -value; } - lo = (int)value_copy; - mid = (int)(value_copy >> 32); + lo = (int)value; + mid = (int)(value >> 32); hi = 0; } @@ -218,33 +168,60 @@ public Decimal(ulong value) // Constructs a Decimal from a float value. // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern Decimal(float value); + public Decimal(float value) + { + DecCalc.VarDecFromR4(value, out AsMutable(ref this)); + } // Constructs a Decimal from a double value. // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern Decimal(double value); - - // Constructs a Decimal from a Currency value. - // - internal Decimal(Currency value) + public Decimal(double value) { - this = Currency.ToDecimal(value); + DecCalc.VarDecFromR8(value, out AsMutable(ref this)); } - // Don't remove these 2 methods below. They are required by the fx when the are dealing with Currency in their - // databases - public static long ToOACurrency(Decimal value) + // + // Decimal <==> Currency conversion. + // + // A Currency represents a positive or negative decimal value with 4 digits past the decimal point. The actual Int64 representation used by these methods + // is the currency value multiplied by 10,000. For example, a currency value of $12.99 would be represented by the Int64 value 129,900. + // + public static decimal FromOACurrency(long cy) { - return new Currency(value).ToOACurrency(); + ulong absoluteCy; // has to be ulong to accommodate the case where cy == long.MinValue. + bool isNegative = false; + if (cy < 0) + { + isNegative = true; + absoluteCy = (ulong)(-cy); + } + else + { + absoluteCy = (ulong)cy; + } + + // In most cases, FromOACurrency() produces a Decimal with Scale set to 4. Unless, that is, some of the trailing digits past the decimal point are zero, + // in which case, for compatibility with .Net, we reduce the Scale by the number of zeros. While the result is still numerically equivalent, the scale does + // affect the ToString() value. In particular, it prevents a converted currency value of $12.95 from printing uglily as "12.9500". + int scale = 4; + if (absoluteCy != 0) // For compatibility, a currency of 0 emits the Decimal "0.0000" (scale set to 4). + { + while (scale != 0 && ((absoluteCy % 10) == 0)) + { + scale--; + absoluteCy /= 10; + } + } + + return new decimal((int)absoluteCy, (int)(absoluteCy >> 32), 0, isNegative, (byte)scale); } - public static Decimal FromOACurrency(long cy) + public static long ToOACurrency(decimal value) { - return Currency.ToDecimal(Currency.FromOACurrency(cy)); + return DecCalc.VarCyFromDec(ref AsMutable(ref value)); } + private static bool IsValid(int flags) => (flags & ~(SignMask | ScaleMask)) == 0 && ((uint)(flags & ScaleMask) <= (28 << ScaleShift)); // Constructs a Decimal from an integer array containing a binary // representation. The bits argument must be a non-null integer @@ -266,22 +243,13 @@ public static Decimal FromOACurrency(long cy) // equally valid, and all are numerically equivalent. // public Decimal(int[] bits) - { - lo = 0; - mid = 0; - hi = 0; - flags = 0; - SetBits(bits); - } - - private void SetBits(int[] bits) { if (bits == null) throw new ArgumentNullException(nameof(bits)); if (bits.Length == 4) { int f = bits[3]; - if ((f & ~(SignMask | ScaleMask)) == 0 && (f & ScaleMask) <= (28 << 16)) + if (IsValid(f)) { lo = bits[0]; mid = bits[1]; @@ -307,38 +275,18 @@ public Decimal(int lo, int mid, int hi, bool isNegative, byte scale) flags |= SignMask; } - [OnSerializing] - private void OnSerializing(StreamingContext ctx) - { - // OnSerializing is called before serialization of an object - try - { - SetBits(GetBits(this)); - } - catch (ArgumentException e) - { - throw new SerializationException(SR.Overflow_Decimal, e); - } - } - - void IDeserializationCallback.OnDeserialization(Object sender) + void IDeserializationCallback.OnDeserialization(object sender) { // OnDeserialization is called after each instance of this class is deserialized. // This callback method performs decimal validation after being deserialized. - try - { - SetBits(GetBits(this)); - } - catch (ArgumentException e) - { - throw new SerializationException(SR.Overflow_Decimal, e); - } + if (!IsValid(flags)) + throw new SerializationException(SR.Overflow_Decimal); } // Constructs a Decimal from its constituent parts. private Decimal(int lo, int mid, int hi, int flags) { - if ((flags & ~(SignMask | ScaleMask)) == 0 && (flags & ScaleMask) <= (28 << 16)) + if (IsValid(flags)) { this.lo = lo; this.mid = mid; @@ -349,153 +297,141 @@ private Decimal(int lo, int mid, int hi, int flags) throw new ArgumentException(SR.Arg_DecBitCtor); } + private Decimal(in decimal d, int flags) + { + this = d; + this.flags = flags; + } + // Returns the absolute value of the given Decimal. If d is // positive, the result is d. If d is negative, the result // is -d. // - internal static Decimal Abs(ref Decimal d) + internal static decimal Abs(ref decimal d) { - return new Decimal(d.lo, d.mid, d.hi, d.flags & ~SignMask); + return new decimal(in d, d.flags & ~SignMask); } // Adds two Decimal values. // - public static Decimal Add(Decimal d1, Decimal d2) + public static decimal Add(decimal d1, decimal d2) { - FCallAddSub(ref d1, ref d2, DECIMAL_ADD); + DecCalc.DecAddSub(ref AsMutable(ref d1), ref AsMutable(ref d2), false); return d1; } - internal bool IsNegative => (flags & SignMask) != 0; - - internal int Scale => (byte)((uint)flags >> ScaleShift); - - // FCallAddSub adds or subtracts two decimal values. On return, d1 contains the result - // of the operation. Passing in DECIMAL_ADD or DECIMAL_NEG for bSign indicates - // addition or subtraction, respectively. - // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallAddSub(ref Decimal d1, ref Decimal d2, byte bSign); // Rounds a Decimal to an integer value. The Decimal argument is rounded // towards positive infinity. - public static Decimal Ceiling(Decimal d) + public static decimal Ceiling(decimal d) { - return (-(Decimal.Floor(-d))); + int flags = d.flags; + if ((flags & ScaleMask) != 0) + DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), DecCalc.RoundingMode.Ceiling); + return d; } // Compares two Decimal values, returning an integer that indicates their // relationship. // - public static int Compare(Decimal d1, Decimal d2) + public static int Compare(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2); + return DecCalc.VarDecCmp(in d1, in d2); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern int FCallCompare(ref Decimal d1, ref Decimal d2); - // Compares this object to another object, returning an integer that // indicates the relationship. // Returns a value less than zero if this object // null is considered to be less than any instance. // If object is not of type Decimal, this method throws an ArgumentException. // - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) return 1; - if (!(value is Decimal)) + if (!(value is decimal)) throw new ArgumentException(SR.Arg_MustBeDecimal); - Decimal other = (Decimal)value; - return FCallCompare(ref this, ref other); + decimal other = (decimal)value; + return DecCalc.VarDecCmp(in this, in other); } - public int CompareTo(Decimal value) + public int CompareTo(decimal value) { - return FCallCompare(ref this, ref value); + return DecCalc.VarDecCmp(in this, in value); } // Divides two Decimal values. // - public static Decimal Divide(Decimal d1, Decimal d2) + public static decimal Divide(decimal d1, decimal d2) { - FCallDivide(ref d1, ref d2); + DecCalc.VarDecDiv(ref AsMutable(ref d1), ref AsMutable(ref d2)); return d1; } - // FCallDivide divides two decimal values. On return, d1 contains the result - // of the operation. - // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallDivide(ref Decimal d1, ref Decimal d2); - - // Checks if this Decimal is equal to a given object. Returns true // if the given object is a boxed Decimal and its value is equal to the // value of this Decimal. Returns false otherwise. // - public override bool Equals(Object value) + public override bool Equals(object value) { - if (value is Decimal) + if (value is decimal) { - Decimal other = (Decimal)value; - return FCallCompare(ref this, ref other) == 0; + decimal other = (decimal)value; + return DecCalc.VarDecCmp(in this, in other) == 0; } return false; } - public bool Equals(Decimal value) + public bool Equals(decimal value) { - return FCallCompare(ref this, ref value) == 0; + return DecCalc.VarDecCmp(in this, in value) == 0; } // Returns the hash code for this Decimal. // - public override int GetHashCode() => GetHashCode(ref this); + public override int GetHashCode() => DecCalc.GetHashCode(in this); // Compares two Decimal values for equality. Returns true if the two // Decimal values are equal, or false if they are not equal. // - public static bool Equals(Decimal d1, Decimal d2) + public static bool Equals(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) == 0; + return DecCalc.VarDecCmp(in d1, in d2) == 0; } // Rounds a Decimal to an integer value. The Decimal argument is rounded // towards negative infinity. // - public static Decimal Floor(Decimal d) + public static decimal Floor(decimal d) { - FCallFloor(ref d); + int flags = d.flags; + if ((flags & ScaleMask) != 0) + DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), DecCalc.RoundingMode.Floor); return d; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallFloor(ref Decimal d); - // Converts this Decimal to a string. The resulting string consists of an // optional minus sign ("-") followed to a sequence of digits ("0" - "9"), // optionally followed by a decimal point (".") and another sequence of // digits. // - public override String ToString() + public override string ToString() { return Number.FormatDecimal(this, null, NumberFormatInfo.CurrentInfo); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatDecimal(this, format, NumberFormatInfo.CurrentInfo); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatDecimal(this, null, NumberFormatInfo.GetInstance(provider)); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatDecimal(this, format, NumberFormatInfo.GetInstance(provider)); } @@ -512,26 +448,26 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan // Parse also allows a currency symbol, a trailing negative sign, and // parentheses in the number. // - public static Decimal Parse(String s) + public static decimal Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo); } - public static Decimal Parse(String s, NumberStyles style) + public static decimal Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDecimal(s, style, NumberFormatInfo.CurrentInfo); } - public static Decimal Parse(String s, IFormatProvider provider) + public static decimal Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDecimal(s, NumberStyles.Number, NumberFormatInfo.GetInstance(provider)); } - public static Decimal Parse(String s, NumberStyles style, IFormatProvider provider) + public static decimal Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -544,7 +480,7 @@ public static decimal Parse(ReadOnlySpan s, NumberStyles style = NumberSty return Number.ParseDecimal(s, style, NumberFormatInfo.GetInstance(provider)); } - public static Boolean TryParse(String s, out Decimal result) + public static bool TryParse(string s, out decimal result) { if (s == null) { @@ -560,7 +496,7 @@ public static bool TryParse(ReadOnlySpan s, out decimal result) return Number.TryParseDecimal(s, NumberStyles.Number, NumberFormatInfo.CurrentInfo, out result); } - public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out Decimal result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out decimal result) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); @@ -589,12 +525,12 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro // indicates the sign of the Decimal value, 0 meaning positive and 1 // meaning negative. // - public static int[] GetBits(Decimal d) + public static int[] GetBits(decimal d) { return new int[] { d.lo, d.mid, d.hi, d.flags }; } - internal static void GetBytes(Decimal d, byte[] buffer) + internal static void GetBytes(decimal d, byte[] buffer) { Debug.Assert((buffer != null && buffer.Length >= 16), "[GetBytes]buffer != null && buffer.Length >= 16"); buffer[0] = (byte)d.lo; @@ -625,174 +561,43 @@ internal static decimal ToDecimal(byte[] buffer) 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); int flags = ((int)buffer[12]) | ((int)buffer[13] << 8) | ((int)buffer[14] << 16) | ((int)buffer[15] << 24); - return new Decimal(lo, mid, hi, flags); - } - - // This method does a 'raw' and 'unchecked' addition of a UInt32 to a Decimal in place. - // 'raw' means that it operates on the internal 96-bit unsigned integer value and - // ingores the sign and scale. This means that it is not equivalent to just adding - // that number, as the sign and scale are effectively applied to the UInt32 value also. - // 'unchecked' means that it does not fail if you overflow the 96 bit value. - private static void InternalAddUInt32RawUnchecked(ref Decimal value, UInt32 i) - { - UInt32 v; - UInt32 sum; - v = (UInt32)value.lo; - sum = v + i; - value.lo = (Int32)sum; - if (sum < v || sum < i) - { - v = (UInt32)value.mid; - sum = v + 1; - value.mid = (Int32)sum; - if (sum < v || sum < 1) - { - value.hi = (Int32)((UInt32)value.hi + 1); - } - } - } - - // This method does an in-place division of a decimal by a UInt32, returning the remainder. - // Although it does not operate on the sign or scale, this does not result in any - // caveat for the result. It is equivalent to dividing by that number. - private static UInt32 InternalDivRemUInt32(ref Decimal value, UInt32 divisor) - { - UInt32 remainder = 0; - UInt64 n; - if (value.hi != 0) - { - n = ((UInt32)value.hi); - value.hi = (Int32)((UInt32)(n / divisor)); - remainder = (UInt32)(n % divisor); - } - if (value.mid != 0 || remainder != 0) - { - n = ((UInt64)remainder << 32) | (UInt32)value.mid; - value.mid = (Int32)((UInt32)(n / divisor)); - remainder = (UInt32)(n % divisor); - } - if (value.lo != 0 || remainder != 0) - { - n = ((UInt64)remainder << 32) | (UInt32)value.lo; - value.lo = (Int32)((UInt32)(n / divisor)); - remainder = (UInt32)(n % divisor); - } - return remainder; - } - - // Does an in-place round the specified number of digits, rounding mid-point values - // away from zero - private static void InternalRoundFromZero(ref Decimal d, int decimalCount) - { - Int32 scale = (d.flags & ScaleMask) >> ScaleShift; - Int32 scaleDifference = scale - decimalCount; - if (scaleDifference <= 0) - { - return; - } - // Divide the value by 10^scaleDifference - UInt32 lastRemainder; - UInt32 lastDivisor; - do - { - Int32 diffChunk = (scaleDifference > MaxInt32Scale) ? MaxInt32Scale : scaleDifference; - lastDivisor = Powers10[diffChunk]; - lastRemainder = InternalDivRemUInt32(ref d, lastDivisor); - scaleDifference -= diffChunk; - } while (scaleDifference > 0); - - // Round away from zero at the mid point - if (lastRemainder >= (lastDivisor >> 1)) - { - InternalAddUInt32RawUnchecked(ref d, 1); - } - - // the scale becomes the desired decimal count - d.flags = ((decimalCount << ScaleShift) & ScaleMask) | (d.flags & SignMask); + return new decimal(lo, mid, hi, flags); } // Returns the larger of two Decimal values. // - internal static Decimal Max(ref Decimal d1, ref Decimal d2) + internal static ref decimal Max(ref decimal d1, ref decimal d2) { - return FCallCompare(ref d1, ref d2) >= 0 ? d1 : d2; + return ref DecCalc.VarDecCmp(in d1, in d2) >= 0 ? ref d1 : ref d2; } // Returns the smaller of two Decimal values. // - internal static Decimal Min(ref Decimal d1, ref Decimal d2) + internal static ref decimal Min(ref decimal d1, ref decimal d2) { - return FCallCompare(ref d1, ref d2) < 0 ? d1 : d2; + return ref DecCalc.VarDecCmp(in d1, in d2) < 0 ? ref d1 : ref d2; } - public static Decimal Remainder(Decimal d1, Decimal d2) + public static decimal Remainder(decimal d1, decimal d2) { - // OleAut doesn't provide a VarDecMod. - - // In the operation x % y the sign of y does not matter. Result will have the sign of x. - d2.flags = (d2.flags & ~SignMask) | (d1.flags & SignMask); - - - // This piece of code is to work around the fact that Dividing a decimal with 28 digits number by decimal which causes - // causes the result to be 28 digits, can cause to be incorrectly rounded up. - // eg. Decimal.MaxValue / 2 * Decimal.MaxValue will overflow since the division by 2 was rounded instead of being truncked. - if (Math.Abs(d1) < Math.Abs(d2)) - { - return d1; - } - d1 -= d2; - - if (d1 == 0) - { - // The sign of D1 will be wrong here. Fall through so that we still get a DivideByZeroException - d1.flags = (d1.flags & ~SignMask) | (d2.flags & SignMask); - } - - // Formula: d1 - (RoundTowardsZero(d1 / d2) * d2) - Decimal dividedResult = Truncate(d1 / d2); - Decimal multipliedResult = dividedResult * d2; - Decimal result = d1 - multipliedResult; - // See if the result has crossed 0 - if ((d1.flags & SignMask) != (result.flags & SignMask)) - { - if (NearNegativeZero <= result && result <= NearPositiveZero) - { - // Certain Remainder operations on decimals with 28 significant digits round - // to [+-]0.000000000000000000000000001m instead of [+-]0m during the intermediate calculations. - // 'zero' results just need their sign corrected. - result.flags = (result.flags & ~SignMask) | (d1.flags & SignMask); - } - else - { - // If the division rounds up because it runs out of digits, the multiplied result can end up with a larger - // absolute value and the result of the formula crosses 0. To correct it can add the divisor back. - result += d2; - } - } - - return result; + DecCalc.VarDecMod(ref AsMutable(ref d1), ref AsMutable(ref d2)); + return d1; } // Multiplies two Decimal values. // - public static Decimal Multiply(Decimal d1, Decimal d2) + public static decimal Multiply(decimal d1, decimal d2) { - FCallMultiply(ref d1, ref d2); + DecCalc.VarDecMul(ref AsMutable(ref d1), ref AsMutable(ref d2)); return d1; } - // FCallMultiply multiples two decimal values. On return, d1 contains the result - // of the operation. - // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallMultiply(ref Decimal d1, ref Decimal d2); - // Returns the negated value of the given Decimal. If d is non-zero, // the result is -d. If d is zero, the result is zero. // - public static Decimal Negate(Decimal d) + public static decimal Negate(decimal d) { - return new Decimal(d.lo, d.mid, d.hi, d.flags ^ SignMask); + return new decimal(in d, d.flags ^ SignMask); } // Rounds a Decimal value to a given number of decimal places. The value @@ -803,52 +608,31 @@ public static Decimal Negate(Decimal d) // By default a mid-point value is rounded to the nearest even number. If the mode is // passed in, it can also round away from zero. - public static Decimal Round(Decimal d) - { - return Round(d, 0); - } + public static decimal Round(decimal d) => Round(ref d, 0, MidpointRounding.ToEven); + public static decimal Round(decimal d, int decimals) => Round(ref d, decimals, MidpointRounding.ToEven); + public static decimal Round(decimal d, MidpointRounding mode) => Round(ref d, 0, mode); + public static decimal Round(decimal d, int decimals, MidpointRounding mode) => Round(ref d, decimals, mode); - public static Decimal Round(Decimal d, int decimals) + private static decimal Round(ref decimal d, int decimals, MidpointRounding mode) { - FCallRound(ref d, decimals); - return d; - } - - public static Decimal Round(Decimal d, MidpointRounding mode) - { - return Round(d, 0, mode); - } - - public static Decimal Round(Decimal d, int decimals, MidpointRounding mode) - { - if ((decimals < 0) || (decimals > 28)) + if ((uint)decimals > 28) throw new ArgumentOutOfRangeException(nameof(decimals), SR.ArgumentOutOfRange_DecimalRound); - if (mode < MidpointRounding.ToEven || mode > MidpointRounding.AwayFromZero) - { + if ((uint)mode > (uint)MidpointRounding.AwayFromZero) throw new ArgumentException(SR.Format(SR.Argument_InvalidEnumValue, mode, nameof(MidpointRounding)), nameof(mode)); - } - if (mode == MidpointRounding.ToEven) - { - FCallRound(ref d, decimals); - } - else - { - InternalRoundFromZero(ref d, decimals); - } + int scale = d.Scale - decimals; + if (scale > 0) + DecCalc.InternalRound(ref AsMutable(ref d), (uint)scale, (DecCalc.RoundingMode)mode); return d; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallRound(ref Decimal d, int decimals); - internal static int Sign(ref decimal d) => (d.lo | d.mid | d.hi) == 0 ? 0 : (d.flags >> 31) | 1; // Subtracts two Decimal values. // - public static Decimal Subtract(Decimal d1, Decimal d2) + public static decimal Subtract(decimal d1, decimal d2) { - FCallAddSub(ref d1, ref d2, DECIMAL_NEG); + DecCalc.DecAddSub(ref AsMutable(ref d1), ref AsMutable(ref d2), true); return d1; } @@ -856,7 +640,7 @@ public static Decimal Subtract(Decimal d1, Decimal d2) // towards zero to the nearest integer value, and the result of this // operation is returned as a byte. // - public static byte ToByte(Decimal value) + public static byte ToByte(decimal value) { uint temp; try @@ -867,7 +651,7 @@ public static byte ToByte(Decimal value) { throw new OverflowException(SR.Overflow_Byte, e); } - if (temp < Byte.MinValue || temp > Byte.MaxValue) throw new OverflowException(SR.Overflow_Byte); + if (temp != (byte)temp) throw new OverflowException(SR.Overflow_Byte); return (byte)temp; } @@ -876,7 +660,7 @@ public static byte ToByte(Decimal value) // operation is returned as a byte. // [CLSCompliant(false)] - public static sbyte ToSByte(Decimal value) + public static sbyte ToSByte(decimal value) { int temp; try @@ -887,7 +671,7 @@ public static sbyte ToSByte(Decimal value) { throw new OverflowException(SR.Overflow_SByte, e); } - if (temp < SByte.MinValue || temp > SByte.MaxValue) throw new OverflowException(SR.Overflow_SByte); + if (temp != (sbyte)temp) throw new OverflowException(SR.Overflow_SByte); return (sbyte)temp; } @@ -895,7 +679,7 @@ public static sbyte ToSByte(Decimal value) // rounded towards zero to the nearest integer value, and the result of // this operation is returned as a short. // - public static short ToInt16(Decimal value) + public static short ToInt16(decimal value) { int temp; try @@ -906,45 +690,29 @@ public static short ToInt16(Decimal value) { throw new OverflowException(SR.Overflow_Int16, e); } - if (temp < Int16.MinValue || temp > Int16.MaxValue) throw new OverflowException(SR.Overflow_Int16); + if (temp != (short)temp) throw new OverflowException(SR.Overflow_Int16); return (short)temp; } - - // Converts a Decimal to a Currency. Since a Currency - // has fewer significant digits than a Decimal, this operation may - // produce round-off errors. - // - internal static Currency ToCurrency(Decimal d) - { - Currency result = new Currency(); - FCallToCurrency(ref result, d); - return result; - } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallToCurrency(ref Currency result, Decimal d); - // Converts a Decimal to a double. Since a double has fewer significant // digits than a Decimal, this operation may produce round-off errors. // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern double ToDouble(Decimal d); - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern int FCallToInt32(Decimal d); + public static double ToDouble(decimal d) + { + return DecCalc.VarR8FromDec(ref d); + } // Converts a Decimal to an integer. The Decimal value is rounded towards // zero to the nearest integer value, and the result of this operation is // returned as an integer. // - public static int ToInt32(Decimal d) + public static int ToInt32(decimal d) { - if ((d.flags & ScaleMask) != 0) FCallTruncate(ref d); - if (d.hi == 0 && d.mid == 0) + Truncate(ref d); + if ((d.hi | d.mid) == 0) { int i = d.lo; - if (d.flags >= 0) + if (!d.IsNegative) { if (i >= 0) return i; } @@ -961,13 +729,13 @@ public static int ToInt32(Decimal d) // to the nearest integer value, and the result of this operation is // returned as a long. // - public static long ToInt64(Decimal d) + public static long ToInt64(decimal d) { - if ((d.flags & ScaleMask) != 0) FCallTruncate(ref d); + Truncate(ref d); if (d.hi == 0) { - long l = d.lo & 0xFFFFFFFFL | (long)d.mid << 32; - if (d.flags >= 0) + long l = (long)d.Low64; + if (!d.IsNegative) { if (l >= 0) return l; } @@ -985,7 +753,7 @@ public static long ToInt64(Decimal d) // result of this operation is returned as an ushort. // [CLSCompliant(false)] - public static ushort ToUInt16(Decimal value) + public static ushort ToUInt16(decimal value) { uint temp; try @@ -996,7 +764,7 @@ public static ushort ToUInt16(Decimal value) { throw new OverflowException(SR.Overflow_UInt16, e); } - if (temp < UInt16.MinValue || temp > UInt16.MaxValue) throw new OverflowException(SR.Overflow_UInt16); + if (temp != (ushort)temp) throw new OverflowException(SR.Overflow_UInt16); return (ushort)temp; } @@ -1005,13 +773,13 @@ public static ushort ToUInt16(Decimal value) // result of this operation is returned as an unsigned integer. // [CLSCompliant(false)] - public static uint ToUInt32(Decimal d) + public static uint ToUInt32(decimal d) { - if ((d.flags & ScaleMask) != 0) FCallTruncate(ref d); - if (d.hi == 0 && d.mid == 0) + Truncate(ref d); + if ((d.hi | d.mid) == 0) { - uint i = (uint)d.lo; - if (d.flags >= 0 || i == 0) + uint i = d.Low; + if (!d.IsNegative || i == 0) return i; } throw new OverflowException(SR.Overflow_UInt32); @@ -1022,13 +790,13 @@ public static uint ToUInt32(Decimal d) // result of this operation is returned as a long. // [CLSCompliant(false)] - public static ulong ToUInt64(Decimal d) + public static ulong ToUInt64(decimal d) { - if ((d.flags & ScaleMask) != 0) FCallTruncate(ref d); + Truncate(ref d); if (d.hi == 0) { - ulong l = ((ulong)(uint)d.lo) | ((ulong)(uint)d.mid << 32); - if (d.flags >= 0 || l == 0) + ulong l = d.Low64; + if (!d.IsNegative || l == 0) return l; } throw new OverflowException(SR.Overflow_UInt64); @@ -1037,98 +805,103 @@ public static ulong ToUInt64(Decimal d) // Converts a Decimal to a float. Since a float has fewer significant // digits than a Decimal, this operation may produce round-off errors. // - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern float ToSingle(Decimal d); + public static float ToSingle(decimal d) + { + return DecCalc.VarR4FromDec(ref d); + } // Truncates a Decimal to an integer value. The Decimal argument is rounded // towards zero to the nearest integer value, corresponding to removing all // digits after the decimal point. // - public static Decimal Truncate(Decimal d) + public static decimal Truncate(decimal d) { - FCallTruncate(ref d); + Truncate(ref d); return d; } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void Truncate(ref decimal d) + { + int flags = d.flags; + if ((flags & ScaleMask) != 0) + DecCalc.InternalRound(ref AsMutable(ref d), (byte)(flags >> ScaleShift), DecCalc.RoundingMode.Truncate); + } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallTruncate(ref Decimal d); - - - public static implicit operator Decimal(byte value) + public static implicit operator decimal(byte value) { - return new Decimal(value); + return new decimal(value); } [CLSCompliant(false)] - public static implicit operator Decimal(sbyte value) + public static implicit operator decimal(sbyte value) { - return new Decimal(value); + return new decimal(value); } - public static implicit operator Decimal(short value) + public static implicit operator decimal(short value) { - return new Decimal(value); + return new decimal(value); } [CLSCompliant(false)] - public static implicit operator Decimal(ushort value) + public static implicit operator decimal(ushort value) { - return new Decimal(value); + return new decimal(value); } - public static implicit operator Decimal(char value) + public static implicit operator decimal(char value) { - return new Decimal(value); + return new decimal(value); } - public static implicit operator Decimal(int value) + public static implicit operator decimal(int value) { - return new Decimal(value); + return new decimal(value); } [CLSCompliant(false)] - public static implicit operator Decimal(uint value) + public static implicit operator decimal(uint value) { - return new Decimal(value); + return new decimal(value); } - public static implicit operator Decimal(long value) + public static implicit operator decimal(long value) { - return new Decimal(value); + return new decimal(value); } [CLSCompliant(false)] - public static implicit operator Decimal(ulong value) + public static implicit operator decimal(ulong value) { - return new Decimal(value); + return new decimal(value); } - public static explicit operator Decimal(float value) + public static explicit operator decimal(float value) { - return new Decimal(value); + return new decimal(value); } - public static explicit operator Decimal(double value) + public static explicit operator decimal(double value) { - return new Decimal(value); + return new decimal(value); } - public static explicit operator byte(Decimal value) + public static explicit operator byte(decimal value) { return ToByte(value); } [CLSCompliant(false)] - public static explicit operator sbyte(Decimal value) + public static explicit operator sbyte(decimal value) { return ToSByte(value); } - public static explicit operator char(Decimal value) + public static explicit operator char(decimal value) { - UInt16 temp; + ushort temp; try { temp = ToUInt16(value); @@ -1140,126 +913,122 @@ public static explicit operator char(Decimal value) return (char)temp; } - public static explicit operator short(Decimal value) + public static explicit operator short(decimal value) { return ToInt16(value); } [CLSCompliant(false)] - public static explicit operator ushort(Decimal value) + public static explicit operator ushort(decimal value) { return ToUInt16(value); } - public static explicit operator int(Decimal value) + public static explicit operator int(decimal value) { return ToInt32(value); } [CLSCompliant(false)] - public static explicit operator uint(Decimal value) + public static explicit operator uint(decimal value) { return ToUInt32(value); } - public static explicit operator long(Decimal value) + public static explicit operator long(decimal value) { return ToInt64(value); } [CLSCompliant(false)] - public static explicit operator ulong(Decimal value) + public static explicit operator ulong(decimal value) { return ToUInt64(value); } - public static explicit operator float(Decimal value) + public static explicit operator float(decimal value) { return ToSingle(value); } - public static explicit operator double(Decimal value) + public static explicit operator double(decimal value) { return ToDouble(value); } - public static Decimal operator +(Decimal d) + public static decimal operator +(decimal d) { return d; } - public static Decimal operator -(Decimal d) + public static decimal operator -(decimal d) { return Negate(d); } - public static Decimal operator ++(Decimal d) + public static decimal operator ++(decimal d) { return Add(d, One); } - public static Decimal operator --(Decimal d) + public static decimal operator --(decimal d) { return Subtract(d, One); } - public static Decimal operator +(Decimal d1, Decimal d2) + public static decimal operator +(decimal d1, decimal d2) { - FCallAddSub(ref d1, ref d2, DECIMAL_ADD); - return d1; + return Add(d1, d2); } - public static Decimal operator -(Decimal d1, Decimal d2) + public static decimal operator -(decimal d1, decimal d2) { - FCallAddSub(ref d1, ref d2, DECIMAL_NEG); - return d1; + return Subtract(d1, d2); } - public static Decimal operator *(Decimal d1, Decimal d2) + public static decimal operator *(decimal d1, decimal d2) { - FCallMultiply(ref d1, ref d2); - return d1; + return Multiply(d1, d2); } - public static Decimal operator /(Decimal d1, Decimal d2) + public static decimal operator /(decimal d1, decimal d2) { - FCallDivide(ref d1, ref d2); - return d1; + return Divide(d1, d2); } - public static Decimal operator %(Decimal d1, Decimal d2) + public static decimal operator %(decimal d1, decimal d2) { return Remainder(d1, d2); } - public static bool operator ==(Decimal d1, Decimal d2) + public static bool operator ==(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) == 0; + return DecCalc.VarDecCmp(in d1, in d2) == 0; } - public static bool operator !=(Decimal d1, Decimal d2) + public static bool operator !=(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) != 0; + return DecCalc.VarDecCmp(in d1, in d2) != 0; } - public static bool operator <(Decimal d1, Decimal d2) + public static bool operator <(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) < 0; + return DecCalc.VarDecCmp(in d1, in d2) < 0; } - public static bool operator <=(Decimal d1, Decimal d2) + public static bool operator <=(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) <= 0; + return DecCalc.VarDecCmp(in d1, in d2) <= 0; } - public static bool operator >(Decimal d1, Decimal d2) + public static bool operator >(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) > 0; + return DecCalc.VarDecCmp(in d1, in d2) > 0; } - public static bool operator >=(Decimal d1, Decimal d2) + public static bool operator >=(decimal d1, decimal d2) { - return FCallCompare(ref d1, ref d2) >= 0; + return DecCalc.VarDecCmp(in d1, in d2) >= 0; } // @@ -1332,7 +1101,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(this); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return this; } @@ -1342,7 +1111,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Decimal", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.Unix.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.Unix.cs index 627ea4ab7edd..86b095e47b00 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Debug.Unix.cs @@ -22,11 +22,11 @@ private static void ShowDialog(string stackTrace, string message, string detailM // Fail in order to avoid anyone catching an exception and masking // an assert failure. DebugAssertException ex; - if (message == String.Empty) + if (message == string.Empty) { ex = new DebugAssertException(stackTrace); } - else if (detailMessage == String.Empty) + else if (detailMessage == string.Empty) { ex = new DebugAssertException(message, stackTrace); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs index 7ad7f0ce96b2..21c2ea0ab6ec 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventProvider.cs @@ -781,10 +781,10 @@ to fill the passed in ETW data descriptor. *uintptr = (uint)data; dataDescriptor->Ptr = (ulong)uintptr; } - else if (data is UInt64) + else if (data is ulong) { dataDescriptor->Size = (uint)sizeof(ulong); - UInt64* ulongptr = (ulong*)dataBuffer; + ulong* ulongptr = (ulong*)dataBuffer; *ulongptr = (ulong)data; dataDescriptor->Ptr = (ulong)ulongptr; } @@ -1290,7 +1290,7 @@ int IEventProvider.EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.Activi } // Define an EventPipeEvent handle. - unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) + unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, long keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) { throw new System.NotSupportedException(); } @@ -1331,7 +1331,7 @@ int IEventProvider.EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.Activi } // Define an EventPipeEvent handle. - unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) + unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, long keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) { return IntPtr.Zero; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs index 59fb59e862ef..534e387d2794 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/EventSource.cs @@ -626,7 +626,7 @@ private unsafe void DefineEventPipeEvents() uint metadataLength = (metadata != null) ? (uint)metadata.Length : 0; string eventName = m_eventData[i].Name; - Int64 keywords = m_eventData[i].Descriptor.Keywords; + long keywords = m_eventData[i].Descriptor.Keywords; uint eventVersion = m_eventData[i].Descriptor.Version; uint level = m_eventData[i].Descriptor.Level; @@ -2025,7 +2025,7 @@ private unsafe void WriteToAllListeners(int eventId, Guid* activityID, Guid* chi } // helper for writing to all EventListeners attached the current eventSource. - private unsafe void WriteToAllListeners(int eventId, Guid* activityID, Guid* childActivityID, params object[] args) + internal unsafe void WriteToAllListeners(int eventId, Guid* activityID, Guid* childActivityID, params object[] args) { EventWrittenEventArgs eventCallbackArgs = new EventWrittenEventArgs(this); eventCallbackArgs.EventId = eventId; @@ -3254,7 +3254,7 @@ private static bool RemoveFirstArgIfRelatedActivityId(ref ParameterInfo[] args) { // If the first parameter is (case insensitive) 'relatedActivityId' then skip it. if (args.Length > 0 && args[0].ParameterType == typeof(Guid) && - string.Compare(args[0].Name, "relatedActivityId", StringComparison.OrdinalIgnoreCase) == 0) + string.Equals(args[0].Name, "relatedActivityId", StringComparison.OrdinalIgnoreCase)) { var newargs = new ParameterInfo[args.Length - 1]; Array.Copy(args, 1, newargs, 0, args.Length - 1); @@ -3948,6 +3948,13 @@ public void EnableEvents(EventSource eventSource, EventLevel level, EventKeyword } eventSource.SendCommand(this, EventProviderType.None, 0, 0, EventCommand.Update, true, level, matchAnyKeyword, arguments); + +#if FEATURE_PERFTRACING + if (eventSource.GetType() == typeof(RuntimeEventSource)) + { + EventPipeEventDispatcher.Instance.SendCommand(this, EventCommand.Update, true, level, matchAnyKeyword); + } +#endif // FEATURE_PERFTRACING } /// /// Disables all events coming from eventSource identified by 'eventSource'. @@ -3962,6 +3969,13 @@ public void DisableEvents(EventSource eventSource) } eventSource.SendCommand(this, EventProviderType.None, 0, 0, EventCommand.Update, false, EventLevel.LogAlways, EventKeywords.None, null); + +#if FEATURE_PERFTRACING + if (eventSource.GetType() == typeof(RuntimeEventSource)) + { + EventPipeEventDispatcher.Instance.SendCommand(this, EventCommand.Update, false, EventLevel.LogAlways, EventKeywords.None); + } +#endif // FEATURE_PERFTRACING } /// @@ -4035,6 +4049,8 @@ internal static void AddEventSource(EventSource newEventSource) if (!s_EventSourceShutdownRegistered) { s_EventSourceShutdownRegistered = true; + AppDomain.CurrentDomain.ProcessExit += DisposeOnShutdown; + AppDomain.CurrentDomain.DomainUnload += DisposeOnShutdown; } @@ -4133,6 +4149,11 @@ private static void RemoveReferencesToListenerInEventSources(EventListener liste } } } + +#if FEATURE_PERFTRACING + // Remove the listener from the EventPipe dispatcher. + EventPipeEventDispatcher.Instance.RemoveEventListener(listenerToRemove); +#endif // FEATURE_PERFTRACING } /// @@ -4433,7 +4454,7 @@ public Guid RelatedActivityId /// /// Gets the payload for the event. /// - public ReadOnlyCollection Payload { get; internal set; } + public ReadOnlyCollection Payload { get; internal set; } /// /// Gets the payload argument names. @@ -5233,7 +5254,7 @@ public void AddEventParameter(Type type, string name) templates.Append(" length=\"").Append(name).Append("Size\""); } // ETW does not support 64-bit value maps, so we don't specify these as ETW maps - if (type.IsEnum() && Enum.GetUnderlyingType(type) != typeof(UInt64) && Enum.GetUnderlyingType(type) != typeof(Int64)) + if (type.IsEnum() && Enum.GetUnderlyingType(type) != typeof(ulong) && Enum.GetUnderlyingType(type) != typeof(long)) { templates.Append(" map=\"").Append(type.Name).Append("\""); if (mapsTab == null) @@ -5796,7 +5817,7 @@ private string TranslateToManifestConvention(string eventMessage, string evtName int leftBracket = i; i++; int argNum = 0; - while (i < eventMessage.Length && Char.IsDigit(eventMessage[i])) + while (i < eventMessage.Length && char.IsDigit(eventMessage[i])) { argNum = argNum * 10 + eventMessage[i] - '0'; i++; diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IEventProvider.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IEventProvider.cs index d34f80eb5130..9bbebc79ed23 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IEventProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/IEventProvider.cs @@ -38,6 +38,6 @@ unsafe int EventWriteTransferWrapper( int EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.ActivityControl ControlCode, ref Guid ActivityId); // Define an EventPipeEvent handle. - unsafe IntPtr DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength); + unsafe IntPtr DefineEventHandle(uint eventID, string eventName, long keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength); } } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs index 13de05a7012d..6f2eb9ba2168 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/StubEnvironment.cs @@ -301,7 +301,7 @@ public static TypeCode GetTypeCode(this Type type) else if (type == typeof(float)) return TypeCode.Single; else if (type == typeof(double)) return TypeCode.Double; else if (type == typeof(DateTime)) return TypeCode.DateTime; - else if (type == (typeof(Decimal))) return TypeCode.Decimal; + else if (type == (typeof(decimal))) return TypeCode.Decimal; else return TypeCode.Object; } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs index b1c7327c180f..a7daf5e757a2 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/NameInfo.cs @@ -42,10 +42,6 @@ internal static void ReserveEventIDsBelow(int eventId) internal readonly int identity; internal readonly byte[] nameMetadata; -#if FEATURE_PERFTRACING - private readonly object eventHandleCreationLock = new object(); -#endif - public NameInfo(string name, EventTags tags, int typeMetadataSize) { this.name = name; @@ -82,14 +78,14 @@ private int Compare(string otherName, EventTags otherTags) } #if FEATURE_PERFTRACING - public IntPtr GetOrCreateEventHandle(EventProvider provider, ConcurrentDictionary eventHandleMap, EventDescriptor descriptor, TraceLoggingEventTypes eventTypes) + public IntPtr GetOrCreateEventHandle(EventProvider provider, TraceLoggingEventHandleTable eventHandleTable, EventDescriptor descriptor, TraceLoggingEventTypes eventTypes) { - IntPtr eventHandle = IntPtr.Zero; - if(!eventHandleMap.TryGetValue(descriptor.EventId, out eventHandle)) + IntPtr eventHandle; + if ((eventHandle = eventHandleTable[descriptor.EventId]) == IntPtr.Zero) { - lock (eventHandleCreationLock) + lock (eventHandleTable) { - if (!eventHandleMap.TryGetValue(descriptor.EventId, out eventHandle)) + if ((eventHandle = eventHandleTable[descriptor.EventId]) == IntPtr.Zero) { byte[] metadataBlob = EventPipeMetadataGenerator.Instance.GenerateEventMetadata( descriptor.EventId, @@ -115,6 +111,9 @@ public IntPtr GetOrCreateEventHandle(EventProvider provider, ConcurrentDictionar metadataLength); } } + + // Cache the event handle. + eventHandleTable.SetEventHandle(descriptor.EventId, eventHandle); } } } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs index 9ff7e83cb832..daa6d9736a2f 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/PropertyValue.cs @@ -40,33 +40,33 @@ unsafe readonly struct PropertyValue public struct Scalar { [FieldOffset(0)] - public Boolean AsBoolean; + public bool AsBoolean; [FieldOffset(0)] - public Byte AsByte; + public byte AsByte; [FieldOffset(0)] - public SByte AsSByte; + public sbyte AsSByte; [FieldOffset(0)] - public Char AsChar; + public char AsChar; [FieldOffset(0)] - public Int16 AsInt16; + public short AsInt16; [FieldOffset(0)] - public UInt16 AsUInt16; + public ushort AsUInt16; [FieldOffset(0)] - public Int32 AsInt32; + public int AsInt32; [FieldOffset(0)] - public UInt32 AsUInt32; + public uint AsUInt32; [FieldOffset(0)] - public Int64 AsInt64; + public long AsInt64; [FieldOffset(0)] - public UInt64 AsUInt64; + public ulong AsUInt64; [FieldOffset(0)] public IntPtr AsIntPtr; [FieldOffset(0)] public UIntPtr AsUIntPtr; [FieldOffset(0)] - public Single AsSingle; + public float AsSingle; [FieldOffset(0)] - public Double AsDouble; + public double AsDouble; [FieldOffset(0)] public Guid AsGuid; [FieldOffset(0)] @@ -76,7 +76,7 @@ public struct Scalar [FieldOffset(0)] public TimeSpan AsTimeSpan; [FieldOffset(0)] - public Decimal AsDecimal; + public decimal AsDecimal; } // Anything not covered by the Scalar union gets stored in this reference. @@ -98,47 +98,47 @@ private PropertyValue(Scalar scalar, int scalarLength) _scalarLength = scalarLength; } - private PropertyValue(Boolean value) : this(new Scalar() { AsBoolean = value }, sizeof(Boolean)) { } - private PropertyValue(Byte value) : this(new Scalar() { AsByte = value }, sizeof(Byte)) { } - private PropertyValue(SByte value) : this(new Scalar() { AsSByte = value }, sizeof(SByte)) { } - private PropertyValue(Char value) : this(new Scalar() { AsChar = value }, sizeof(Char)) { } - private PropertyValue(Int16 value) : this(new Scalar() { AsInt16 = value }, sizeof(Int16)) { } - private PropertyValue(UInt16 value) : this(new Scalar() { AsUInt16 = value }, sizeof(UInt16)) { } - private PropertyValue(Int32 value) : this(new Scalar() { AsInt32 = value }, sizeof(Int32)) { } - private PropertyValue(UInt32 value) : this(new Scalar() { AsUInt32 = value }, sizeof(UInt32)) { } - private PropertyValue(Int64 value) : this(new Scalar() { AsInt64 = value }, sizeof(Int64)) { } - private PropertyValue(UInt64 value) : this(new Scalar() { AsUInt64 = value }, sizeof(UInt64)) { } + private PropertyValue(bool value) : this(new Scalar() { AsBoolean = value }, sizeof(bool)) { } + private PropertyValue(byte value) : this(new Scalar() { AsByte = value }, sizeof(byte)) { } + private PropertyValue(sbyte value) : this(new Scalar() { AsSByte = value }, sizeof(sbyte)) { } + private PropertyValue(char value) : this(new Scalar() { AsChar = value }, sizeof(char)) { } + private PropertyValue(short value) : this(new Scalar() { AsInt16 = value }, sizeof(short)) { } + private PropertyValue(ushort value) : this(new Scalar() { AsUInt16 = value }, sizeof(ushort)) { } + private PropertyValue(int value) : this(new Scalar() { AsInt32 = value }, sizeof(int)) { } + private PropertyValue(uint value) : this(new Scalar() { AsUInt32 = value }, sizeof(uint)) { } + private PropertyValue(long value) : this(new Scalar() { AsInt64 = value }, sizeof(long)) { } + private PropertyValue(ulong value) : this(new Scalar() { AsUInt64 = value }, sizeof(ulong)) { } private PropertyValue(IntPtr value) : this(new Scalar() { AsIntPtr = value }, sizeof(IntPtr)) { } private PropertyValue(UIntPtr value) : this(new Scalar() { AsUIntPtr = value }, sizeof(UIntPtr)) { } - private PropertyValue(Single value) : this(new Scalar() { AsSingle = value }, sizeof(Single)) { } - private PropertyValue(Double value) : this(new Scalar() { AsDouble = value }, sizeof(Double)) { } + private PropertyValue(float value) : this(new Scalar() { AsSingle = value }, sizeof(float)) { } + private PropertyValue(double value) : this(new Scalar() { AsDouble = value }, sizeof(double)) { } private PropertyValue(Guid value) : this(new Scalar() { AsGuid = value }, sizeof(Guid)) { } private PropertyValue(DateTime value) : this(new Scalar() { AsDateTime = value }, sizeof(DateTime)) { } private PropertyValue(DateTimeOffset value) : this(new Scalar() { AsDateTimeOffset = value }, sizeof(DateTimeOffset)) { } private PropertyValue(TimeSpan value) : this(new Scalar() { AsTimeSpan = value }, sizeof(TimeSpan)) { } - private PropertyValue(Decimal value) : this(new Scalar() { AsDecimal = value }, sizeof(Decimal)) { } + private PropertyValue(decimal value) : this(new Scalar() { AsDecimal = value }, sizeof(decimal)) { } public static Func GetFactory(Type type) { - if (type == typeof(Boolean)) return value => new PropertyValue((Boolean)value); - if (type == typeof(Byte)) return value => new PropertyValue((Byte)value); - if (type == typeof(SByte)) return value => new PropertyValue((SByte)value); - if (type == typeof(Char)) return value => new PropertyValue((Char)value); - if (type == typeof(Int16)) return value => new PropertyValue((Int16)value); - if (type == typeof(UInt16)) return value => new PropertyValue((UInt16)value); - if (type == typeof(Int32)) return value => new PropertyValue((Int32)value); - if (type == typeof(UInt32)) return value => new PropertyValue((UInt32)value); - if (type == typeof(Int64)) return value => new PropertyValue((Int64)value); - if (type == typeof(UInt64)) return value => new PropertyValue((UInt64)value); + if (type == typeof(bool)) return value => new PropertyValue((bool)value); + if (type == typeof(byte)) return value => new PropertyValue((byte)value); + if (type == typeof(sbyte)) return value => new PropertyValue((sbyte)value); + if (type == typeof(char)) return value => new PropertyValue((char)value); + if (type == typeof(short)) return value => new PropertyValue((short)value); + if (type == typeof(ushort)) return value => new PropertyValue((ushort)value); + if (type == typeof(int)) return value => new PropertyValue((int)value); + if (type == typeof(uint)) return value => new PropertyValue((uint)value); + if (type == typeof(long)) return value => new PropertyValue((long)value); + if (type == typeof(ulong)) return value => new PropertyValue((ulong)value); if (type == typeof(IntPtr)) return value => new PropertyValue((IntPtr)value); if (type == typeof(UIntPtr)) return value => new PropertyValue((UIntPtr)value); - if (type == typeof(Single)) return value => new PropertyValue((Single)value); - if (type == typeof(Double)) return value => new PropertyValue((Double)value); + if (type == typeof(float)) return value => new PropertyValue((float)value); + if (type == typeof(double)) return value => new PropertyValue((double)value); if (type == typeof(Guid)) return value => new PropertyValue((Guid)value); if (type == typeof(DateTime)) return value => new PropertyValue((DateTime)value); if (type == typeof(DateTimeOffset)) return value => new PropertyValue((DateTimeOffset)value); if (type == typeof(TimeSpan)) return value => new PropertyValue((TimeSpan)value); - if (type == typeof(Decimal)) return value => new PropertyValue((Decimal)value); + if (type == typeof(decimal)) return value => new PropertyValue((decimal)value); return value => new PropertyValue(value); } @@ -249,25 +249,25 @@ public override Func GetPropertyGetter(PropertyInf if (type.GetTypeInfo().IsEnum) type = Enum.GetUnderlyingType(type); - if (type == typeof(Boolean)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Byte)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(SByte)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Char)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int16)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt16)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int32)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt32)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Int64)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(UInt64)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(bool)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(byte)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(sbyte)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(char)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(short)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(ushort)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(int)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(uint)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(long)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(ulong)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(IntPtr)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(UIntPtr)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Single)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Double)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(float)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(double)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(Guid)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(DateTime)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(DateTimeOffset)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } if (type == typeof(TimeSpan)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } - if (type == typeof(Decimal)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } + if (type == typeof(decimal)) { var f = (Func)GetGetMethod(property, type); return container => new PropertyValue(f((TContainer)container.ReferenceValue)); } return container => new PropertyValue(property.GetValue(container.ReferenceValue)); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs index 001a8e8f0563..e0a937479037 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/SimpleTypeInfos.cs @@ -73,20 +73,20 @@ public override void WriteData(TraceLoggingDataCollector collector, PropertyValu collector.AddScalar(value); } - public static TraceLoggingTypeInfo Boolean() { return new ScalarTypeInfo(typeof(Boolean), Statics.Format8, TraceLoggingDataType.Boolean8); } - public static TraceLoggingTypeInfo Byte() { return new ScalarTypeInfo(typeof(Byte), Statics.Format8, TraceLoggingDataType.UInt8); } - public static TraceLoggingTypeInfo SByte() { return new ScalarTypeInfo(typeof(SByte), Statics.Format8, TraceLoggingDataType.Int8); } - public static TraceLoggingTypeInfo Char() { return new ScalarTypeInfo(typeof(Char), Statics.Format16, TraceLoggingDataType.Char16); } - public static TraceLoggingTypeInfo Int16() { return new ScalarTypeInfo(typeof(Int16), Statics.Format16, TraceLoggingDataType.Int16); } - public static TraceLoggingTypeInfo UInt16() { return new ScalarTypeInfo(typeof(UInt16), Statics.Format16, TraceLoggingDataType.UInt16); } - public static TraceLoggingTypeInfo Int32() { return new ScalarTypeInfo(typeof(Int32), Statics.Format32, TraceLoggingDataType.Int32); } - public static TraceLoggingTypeInfo UInt32() { return new ScalarTypeInfo(typeof(UInt32), Statics.Format32, TraceLoggingDataType.UInt32); } - public static TraceLoggingTypeInfo Int64() { return new ScalarTypeInfo(typeof(Int64), Statics.Format64, TraceLoggingDataType.Int64); } - public static TraceLoggingTypeInfo UInt64() { return new ScalarTypeInfo(typeof(UInt64), Statics.Format64, TraceLoggingDataType.UInt64); } + public static TraceLoggingTypeInfo Boolean() { return new ScalarTypeInfo(typeof(bool), Statics.Format8, TraceLoggingDataType.Boolean8); } + public static TraceLoggingTypeInfo Byte() { return new ScalarTypeInfo(typeof(byte), Statics.Format8, TraceLoggingDataType.UInt8); } + public static TraceLoggingTypeInfo SByte() { return new ScalarTypeInfo(typeof(sbyte), Statics.Format8, TraceLoggingDataType.Int8); } + public static TraceLoggingTypeInfo Char() { return new ScalarTypeInfo(typeof(char), Statics.Format16, TraceLoggingDataType.Char16); } + public static TraceLoggingTypeInfo Int16() { return new ScalarTypeInfo(typeof(short), Statics.Format16, TraceLoggingDataType.Int16); } + public static TraceLoggingTypeInfo UInt16() { return new ScalarTypeInfo(typeof(ushort), Statics.Format16, TraceLoggingDataType.UInt16); } + public static TraceLoggingTypeInfo Int32() { return new ScalarTypeInfo(typeof(int), Statics.Format32, TraceLoggingDataType.Int32); } + public static TraceLoggingTypeInfo UInt32() { return new ScalarTypeInfo(typeof(uint), Statics.Format32, TraceLoggingDataType.UInt32); } + public static TraceLoggingTypeInfo Int64() { return new ScalarTypeInfo(typeof(long), Statics.Format64, TraceLoggingDataType.Int64); } + public static TraceLoggingTypeInfo UInt64() { return new ScalarTypeInfo(typeof(ulong), Statics.Format64, TraceLoggingDataType.UInt64); } public static TraceLoggingTypeInfo IntPtr() { return new ScalarTypeInfo(typeof(IntPtr), Statics.FormatPtr, Statics.IntPtrType); } public static TraceLoggingTypeInfo UIntPtr() { return new ScalarTypeInfo(typeof(UIntPtr), Statics.FormatPtr, Statics.UIntPtrType); } - public static TraceLoggingTypeInfo Single() { return new ScalarTypeInfo(typeof(Single), Statics.Format32, TraceLoggingDataType.Float); } - public static TraceLoggingTypeInfo Double() { return new ScalarTypeInfo(typeof(Double), Statics.Format64, TraceLoggingDataType.Double); } + public static TraceLoggingTypeInfo Single() { return new ScalarTypeInfo(typeof(float), Statics.Format32, TraceLoggingDataType.Float); } + public static TraceLoggingTypeInfo Double() { return new ScalarTypeInfo(typeof(double), Statics.Format64, TraceLoggingDataType.Double); } public static TraceLoggingTypeInfo Guid() { return new ScalarTypeInfo(typeof(Guid), (f, t) => Statics.MakeDataType(TraceLoggingDataType.Guid, f), TraceLoggingDataType.Guid); } } @@ -122,20 +122,20 @@ public override void WriteData(TraceLoggingDataCollector collector, PropertyValu collector.AddArray(value, elementSize); } - public static TraceLoggingTypeInfo Boolean() { return new ScalarArrayTypeInfo(typeof(Boolean[]), Statics.Format8, TraceLoggingDataType.Boolean8, sizeof(Boolean)); } - public static TraceLoggingTypeInfo Byte() { return new ScalarArrayTypeInfo(typeof(Byte[]), Statics.Format8, TraceLoggingDataType.UInt8, sizeof(Byte)); } - public static TraceLoggingTypeInfo SByte() { return new ScalarArrayTypeInfo(typeof(SByte[]), Statics.Format8, TraceLoggingDataType.Int8, sizeof(SByte)); } - public static TraceLoggingTypeInfo Char() { return new ScalarArrayTypeInfo(typeof(Char[]), Statics.Format16, TraceLoggingDataType.Char16, sizeof(Char)); } - public static TraceLoggingTypeInfo Int16() { return new ScalarArrayTypeInfo(typeof(Int16[]), Statics.Format16, TraceLoggingDataType.Int16, sizeof(Int16)); } - public static TraceLoggingTypeInfo UInt16() { return new ScalarArrayTypeInfo(typeof(UInt16[]), Statics.Format16, TraceLoggingDataType.UInt16, sizeof(UInt16)); } - public static TraceLoggingTypeInfo Int32() { return new ScalarArrayTypeInfo(typeof(Int32[]), Statics.Format32, TraceLoggingDataType.Int32, sizeof(Int32)); } - public static TraceLoggingTypeInfo UInt32() { return new ScalarArrayTypeInfo(typeof(UInt32[]), Statics.Format32, TraceLoggingDataType.UInt32, sizeof(UInt32)); } - public static TraceLoggingTypeInfo Int64() { return new ScalarArrayTypeInfo(typeof(Int64[]), Statics.Format64, TraceLoggingDataType.Int64, sizeof(Int64)); } - public static TraceLoggingTypeInfo UInt64() { return new ScalarArrayTypeInfo(typeof(UInt64[]), Statics.Format64, TraceLoggingDataType.UInt64, sizeof(UInt64)); } + public static TraceLoggingTypeInfo Boolean() { return new ScalarArrayTypeInfo(typeof(bool[]), Statics.Format8, TraceLoggingDataType.Boolean8, sizeof(bool)); } + public static TraceLoggingTypeInfo Byte() { return new ScalarArrayTypeInfo(typeof(byte[]), Statics.Format8, TraceLoggingDataType.UInt8, sizeof(byte)); } + public static TraceLoggingTypeInfo SByte() { return new ScalarArrayTypeInfo(typeof(sbyte[]), Statics.Format8, TraceLoggingDataType.Int8, sizeof(sbyte)); } + public static TraceLoggingTypeInfo Char() { return new ScalarArrayTypeInfo(typeof(char[]), Statics.Format16, TraceLoggingDataType.Char16, sizeof(char)); } + public static TraceLoggingTypeInfo Int16() { return new ScalarArrayTypeInfo(typeof(short[]), Statics.Format16, TraceLoggingDataType.Int16, sizeof(short)); } + public static TraceLoggingTypeInfo UInt16() { return new ScalarArrayTypeInfo(typeof(ushort[]), Statics.Format16, TraceLoggingDataType.UInt16, sizeof(ushort)); } + public static TraceLoggingTypeInfo Int32() { return new ScalarArrayTypeInfo(typeof(int[]), Statics.Format32, TraceLoggingDataType.Int32, sizeof(int)); } + public static TraceLoggingTypeInfo UInt32() { return new ScalarArrayTypeInfo(typeof(uint[]), Statics.Format32, TraceLoggingDataType.UInt32, sizeof(uint)); } + public static TraceLoggingTypeInfo Int64() { return new ScalarArrayTypeInfo(typeof(long[]), Statics.Format64, TraceLoggingDataType.Int64, sizeof(long)); } + public static TraceLoggingTypeInfo UInt64() { return new ScalarArrayTypeInfo(typeof(ulong[]), Statics.Format64, TraceLoggingDataType.UInt64, sizeof(ulong)); } public static TraceLoggingTypeInfo IntPtr() { return new ScalarArrayTypeInfo(typeof(IntPtr[]), Statics.FormatPtr, Statics.IntPtrType, System.IntPtr.Size); } public static TraceLoggingTypeInfo UIntPtr() { return new ScalarArrayTypeInfo(typeof(UIntPtr[]), Statics.FormatPtr, Statics.UIntPtrType, System.IntPtr.Size); } - public static TraceLoggingTypeInfo Single() { return new ScalarArrayTypeInfo(typeof(Single[]), Statics.Format32, TraceLoggingDataType.Float, sizeof(Single)); } - public static TraceLoggingTypeInfo Double() { return new ScalarArrayTypeInfo(typeof(Double[]), Statics.Format64, TraceLoggingDataType.Double, sizeof(Double)); } + public static TraceLoggingTypeInfo Single() { return new ScalarArrayTypeInfo(typeof(float[]), Statics.Format32, TraceLoggingDataType.Float, sizeof(float)); } + public static TraceLoggingTypeInfo Double() { return new ScalarArrayTypeInfo(typeof(double[]), Statics.Format64, TraceLoggingDataType.Double, sizeof(double)); } public static unsafe TraceLoggingTypeInfo Guid() { return new ScalarArrayTypeInfo(typeof(Guid), (f, t) => Statics.MakeDataType(TraceLoggingDataType.Guid, f), TraceLoggingDataType.Guid, sizeof(Guid)); } } @@ -243,11 +243,11 @@ public override void WriteData(TraceLoggingDataCollector collector, PropertyValu } /// - /// TraceLogging: Type handler for Decimal. (Note: not full-fidelity, exposed as Double.) + /// TraceLogging: Type handler for decimal. (Note: not full-fidelity, exposed as Double.) /// internal sealed class DecimalTypeInfo : TraceLoggingTypeInfo { - public DecimalTypeInfo() : base(typeof(Decimal)) { } + public DecimalTypeInfo() : base(typeof(decimal)) { } public override void WriteMetadata( TraceLoggingMetadataCollector collector, diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/Statics.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/Statics.cs index 05539ab4fd65..0c21672131c1 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/Statics.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/Statics.cs @@ -548,51 +548,51 @@ public static TraceLoggingTypeInfo CreateDefaultTypeInfo( else if (dataType.IsArray) { var elementType = dataType.GetElementType(); - if (elementType == typeof(Boolean)) + if (elementType == typeof(bool)) { result = ScalarArrayTypeInfo.Boolean(); } - else if (elementType == typeof(Byte)) + else if (elementType == typeof(byte)) { result = ScalarArrayTypeInfo.Byte(); } - else if (elementType == typeof(SByte)) + else if (elementType == typeof(sbyte)) { result = ScalarArrayTypeInfo.SByte(); } - else if (elementType == typeof(Int16)) + else if (elementType == typeof(short)) { result = ScalarArrayTypeInfo.Int16(); } - else if (elementType == typeof(UInt16)) + else if (elementType == typeof(ushort)) { result = ScalarArrayTypeInfo.UInt16(); } - else if (elementType == typeof(Int32)) + else if (elementType == typeof(int)) { result = ScalarArrayTypeInfo.Int32(); } - else if (elementType == typeof(UInt32)) + else if (elementType == typeof(uint)) { result = ScalarArrayTypeInfo.UInt32(); } - else if (elementType == typeof(Int64)) + else if (elementType == typeof(long)) { result = ScalarArrayTypeInfo.Int64(); } - else if (elementType == typeof(UInt64)) + else if (elementType == typeof(ulong)) { result = ScalarArrayTypeInfo.UInt64(); } - else if (elementType == typeof(Char)) + else if (elementType == typeof(char)) { result = ScalarArrayTypeInfo.Char(); } - else if (elementType == typeof(Double)) + else if (elementType == typeof(double)) { result = ScalarArrayTypeInfo.Double(); } - else if (elementType == typeof(Single)) + else if (elementType == typeof(float)) { result = ScalarArrayTypeInfo.Single(); } @@ -618,55 +618,55 @@ public static TraceLoggingTypeInfo CreateDefaultTypeInfo( if (Statics.IsEnum(dataType)) dataType = Enum.GetUnderlyingType(dataType); - if (dataType == typeof(String)) + if (dataType == typeof(string)) { result = new StringTypeInfo(); } - else if (dataType == typeof(Boolean)) + else if (dataType == typeof(bool)) { result = ScalarTypeInfo.Boolean(); } - else if (dataType == typeof(Byte)) + else if (dataType == typeof(byte)) { result = ScalarTypeInfo.Byte(); } - else if (dataType == typeof(SByte)) + else if (dataType == typeof(sbyte)) { result = ScalarTypeInfo.SByte(); } - else if (dataType == typeof(Int16)) + else if (dataType == typeof(short)) { result = ScalarTypeInfo.Int16(); } - else if (dataType == typeof(UInt16)) + else if (dataType == typeof(ushort)) { result = ScalarTypeInfo.UInt16(); } - else if (dataType == typeof(Int32)) + else if (dataType == typeof(int)) { result = ScalarTypeInfo.Int32(); } - else if (dataType == typeof(UInt32)) + else if (dataType == typeof(uint)) { result = ScalarTypeInfo.UInt32(); } - else if (dataType == typeof(Int64)) + else if (dataType == typeof(long)) { result = ScalarTypeInfo.Int64(); } - else if (dataType == typeof(UInt64)) + else if (dataType == typeof(ulong)) { result = ScalarTypeInfo.UInt64(); } - else if (dataType == typeof(Char)) + else if (dataType == typeof(char)) { result = ScalarTypeInfo.Char(); } - else if (dataType == typeof(Double)) + else if (dataType == typeof(double)) { result = ScalarTypeInfo.Double(); } - else if (dataType == typeof(Single)) + else if (dataType == typeof(float)) { result = ScalarTypeInfo.Single(); } @@ -674,7 +674,7 @@ public static TraceLoggingTypeInfo CreateDefaultTypeInfo( { result = new DateTimeTypeInfo(); } - else if (dataType == typeof(Decimal)) + else if (dataType == typeof(decimal)) { result = new DecimalTypeInfo(); } diff --git a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs index 0bf6657ffa2a..0553f9899936 100644 --- a/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs +++ b/src/System.Private.CoreLib/shared/System/Diagnostics/Tracing/TraceLogging/TraceLoggingEventSource.cs @@ -24,7 +24,6 @@ using System.Runtime.InteropServices; using System.Security; using System.Collections.ObjectModel; -using System.Collections.Concurrent; #if !ES_BUILD_AGAINST_DOTNET_V35 using Contract = System.Diagnostics.Contracts.Contract; @@ -49,7 +48,7 @@ public partial class EventSource #endif #if FEATURE_PERFTRACING - private ConcurrentDictionary m_eventHandleMap = new ConcurrentDictionary(); + private readonly TraceLoggingEventHandleTable m_eventHandleTable = new TraceLoggingEventHandleTable(); #endif /// @@ -437,7 +436,7 @@ private unsafe void WriteMultiMergeInner( EventDescriptor descriptor = new EventDescriptor(identity, level, opcode, (long)keywords); #if FEATURE_PERFTRACING - IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes); + IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleTable, descriptor, eventTypes); Debug.Assert(eventHandle != IntPtr.Zero); #else IntPtr eventHandle = IntPtr.Zero; @@ -552,7 +551,7 @@ internal unsafe void WriteMultiMerge( } #if FEATURE_PERFTRACING - IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes); + IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleTable, descriptor, eventTypes); Debug.Assert(eventHandle != IntPtr.Zero); #else IntPtr eventHandle = IntPtr.Zero; @@ -621,7 +620,7 @@ private unsafe void WriteImpl( } #if FEATURE_PERFTRACING - IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleMap, descriptor, eventTypes); + IntPtr eventHandle = nameInfo.GetOrCreateEventHandle(m_eventPipeProvider, m_eventHandleTable, descriptor, eventTypes); Debug.Assert(eventHandle != IntPtr.Zero); #else IntPtr eventHandle = IntPtr.Zero; diff --git a/src/System.Private.CoreLib/shared/System/DivideByZeroException.cs b/src/System.Private.CoreLib/shared/System/DivideByZeroException.cs index b309695ff3fb..27f57414ff7f 100644 --- a/src/System.Private.CoreLib/shared/System/DivideByZeroException.cs +++ b/src/System.Private.CoreLib/shared/System/DivideByZeroException.cs @@ -25,13 +25,13 @@ public DivideByZeroException() HResult = HResults.COR_E_DIVIDEBYZERO; } - public DivideByZeroException(String message) + public DivideByZeroException(string message) : base(message) { HResult = HResults.COR_E_DIVIDEBYZERO; } - public DivideByZeroException(String message, Exception innerException) + public DivideByZeroException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_DIVIDEBYZERO; diff --git a/src/System.Private.CoreLib/shared/System/DllNotFoundException.cs b/src/System.Private.CoreLib/shared/System/DllNotFoundException.cs index 14fb50d9c515..bd29b8b13a87 100644 --- a/src/System.Private.CoreLib/shared/System/DllNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/DllNotFoundException.cs @@ -26,13 +26,13 @@ public DllNotFoundException() HResult = HResults.COR_E_DLLNOTFOUND; } - public DllNotFoundException(String message) + public DllNotFoundException(string message) : base(message) { HResult = HResults.COR_E_DLLNOTFOUND; } - public DllNotFoundException(String message, Exception inner) + public DllNotFoundException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_DLLNOTFOUND; diff --git a/src/System.Private.CoreLib/shared/System/Double.cs b/src/System.Private.CoreLib/shared/System/Double.cs index e46693595369..181086477af0 100644 --- a/src/System.Private.CoreLib/shared/System/Double.cs +++ b/src/System.Private.CoreLib/shared/System/Double.cs @@ -24,9 +24,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Double : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public struct Double : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private double m_value; // Do not rename (binary serialization) + private readonly double m_value; // Do not rename (binary serialization) // // Public Constants @@ -76,8 +76,7 @@ public static unsafe bool IsNaN(double d) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsNegative(double d) { - var bits = unchecked((ulong)BitConverter.DoubleToInt64Bits(d)); - return (bits & 0x8000000000000000) == 0x8000000000000000; + return BitConverter.DoubleToInt64Bits(d) < 0; } /// Determines whether the specified value is negative infinity. @@ -123,13 +122,13 @@ public static unsafe bool IsSubnormal(double d) // // Returns a value less than zero if this object // - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) { return 1; } - if (value is Double) + if (value is double) { double d = (double)value; if (m_value < d) return -1; @@ -145,7 +144,7 @@ public int CompareTo(Object value) throw new ArgumentException(SR.Arg_MustBeDouble); } - public int CompareTo(Double value) + public int CompareTo(double value) { if (m_value < value) return -1; if (m_value > value) return 1; @@ -160,13 +159,13 @@ public int CompareTo(Double value) // True if obj is another Double with the same value as the current instance. This is // a method of object equality, that only returns true if obj is also a double. - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (!(obj is Double)) + if (!(obj is double)) { return false; } - double temp = ((Double)obj).m_value; + double temp = ((double)obj).m_value; // This code below is written this way for performance reasons i.e the != and == check is intentional. if (temp == m_value) { @@ -176,42 +175,42 @@ public override bool Equals(Object obj) } [NonVersionable] - public static bool operator ==(Double left, Double right) + public static bool operator ==(double left, double right) { return left == right; } [NonVersionable] - public static bool operator !=(Double left, Double right) + public static bool operator !=(double left, double right) { return left != right; } [NonVersionable] - public static bool operator <(Double left, Double right) + public static bool operator <(double left, double right) { return left < right; } [NonVersionable] - public static bool operator >(Double left, Double right) + public static bool operator >(double left, double right) { return left > right; } [NonVersionable] - public static bool operator <=(Double left, Double right) + public static bool operator <=(double left, double right) { return left <= right; } [NonVersionable] - public static bool operator >=(Double left, Double right) + public static bool operator >=(double left, double right) { return left >= right; } - public bool Equals(Double obj) + public bool Equals(double obj) { if (obj == m_value) { @@ -226,7 +225,7 @@ public bool Equals(Double obj) [MethodImpl(MethodImplOptions.AggressiveInlining)] // 64-bit constants make the IL unusually large that makes the inliner to reject the method public override int GetHashCode() { - var bits = Unsafe.As(ref m_value); + var bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); // Optimized check for IsNan() || IsZero() if (((bits - 1) & 0x7FFFFFFFFFFFFFFF) >= 0x7FF0000000000000) @@ -238,22 +237,22 @@ public override int GetHashCode() return unchecked((int)bits) ^ ((int)(bits >> 32)); } - public override String ToString() + public override string ToString() { return Number.FormatDouble(m_value, null, NumberFormatInfo.CurrentInfo); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatDouble(m_value, format, NumberFormatInfo.CurrentInfo); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatDouble(m_value, null, NumberFormatInfo.GetInstance(provider)); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatDouble(m_value, format, NumberFormatInfo.GetInstance(provider)); } @@ -263,26 +262,26 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return Number.TryFormatDouble(m_value, format, NumberFormatInfo.GetInstance(provider), destination, out charsWritten); } - public static double Parse(String s) + public static double Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo); } - public static double Parse(String s, NumberStyles style) + public static double Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDouble(s, style, NumberFormatInfo.CurrentInfo); } - public static double Parse(String s, IFormatProvider provider) + public static double Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseDouble(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider)); } - public static double Parse(String s, NumberStyles style, IFormatProvider provider) + public static double Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -305,7 +304,7 @@ public static double Parse(ReadOnlySpan s, NumberStyles style = NumberStyl - public static bool TryParse(String s, out double result) + public static bool TryParse(string s, out double result) { if (s == null) { @@ -321,7 +320,7 @@ public static bool TryParse(ReadOnlySpan s, out double result) return TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo, out result); } - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out double result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out double result) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); @@ -435,7 +434,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return m_value; } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -445,7 +444,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Double", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/DuplicateWaitObjectException.cs b/src/System.Private.CoreLib/shared/System/DuplicateWaitObjectException.cs index 77303846a37d..f48e4be1740d 100644 --- a/src/System.Private.CoreLib/shared/System/DuplicateWaitObjectException.cs +++ b/src/System.Private.CoreLib/shared/System/DuplicateWaitObjectException.cs @@ -21,9 +21,9 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class DuplicateWaitObjectException : ArgumentException { - private static volatile String s_duplicateWaitObjectMessage = null; + private static volatile string s_duplicateWaitObjectMessage = null; - private static String DuplicateWaitObjectMessage + private static string DuplicateWaitObjectMessage { get { @@ -41,19 +41,19 @@ public DuplicateWaitObjectException() HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } - public DuplicateWaitObjectException(String parameterName) + public DuplicateWaitObjectException(string parameterName) : base(DuplicateWaitObjectMessage, parameterName) { HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } - public DuplicateWaitObjectException(String parameterName, String message) + public DuplicateWaitObjectException(string parameterName, string message) : base(message, parameterName) { HResult = HResults.COR_E_DUPLICATEWAITOBJECT; } - public DuplicateWaitObjectException(String message, Exception innerException) + public DuplicateWaitObjectException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_DUPLICATEWAITOBJECT; diff --git a/src/System.Private.CoreLib/shared/System/EntryPointNotFoundException.cs b/src/System.Private.CoreLib/shared/System/EntryPointNotFoundException.cs index dac1cdb97158..606743aa1e51 100644 --- a/src/System.Private.CoreLib/shared/System/EntryPointNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/EntryPointNotFoundException.cs @@ -26,13 +26,13 @@ public EntryPointNotFoundException() HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; } - public EntryPointNotFoundException(String message) + public EntryPointNotFoundException(string message) : base(message) { HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; } - public EntryPointNotFoundException(String message, Exception inner) + public EntryPointNotFoundException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_ENTRYPOINTNOTFOUND; diff --git a/src/System.Private.CoreLib/shared/System/EventHandler.cs b/src/System.Private.CoreLib/shared/System/EventHandler.cs index 3d1cbfef2676..c38e17ce6fb7 100644 --- a/src/System.Private.CoreLib/shared/System/EventHandler.cs +++ b/src/System.Private.CoreLib/shared/System/EventHandler.cs @@ -6,7 +6,7 @@ namespace System { - public delegate void EventHandler(Object sender, EventArgs e); + public delegate void EventHandler(object sender, EventArgs e); - public delegate void EventHandler(Object sender, TEventArgs e); // Removed TEventArgs constraint post-.NET 4 + public delegate void EventHandler(object sender, TEventArgs e); // Removed TEventArgs constraint post-.NET 4 } diff --git a/src/System.Private.CoreLib/shared/System/ExecutionEngineException.cs b/src/System.Private.CoreLib/shared/System/ExecutionEngineException.cs index 5edd5cf19ff8..5649cc082b3f 100644 --- a/src/System.Private.CoreLib/shared/System/ExecutionEngineException.cs +++ b/src/System.Private.CoreLib/shared/System/ExecutionEngineException.cs @@ -31,13 +31,13 @@ public ExecutionEngineException() HResult = HResults.COR_E_EXECUTIONENGINE; } - public ExecutionEngineException(String message) + public ExecutionEngineException(string message) : base(message) { HResult = HResults.COR_E_EXECUTIONENGINE; } - public ExecutionEngineException(String message, Exception innerException) + public ExecutionEngineException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_EXECUTIONENGINE; diff --git a/src/System.Private.CoreLib/shared/System/FieldAccessException.cs b/src/System.Private.CoreLib/shared/System/FieldAccessException.cs index cb28264d61b3..b23984133c99 100644 --- a/src/System.Private.CoreLib/shared/System/FieldAccessException.cs +++ b/src/System.Private.CoreLib/shared/System/FieldAccessException.cs @@ -23,13 +23,13 @@ public FieldAccessException() HResult = HResults.COR_E_FIELDACCESS; } - public FieldAccessException(String message) + public FieldAccessException(string message) : base(message) { HResult = HResults.COR_E_FIELDACCESS; } - public FieldAccessException(String message, Exception inner) + public FieldAccessException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_FIELDACCESS; diff --git a/src/System.Private.CoreLib/shared/System/FormatException.cs b/src/System.Private.CoreLib/shared/System/FormatException.cs index b0e273369cd4..97d5001f3fd9 100644 --- a/src/System.Private.CoreLib/shared/System/FormatException.cs +++ b/src/System.Private.CoreLib/shared/System/FormatException.cs @@ -25,13 +25,13 @@ public FormatException() HResult = HResults.COR_E_FORMAT; } - public FormatException(String message) + public FormatException(string message) : base(message) { HResult = HResults.COR_E_FORMAT; } - public FormatException(String message, Exception innerException) + public FormatException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_FORMAT; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs index d38d0da0ede5..66a63694a589 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/Calendar.cs @@ -736,7 +736,7 @@ public virtual DateTime ToDateTime(int year, int month, int day, int hour, int m public abstract DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era); - internal virtual Boolean TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result) + internal virtual bool TryToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era, out DateTime result) { result = DateTime.MinValue; try diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs index 1d37926b421e..61e06914c073 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Unix.cs @@ -32,7 +32,7 @@ internal enum CalendarDataType internal partial class CalendarData { - private bool LoadCalendarDataFromSystem(String localeName, CalendarId calendarId) + private bool LoadCalendarDataFromSystem(string localeName, CalendarId calendarId) { bool result = true; result &= GetCalendarInfo(localeName, calendarId, CalendarDataType.NativeName, out this.sNativeName); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Windows.cs b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Windows.cs index 03f9088d62b9..de5037441217 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CalendarData.Windows.cs @@ -13,7 +13,7 @@ namespace System.Globalization { internal partial class CalendarData { - private bool LoadCalendarDataFromSystem(String localeName, CalendarId calendarId) + private bool LoadCalendarDataFromSystem(string localeName, CalendarId calendarId) { Debug.Assert(!GlobalizationMode.Invariant); @@ -127,7 +127,7 @@ internal static int GetTwoDigitYearMax(CalendarId calendarId) } // Call native side to figure out which calendars are allowed - internal static int GetCalendars(String localeName, bool useUserOverride, CalendarId[] calendars) + internal static int GetCalendars(string localeName, bool useUserOverride, CalendarId[] calendars) { Debug.Assert(!GlobalizationMode.Invariant); @@ -451,7 +451,7 @@ private static unsafe Interop.BOOL EnumCalendarsCallback(char* lpCalendarInfoStr } } - private static unsafe String GetUserDefaultLocaleName() + private static unsafe string GetUserDefaultLocaleName() { Debug.Assert(!GlobalizationMode.Invariant); @@ -463,7 +463,7 @@ private static unsafe String GetUserDefaultLocaleName() char* localeName = stackalloc char[LOCALE_NAME_MAX_LENGTH]; result = CultureData.GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SNAME, localeName, LOCALE_NAME_MAX_LENGTH); - return result <= 0 ? "" : new String(localeName, 0, result - 1); // exclude the null termination + return result <= 0 ? "" : new string(localeName, 0, result - 1); // exclude the null termination } } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs index 0cd8429bbcd6..d8d621cb0574 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CharUnicodeInfo.cs @@ -13,6 +13,7 @@ //////////////////////////////////////////////////////////////////////////// using System.Diagnostics; +using System.Text; namespace System.Globalization { @@ -29,6 +30,7 @@ public static partial class CharUnicodeInfo internal const char HIGH_SURROGATE_END = '\udbff'; internal const char LOW_SURROGATE_START = '\udc00'; internal const char LOW_SURROGATE_END = '\udfff'; + internal const int HIGH_SURROGATE_RANGE = 0x3FF; internal const int UNICODE_CATEGORY_OFFSET = 0; internal const int BIDI_CATEGORY_OFFSET = 1; @@ -41,7 +43,7 @@ public static partial class CharUnicodeInfo // // Actions: // Convert the BMP character or surrogate pointed by index to a UTF32 value. - // This is similar to Char.ConvertToUTF32, but the difference is that + // This is similar to char.ConvertToUTF32, but the difference is that // it does not throw exceptions when invalid surrogate characters are passed in. // // WARNING: since it doesn't throw an exception it CAN return a value @@ -49,17 +51,17 @@ public static partial class CharUnicodeInfo // //////////////////////////////////////////////////////////////////////// - internal static int InternalConvertToUtf32(String s, int index) + internal static int InternalConvertToUtf32(string s, int index) { Debug.Assert(s != null, "s != null"); Debug.Assert(index >= 0 && index < s.Length, "index < s.Length"); if (index < s.Length - 1) { int temp1 = (int)s[index] - HIGH_SURROGATE_START; - if (temp1 >= 0 && temp1 <= 0x3ff) + if (temp1 >= 0 && temp1 <= HIGH_SURROGATE_RANGE) { int temp2 = (int)s[index + 1] - LOW_SURROGATE_START; - if (temp2 >= 0 && temp2 <= 0x3ff) + if (temp2 >= 0 && temp2 <= HIGH_SURROGATE_RANGE) { // Convert the surrogate to UTF32 and get the result. return ((temp1 * 0x400) + temp2 + UNICODE_PLANE01_START); @@ -68,6 +70,29 @@ internal static int InternalConvertToUtf32(String s, int index) } return ((int)s[index]); } + + internal static int InternalConvertToUtf32(StringBuilder s, int index) + { + Debug.Assert(s != null, "s != null"); + Debug.Assert(index >= 0 && index < s.Length, "index < s.Length"); + + int c = (int)s[index]; + if (index < s.Length - 1) + { + int temp1 = c - HIGH_SURROGATE_START; + if (temp1 >= 0 && temp1 <= HIGH_SURROGATE_RANGE) + { + int temp2 = (int)s[index + 1] - LOW_SURROGATE_START; + if (temp2 >= 0 && temp2 <= HIGH_SURROGATE_RANGE) + { + // Convert the surrogate to UTF32 and get the result. + return ((temp1 * 0x400) + temp2 + UNICODE_PLANE01_START); + } + } + } + return c; + } + //////////////////////////////////////////////////////////////////////// // // Convert a character or a surrogate pair starting at index of string s @@ -90,7 +115,7 @@ internal static int InternalConvertToUtf32(String s, int index) // //////////////////////////////////////////////////////////////////////// - internal static int InternalConvertToUtf32(String s, int index, out int charLength) + internal static int InternalConvertToUtf32(string s, int index, out int charLength) { Debug.Assert(s != null, "s != null"); Debug.Assert(s.Length > 0, "s.Length > 0"); @@ -99,10 +124,10 @@ internal static int InternalConvertToUtf32(String s, int index, out int charLeng if (index < s.Length - 1) { int temp1 = (int)s[index] - HIGH_SURROGATE_START; - if (temp1 >= 0 && temp1 <= 0x3ff) + if (temp1 >= 0 && temp1 <= HIGH_SURROGATE_RANGE) { int temp2 = (int)s[index + 1] - LOW_SURROGATE_START; - if (temp2 >= 0 && temp2 <= 0x3ff) + if (temp2 >= 0 && temp2 <= HIGH_SURROGATE_RANGE) { // Convert the surrogate to UTF32 and get the result. charLength++; @@ -121,7 +146,7 @@ internal static int InternalConvertToUtf32(String s, int index, out int charLeng // //////////////////////////////////////////////////////////////////////// - internal static bool IsWhiteSpace(String s, int index) + internal static bool IsWhiteSpace(string s, int index) { Debug.Assert(s != null, "s!=null"); Debug.Assert(index >= 0 && index < s.Length, "index >= 0 && index < s.Length"); @@ -221,7 +246,7 @@ public static double GetNumericValue(char ch) } - public static double GetNumericValue(String s, int index) + public static double GetNumericValue(string s, int index) { if (s == null) { @@ -239,7 +264,7 @@ public static int GetDecimalDigitValue(char ch) return (sbyte)(InternalGetDigitValues(ch) >> 8); } - public static int GetDecimalDigitValue(String s, int index) + public static int GetDecimalDigitValue(string s, int index) { if (s == null) { @@ -259,7 +284,7 @@ public static int GetDigitValue(char ch) return (sbyte)(InternalGetDigitValues(ch) & 0x00FF); } - public static int GetDigitValue(String s, int index) + public static int GetDigitValue(string s, int index) { if (s == null) { @@ -279,7 +304,7 @@ public static UnicodeCategory GetUnicodeCategory(char ch) return (GetUnicodeCategory((int)ch)); } - public static UnicodeCategory GetUnicodeCategory(String s, int index) + public static UnicodeCategory GetUnicodeCategory(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -347,7 +372,7 @@ internal static unsafe byte InternalGetCategoryValue(int ch, int offset) // //////////////////////////////////////////////////////////////////////// - internal static UnicodeCategory InternalGetUnicodeCategory(String value, int index) + internal static UnicodeCategory InternalGetUnicodeCategory(string value, int index) { Debug.Assert(value != null, "value can not be null"); Debug.Assert(index < value.Length, "index < value.Length"); @@ -355,7 +380,7 @@ internal static UnicodeCategory InternalGetUnicodeCategory(String value, int ind return (GetUnicodeCategory(InternalConvertToUtf32(value, index))); } - internal static BidiCategory GetBidiCategory(String s, int index) + internal static BidiCategory GetBidiCategory(string s, int index) { if (s == null) throw new ArgumentNullException(nameof(s)); @@ -368,6 +393,14 @@ internal static BidiCategory GetBidiCategory(String s, int index) return ((BidiCategory) InternalGetCategoryValue(InternalConvertToUtf32(s, index), BIDI_CATEGORY_OFFSET)); } + internal static BidiCategory GetBidiCategory(StringBuilder s, int index) + { + Debug.Assert(s != null, "s can not be null"); + Debug.Assert(index >= 0 && index < s.Length, "invalid index"); ; + + return ((BidiCategory) InternalGetCategoryValue(InternalConvertToUtf32(s, index), BIDI_CATEGORY_OFFSET)); + } + //////////////////////////////////////////////////////////////////////// // // Get the Unicode category of the character starting at index. If the character is in BMP, charLength will return 1. @@ -375,7 +408,7 @@ internal static BidiCategory GetBidiCategory(String s, int index) // //////////////////////////////////////////////////////////////////////// - internal static UnicodeCategory InternalGetUnicodeCategory(String str, int index, out int charLength) + internal static UnicodeCategory InternalGetUnicodeCategory(string str, int index, out int charLength) { Debug.Assert(str != null, "str can not be null"); Debug.Assert(str.Length > 0, "str.Length > 0"); ; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Invariant.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Invariant.cs index 29e4f53212fb..16201b8d1faa 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Invariant.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Invariant.cs @@ -18,7 +18,7 @@ internal static unsafe int InvariantIndexOf(string source, string value, int sta fixed (char* pSource = source) fixed (char* pValue = value) { char* pSrc = &pSource[startIndex]; - int index = InvariantFindString(pSrc, count, pValue, value.Length, ignoreCase, start : true); + int index = InvariantFindString(pSrc, count, pValue, value.Length, ignoreCase, fromBeginning : true); if (index >= 0) { return index + startIndex; @@ -27,7 +27,7 @@ internal static unsafe int InvariantIndexOf(string source, string value, int sta } } - internal static unsafe int InvariantIndexOf(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase) + internal static unsafe int InvariantIndexOf(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase, bool fromBeginning = true) { Debug.Assert(source.Length != 0); Debug.Assert(value.Length != 0); @@ -35,7 +35,7 @@ internal static unsafe int InvariantIndexOf(ReadOnlySpan source, ReadOnlyS fixed (char* pSource = &MemoryMarshal.GetReference(source)) fixed (char* pValue = &MemoryMarshal.GetReference(value)) { - return InvariantFindString(pSource, source.Length, pValue, value.Length, ignoreCase, start: true); + return InvariantFindString(pSource, source.Length, pValue, value.Length, ignoreCase, fromBeginning); } } @@ -48,7 +48,7 @@ internal static unsafe int InvariantLastIndexOf(string source, string value, int fixed (char* pSource = source) fixed (char* pValue = value) { char* pSrc = &pSource[startIndex - count + 1]; - int index = InvariantFindString(pSrc, count, pValue, value.Length, ignoreCase, start : false); + int index = InvariantFindString(pSrc, count, pValue, value.Length, ignoreCase, fromBeginning : false); if (index >= 0) { return index + startIndex - count + 1; @@ -57,7 +57,7 @@ internal static unsafe int InvariantLastIndexOf(string source, string value, int } } - private static unsafe int InvariantFindString(char* source, int sourceCount, char* value, int valueCount, bool ignoreCase, bool start) + private static unsafe int InvariantFindString(char* source, int sourceCount, char* value, int valueCount, bool ignoreCase, bool fromBeginning) { int ctrSource = 0; // index value into source int ctrValue = 0; // index value into value @@ -72,7 +72,7 @@ private static unsafe int InvariantFindString(char* source, int sourceCount, cha if (valueCount == 0) { - return start ? 0 : sourceCount - 1; + return fromBeginning ? 0 : sourceCount - 1; } if (sourceCount < valueCount) @@ -80,7 +80,7 @@ private static unsafe int InvariantFindString(char* source, int sourceCount, cha return -1; } - if (start) + if (fromBeginning) { lastSourceStart = sourceCount - valueCount; if (ignoreCase) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs index 25c9d34c33dd..f51754009964 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Unix.cs @@ -88,7 +88,7 @@ internal static unsafe int IndexOfOrdinalCore(string source, string value, int s return -1; } - internal static unsafe int IndexOfOrdinalCore(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase) + internal static unsafe int IndexOfOrdinalCore(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase, bool fromBeginning) { Debug.Assert(!GlobalizationMode.Invariant); @@ -105,13 +105,29 @@ internal static unsafe int IndexOfOrdinalCore(ReadOnlySpan source, ReadOnl fixed (char* pSource = &MemoryMarshal.GetReference(source)) fixed (char* pValue = &MemoryMarshal.GetReference(value)) { - int index = Interop.Globalization.IndexOfOrdinalIgnoreCase(pValue, value.Length, pSource, source.Length, findLast: false); - return index; + return Interop.Globalization.IndexOfOrdinalIgnoreCase(pValue, value.Length, pSource, source.Length, findLast: !fromBeginning); } } - int endIndex = source.Length - value.Length; - for (int i = 0; i <= endIndex; i++) + int startIndex, endIndex, jump; + if (fromBeginning) + { + // Left to right, from zero to last possible index in the source string. + // Incrementing by one after each iteration. Stop condition is last possible index plus 1. + startIndex = 0; + endIndex = source.Length - value.Length + 1; + jump = 1; + } + else + { + // Right to left, from first possible index in the source string to zero. + // Decrementing by one after each iteration. Stop condition is last possible index minus 1. + startIndex = source.Length - value.Length; + endIndex = -1; + jump = -1; + } + + for (int i = startIndex; i != endIndex; i += jump) { int valueIndex, sourceIndex; @@ -259,15 +275,16 @@ internal unsafe int IndexOfCore(string source, string target, int startIndex, in #endif fixed (char* pSource = source) + fixed (char* pTarget = target) { - index = Interop.Globalization.IndexOf(_sortHandle, target, target.Length, pSource + startIndex, count, options, matchLengthPtr); + index = Interop.Globalization.IndexOf(_sortHandle, pTarget, target.Length, pSource + startIndex, count, options, matchLengthPtr); return index != -1 ? index + startIndex : -1; } } // For now, this method is only called from Span APIs with either options == CompareOptions.None or CompareOptions.IgnoreCase - internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr) + internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr, bool fromBeginning) { Debug.Assert(!_invariantMode); Debug.Assert(source.Length != 0); @@ -276,25 +293,29 @@ internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan ta if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options)) { if ((options & CompareOptions.IgnoreCase) == CompareOptions.IgnoreCase) - { - return IndexOfOrdinalIgnoreCaseHelper(source, target, options, matchLengthPtr); - } + return IndexOfOrdinalIgnoreCaseHelper(source, target, options, matchLengthPtr, fromBeginning); else - { - return IndexOfOrdinalHelper(source, target, options, matchLengthPtr); - } + return IndexOfOrdinalHelper(source, target, options, matchLengthPtr, fromBeginning); } else { fixed (char* pSource = &MemoryMarshal.GetReference(source)) fixed (char* pTarget = &MemoryMarshal.GetReference(target)) { - return Interop.Globalization.IndexOf(_sortHandle, pTarget, target.Length, pSource, source.Length, options, matchLengthPtr); + if (fromBeginning) + return Interop.Globalization.IndexOf(_sortHandle, pTarget, target.Length, pSource, source.Length, options, matchLengthPtr); + else + return Interop.Globalization.LastIndexOf(_sortHandle, pTarget, target.Length, pSource, source.Length, options); } } } - private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr) + /// + /// Duplicate of IndexOfOrdinalHelper that also handles ignore case. Can't converge both methods + /// as the JIT wouldn't be able to optimize the ignoreCase path away. + /// + /// + private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr, bool fromBeginning) { Debug.Assert(!_invariantMode); @@ -307,9 +328,8 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, Rea { char* a = ap; char* b = bp; - int endIndex = source.Length - target.Length; - if (endIndex < 0) + if (target.Length > source.Length) goto InteropCall; for (int j = 0; j < target.Length; j++) @@ -319,20 +339,36 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, Rea goto InteropCall; } - int i = 0; - for (; i <= endIndex; i++) + int startIndex, endIndex, jump; + if (fromBeginning) + { + // Left to right, from zero to last possible index in the source string. + // Incrementing by one after each iteration. Stop condition is last possible index plus 1. + startIndex = 0; + endIndex = source.Length - target.Length + 1; + jump = 1; + } + else + { + // Right to left, from first possible index in the source string to zero. + // Decrementing by one after each iteration. Stop condition is last possible index minus 1. + startIndex = source.Length - target.Length; + endIndex = -1; + jump = -1; + } + + for (int i = startIndex; i != endIndex; i += jump) { int targetIndex = 0; int sourceIndex = i; - for (; targetIndex < target.Length; targetIndex++) + for (; targetIndex < target.Length; targetIndex++, sourceIndex++) { char valueChar = *(a + sourceIndex); char targetChar = *(b + targetIndex); if (valueChar == targetChar && valueChar < 0x80 && !s_highCharTable[valueChar]) { - sourceIndex++; continue; } @@ -346,7 +382,6 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, Rea goto InteropCall; else if (valueChar != targetChar) break; - sourceIndex++; } if (targetIndex == target.Length) @@ -356,14 +391,17 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan source, Rea return i; } } - if (i > endIndex) - return -1; - InteropCall: - return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); + + return -1; + InteropCall: + if (fromBeginning) + return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); + else + return Interop.Globalization.LastIndexOf(_sortHandle, b, target.Length, a, source.Length, options); } } - private unsafe int IndexOfOrdinalHelper(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr) + private unsafe int IndexOfOrdinalHelper(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr, bool fromBeginning) { Debug.Assert(!_invariantMode); @@ -376,9 +414,8 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan source, ReadOnlySpan< { char* a = ap; char* b = bp; - int endIndex = source.Length - target.Length; - if (endIndex < 0) + if (target.Length > source.Length) goto InteropCall; for (int j = 0; j < target.Length; j++) @@ -388,21 +425,38 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan source, ReadOnlySpan< goto InteropCall; } - int i = 0; - for (; i <= endIndex; i++) + int startIndex, endIndex, jump; + if (fromBeginning) + { + // Left to right, from zero to last possible index in the source string. + // Incrementing by one after each iteration. Stop condition is last possible index plus 1. + startIndex = 0; + endIndex = source.Length - target.Length + 1; + jump = 1; + } + else + { + // Right to left, from first possible index in the source string to zero. + // Decrementing by one after each iteration. Stop condition is last possible index minus 1. + startIndex = source.Length - target.Length; + endIndex = -1; + jump = -1; + } + + for (int i = startIndex; i != endIndex; i += jump) { int targetIndex = 0; int sourceIndex = i; - for (; targetIndex < target.Length; targetIndex++) + for (; targetIndex < target.Length; targetIndex++, sourceIndex++) { char valueChar = *(a + sourceIndex); char targetChar = *(b + targetIndex); + if (valueChar >= 0x80 || s_highCharTable[valueChar]) goto InteropCall; else if (valueChar != targetChar) break; - sourceIndex++; } if (targetIndex == target.Length) @@ -412,10 +466,13 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan source, ReadOnlySpan< return i; } } - if (i > endIndex) - return -1; + + return -1; InteropCall: - return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); + if (fromBeginning) + return Interop.Globalization.IndexOf(_sortHandle, b, target.Length, a, source.Length, options, matchLengthPtr); + else + return Interop.Globalization.LastIndexOf(_sortHandle, b, target.Length, a, source.Length, options); } } @@ -449,8 +506,9 @@ private unsafe int LastIndexOfCore(string source, string target, int startIndex, int leftStartIndex = (startIndex - count + 1); fixed (char* pSource = source) + fixed (char* pTarget = target) { - int lastIndex = Interop.Globalization.LastIndexOf(_sortHandle, target, target.Length, pSource + (startIndex - count + 1), count, options); + int lastIndex = Interop.Globalization.LastIndexOf(_sortHandle, pTarget, target.Length, pSource + (startIndex - count + 1), count, options); return lastIndex != -1 ? lastIndex + leftStartIndex : -1; } @@ -722,7 +780,7 @@ private unsafe bool EndsWithOrdinalHelper(ReadOnlySpan source, ReadOnlySpa } } - private unsafe SortKey CreateSortKey(String source, CompareOptions options) + private unsafe SortKey CreateSortKey(string source, CompareOptions options) { Debug.Assert(!_invariantMode); @@ -764,12 +822,12 @@ private static unsafe bool IsSortable(char *text, int length) while (index < length) { - if (Char.IsHighSurrogate(text[index])) + if (char.IsHighSurrogate(text[index])) { - if (index == length - 1 || !Char.IsLowSurrogate(text[index+1])) + if (index == length - 1 || !char.IsLowSurrogate(text[index+1])) return false; // unpaired surrogate - uc = CharUnicodeInfo.GetUnicodeCategory(Char.ConvertToUtf32(text[index], text[index+1])); + uc = CharUnicodeInfo.GetUnicodeCategory(char.ConvertToUtf32(text[index], text[index+1])); if (uc == UnicodeCategory.PrivateUse || uc == UnicodeCategory.OtherNotAssigned) return false; @@ -777,7 +835,7 @@ private static unsafe bool IsSortable(char *text, int length) continue; } - if (Char.IsLowSurrogate(text[index])) + if (char.IsLowSurrogate(text[index])) { return false; // unpaired surrogate } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs index 063095f31ec8..d1b12c664fb4 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.Windows.cs @@ -91,14 +91,15 @@ internal static int IndexOfOrdinalCore(string source, string value, int startInd return FindStringOrdinal(FIND_FROMSTART, source, startIndex, count, value, value.Length, ignoreCase); } - internal static int IndexOfOrdinalCore(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase) + internal static int IndexOfOrdinalCore(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase, bool fromBeginning) { Debug.Assert(!GlobalizationMode.Invariant); Debug.Assert(source.Length != 0); Debug.Assert(value.Length != 0); - return FindStringOrdinal(FIND_FROMSTART, source, value, ignoreCase); + uint positionFlag = fromBeginning ? (uint)FIND_FROMSTART : FIND_FROMEND; + return FindStringOrdinal(positionFlag, source, value, ignoreCase); } internal static int LastIndexOfOrdinalCore(string source, string value, int startIndex, int count, bool ignoreCase) @@ -316,7 +317,7 @@ private unsafe int FindString( } } - internal unsafe int IndexOfCore(String source, String target, int startIndex, int count, CompareOptions options, int* matchLengthPtr) + internal unsafe int IndexOfCore(string source, string target, int startIndex, int count, CompareOptions options, int* matchLengthPtr) { Debug.Assert(!_invariantMode); @@ -359,7 +360,7 @@ internal unsafe int IndexOfCore(String source, String target, int startIndex, in return -1; } - internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr) + internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan target, CompareOptions options, int* matchLengthPtr, bool fromBeginning) { Debug.Assert(!_invariantMode); @@ -367,8 +368,8 @@ internal unsafe int IndexOfCore(ReadOnlySpan source, ReadOnlySpan ta Debug.Assert(target.Length != 0); Debug.Assert((options == CompareOptions.None || options == CompareOptions.IgnoreCase)); - int retValue = FindString(FIND_FROMSTART | (uint)GetNativeCompareFlags(options), source, target, matchLengthPtr); - return retValue; + uint positionFlag = fromBeginning ? (uint)FIND_FROMSTART : FIND_FROMEND; + return FindString(positionFlag | (uint)GetNativeCompareFlags(options), source, target, matchLengthPtr); } private unsafe int LastIndexOfCore(string source, string target, int startIndex, int count, CompareOptions options) @@ -533,7 +534,7 @@ private static unsafe int FastIndexOfString(string source, string target, int st return retValue; } - private unsafe SortKey CreateSortKey(String source, CompareOptions options) + private unsafe SortKey CreateSortKey(string source, CompareOptions options) { Debug.Assert(!_invariantMode); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs index ef016369a878..92742c7b9fcc 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CompareInfo.cs @@ -107,7 +107,7 @@ public static CompareInfo GetCompareInfo(int culture, Assembly assembly) { throw new ArgumentNullException(nameof(assembly)); } - if (assembly != typeof(Object).Module.Assembly) + if (assembly != typeof(object).Module.Assembly) { throw new ArgumentException(SR.Argument_OnlyMscorlib); } @@ -134,7 +134,7 @@ public static CompareInfo GetCompareInfo(string name, Assembly assembly) throw new ArgumentNullException(name == null ? nameof(name) : nameof(assembly)); } - if (assembly != typeof(Object).Module.Assembly) + if (assembly != typeof(object).Module.Assembly) { throw new ArgumentException(SR.Argument_OnlyMscorlib); } @@ -633,7 +633,7 @@ internal static bool EqualsOrdinalIgnoreCase(ref char strA, ref char strB, int l // IsPrefix // // Determines whether prefix is a prefix of string. If prefix equals - // String.Empty, true is returned. + // string.Empty, true is returned. // //////////////////////////////////////////////////////////////////////// public virtual bool IsPrefix(string source, string prefix, CompareOptions options) @@ -698,7 +698,7 @@ public virtual bool IsPrefix(string source, string prefix) // IsSuffix // // Determines whether suffix is a suffix of string. If suffix equals - // String.Empty, true is returned. + // string.Empty, true is returned. // //////////////////////////////////////////////////////////////////////// public virtual bool IsSuffix(string source, string suffix, CompareOptions options) @@ -765,7 +765,7 @@ public virtual bool IsSuffix(string source, string suffix) // // Returns the first index where value is found in string. The // search starts from startIndex and ends at endIndex. Returns -1 if - // the specified value is not found. If value equals String.Empty, + // the specified value is not found. If value equals string.Empty, // startIndex is returned. Throws IndexOutOfRange if startIndex or // endIndex is less than zero or greater than the length of string. // Throws ArgumentException if value is null. @@ -939,7 +939,15 @@ internal int IndexOfOrdinal(ReadOnlySpan source, ReadOnlySpan value, Debug.Assert(!_invariantMode); Debug.Assert(!source.IsEmpty); Debug.Assert(!value.IsEmpty); - return IndexOfOrdinalCore(source, value, ignoreCase); + return IndexOfOrdinalCore(source, value, ignoreCase, fromBeginning: true); + } + + internal int LastIndexOfOrdinal(ReadOnlySpan source, ReadOnlySpan value, bool ignoreCase) + { + Debug.Assert(!_invariantMode); + Debug.Assert(!source.IsEmpty); + Debug.Assert(!value.IsEmpty); + return IndexOfOrdinalCore(source, value, ignoreCase, fromBeginning: false); } internal unsafe int IndexOf(ReadOnlySpan source, ReadOnlySpan value, CompareOptions options) @@ -947,7 +955,15 @@ internal unsafe int IndexOf(ReadOnlySpan source, ReadOnlySpan value, Debug.Assert(!_invariantMode); Debug.Assert(!source.IsEmpty); Debug.Assert(!value.IsEmpty); - return IndexOfCore(source, value, options, null); + return IndexOfCore(source, value, options, null, fromBeginning: true); + } + + internal unsafe int LastIndexOf(ReadOnlySpan source, ReadOnlySpan value, CompareOptions options) + { + Debug.Assert(!_invariantMode); + Debug.Assert(!source.IsEmpty); + Debug.Assert(!value.IsEmpty); + return IndexOfCore(source, value, options, null, fromBeginning: false); } // The following IndexOf overload is mainly used by String.Replace. This overload assumes the parameters are already validated @@ -1013,7 +1029,7 @@ internal int IndexOfOrdinal(string source, string value, int startIndex, int cou // // Returns the last index where value is found in string. The // search starts from startIndex and ends at endIndex. Returns -1 if - // the specified value is not found. If value equals String.Empty, + // the specified value is not found. If value equals string.Empty, // endIndex is returned. Throws IndexOutOfRange if startIndex or // endIndex is less than zero or greater than the length of string. // Throws ArgumentException if value is null. @@ -1021,7 +1037,7 @@ internal int IndexOfOrdinal(string source, string value, int startIndex, int cou //////////////////////////////////////////////////////////////////////// - public virtual int LastIndexOf(String source, char value) + public virtual int LastIndexOf(string source, char value) { if (source == null) throw new ArgumentNullException(nameof(source)); @@ -1236,7 +1252,7 @@ public virtual SortKey GetSortKey(string source) //////////////////////////////////////////////////////////////////////// - public override bool Equals(Object value) + public override bool Equals(object value) { CompareInfo that = value as CompareInfo; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs b/src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs index 3fce527929d9..4b21f2e7d3d5 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/CultureData.Unix.cs @@ -149,7 +149,7 @@ private string GetLocaleInfo(string localeName, LocaleStringData type) // Failed, just use empty string StringBuilderCache.Release(sb); Debug.Fail("[CultureData.GetLocaleInfo(LocaleStringData)] Failed"); - return String.Empty; + return string.Empty; } return StringBuilderCache.GetStringAndRelease(sb); } @@ -216,7 +216,7 @@ private string GetTimeFormatString(bool shortFormat) // Failed, just use empty string StringBuilderCache.Release(sb); Debug.Fail("[CultureData.GetTimeFormatString(bool shortFormat)] Failed"); - return String.Empty; + return string.Empty; } return ConvertIcuTimeFormatString(StringBuilderCache.GetStringAndRelease(sb)); @@ -227,19 +227,19 @@ private int GetFirstDayOfWeek() return this.GetLocaleInfo(LocaleNumberData.FirstDayOfWeek); } - private String[] GetTimeFormats() + private string[] GetTimeFormats() { string format = GetTimeFormatString(false); return new string[] { format }; } - private String[] GetShortTimeFormats() + private string[] GetShortTimeFormats() { string format = GetTimeFormatString(true); return new string[] { format }; } - private static CultureData GetCultureDataFromRegionName(String regionName) + private static CultureData GetCultureDataFromRegionName(string regionName) { // no support to lookup by region name, other than the hard-coded list in CultureData return null; @@ -371,7 +371,7 @@ private static CultureInfo[] EnumCultures(CultureTypes types) return Array.Empty(); } - Char [] chars = new Char[bufferLength]; + char [] chars = new char[bufferLength]; bufferLength = Interop.Globalization.GetLocales(chars, bufferLength); if (bufferLength <= 0) @@ -394,7 +394,7 @@ private static CultureInfo[] EnumCultures(CultureTypes types) int length = (int) chars[index++]; if (index + length <= bufferLength) { - CultureInfo ci = CultureInfo.GetCultureInfo(new String(chars, index, length)); + CultureInfo ci = CultureInfo.GetCultureInfo(new string(chars, index, length)); if ((enumNeutrals && ci.IsNeutralCulture) || (enumSpecificss && !ci.IsNeutralCulture)) { list.Add(ci); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs index 81e81d0dab9a..73fb0e9b3d62 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormat.cs @@ -165,7 +165,7 @@ class DateTimeFormat // If the digits of the value is greater than len, no leading zero is added. // // Notes: - // The function can format to Int32.MaxValue. + // The function can format to int.MaxValue. // //////////////////////////////////////////////////////////////////////////// internal static void FormatDigits(StringBuilder outputBuffer, int value, int len) @@ -765,10 +765,10 @@ private static StringBuilder FormatCustomized( // output the 'z' famliy of formats, which output a the offset from UTC, e.g. "-07:30" - private static void FormatCustomizedTimeZone(DateTime dateTime, TimeSpan offset, ReadOnlySpan format, Int32 tokenLen, Boolean timeOnly, StringBuilder result) + private static void FormatCustomizedTimeZone(DateTime dateTime, TimeSpan offset, ReadOnlySpan format, int tokenLen, bool timeOnly, StringBuilder result) { // See if the instance already has an offset - Boolean dateTimeFormat = (offset == NullOffset); + bool dateTimeFormat = (offset == NullOffset); if (dateTimeFormat) { // No offset. The instance is a DateTime and the output should be the local time zone @@ -1069,7 +1069,7 @@ private static StringBuilder FormatStringBuilder(DateTime dateTime, ReadOnlySpan Debug.Assert(dtfi != null); if (format.Length == 0) { - Boolean timeOnlySpecialCase = false; + bool timeOnlySpecialCase = false; if (dateTime.Ticks < Calendar.TicksPerDay) { // If the time is less than 1 day, consider it as time of day. diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs index edec75ac85bb..1b47c372cb2c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfo.cs @@ -58,10 +58,10 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable private CultureData _cultureData; // The culture name used to create this DTFI. - private String _name = null; + private string _name = null; // The language name of the culture used to create this DTFI. - private String _langName = null; + private string _langName = null; // CompareInfo usually used by the parser. private CompareInfo _compareInfo = null; @@ -73,28 +73,28 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable // Caches for various properties. // - private String amDesignator = null; - private String pmDesignator = null; + private string amDesignator = null; + private string pmDesignator = null; - private String dateSeparator = null; // derived from short date (whidbey expects, arrowhead doesn't) + private string dateSeparator = null; // derived from short date (whidbey expects, arrowhead doesn't) - private String generalShortTimePattern = null; // short date + short time (whidbey expects, arrowhead doesn't) + private string generalShortTimePattern = null; // short date + short time (whidbey expects, arrowhead doesn't) - private String generalLongTimePattern = null; // short date + long time (whidbey expects, arrowhead doesn't) + private string generalLongTimePattern = null; // short date + long time (whidbey expects, arrowhead doesn't) - private String timeSeparator = null; // derived from long time (whidbey expects, arrowhead doesn't) - private String monthDayPattern = null; + private string timeSeparator = null; // derived from long time (whidbey expects, arrowhead doesn't) + private string monthDayPattern = null; // added in .NET Framework Release {2.0SP1/3.0SP1/3.5RTM} - private String dateTimeOffsetPattern = null; + private string dateTimeOffsetPattern = null; // // The following are constant values. // - private const String rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; + private const string rfc1123Pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; // The sortable pattern is based on ISO 8601. - private const String sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; - private const String universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"; + private const string sortableDateTimePattern = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"; + private const string universalSortableDateTimePattern = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"; // // The following are affected by calendar settings. @@ -105,27 +105,27 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable private int calendarWeekRule = -1; - private String fullDateTimePattern = null; // long date + long time (whidbey expects, arrowhead doesn't) + private string fullDateTimePattern = null; // long date + long time (whidbey expects, arrowhead doesn't) - private String[] abbreviatedDayNames = null; + private string[] abbreviatedDayNames = null; - private String[] m_superShortDayNames = null; + private string[] m_superShortDayNames = null; - private String[] dayNames = null; - private String[] abbreviatedMonthNames = null; - private String[] monthNames = null; + private string[] dayNames = null; + private string[] abbreviatedMonthNames = null; + private string[] monthNames = null; // Cache the genitive month names that we retrieve from the data table. - private String[] genitiveMonthNames = null; + private string[] genitiveMonthNames = null; // Cache the abbreviated genitive month names that we retrieve from the data table. - private String[] m_genitiveAbbreviatedMonthNames = null; + private string[] m_genitiveAbbreviatedMonthNames = null; // Cache the month names of a leap year that we retrieve from the data table. - private String[] leapYearMonthNames = null; + private string[] leapYearMonthNames = null; // For our "patterns" arrays we have 2 variables, a string and a string[] // @@ -134,23 +134,23 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable // When we initially construct our string[], we set the string to string[0] // The "default" Date/time patterns - private String longDatePattern = null; - private String shortDatePattern = null; - private String yearMonthPattern = null; - private String longTimePattern = null; - private String shortTimePattern = null; + private string longDatePattern = null; + private string shortDatePattern = null; + private string yearMonthPattern = null; + private string longTimePattern = null; + private string shortTimePattern = null; - private String[] allYearMonthPatterns = null; + private string[] allYearMonthPatterns = null; - private String[] allShortDatePatterns = null; - private String[] allLongDatePatterns = null; - private String[] allShortTimePatterns = null; - private String[] allLongTimePatterns = null; + private string[] allShortDatePatterns = null; + private string[] allLongDatePatterns = null; + private string[] allShortTimePatterns = null; + private string[] allLongTimePatterns = null; // Cache the era names for this DateTimeFormatInfo instance. - private String[] m_eraNames = null; - private String[] m_abbrevEraNames = null; - private String[] m_abbrevEnglishEraNames = null; + private string[] m_eraNames = null; + private string[] m_abbrevEraNames = null; + private string[] m_abbrevEnglishEraNames = null; private CalendarId[] optionalCalendars = null; @@ -164,7 +164,7 @@ public sealed class DateTimeFormatInfo : IFormatProvider, ICloneable private DateTimeFormatFlags formatFlags = DateTimeFormatFlags.NotInitialized; - private String CultureName + private string CultureName { get { @@ -189,7 +189,7 @@ private CultureInfo Culture } // TODO: This ignores other cultures that might want to do something similar - private String LanguageName + private string LanguageName { get { @@ -261,9 +261,9 @@ private string[] internalGetDayOfWeekNamesCore() // //////////////////////////////////////////////////////////////////////////// - private String[] internalGetAbbreviatedMonthNames() => this.abbreviatedMonthNames ?? internalGetAbbreviatedMonthNamesCore(); + private string[] internalGetAbbreviatedMonthNames() => this.abbreviatedMonthNames ?? internalGetAbbreviatedMonthNamesCore(); [MethodImpl(MethodImplOptions.NoInlining)] - private String[] internalGetAbbreviatedMonthNamesCore() + private string[] internalGetAbbreviatedMonthNamesCore() { // Get the month names for our current calendar this.abbreviatedMonthNames = _cultureData.AbbreviatedMonthNames(Calendar.ID); @@ -386,13 +386,13 @@ public static DateTimeFormatInfo GetInstance(IFormatProvider provider) => provider.GetFormat(typeof(DateTimeFormatInfo)) is DateTimeFormatInfo info2 ? info2 : CurrentInfo; // Couldn't get anything, just use currentInfo as fallback - public Object GetFormat(Type formatType) + public object GetFormat(Type formatType) { return (formatType == typeof(DateTimeFormatInfo) ? this : null); } - public Object Clone() + public object Clone() { DateTimeFormatInfo n = (DateTimeFormatInfo)MemberwiseClone(); // We can use the data member calendar in the setter, instead of the property Calendar, @@ -403,7 +403,7 @@ public Object Clone() } - public String AMDesignator + public string AMDesignator { get { @@ -546,7 +546,7 @@ private CalendarId[] OptionalCalendars ============================================================================*/ - public int GetEra(String eraName) + public int GetEra(string eraName) { if (eraName == null) { @@ -602,7 +602,7 @@ public int GetEra(String eraName) } - internal String[] EraNames + internal string[] EraNames { get { @@ -624,7 +624,7 @@ internal String[] EraNames ============================================================================*/ // Era names are 1 indexed - public String GetEraName(int era) + public string GetEraName(int era) { if (era == Calendar.CurrentEra) { @@ -641,7 +641,7 @@ public String GetEraName(int era) throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue); } - internal String[] AbbreviatedEraNames + internal string[] AbbreviatedEraNames { get { @@ -654,7 +654,7 @@ internal String[] AbbreviatedEraNames } // Era names are 1 indexed - public String GetAbbreviatedEraName(int era) + public string GetAbbreviatedEraName(int era) { if (AbbreviatedEraNames.Length == 0) { @@ -673,7 +673,7 @@ public String GetAbbreviatedEraName(int era) throw new ArgumentOutOfRangeException(nameof(era), SR.ArgumentOutOfRange_InvalidEraValue); } - internal String[] AbbreviatedEnglishEraNames + internal string[] AbbreviatedEnglishEraNames { get { @@ -772,7 +772,7 @@ public CalendarWeekRule CalendarWeekRule } } - public String FullDateTimePattern + public string FullDateTimePattern { get { @@ -802,7 +802,7 @@ public String FullDateTimePattern // The string[] contains the list of patterns, EXCEPT the default may not be included. // The string contains the default pattern. // When we initially construct our string[], we set the string to string[0] - public String LongDatePattern + public string LongDatePattern { get { @@ -842,7 +842,7 @@ public String LongDatePattern // The string[] contains the list of patterns, EXCEPT the default may not be included. // The string contains the default pattern. // When we initially construct our string[], we set the string to string[0] - public String LongTimePattern + public string LongTimePattern { get { @@ -881,7 +881,7 @@ public String LongTimePattern // Note: just to be confusing there's only 1 month day pattern, not a whole list - public String MonthDayPattern + public string MonthDayPattern { get { @@ -909,7 +909,7 @@ public String MonthDayPattern } - public String PMDesignator + public string PMDesignator { get { @@ -937,7 +937,7 @@ public String PMDesignator } - public String RFC1123Pattern + public string RFC1123Pattern { get { @@ -950,7 +950,7 @@ public String RFC1123Pattern // The string[] contains the list of patterns, EXCEPT the default may not be included. // The string contains the default pattern. // When we initially construct our string[], we set the string to string[0] - public String ShortDatePattern + public string ShortDatePattern { get { @@ -991,7 +991,7 @@ public String ShortDatePattern // The string[] contains the list of patterns, EXCEPT the default may not be included. // The string contains the default pattern. // When we initially construct our string[], we set the string to string[0] - public String ShortTimePattern + public string ShortTimePattern { get { @@ -1026,7 +1026,7 @@ public String ShortTimePattern } - public String SortableDateTimePattern + public string SortableDateTimePattern { get { @@ -1041,7 +1041,7 @@ public String SortableDateTimePattern ** concatation every time somebody asks for the general format. ==============================================================================*/ - internal String GeneralShortTimePattern + internal string GeneralShortTimePattern { get { @@ -1060,7 +1060,7 @@ internal String GeneralShortTimePattern ** concatation every time somebody asks for the general format. ==============================================================================*/ - internal String GeneralLongTimePattern + internal string GeneralLongTimePattern { get { @@ -1079,7 +1079,7 @@ internal String GeneralLongTimePattern ** concatation every time somebody uses this form ==============================================================================*/ - internal String DateTimeOffsetPattern + internal string DateTimeOffsetPattern { get { @@ -1168,7 +1168,7 @@ public string TimeSeparator } } - public String UniversalSortableDateTimePattern + public string UniversalSortableDateTimePattern { get { @@ -1181,7 +1181,7 @@ public String UniversalSortableDateTimePattern // The string[] contains the list of patterns, EXCEPT the default may not be included. // The string contains the default pattern. // When we initially construct our string[], we set the string to string[0] - public String YearMonthPattern + public string YearMonthPattern { get { @@ -1215,7 +1215,7 @@ public String YearMonthPattern // // Check if a string array contains a null value, and throw ArgumentNullException with parameter name "value" // - private static void CheckNullValue(String[] values, int length) + private static void CheckNullValue(string[] values, int length) { Debug.Assert(values != null, "value != null"); Debug.Assert(values.Length >= length); @@ -1230,11 +1230,11 @@ private static void CheckNullValue(String[] values, int length) } - public String[] AbbreviatedDayNames + public string[] AbbreviatedDayNames { get { - return ((String[])internalGetAbbreviatedDayOfWeekNames().Clone()); + return ((string[])internalGetAbbreviatedDayOfWeekNames().Clone()); } set @@ -1258,11 +1258,11 @@ public String[] AbbreviatedDayNames } // Returns the string array of the one-letter day of week names. - public String[] ShortestDayNames + public string[] ShortestDayNames { get { - return ((String[])internalGetSuperShortDayNames().Clone()); + return ((string[])internalGetSuperShortDayNames().Clone()); } set @@ -1284,11 +1284,11 @@ public String[] ShortestDayNames } - public String[] DayNames + public string[] DayNames { get { - return ((String[])internalGetDayOfWeekNames().Clone()); + return ((string[])internalGetDayOfWeekNames().Clone()); } set @@ -1312,11 +1312,11 @@ public String[] DayNames } - public String[] AbbreviatedMonthNames + public string[] AbbreviatedMonthNames { get { - return ((String[])internalGetAbbreviatedMonthNames().Clone()); + return ((string[])internalGetAbbreviatedMonthNames().Clone()); } set @@ -1339,11 +1339,11 @@ public String[] AbbreviatedMonthNames } - public String[] MonthNames + public string[] MonthNames { get { - return ((String[])internalGetMonthNames().Clone()); + return ((string[])internalGetMonthNames().Clone()); } set @@ -1398,13 +1398,13 @@ internal bool HasSpacesInDayNames // Exceptions: // ArgumentOutOfRangeException When month name is invalid. // - internal String internalGetMonthName(int month, MonthNameStyles style, bool abbreviated) + internal string internalGetMonthName(int month, MonthNameStyles style, bool abbreviated) { // // Right now, style is mutual exclusive, but I make the style to be flag so that // maybe we can combine flag if there is such a need. // - String[] monthNamesArray = null; + string[] monthNamesArray = null; switch (style) { case MonthNameStyles.Genitive: @@ -1436,7 +1436,7 @@ internal String internalGetMonthName(int month, MonthNameStyles style, bool abbr // Arguments: // abbreviated When true, return abbreviated form. Otherwise, return a full form. // - private String[] internalGetGenitiveMonthNames(bool abbreviated) + private string[] internalGetGenitiveMonthNames(bool abbreviated) { if (abbreviated) { @@ -1465,7 +1465,7 @@ private String[] internalGetGenitiveMonthNames(bool abbreviated) // If this culture does not have different month names in a leap year, the normal month name is returned. // Arguments: None. (can use abbreviated later if needed) // - internal String[] internalGetLeapYearMonthNames(/*bool abbreviated*/) + internal string[] internalGetLeapYearMonthNames(/*bool abbreviated*/) { if (this.leapYearMonthNames == null) { @@ -1478,7 +1478,7 @@ internal String[] internalGetLeapYearMonthNames(/*bool abbreviated*/) } - public String GetAbbreviatedDayName(DayOfWeek dayofweek) + public string GetAbbreviatedDayName(DayOfWeek dayofweek) { if ((int)dayofweek < 0 || (int)dayofweek > 6) { @@ -1510,13 +1510,13 @@ public string GetShortestDayName(DayOfWeek dayOfWeek) } // Get all possible combination of inputs - private static String[] GetCombinedPatterns(String[] patterns1, String[] patterns2, String connectString) + private static string[] GetCombinedPatterns(string[] patterns1, string[] patterns2, string connectString) { Debug.Assert(patterns1 != null); Debug.Assert(patterns2 != null); // Get array size - String[] result = new String[patterns1.Length * patterns2.Length]; + string[] result = new string[patterns1.Length * patterns2.Length]; // Counter of actual results int k = 0; @@ -1535,11 +1535,11 @@ private static String[] GetCombinedPatterns(String[] patterns1, String[] pattern public string[] GetAllDateTimePatterns() { - List results = new List(DEFAULT_ALL_DATETIMES_SIZE); + List results = new List(DEFAULT_ALL_DATETIMES_SIZE); for (int i = 0; i < DateTimeFormat.allStandardFormats.Length; i++) { - String[] strings = GetAllDateTimePatterns(DateTimeFormat.allStandardFormats[i]); + string[] strings = GetAllDateTimePatterns(DateTimeFormat.allStandardFormats[i]); for (int j = 0; j < strings.Length; j++) { results.Add(strings[j]); @@ -1550,7 +1550,7 @@ public string[] GetAllDateTimePatterns() public string[] GetAllDateTimePatterns(char format) { - String[] result = null; + string[] result = null; switch (format) { @@ -1575,18 +1575,18 @@ public string[] GetAllDateTimePatterns(char format) break; case 'm': case 'M': - result = new String[] { MonthDayPattern }; + result = new string[] { MonthDayPattern }; break; case 'o': case 'O': - result = new String[] { RoundtripFormat }; + result = new string[] { RoundtripFormat }; break; case 'r': case 'R': - result = new String[] { rfc1123Pattern }; + result = new string[] { rfc1123Pattern }; break; case 's': - result = new String[] { sortableDateTimePattern }; + result = new string[] { sortableDateTimePattern }; break; case 't': result = this.AllShortTimePatterns; @@ -1595,7 +1595,7 @@ public string[] GetAllDateTimePatterns(char format) result = this.AllLongTimePatterns; break; case 'u': - result = new String[] { UniversalSortableDateTimePattern }; + result = new string[] { UniversalSortableDateTimePattern }; break; case 'y': case 'Y': @@ -1608,7 +1608,7 @@ public string[] GetAllDateTimePatterns(char format) } - public String GetDayName(DayOfWeek dayofweek) + public string GetDayName(DayOfWeek dayofweek) { if ((int)dayofweek < 0 || (int)dayofweek > 6) { @@ -1621,7 +1621,7 @@ public String GetDayName(DayOfWeek dayofweek) return (internalGetDayOfWeekNames()[(int)dayofweek]); } - public String GetAbbreviatedMonthName(int month) + public string GetAbbreviatedMonthName(int month) { if (month < 1 || month > 13) { @@ -1633,7 +1633,7 @@ public String GetAbbreviatedMonthName(int month) return (internalGetAbbreviatedMonthNames()[month - 1]); } - public String GetMonthName(int month) + public string GetMonthName(int month) { if (month < 1 || month > 13) { @@ -1690,7 +1690,7 @@ private static string[] GetMergedPatterns(string[] patterns, string defaultPatte else { // Not found, make room for it - newPatterns = new String[patterns.Length + 1]; + newPatterns = new string[patterns.Length + 1]; // Copy existing array Array.Copy(patterns, 0, newPatterns, 1, patterns.Length); @@ -1704,12 +1704,12 @@ private static string[] GetMergedPatterns(string[] patterns, string defaultPatte } // Needed by DateTimeFormatInfo and DateTimeFormat - internal const String RoundtripFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; - internal const String RoundtripDateTimeUnfixed = "yyyy'-'MM'-'ddTHH':'mm':'ss zzz"; + internal const string RoundtripFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK"; + internal const string RoundtripDateTimeUnfixed = "yyyy'-'MM'-'ddTHH':'mm':'ss zzz"; // Default string isn't necessarily in our string array, so get the // merged patterns of both - private String[] AllYearMonthPatterns + private string[] AllYearMonthPatterns { get { @@ -1717,7 +1717,7 @@ private String[] AllYearMonthPatterns } } - private String[] AllShortDatePatterns + private string[] AllShortDatePatterns { get { @@ -1725,7 +1725,7 @@ private String[] AllShortDatePatterns } } - private String[] AllShortTimePatterns + private string[] AllShortTimePatterns { get { @@ -1733,7 +1733,7 @@ private String[] AllShortTimePatterns } } - private String[] AllLongDatePatterns + private string[] AllLongDatePatterns { get { @@ -1741,7 +1741,7 @@ private String[] AllLongDatePatterns } } - private String[] AllLongTimePatterns + private string[] AllLongTimePatterns { get { @@ -1751,7 +1751,7 @@ private String[] AllLongTimePatterns // NOTE: Clone this string array if you want to return it to user. Otherwise, you are returning a writable cache copy. // This won't include default, call AllYearMonthPatterns - private String[] UnclonedYearMonthPatterns + private string[] UnclonedYearMonthPatterns { get { @@ -1770,7 +1770,7 @@ private String[] UnclonedYearMonthPatterns // NOTE: Clone this string array if you want to return it to user. Otherwise, you are returning a writable cache copy. // This won't include default, call AllShortDatePatterns - private String[] UnclonedShortDatePatterns + private string[] UnclonedShortDatePatterns { get { @@ -1788,7 +1788,7 @@ private String[] UnclonedShortDatePatterns // NOTE: Clone this string array if you want to return it to user. Otherwise, you are returning a writable cache copy. // This won't include default, call AllLongDatePatterns - private String[] UnclonedLongDatePatterns + private string[] UnclonedLongDatePatterns { get { @@ -1806,7 +1806,7 @@ private String[] UnclonedLongDatePatterns // NOTE: Clone this string array if you want to return it to user. Otherwise, you are returning a writable cache copy. // This won't include default, call AllShortTimePatterns - private String[] UnclonedShortTimePatterns + private string[] UnclonedShortTimePatterns { get { @@ -1823,7 +1823,7 @@ private String[] UnclonedShortTimePatterns // NOTE: Clone this string array if you want to return it to user. Otherwise, you are returning a writable cache copy. // This won't include default, call AllLongTimePatterns - private String[] UnclonedLongTimePatterns + private string[] UnclonedLongTimePatterns { get { @@ -1896,7 +1896,7 @@ public string NativeCalendarName // // WARNING: If more validation is ever done in one place, it should be done in the other. // - public void SetAllDateTimePatterns(String[] patterns, char format) + public void SetAllDateTimePatterns(string[] patterns, char format) { if (IsReadOnly) throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); @@ -1957,11 +1957,11 @@ public void SetAllDateTimePatterns(String[] patterns, char format) ClearTokenHashTable(); } - public String[] AbbreviatedMonthGenitiveNames + public string[] AbbreviatedMonthGenitiveNames { get { - return ((String[])internalGetGenitiveMonthNames(true).Clone()); + return ((string[])internalGetGenitiveMonthNames(true).Clone()); } set @@ -1983,11 +1983,11 @@ public String[] AbbreviatedMonthGenitiveNames } } - public String[] MonthGenitiveNames + public string[] MonthGenitiveNames { get { - return ((String[])internalGetGenitiveMonthNames(false).Clone()); + return ((string[])internalGetGenitiveMonthNames(false).Clone()); } set @@ -2013,7 +2013,7 @@ public String[] MonthGenitiveNames // Positive TimeSpan Pattern // private string _fullTimeSpanPositivePattern; - internal String FullTimeSpanPositivePattern + internal string FullTimeSpanPositivePattern { get { @@ -2024,7 +2024,7 @@ internal String FullTimeSpanPositivePattern cultureDataWithoutUserOverrides = CultureData.GetCultureData(_cultureData.CultureName, false); else cultureDataWithoutUserOverrides = _cultureData; - String decimalSeparator = new NumberFormatInfo(cultureDataWithoutUserOverrides).NumberDecimalSeparator; + string decimalSeparator = new NumberFormatInfo(cultureDataWithoutUserOverrides).NumberDecimalSeparator; _fullTimeSpanPositivePattern = "d':'h':'mm':'ss'" + decimalSeparator + "'FFFFFFF"; } @@ -2036,7 +2036,7 @@ internal String FullTimeSpanPositivePattern // Negative TimeSpan Pattern // private string _fullTimeSpanNegativePattern; - internal String FullTimeSpanNegativePattern + internal string FullTimeSpanNegativePattern { get { @@ -2070,7 +2070,7 @@ internal CompareInfo CompareInfo | DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal | DateTimeStyles.AssumeUniversal | DateTimeStyles.RoundtripKind); - internal static void ValidateStyles(DateTimeStyles style, String parameterName) + internal static void ValidateStyles(DateTimeStyles style, string parameterName) { if ((style & InvalidDateTimeStyles) != 0) { @@ -2106,7 +2106,7 @@ private DateTimeFormatFlags InitializeFormatFlags() return formatFlags; } - internal Boolean HasForceTwoDigitYears + internal bool HasForceTwoDigitYears { get { @@ -2129,7 +2129,7 @@ internal Boolean HasForceTwoDigitYears } // Returns whether the YearMonthAdjustment function has any fix-up work to do for this culture/calendar. - internal Boolean HasYearMonthAdjustment + internal bool HasYearMonthAdjustment { get { @@ -2142,7 +2142,7 @@ internal Boolean HasYearMonthAdjustment // the Hebrew calendar, but this could be extended to other cultures. // // The return value is whether the year and month are actually valid for this calendar. - internal Boolean YearMonthAdjustment(ref int year, ref int month, Boolean parsedMonthName) + internal bool YearMonthAdjustment(ref int year, ref int month, bool parsedMonthName) { if ((FormatFlags & DateTimeFormatFlags.UseHebrewRule) != 0) { @@ -2189,45 +2189,45 @@ internal Boolean YearMonthAdjustment(ref int year, ref int month, Boolean parsed private const int TOKEN_HASH_SIZE = 199; private const int SECOND_PRIME = 197; - private const String dateSeparatorOrTimeZoneOffset = "-"; - private const String invariantDateSeparator = "/"; - private const String invariantTimeSeparator = ":"; + private const string dateSeparatorOrTimeZoneOffset = "-"; + private const string invariantDateSeparator = "/"; + private const string invariantTimeSeparator = ":"; // // Common Ignorable Symbols // - internal const String IgnorablePeriod = "."; - internal const String IgnorableComma = ","; + internal const string IgnorablePeriod = "."; + internal const string IgnorableComma = ","; // // Year/Month/Day suffixes // - internal const String CJKYearSuff = "\u5e74"; - internal const String CJKMonthSuff = "\u6708"; - internal const String CJKDaySuff = "\u65e5"; + internal const string CJKYearSuff = "\u5e74"; + internal const string CJKMonthSuff = "\u6708"; + internal const string CJKDaySuff = "\u65e5"; - internal const String KoreanYearSuff = "\ub144"; - internal const String KoreanMonthSuff = "\uc6d4"; - internal const String KoreanDaySuff = "\uc77c"; + internal const string KoreanYearSuff = "\ub144"; + internal const string KoreanMonthSuff = "\uc6d4"; + internal const string KoreanDaySuff = "\uc77c"; - internal const String KoreanHourSuff = "\uc2dc"; - internal const String KoreanMinuteSuff = "\ubd84"; - internal const String KoreanSecondSuff = "\ucd08"; + internal const string KoreanHourSuff = "\uc2dc"; + internal const string KoreanMinuteSuff = "\ubd84"; + internal const string KoreanSecondSuff = "\ucd08"; - internal const String CJKHourSuff = "\u6642"; - internal const String ChineseHourSuff = "\u65f6"; + internal const string CJKHourSuff = "\u6642"; + internal const string ChineseHourSuff = "\u65f6"; - internal const String CJKMinuteSuff = "\u5206"; - internal const String CJKSecondSuff = "\u79d2"; + internal const string CJKMinuteSuff = "\u5206"; + internal const string CJKSecondSuff = "\u79d2"; - internal const String LocalTimeMark = "T"; + internal const string LocalTimeMark = "T"; - internal const String GMTName = "GMT"; - internal const String ZuluName = "Z"; + internal const string GMTName = "GMT"; + internal const string ZuluName = "Z"; - internal const String KoreanLangName = "ko"; - internal const String JapaneseLangName = "ja"; - internal const String EnglishLangName = "en"; + internal const string KoreanLangName = "ko"; + internal const string JapaneseLangName = "ja"; + internal const string EnglishLangName = "en"; private static volatile DateTimeFormatInfo s_jajpDTFI; private static volatile DateTimeFormatInfo s_zhtwDTFI; @@ -2341,7 +2341,7 @@ internal TokenHashValue[] CreateTokenHashTable() InsertHash(temp, dateSeparatorOrTimeZoneOffset, TokenType.SEP_DateOrOffset, 0); } - String[] dateWords = null; + string[] dateWords = null; DateTimeFormatInfoScanner scanner = null; // We need to rescan the date words since we're always synthetic @@ -2355,7 +2355,7 @@ internal TokenHashValue[] CreateTokenHashTable() // This is determined in DateTimeFormatInfoScanner. Use this flag to determine if we should treat date separator as ignorable symbol. bool useDateSepAsIgnorableSymbol = false; - String monthPostfix = null; + string monthPostfix = null; if (dateWords != null) { // There are DateWords. It could be a real date word (such as "de"), or a monthPostfix. @@ -2372,7 +2372,7 @@ internal TokenHashValue[] CreateTokenHashTable() AddMonthNames(temp, monthPostfix); break; case DateTimeFormatInfoScanner.IgnorableSymbolChar: - String symbol = dateWords[i].Substring(1); + string symbol = dateWords[i].Substring(1); InsertHash(temp, symbol, TokenType.IgnorableSymbol, 0); if (this.DateSeparator.Trim(null).Equals(symbol)) { @@ -2412,7 +2412,7 @@ internal TokenHashValue[] CreateTokenHashTable() { for (int i = 1; i <= 13; i++) { - String str; + string str; str = internalGetMonthName(i, MonthNameStyles.Genitive, false); InsertHash(temp, str, TokenType.MonthToken, i); } @@ -2422,7 +2422,7 @@ internal TokenHashValue[] CreateTokenHashTable() { for (int i = 1; i <= 13; i++) { - String str; + string str; str = internalGetMonthName(i, MonthNameStyles.LeapYear, false); InsertHash(temp, str, TokenType.MonthToken, i); } @@ -2432,7 +2432,7 @@ internal TokenHashValue[] CreateTokenHashTable() { //String str = GetDayOfWeekNames()[i]; // We have to call public methods here to work with inherited DTFI. - String str = GetDayName((DayOfWeek)i); + string str = GetDayName((DayOfWeek)i); InsertHash(temp, str, TokenType.DayOfWeekToken, i); str = GetAbbreviatedDayName((DayOfWeek)i); @@ -2452,7 +2452,7 @@ internal TokenHashValue[] CreateTokenHashTable() // Japanese allows day of week forms like: "(Tue)" for (int i = 0; i < 7; i++) { - String specialDayOfWeek = "(" + GetAbbreviatedDayName((DayOfWeek)i) + ")"; + string specialDayOfWeek = "(" + GetAbbreviatedDayName((DayOfWeek)i) + ")"; InsertHash(temp, specialDayOfWeek, TokenType.DayOfWeekToken, i); } if (this.Calendar.GetType() != typeof(JapaneseCalendar)) @@ -2488,7 +2488,7 @@ internal TokenHashValue[] CreateTokenHashTable() // Add invariant month names and day names. for (int i = 1; i <= 12; i++) { - String str; + string str; // We have to call public methods here to work with inherited DTFI. // Insert the month name first, so that they are at the front of abbreviated // month names. @@ -2501,7 +2501,7 @@ internal TokenHashValue[] CreateTokenHashTable() for (int i = 0; i < 7; i++) { // We have to call public methods here to work with inherited DTFI. - String str = InvariantInfo.GetDayName((DayOfWeek)i); + string str = InvariantInfo.GetDayName((DayOfWeek)i); InsertHash(temp, str, TokenType.DayOfWeekToken, i); str = InvariantInfo.GetAbbreviatedDayName((DayOfWeek)i); @@ -2526,11 +2526,11 @@ internal TokenHashValue[] CreateTokenHashTable() return (temp); } - private void AddMonthNames(TokenHashValue[] temp, String monthPostfix) + private void AddMonthNames(TokenHashValue[] temp, string monthPostfix) { for (int i = 1; i <= 13; i++) { - String str; + string str; //str = internalGetMonthName(i, MonthNameStyles.Regular, false); // We have to call public methods here to work with inherited DTFI. // Insert the month name first, so that they are at the front of abbreviated @@ -2568,7 +2568,7 @@ private void AddMonthNames(TokenHashValue[] temp, String monthPostfix) private static bool TryParseHebrewNumber( ref __DTString str, - out Boolean badFormat, + out bool badFormat, out int number) { number = -1; @@ -2631,7 +2631,7 @@ internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tok Debug.Assert(str.Index < str.Value.Length, "DateTimeFormatInfo.Tokenize(): start < value.Length"); char ch = str.m_current; - bool isLetter = Char.IsLetter(ch); + bool isLetter = char.IsLetter(ch); if (isLetter) { ch = this.Culture.TextInfo.ToLower(ch); @@ -2689,7 +2689,7 @@ internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tok { // Check word boundary. The next character should NOT be a letter. char nextCh = str.Value[nextCharIndex]; - compareStrings = !(Char.IsLetter(nextCh)); + compareStrings = !(char.IsLetter(nextCh)); } } @@ -2724,7 +2724,7 @@ internal bool Tokenize(TokenType TokenMask, out TokenType tokenType, out int tok return (false); } - private void InsertAtCurrentHashNode(TokenHashValue[] hashTable, String str, char ch, TokenType tokenType, int tokenValue, int pos, int hashcode, int hashProbe) + private void InsertAtCurrentHashNode(TokenHashValue[] hashTable, string str, char ch, TokenType tokenType, int tokenValue, int pos, int hashcode, int hashProbe) { // Remember the current slot. TokenHashValue previousNode = hashTable[hashcode]; @@ -2757,7 +2757,7 @@ private void InsertAtCurrentHashNode(TokenHashValue[] hashTable, String str, cha Debug.Fail("The hashtable is full. This should not happen."); } - private void InsertHash(TokenHashValue[] hashTable, String str, TokenType tokenType, int tokenValue) + private void InsertHash(TokenHashValue[] hashTable, string str, TokenType tokenType, int tokenValue) { // The month of the 13th month is allowed to be null, so make sure that we ignore null value here. if (str == null || str.Length == 0) @@ -2768,7 +2768,7 @@ private void InsertHash(TokenHashValue[] hashTable, String str, TokenType tokenT int i = 0; // If there is whitespace characters in the beginning and end of the string, trim them since whitespaces are skipped by // DateTime.Parse(). - if (Char.IsWhiteSpace(str[0]) || Char.IsWhiteSpace(str[str.Length - 1])) + if (char.IsWhiteSpace(str[0]) || char.IsWhiteSpace(str[str.Length - 1])) { str = str.Trim(null); // Trim white space characters. // Could have space for separators @@ -2860,11 +2860,11 @@ private bool CompareStringIgnoreCaseOptimized(string string1, int offset1, int l internal class TokenHashValue { - internal String tokenString; + internal string tokenString; internal TokenType tokenType; internal int tokenValue; - internal TokenHashValue(String tokenString, TokenType tokenType, int tokenValue) + internal TokenHashValue(string tokenString, TokenType tokenType, int tokenValue) { this.tokenString = tokenString; this.tokenType = tokenType; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs index d7e0abfba1d2..de43c2da3ea9 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeFormatInfoScanner.cs @@ -189,7 +189,7 @@ internal static int SkipWhiteSpacesAndNonLetter(string pattern, int currentIndex break; } } - if (Char.IsLetter(ch) || ch == '\'' || ch == '.') + if (char.IsLetter(ch) || ch == '\'' || ch == '.') { break; } @@ -314,7 +314,7 @@ internal int AddDateWords(string pattern, int index, string formatPostfix) index++; } } - else if (Char.IsWhiteSpace(ch)) + else if (char.IsWhiteSpace(ch)) { // Found a whitespace. We have to add the current date word/postfix. AddDateWordOrPostfix(formatPostfix, dateWord.ToString()); @@ -479,7 +479,7 @@ internal void ScanDateWord(string pattern) i++; break; default: - if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !Char.IsWhiteSpace(ch)) + if (_ymdFlags == FoundDatePattern.FoundYMDPatternFlag && !char.IsWhiteSpace(ch)) { // We are not seeing "." after YMD. Clear the flag. _ymdFlags = FoundDatePattern.None; @@ -659,7 +659,7 @@ private static bool ArrayElementsHaveSpace(string[] array) // so we don't have to go to native code side. for (int j = 0; j < array[i].Length; j++) { - if (Char.IsWhiteSpace(array[i][j])) + if (char.IsWhiteSpace(array[i][j])) { return true; } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs index 0c2d6c406e97..b9da90078980 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/DateTimeParse.cs @@ -11,7 +11,7 @@ namespace System { internal static class DateTimeParse { - internal const Int32 MaxDateTimeNumberDigits = 8; + internal const int MaxDateTimeNumberDigits = 8; internal delegate bool MatchNumberDelegate(ref __DTString str, int digitLen, out int result); @@ -418,7 +418,7 @@ private static bool MatchWord(ref __DTString str, string target) if (nextCharIndex < str.Value.Length) { char nextCh = str.Value[nextCharIndex]; - if (Char.IsLetter(nextCh)) + if (char.IsLetter(nextCh)) { return (false); } @@ -573,7 +573,7 @@ private static bool HandleTimeZone(ref __DTString str, ref DateTimeResult result char nextCh = str.Value[str.Index]; // Skip whitespace, but don't update the index unless we find a time zone marker int whitespaceCount = 0; - while (Char.IsWhiteSpace(nextCh) && str.Index + whitespaceCount < str.Length - 1) + while (char.IsWhiteSpace(nextCh) && str.Index + whitespaceCount < str.Length - 1) { whitespaceCount++; nextCh = str.Value[str.Index + whitespaceCount]; @@ -602,7 +602,7 @@ private static bool HandleTimeZone(ref __DTString str, ref DateTimeResult result // This is the lexer. Check the character at the current index, and put the found token in dtok and // some raw date/time information in raw. // - private static Boolean Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi, DateTimeStyles styles) + private static bool Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, ref DateTimeRawInfo raw, ref DateTimeResult result, ref DateTimeFormatInfo dtfi, DateTimeStyles styles) { TokenType tokenType; int tokenValue; @@ -1119,7 +1119,7 @@ private static Boolean Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, r } break; case TokenType.UnknownToken: - if (Char.IsLetter(str.m_current)) + if (char.IsLetter(str.m_current)) { result.SetFailure(ParseFailureKind.FormatWithOriginalDateTimeAndParameter, nameof(SR.Format_UnknownDateTimeWord), str.Index); LexTraceExit("0200", dps); @@ -1128,7 +1128,7 @@ private static Boolean Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, r if ((str.m_current == '-' || str.m_current == '+') && ((result.flags & ParseFlags.TimeZoneUsed) == 0)) { - Int32 originalIndex = str.Index; + int originalIndex = str.Index; if (ParseTimeZone(ref str, ref result.timeZoneOffset)) { result.flags |= ParseFlags.TimeZoneUsed; @@ -1160,10 +1160,10 @@ private static Boolean Lex(DS dps, ref __DTString str, ref DateTimeToken dtok, r return true; } - private static Boolean VerifyValidPunctuation(ref __DTString str) + private static bool VerifyValidPunctuation(ref __DTString str) { // Compatability Behavior. Allow trailing nulls and surrounding hashes - Char ch = str.Value[str.Index]; + char ch = str.Value[str.Index]; if (ch == '#') { bool foundStart = false; @@ -1198,7 +1198,7 @@ private static Boolean VerifyValidPunctuation(ref __DTString str) return false; } } - else if ((!Char.IsWhiteSpace(ch))) + else if ((!char.IsWhiteSpace(ch))) { // Anything other than whitespace outside hashes is invalid if (!foundStart || foundEnd) @@ -1247,7 +1247,7 @@ private static Boolean VerifyValidPunctuation(ref __DTString str) // // Return 0 for YMD, 1 for MDY, 2 for DMY, otherwise -1. // - private static Boolean GetYearMonthDayOrder(string datePattern, DateTimeFormatInfo dtfi, out int order) + private static bool GetYearMonthDayOrder(string datePattern, DateTimeFormatInfo dtfi, out int order) { int yearOrder = -1; int monthOrder = -1; @@ -1345,7 +1345,7 @@ private static Boolean GetYearMonthDayOrder(string datePattern, DateTimeFormatIn // // Return 0 for YM, 1 for MY, otherwise -1. // - private static Boolean GetYearMonthOrder(string pattern, DateTimeFormatInfo dtfi, out int order) + private static bool GetYearMonthOrder(string pattern, DateTimeFormatInfo dtfi, out int order) { int yearOrder = -1; int monthOrder = -1; @@ -1411,7 +1411,7 @@ private static Boolean GetYearMonthOrder(string pattern, DateTimeFormatInfo dtfi // // Return 0 for MD, 1 for DM, otherwise -1. // - private static Boolean GetMonthDayOrder(string pattern, DateTimeFormatInfo dtfi, out int order) + private static bool GetMonthDayOrder(string pattern, DateTimeFormatInfo dtfi, out int order) { int monthOrder = -1; int dayOrder = -1; @@ -1539,7 +1539,7 @@ private static void GetDefaultYear(ref DateTimeResult result, ref DateTimeStyles } // Processing teriminal case: DS.DX_NN - private static Boolean GetDayOfNN(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfNN(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1582,7 +1582,7 @@ private static Boolean GetDayOfNN(ref DateTimeResult result, ref DateTimeStyles } // Processing teriminal case: DS.DX_NNN - private static Boolean GetDayOfNNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfNNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1639,7 +1639,7 @@ private static Boolean GetDayOfNNN(ref DateTimeResult result, ref DateTimeRawInf return false; } - private static Boolean GetDayOfMN(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfMN(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1701,7 +1701,7 @@ private static Boolean GetDayOfMN(ref DateTimeResult result, ref DateTimeStyles // //////////////////////////////////////////////////////////////////////// - private static Boolean GetHebrewDayOfNM(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetHebrewDayOfNM(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { int monthDayOrder; if (!GetMonthDayOrder(dtfi.MonthDayPattern, dtfi, out monthDayOrder)) @@ -1722,7 +1722,7 @@ private static Boolean GetHebrewDayOfNM(ref DateTimeResult result, ref DateTimeR return false; } - private static Boolean GetDayOfNM(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfNM(ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1778,7 +1778,7 @@ private static Boolean GetDayOfNM(ref DateTimeResult result, ref DateTimeStyles return true; } - private static Boolean GetDayOfMNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfMNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1848,7 +1848,7 @@ private static Boolean GetDayOfMNN(ref DateTimeResult result, ref DateTimeRawInf return false; } - private static Boolean GetDayOfYNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfYNN(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1883,7 +1883,7 @@ private static Boolean GetDayOfYNN(ref DateTimeResult result, ref DateTimeRawInf return false; } - private static Boolean GetDayOfNNY(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDayOfNNY(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1923,7 +1923,7 @@ private static Boolean GetDayOfNNY(ref DateTimeResult result, ref DateTimeRawInf } - private static Boolean GetDayOfYMN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetDayOfYMN(ref DateTimeResult result, ref DateTimeRawInfo raw) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1941,7 +1941,7 @@ private static Boolean GetDayOfYMN(ref DateTimeResult result, ref DateTimeRawInf return false; } - private static Boolean GetDayOfYN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetDayOfYN(ref DateTimeResult result, ref DateTimeRawInfo raw) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -1959,7 +1959,7 @@ private static Boolean GetDayOfYN(ref DateTimeResult result, ref DateTimeRawInfo return false; } - private static Boolean GetDayOfYM(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetDayOfYM(ref DateTimeResult result, ref DateTimeRawInfo raw) { if ((result.flags & ParseFlags.HaveDate) != 0) { @@ -2004,7 +2004,7 @@ private static void AdjustTimeMark(DateTimeFormatInfo dtfi, ref DateTimeRawInfo // // Adjust hour according to the time mark. // - private static Boolean AdjustHour(ref int hour, TM timeMark) + private static bool AdjustHour(ref int hour, TM timeMark) { if (timeMark != TM.NotSet) { @@ -2031,7 +2031,7 @@ private static Boolean AdjustHour(ref int hour, TM timeMark) return true; } - private static Boolean GetTimeOfN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetTimeOfN(ref DateTimeResult result, ref DateTimeRawInfo raw) { if ((result.flags & ParseFlags.HaveTime) != 0) { @@ -2052,7 +2052,7 @@ private static Boolean GetTimeOfN(ref DateTimeResult result, ref DateTimeRawInfo return true; } - private static Boolean GetTimeOfNN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetTimeOfNN(ref DateTimeResult result, ref DateTimeRawInfo raw) { Debug.Assert(raw.numCount >= 2, "raw.numCount >= 2"); if ((result.flags & ParseFlags.HaveTime) != 0) @@ -2068,7 +2068,7 @@ private static Boolean GetTimeOfNN(ref DateTimeResult result, ref DateTimeRawInf return true; } - private static Boolean GetTimeOfNNN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetTimeOfNNN(ref DateTimeResult result, ref DateTimeRawInfo raw) { if ((result.flags & ParseFlags.HaveTime) != 0) { @@ -2087,7 +2087,7 @@ private static Boolean GetTimeOfNNN(ref DateTimeResult result, ref DateTimeRawIn // // Processing terminal state: A Date suffix followed by one number. // - private static Boolean GetDateOfDSN(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetDateOfDSN(ref DateTimeResult result, ref DateTimeRawInfo raw) { if (raw.numCount != 1 || result.Day != -1) { @@ -2098,7 +2098,7 @@ private static Boolean GetDateOfDSN(ref DateTimeResult result, ref DateTimeRawIn return true; } - private static Boolean GetDateOfNDS(ref DateTimeResult result, ref DateTimeRawInfo raw) + private static bool GetDateOfNDS(ref DateTimeResult result, ref DateTimeRawInfo raw) { if (result.Month == -1) { @@ -2122,7 +2122,7 @@ private static Boolean GetDateOfNDS(ref DateTimeResult result, ref DateTimeRawIn return true; } - private static Boolean GetDateOfNNDS(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + private static bool GetDateOfNNDS(ref DateTimeResult result, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { // For partial CJK Dates, the only valid formats are with a specified year, followed by two numbers, which // will be the Month and Day, and with a specified Month, when the numbers are either the year and day or @@ -2236,7 +2236,7 @@ private static bool ProcessDateTimeSuffix(ref DateTimeResult result, ref DateTim // //////////////////////////////////////////////////////////////////////// - internal static Boolean ProcessHebrewTerminalState(DS dps, ref __DTString str, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + internal static bool ProcessHebrewTerminalState(DS dps, ref __DTString str, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { // The following are accepted terminal state for Hebrew date. switch (dps) @@ -2346,7 +2346,7 @@ internal static Boolean ProcessHebrewTerminalState(DS dps, ref __DTString str, r // A terminal state has been reached, call the appropriate function to fill in the parsing result. // Return true if the state is a terminal state. // - internal static Boolean ProcessTerminalState(DS dps, ref __DTString str, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) + internal static bool ProcessTerminalState(DS dps, ref __DTString str, ref DateTimeResult result, ref DateTimeStyles styles, ref DateTimeRawInfo raw, DateTimeFormatInfo dtfi) { bool passed = true; switch (dps) @@ -2516,7 +2516,7 @@ internal static bool TryParse(ReadOnlySpan s, DateTimeFormatInfo dtfi, Dat DateTimeRawInfo raw = new DateTimeRawInfo(); // The buffer to store temporary parsing information. unsafe { - Int32* numberPointer = stackalloc Int32[3]; + int* numberPointer = stackalloc int[3]; raw.Init(numberPointer); } raw.hasSameDateAndTimeSeparators = dtfi.DateSeparator.Equals(dtfi.TimeSeparator, StringComparison.Ordinal); @@ -2719,7 +2719,7 @@ internal static bool TryParse(ReadOnlySpan s, DateTimeFormatInfo dtfi, Dat result.parsedDate = time; - if (!DetermineTimeZoneAdjustments(ref str, ref result, styles, bTimeOnly)) + if (!DetermineTimeZoneAdjustments(ref result, styles, bTimeOnly)) { TPTraceExit("0120 (DetermineTimeZoneAdjustments)", dps); return false; @@ -2730,17 +2730,17 @@ internal static bool TryParse(ReadOnlySpan s, DateTimeFormatInfo dtfi, Dat // Handles time zone adjustments and sets DateTimeKind values as required by the styles - private static Boolean DetermineTimeZoneAdjustments(ref __DTString str, ref DateTimeResult result, DateTimeStyles styles, Boolean bTimeOnly) + private static bool DetermineTimeZoneAdjustments(ref DateTimeResult result, DateTimeStyles styles, bool bTimeOnly) { if ((result.flags & ParseFlags.CaptureOffset) != 0) { // This is a DateTimeOffset parse, so the offset will actually be captured directly, and // no adjustment is required in most cases - return DateTimeOffsetTimeZonePostProcessing(ref str, ref result, styles); + return DateTimeOffsetTimeZonePostProcessing(ref result, styles); } else { - Int64 offsetTicks = result.timeZoneOffset.Ticks; + long offsetTicks = result.timeZoneOffset.Ticks; // the DateTime offset must be within +- 14:00 hours. if (offsetTicks < DateTimeOffset.MinOffset || offsetTicks > DateTimeOffset.MaxOffset) @@ -2808,7 +2808,7 @@ private static Boolean DetermineTimeZoneAdjustments(ref __DTString str, ref Date } // Apply validation and adjustments specific to DateTimeOffset - private static Boolean DateTimeOffsetTimeZonePostProcessing(ref __DTString str, ref DateTimeResult result, DateTimeStyles styles) + private static bool DateTimeOffsetTimeZonePostProcessing(ref DateTimeResult result, DateTimeStyles styles) { // For DateTimeOffset, default to the Utc or Local offset when an offset was not specified by // the input string. @@ -2826,11 +2826,11 @@ private static Boolean DateTimeOffsetTimeZonePostProcessing(ref __DTString str, } } - Int64 offsetTicks = result.timeZoneOffset.Ticks; + long offsetTicks = result.timeZoneOffset.Ticks; // there should be no overflow, because the offset can be no more than -+100 hours and the date already // fits within a DateTime. - Int64 utcTicks = result.parsedDate.Ticks - offsetTicks; + long utcTicks = result.parsedDate.Ticks - offsetTicks; // For DateTimeOffset, both the parsed time and the corresponding UTC value must be within the boundaries // of a DateTime instance. @@ -2854,7 +2854,7 @@ private static Boolean DateTimeOffsetTimeZonePostProcessing(ref __DTString str, if (((result.flags & ParseFlags.TimeZoneUsed) == 0) && ((styles & DateTimeStyles.AssumeUniversal) == 0)) { // Handle the special case where the timeZoneOffset was defaulted to Local - Boolean toUtcResult = AdjustTimeZoneToUniversal(ref result); + bool toUtcResult = AdjustTimeZoneToUniversal(ref result); result.timeZoneOffset = TimeSpan.Zero; return toUtcResult; } @@ -2875,7 +2875,7 @@ private static Boolean DateTimeOffsetTimeZonePostProcessing(ref __DTString str, // the time is 2001/06/08 14:00, and timeZoneOffset = -07:00. // The result will be "2001/06/08 21:00" // - private static Boolean AdjustTimeZoneToUniversal(ref DateTimeResult result) + private static bool AdjustTimeZoneToUniversal(ref DateTimeResult result) { long resultTicks = result.parsedDate.Ticks; resultTicks -= result.timeZoneOffset.Ticks; @@ -2900,12 +2900,12 @@ private static Boolean AdjustTimeZoneToUniversal(ref DateTimeResult result) // the time is 2001/06/08 14:00, and timeZoneOffset = -05:00. // The result will be "2001/06/08 11:00" // - private static Boolean AdjustTimeZoneToLocal(ref DateTimeResult result, bool bTimeOnly) + private static bool AdjustTimeZoneToLocal(ref DateTimeResult result, bool bTimeOnly) { long resultTicks = result.parsedDate.Ticks; // Convert to local ticks TimeZoneInfo tz = TimeZoneInfo.Local; - Boolean isAmbiguousLocalDst = false; + bool isAmbiguousLocalDst = false; if (resultTicks < Calendar.TicksPerDay) { // @@ -2936,7 +2936,7 @@ private static Boolean AdjustTimeZoneToLocal(ref DateTimeResult result, bool bTi { // Convert the GMT time to local time. DateTime utcDt = new DateTime(resultTicks, DateTimeKind.Utc); - Boolean isDaylightSavings = false; + bool isDaylightSavings = false; resultTicks += TimeZoneInfo.GetUtcOffsetFromUtc(utcDt, TimeZoneInfo.Local, out isDaylightSavings, out isAmbiguousLocalDst).Ticks; } } @@ -3061,7 +3061,7 @@ private static bool ParseISO8601(ref DateTimeRawInfo raw, ref __DTString str, Da time = time.AddTicks((long)Math.Round(partSecond * Calendar.TicksPerSecond)); result.parsedDate = time; - if (!DetermineTimeZoneAdjustments(ref str, ref result, styles, false)) + if (!DetermineTimeZoneAdjustments(ref result, styles, false)) { return false; } @@ -3782,24 +3782,14 @@ private static string ExpandPredefinedFormat(ReadOnlySpan format, ref Date // switch (format[0]) { + case 's': // Sortable format (in local time) case 'o': case 'O': // Round Trip Format - parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); - dtfi = DateTimeFormatInfo.InvariantInfo; + ConfigureFormatOS(ref dtfi, ref parseInfo); break; case 'r': case 'R': // RFC 1123 Standard. (in Universal time) - parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); - dtfi = DateTimeFormatInfo.InvariantInfo; - - if ((result.flags & ParseFlags.CaptureOffset) != 0) - { - result.flags |= ParseFlags.Rfc1123Pattern; - } - break; - case 's': // Sortable format (in local time) - dtfi = DateTimeFormatInfo.InvariantInfo; - parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); + ConfigureFormatR(ref dtfi, ref parseInfo, ref result); break; case 'u': // Universal time format in sortable format. parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); @@ -3829,9 +3819,21 @@ private static string ExpandPredefinedFormat(ReadOnlySpan format, ref Date return (DateTimeFormat.GetRealFormat(format, dtfi)); } + private static void ConfigureFormatR(ref DateTimeFormatInfo dtfi, ref ParsingInfo parseInfo, ref DateTimeResult result) + { + parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); + dtfi = DateTimeFormatInfo.InvariantInfo; + if ((result.flags & ParseFlags.CaptureOffset) != 0) + { + result.flags |= ParseFlags.Rfc1123Pattern; + } + } - - + private static void ConfigureFormatOS(ref DateTimeFormatInfo dtfi, ref ParsingInfo parseInfo) + { + parseInfo.calendar = GregorianCalendar.GetDefaultInstance(); + dtfi = DateTimeFormatInfo.InvariantInfo; + } // Given a specified format character, parse and update the parsing result. // @@ -4443,12 +4445,32 @@ private static bool DoStrictParse( if (formatParam.Length == 1) { - if (((result.flags & ParseFlags.CaptureOffset) != 0) && formatParam[0] == 'U') + char formatParamChar = formatParam[0]; + + // Fast-paths for common and important formats/configurations. + if (styles == DateTimeStyles.None) + { + switch (formatParamChar) + { + case 'R': + case 'r': + ConfigureFormatR(ref dtfi, ref parseInfo, ref result); + return ParseFormatR(s, ref parseInfo, ref result); + + case 'O': + case 'o': + ConfigureFormatOS(ref dtfi, ref parseInfo); + return ParseFormatO(s, ref parseInfo, ref result); + } + } + + if (((result.flags & ParseFlags.CaptureOffset) != 0) && formatParamChar == 'U') { // The 'U' format is not allowed for DateTimeOffset result.SetBadFormatSpecifierFailure(formatParam); return false; } + formatParam = ExpandPredefinedFormat(formatParam, ref dtfi, ref parseInfo, ref result); } @@ -4614,13 +4636,417 @@ private static bool DoStrictParse( } - if (!DetermineTimeZoneAdjustments(ref str, ref result, styles, bTimeOnly)) + if (!DetermineTimeZoneAdjustments(ref result, styles, bTimeOnly)) { return false; } return true; } + private static bool ParseFormatR(ReadOnlySpan source, ref ParsingInfo parseInfo, ref DateTimeResult result) + { + // Example: + // Tue, 03 Jan 2017 08:08:05 GMT + + // The format is exactly 29 characters. + if ((uint)source.Length != 29) + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the three-letter day of week. Any casing is valid. + DayOfWeek dayOfWeek; + { + uint dow0 = source[0], dow1 = source[1], dow2 = source[2], comma = source[3]; + + if ((dow0 | dow1 | dow2 | comma) > 0x7F) + { + result.SetBadDateTimeFailure(); + return false; + } + + uint dowString = (dow0 << 24) | (dow1 << 16) | (dow2 << 8) | comma | 0x20202000; + switch (dowString) + { + case 0x73756E2c /* 'sun,' */: dayOfWeek = DayOfWeek.Sunday; break; + case 0x6d6f6e2c /* 'mon,' */: dayOfWeek = DayOfWeek.Monday; break; + case 0x7475652c /* 'tue,' */: dayOfWeek = DayOfWeek.Tuesday; break; + case 0x7765642c /* 'wed,' */: dayOfWeek = DayOfWeek.Wednesday; break; + case 0x7468752c /* 'thu,' */: dayOfWeek = DayOfWeek.Thursday; break; + case 0x6672692c /* 'fri,' */: dayOfWeek = DayOfWeek.Friday; break; + case 0x7361742c /* 'sat,' */: dayOfWeek = DayOfWeek.Saturday; break; + default: + result.SetBadDateTimeFailure(); + return false; + } + } + + if (source[4] != ' ') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the two digit day. + int day; + { + uint digit1 = (uint)(source[5] - '0'), digit2 = (uint)(source[6] - '0'); + + if (digit1 > 9 || digit2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + day = (int)(digit1*10 + digit2); + } + + if (source[7] != ' ') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the three letter month (followed by a space). Any casing is valid. + int month; + { + uint m0 = source[8], m1 = source[9], m2 = source[10], space = source[11]; + + if ((m0 | m1 | m2 | space) > 0x7F) + { + result.SetBadDateTimeFailure(); + return false; + } + + switch ((m0 << 24) | (m1 << 16) | (m2 << 8) | space | 0x20202000) + { + case 0x6a616e20 /* 'jan ' */ : month = 1; break; + case 0x66656220 /* 'feb ' */ : month = 2; break; + case 0x6d617220 /* 'mar ' */ : month = 3; break; + case 0x61707220 /* 'apr ' */ : month = 4; break; + case 0x6d617920 /* 'may ' */ : month = 5; break; + case 0x6a756e20 /* 'jun ' */ : month = 6; break; + case 0x6a756c20 /* 'jul ' */ : month = 7; break; + case 0x61756720 /* 'aug ' */ : month = 8; break; + case 0x73657020 /* 'sep ' */ : month = 9; break; + case 0x6f637420 /* 'oct ' */ : month = 10; break; + case 0x6e6f7620 /* 'nov ' */ : month = 11; break; + case 0x64656320 /* 'dec ' */ : month = 12; break; + default: + result.SetBadDateTimeFailure(); + return false; + } + } + + // Parse the four-digit year. + int year; + { + uint y1 = (uint)(source[12] - '0'), y2 = (uint)(source[13] - '0'), y3 = (uint)(source[14] - '0'), y4 = (uint)(source[15] - '0'); + + if (y1 > 9 || y2 > 9 || y3 > 9 || y4 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + year = (int)(y1*1000 + y2*100 + y3*10 + y4); + } + + if (source[16] != ' ') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the two digit hour. + int hour; + { + uint h1 = (uint)(source[17] - '0'), h2 = (uint)(source[18] - '0'); + + if (h1 > 9 || h2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + hour = (int)(h1*10 + h2); + } + + if (source[19] != ':') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the two-digit minute. + int minute; + { + uint m1 = (uint)(source[20] - '0'); + uint m2 = (uint)(source[21] - '0'); + + if (m1 > 9 || m2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + minute = (int)(m1*10 + m2); + } + + if (source[22] != ':') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Parse the two-digit second. + int second; + { + uint s1 = (uint)(source[23] - '0'), s2 = (uint)(source[24] - '0'); + + if (s1 > 9 || s2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + second = (int)(s1*10 + s2); + } + + // Parse " GMT". It must be upper case. + if (source[25] != ' ' || source[26] != 'G' || source[27] != 'M' || source[28] != 'T') + { + result.SetBadDateTimeFailure(); + return false; + } + + // Validate that the parsed date is valid according to the calendar. + if (!parseInfo.calendar.TryToDateTime(year, month, day, hour, minute, second, 0, 0, out result.parsedDate)) + { + result.SetFailure(ParseFailureKind.FormatBadDateTimeCalendar, nameof(SR.Format_BadDateTimeCalendar)); + return false; + } + + // And validate that the parsed day of week matches what the calendar said it should be. + if (dayOfWeek != result.parsedDate.DayOfWeek) + { + result.SetFailure(ParseFailureKind.FormatWithOriginalDateTime, nameof(SR.Format_BadDayOfWeek)); + return false; + } + + return true; + } + + private static bool ParseFormatO(ReadOnlySpan source, ref ParsingInfo parseInfo, ref DateTimeResult result) + { + // Examples: + // 2017-06-12T05:30:45.7680000 (interpreted as local time wrt to current time zone) + // 2017-06-12T05:30:45.7680000Z (Z is short for "+00:00" but also distinguishes DateTimeKind.Utc from DateTimeKind.Local) + // 2017-06-12T05:30:45.7680000-7:00 (special-case of one-digit offset hour) + // 2017-06-12T05:30:45.7680000-07:00 + + if ((uint)source.Length < 27 || + source[4] != '-' || + source[7] != '-' || + source[10] != 'T' || + source[13] != ':' || + source[16] != ':' || + source[19] != '.') + { + result.SetBadDateTimeFailure(); + return false; + } + + int year; + { + uint y1 = (uint)(source[0] - '0'), y2 = (uint)(source[1] - '0'), y3 = (uint)(source[2] - '0'), y4 = (uint)(source[3] - '0'); + + if (y1 > 9 || y2 > 9 || y3 > 9 || y4 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + year = (int)(y1*1000 + y2*100 + y3*10 + y4); + } + + int month; + { + uint m1 = (uint)(source[5] - '0'), m2 = (uint)(source[6] - '0'); + + if (m1 > 9 || m2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + month = (int)(m1*10 + m2); + } + + int day; + { + uint d1 = (uint)(source[8] - '0'), d2 = (uint)(source[9] - '0'); + + if (d1 > 9 || d2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + day = (int)(d1*10 + d2); + } + + int hour; + { + uint h1 = (uint)(source[11] - '0'), h2 = (uint)(source[12] - '0'); + + if (h1 > 9 || h2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + hour = (int)(h1*10 + h2); + } + + int minute; + { + uint m1 = (uint)(source[14] - '0'), m2 = (uint)(source[15] - '0'); + + if (m1 > 9 || m2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + minute = (int)(m1*10 + m2); + } + + int second; + { + uint s1 = (uint)(source[17] - '0'), s2 = (uint)(source[18] - '0'); + + if (s1 > 9 || s2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + second = (int)(s1*10 + s2); + } + + double fraction; + { + uint f1 = (uint)(source[20] - '0'); + uint f2 = (uint)(source[21] - '0'); + uint f3 = (uint)(source[22] - '0'); + uint f4 = (uint)(source[23] - '0'); + uint f5 = (uint)(source[24] - '0'); + uint f6 = (uint)(source[25] - '0'); + uint f7 = (uint)(source[26] - '0'); + + if (f1 > 9 || f2 > 9 || f3 > 9 || f4 > 9 || f5 > 9 || f6 > 9 || f7 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + fraction = (f1*1000000 + f2*100000 + f3*10000 + f4*1000 + f5*100 + f6*10 + f7) / 10000000.0; + } + + if (!DateTime.TryCreate(year, month, day, hour, minute, second, 0, out DateTime dateTime)) + { + result.SetBadDateTimeFailure(); + return false; + } + result.parsedDate = dateTime.AddTicks((long)Math.Round(fraction * Calendar.TicksPerSecond)); + + if ((uint)source.Length > 27) + { + char offsetChar = source[27]; + switch (offsetChar) + { + case 'Z': + if (source.Length != 28) + { + result.SetBadDateTimeFailure(); + return false; + } + result.flags |= ParseFlags.TimeZoneUsed | ParseFlags.TimeZoneUtc; + break; + + case '+': + case '-': + int offsetHours, colonIndex; + + if ((uint)source.Length == 33) + { + uint oh1 = (uint)(source[28] - '0'), oh2 = (uint)(source[29] - '0'); + + if (oh1 > 9 || oh2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + offsetHours = (int)(oh1 * 10 + oh2); + colonIndex = 30; + } + else if ((uint)source.Length == 32) // special-case allowed for compat: only one offset hour digit + { + offsetHours = source[28] - '0'; + + if ((uint)offsetHours > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + colonIndex = 29; + } + else + { + result.SetBadDateTimeFailure(); + return false; + } + + if (source[colonIndex] != ':') + { + result.SetBadDateTimeFailure(); + return false; + } + + int offsetMinutes; + { + uint om1 = (uint)(source[colonIndex + 1] - '0'), om2 = (uint)(source[colonIndex + 2] - '0'); + + if (om1 > 9 || om2 > 9) + { + result.SetBadDateTimeFailure(); + return false; + } + + offsetMinutes = (int)(om1*10 + om2); + } + + result.flags |= ParseFlags.TimeZoneUsed; + result.timeZoneOffset = new TimeSpan(offsetHours, offsetMinutes, 0); + if (offsetChar == '-') + { + result.timeZoneOffset = result.timeZoneOffset.Negate(); + } + break; + + default: + result.SetBadDateTimeFailure(); + return false; + } + } + + return DetermineTimeZoneAdjustments(ref result, DateTimeStyles.None, bTimeOnly: false); + } + private static Exception GetDateTimeParseException(ref DateTimeResult result) { switch (result.failure) @@ -4948,13 +5374,13 @@ internal void GetRegularToken(out TokenType tokenType, out int tokenValue, DateT } } } - else if (Char.IsWhiteSpace(m_current)) + else if (char.IsWhiteSpace(m_current)) { // Just skip to the next character. while (++Index < Length) { m_current = Value[Index]; - if (!(Char.IsWhiteSpace(m_current))) + if (!(char.IsWhiteSpace(m_current))) { goto Start; } @@ -5002,7 +5428,7 @@ internal bool MatchSpecifiedWord(string target) => Index + target.Length <= Length && m_info.Compare(Value.Slice(Index, target.Length), target, CompareOptions.IgnoreCase) == 0; - private static readonly Char[] WhiteSpaceChecks = new Char[] { ' ', '\u00A0' }; + private static readonly char[] WhiteSpaceChecks = new char[] { ' ', '\u00A0' }; internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int matchLength) { @@ -5035,7 +5461,7 @@ internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int else { // Make sure we also have whitespace in the input string - if (!Char.IsWhiteSpace(Value[thisPosition + segmentLength])) + if (!char.IsWhiteSpace(Value[thisPosition + segmentLength])) { return false; } @@ -5051,7 +5477,7 @@ internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int // Skip past multiple whitespace - while (thisPosition < Value.Length && Char.IsWhiteSpace(Value[thisPosition])) + while (thisPosition < Value.Length && char.IsWhiteSpace(Value[thisPosition])) { thisPosition++; matchLength++; @@ -5077,7 +5503,7 @@ internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int int nextCharIndex = Index + matchLength; if (nextCharIndex < Value.Length) { - if (Char.IsLetter(Value[nextCharIndex])) + if (char.IsLetter(Value[nextCharIndex])) { return (false); } @@ -5219,7 +5645,7 @@ internal void SkipWhiteSpaces() while (Index + 1 < Length) { char ch = Value[Index + 1]; - if (!Char.IsWhiteSpace(ch)) + if (!char.IsWhiteSpace(ch)) { return; } @@ -5240,7 +5666,7 @@ internal bool SkipWhiteSpaceCurrent() return (false); } - if (!Char.IsWhiteSpace(m_current)) + if (!char.IsWhiteSpace(m_current)) { return (true); } @@ -5248,7 +5674,7 @@ internal bool SkipWhiteSpaceCurrent() while (++Index < Length) { m_current = Value[Index]; - if (!Char.IsWhiteSpace(m_current)) + if (!char.IsWhiteSpace(m_current)) { return (true); } @@ -5260,7 +5686,7 @@ internal bool SkipWhiteSpaceCurrent() internal void TrimTail() { int i = Length - 1; - while (i >= 0 && Char.IsWhiteSpace(Value[i])) + while (i >= 0 && char.IsWhiteSpace(Value[i])) { i--; } @@ -5330,7 +5756,7 @@ internal DTSubString GetSubString() while (Index + sub.length < Length) { DTSubStringType currentType; - Char ch = Value[Index + sub.length]; + char ch = Value[Index + sub.length]; if (ch >= '0' && ch <= '9') { currentType = DTSubStringType.Number; @@ -5406,12 +5832,12 @@ internal enum DTSubStringType internal ref struct DTSubString { internal ReadOnlySpan s; - internal Int32 index; - internal Int32 length; + internal int index; + internal int length; internal DTSubStringType type; - internal Int32 value; + internal int value; - internal Char this[Int32 relativeIndex] + internal char this[int relativeIndex] { get { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs index a01821697b78..6b08ee540531 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/GregorianCalendar.cs @@ -20,8 +20,14 @@ public class GregorianCalendar : Calendar public const int ADEra = 1; // - // This is the max Gregorian year can be represented by DateTime class. The limitation - // is derived from DateTime class. + // This is the min Gregorian year can be represented by the DateTime class. + // The limitation is derived from the DateTime class. + // + internal const int MinYear = 1; + + // + // This is the max Gregorian year can be represented by the DateTime class. + // The limitation is derived from the DateTime class. // internal const int MaxYear = 9999; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs index 51749927022b..06807811e2b4 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HebrewCalendar.cs @@ -100,7 +100,7 @@ 2nd number determines the type of the Hebrew year. (the type determines how A 99 means the year is not supported for translation. for convenience the table was defined for 750 year, but only 640 years are supported. (from 1583 to 2239) - the years before 1582 (starting of Georgian calander) + the years before 1582 (starting of Georgian calendar) and after 2239, are filled with 99. Greogrian January 1st falls usually in Tevet (4th month). Tevet has always 29 days. diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HebrewNumber.cs b/src/System.Private.CoreLib/shared/System/Globalization/HebrewNumber.cs index 1e8fff2bcb25..4413cd9fa0a5 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HebrewNumber.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HebrewNumber.cs @@ -87,7 +87,7 @@ private HebrewNumber() // //////////////////////////////////////////////////////////////////////////// - internal static String ToString(int Number) + internal static string ToString(int Number) { char cTens = '\x0'; char cUnits; // tens and units chars diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs index 657163fba0c6..42a79ec3919c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.Win32.cs @@ -10,7 +10,7 @@ public partial class HijriCalendar : Calendar { private int GetHijriDateAdjustment() { - if (_hijriAdvance == Int32.MinValue) + if (_hijriAdvance == int.MinValue) { // Never been set before. Use the system value from registry. _hijriAdvance = GetAdvanceHijriDate(); @@ -55,7 +55,7 @@ private static int GetAdvanceHijriDate() { try { - Object value = key.InternalGetValue(HijriAdvanceRegKeyEntry, null, false, false); + object value = key.InternalGetValue(HijriAdvanceRegKeyEntry, null, false, false); if (value == null) { return (0); @@ -69,7 +69,7 @@ private static int GetAdvanceHijriDate() { try { - int advance = Int32.Parse(str.AsSpan(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture); + int advance = int.Parse(str.AsSpan(HijriAdvanceRegKeyEntry.Length), provider:CultureInfo.InvariantCulture); if ((advance >= MinAdvancedHijri) && (advance <= MaxAdvancedHijri)) { hijriAdvance = advance; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs index d6f2bc970f02..3eaf3d2539f3 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/HijriCalendar.cs @@ -55,7 +55,7 @@ public partial class HijriCalendar : Calendar internal static readonly int[] HijriMonthDays = { 0, 30, 59, 89, 118, 148, 177, 207, 236, 266, 295, 325, 355 }; - private int _hijriAdvance = Int32.MinValue; + private int _hijriAdvance = int.MinValue; // DateTime.MaxValue = Hijri calendar (year:9666, month: 4, day: 3). internal const int MaxCalendarYear = 9666; @@ -176,7 +176,7 @@ public int HijriAdjustment { get { - if (_hijriAdvance == Int32.MinValue) + if (_hijriAdvance == int.MinValue) { // Never been set before. Use the system value from registry. _hijriAdvance = GetHijriDateAdjustment(); diff --git a/src/System.Private.CoreLib/shared/System/Globalization/ISOWeek.cs b/src/System.Private.CoreLib/shared/System/Globalization/ISOWeek.cs new file mode 100644 index 000000000000..3b3ba15ec852 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Globalization/ISOWeek.cs @@ -0,0 +1,162 @@ +// 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 static System.Globalization.GregorianCalendar; + +namespace System.Globalization +{ + public static class ISOWeek + { + private const int WeeksInLongYear = 53; + private const int WeeksInShortYear = 52; + + private const int MinWeek = 1; + private const int MaxWeek = WeeksInLongYear; + + public static int GetWeekOfYear(DateTime date) + { + int week = GetWeekNumber(date); + + if (week < MinWeek) + { + // If the week number obtained equals 0, it means that the + // given date belongs to the preceding (week-based) year. + return GetWeeksInYear(date.Year - 1); + } + + if (week > GetWeeksInYear(date.Year)) + { + // If a week number of 53 is obtained, one must check that + // the date is not actually in week 1 of the following year. + return MinWeek; + } + + return week; + } + + public static int GetYear(DateTime date) + { + int week = GetWeekNumber(date); + + if (week < MinWeek) + { + // If the week number obtained equals 0, it means that the + // given date belongs to the preceding (week-based) year. + return date.Year - 1; + } + + if (week > GetWeeksInYear(date.Year)) + { + // If a week number of 53 is obtained, one must check that + // the date is not actually in week 1 of the following year. + return date.Year + 1; + } + + return date.Year; + } + + // The year parameter represents an ISO week-numbering year (also called ISO year informally). + // Each week's year is the Gregorian year in which the Thursday falls. + // The first week of the year, hence, always contains 4 January. + // ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January. + public static DateTime GetYearStart(int year) + { + return ToDateTime(year, MinWeek, DayOfWeek.Monday); + } + + // The year parameter represents an ISO week-numbering year (also called ISO year informally). + // Each week's year is the Gregorian year in which the Thursday falls. + // The first week of the year, hence, always contains 4 January. + // ISO week year numbering therefore slightly deviates from the Gregorian for some days close to 1 January. + public static DateTime GetYearEnd(int year) + { + return ToDateTime(year, GetWeeksInYear(year), DayOfWeek.Sunday); + } + + // From https://en.wikipedia.org/wiki/ISO_week_date#Weeks_per_year: + // + // The long years, with 53 weeks in them, can be described by any of the following equivalent definitions: + // + // - Any year starting on Thursday and any leap year starting on Wednesday. + // - Any year ending on Thursday and any leap year ending on Friday. + // - Years in which 1 January and 31 December (in common years) or either (in leap years) are Thursdays. + // + // All other week-numbering years are short years and have 52 weeks. + public static int GetWeeksInYear(int year) + { + if (year < MinYear || year > MaxYear) + { + throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_Year); + } + + int P(int y) => (y + (y / 4) - (y / 100) + (y / 400)) % 7; + + if (P(year) == 4 || P(year - 1) == 3) + { + return WeeksInLongYear; + } + + return WeeksInShortYear; + } + + // From https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year,_week_number_and_weekday: + // + // This method requires that one know the weekday of 4 January of the year in question. + // Add 3 to the number of this weekday, giving a correction to be used for dates within this year. + // + // Multiply the week number by 7, then add the weekday. From this sum subtract the correction for the year. + // The result is the ordinal date, which can be converted into a calendar date. + // + // If the ordinal date thus obtained is zero or negative, the date belongs to the previous calendar year. + // If greater than the number of days in the year, to the following year. + public static DateTime ToDateTime(int year, int week, DayOfWeek dayOfWeek) + { + if (year < MinYear || year > MaxYear) + { + throw new ArgumentOutOfRangeException(nameof(year), SR.ArgumentOutOfRange_Year); + } + + if (week < MinWeek || week > MaxWeek) + { + throw new ArgumentOutOfRangeException(nameof(week), SR.ArgumentOutOfRange_Week_ISO); + } + + // We allow 7 for convenience in cases where a user already has a valid ISO + // day of week value for Sunday. This means that both 0 and 7 will map to Sunday. + // The GetWeekday method will normalize this into the 1-7 range required by ISO. + if ((int)dayOfWeek < 0 || (int)dayOfWeek > 7) + { + throw new ArgumentOutOfRangeException(nameof(dayOfWeek), SR.ArgumentOutOfRange_DayOfWeek); + } + + var jan4 = new DateTime(year, month: 1, day: 4); + + int correction = GetWeekday(jan4.DayOfWeek) + 3; + + int ordinal = (week * 7) + GetWeekday(dayOfWeek) - correction; + + return new DateTime(year, month: 1, day: 1).AddDays(ordinal - 1); + } + + // From https://en.wikipedia.org/wiki/ISO_week_date#Calculating_the_week_number_of_a_given_date: + // + // Using ISO weekday numbers (running from 1 for Monday to 7 for Sunday), + // subtract the weekday from the ordinal date, then add 10. Divide the result by 7. + // Ignore the remainder; the quotient equals the week number. + // + // If the week number thus obtained equals 0, it means that the given date belongs to the preceding (week-based) year. + // If a week number of 53 is obtained, one must check that the date is not actually in week 1 of the following year. + private static int GetWeekNumber(DateTime date) + { + return (date.DayOfYear - GetWeekday(date.DayOfWeek) + 10) / 7; + } + + // Day of week in ISO is represented by an integer from 1 through 7, beginning with Monday and ending with Sunday. + // This matches the underlying values of the DayOfWeek enum, except for Sunday, which needs to be converted. + private static int GetWeekday(DayOfWeek dayOfWeek) + { + return dayOfWeek == DayOfWeek.Sunday ? 7 : (int) dayOfWeek; + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Globalization/IdnMapping.cs b/src/System.Private.CoreLib/shared/System/Globalization/IdnMapping.cs index 6da6f79f2431..164e46dc8a9b 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/IdnMapping.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/IdnMapping.cs @@ -281,7 +281,7 @@ static bool ValidateStd3AndAscii(string unicode, bool bUseStd3, bool bCheckAscii // Need to validate entire string length, 1 shorter if last char wasn't a dot if (unicode.Length > c_defaultNameLimit - (IsDot(unicode[unicode.Length - 1]) ? 0 : 1)) - throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, + throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, c_defaultNameLimit - (IsDot(unicode[unicode.Length - 1]) ? 0 : 1)), nameof(unicode)); // If last char wasn't a dot we need to check for trailing - @@ -361,7 +361,7 @@ static string PunycodeEncode(string unicode) // Check last char int iTest = iNextDot - 1; - if (Char.IsLowSurrogate(unicode, iTest)) + if (char.IsLowSurrogate(unicode, iTest)) { iTest--; } @@ -380,7 +380,7 @@ static string PunycodeEncode(string unicode) for (basicCount = iAfterLastDot; basicCount < iNextDot; basicCount++) { // Can't be lonely surrogate because it would've thrown in normalization - Debug.Assert(Char.IsLowSurrogate(unicode, basicCount) == false, "[IdnMapping.punycode_encode]Unexpected low surrogate"); + Debug.Assert(char.IsLowSurrogate(unicode, basicCount) == false, "[IdnMapping.punycode_encode]Unexpected low surrogate"); // Double check our bidi rules BidiCategory testBidi = CharUnicodeInfo.GetBidiCategory(unicode, basicCount); @@ -406,7 +406,7 @@ static string PunycodeEncode(string unicode) numProcessed++; } // If its a surrogate, skip the next since our bidi category tester doesn't handle it. - else if (Char.IsSurrogatePair(unicode, basicCount)) + else if (char.IsSurrogatePair(unicode, basicCount)) basicCount++; } @@ -452,7 +452,7 @@ static string PunycodeEncode(string unicode) j < iNextDot; j += IsSupplementary(test) ? 2 : 1) { - test = Char.ConvertToUtf32(unicode, j); + test = char.ConvertToUtf32(unicode, j); if (test >= n && test < m) m = test; } @@ -465,7 +465,7 @@ static string PunycodeEncode(string unicode) for (j = iAfterLastDot; j < iNextDot; j+= IsSupplementary(test) ? 2 : 1) { // Make sure we're aware of surrogates - test = Char.ConvertToUtf32(unicode, j); + test = char.ConvertToUtf32(unicode, j); // Adjust for character position (only the chars in our string already, some // haven't been processed. @@ -521,7 +521,7 @@ static string PunycodeEncode(string unicode) // Throw if we're too long if (output.Length > c_defaultNameLimit - (IsDot(unicode[unicode.Length-1]) ? 0 : 1)) - throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, + throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, c_defaultNameLimit - (IsDot(unicode[unicode.Length-1]) ? 0 : 1)), nameof(unicode)); // Return our output string return output.ToString(); @@ -603,7 +603,7 @@ private static string PunycodeDecode(string ascii) // Throw if we're too long if (ascii.Length > c_defaultNameLimit - (IsDot(ascii[ascii.Length-1]) ? 0 : 1)) - throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, + throw new ArgumentException(SR.Format(SR.Argument_IdnBadNameSize, c_defaultNameLimit - (IsDot(ascii[ascii.Length-1]) ? 0 : 1)), nameof(ascii)); // output stringbuilder @@ -637,11 +637,11 @@ private static string PunycodeDecode(string ascii) throw new ArgumentException(SR.Argument_IdnBadLabelSize, nameof(ascii)); // See if this section's ASCII or ACE - if (ascii.Length < c_strAcePrefix.Length + iAfterLastDot || - !ascii.Substring(iAfterLastDot,c_strAcePrefix.Length).Equals(c_strAcePrefix, StringComparison.OrdinalIgnoreCase)) + if (ascii.Length < c_strAcePrefix.Length + iAfterLastDot || + string.Compare(ascii, iAfterLastDot, c_strAcePrefix, 0, c_strAcePrefix.Length, StringComparison.OrdinalIgnoreCase) != 0) { // Its ASCII, copy it - output.Append(ascii.Substring(iAfterLastDot, iNextDot - iAfterLastDot)); + output.Append(ascii, iAfterLastDot, iNextDot - iAfterLastDot); } else { @@ -715,7 +715,7 @@ private static string PunycodeDecode(string ascii) i += (int)(digit * w); int t = k <= bias ? c_tmin : k >= bias + c_tmax ? c_tmax : k - bias; - if (digit < t) + if (digit < t) break; Debug.Assert(c_punycodeBase != t, "[IdnMapping.punycode_decode]Expected t != c_punycodeBase (36)"); if (w > c_maxint / (c_punycodeBase - t)) @@ -740,7 +740,7 @@ private static string PunycodeDecode(string ascii) // insert n at position i of the output: Really tricky if we have surrogates int iUseInsertLocation; - String strTemp = Char.ConvertFromUtf32(n); + string strTemp = char.ConvertFromUtf32(n); // If we have supplimentary characters if (numSurrogatePairs > 0) @@ -752,7 +752,7 @@ private static string PunycodeDecode(string ascii) // If its a surrogate, we have to go one more if (iUseInsertLocation >= output.Length) throw new ArgumentException(SR.Argument_IdnBadPunycode, nameof(ascii)); - if (Char.IsSurrogate(output[iUseInsertLocation])) + if (char.IsSurrogate(output[iUseInsertLocation])) iUseInsertLocation++; } } @@ -777,7 +777,7 @@ private static string PunycodeDecode(string ascii) bool bRightToLeft = false; // Check for RTL. If right-to-left, then 1st & last chars must be RTL - BidiCategory eBidi = CharUnicodeInfo.GetBidiCategory(output.ToString(), iOutputAfterLastDot); + BidiCategory eBidi = CharUnicodeInfo.GetBidiCategory(output, iOutputAfterLastDot); if (eBidi == BidiCategory.RightToLeft || eBidi == BidiCategory.RightToLeftArabic) { // It has to be right to left. @@ -788,11 +788,11 @@ private static string PunycodeDecode(string ascii) for (int iTest = iOutputAfterLastDot; iTest < output.Length; iTest++) { // This might happen if we run into a pair - if (Char.IsLowSurrogate(output.ToString(), iTest)) + if (char.IsLowSurrogate(output[iTest])) continue; // Check to see if its LTR - eBidi = CharUnicodeInfo.GetBidiCategory(output.ToString(), iTest); + eBidi = CharUnicodeInfo.GetBidiCategory(output, iTest); if ((bRightToLeft && eBidi == BidiCategory.LeftToRight) || (!bRightToLeft && (eBidi == BidiCategory.RightToLeft || eBidi == BidiCategory.RightToLeftArabic))) throw new ArgumentException(SR.Argument_IdnBadBidi, nameof(ascii)); @@ -897,6 +897,5 @@ private static char EncodeDigit(int d) // 0-25 map to a-z or A-Z return (char)(d + 'a'); } - } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/InternalGlobalizationHelper.cs b/src/System.Private.CoreLib/shared/System/Globalization/InternalGlobalizationHelper.cs index 60abcecf6110..6dc2b1951561 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/InternalGlobalizationHelper.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/InternalGlobalizationHelper.cs @@ -25,8 +25,8 @@ internal static long TimeToTicks(int hour, int minute, int second) internal const long TicksPerMillisecond = 10000; internal const long TicksPerTenthSecond = TicksPerMillisecond * 100; internal const long TicksPerSecond = TicksPerMillisecond * 1000; // 10,000,000 - internal const long MaxSeconds = Int64.MaxValue / TicksPerSecond; - internal const long MinSeconds = Int64.MinValue / TicksPerSecond; + internal const long MaxSeconds = long.MaxValue / TicksPerSecond; + internal const long MinSeconds = long.MinValue / TicksPerSecond; private const int DaysPerYear = 365; private const int DaysPer4Years = DaysPerYear * 4 + 1; // 1461 private const int DaysPer100Years = DaysPer4Years * 25 - 1; // 36524 @@ -37,12 +37,12 @@ internal static long TimeToTicks(int hour, int minute, int second) private const long TicksPerDay = TicksPerHour * 24; internal const long MaxTicks = DaysTo10000 * TicksPerDay - 1; internal const long MinTicks = 0; - internal const long MaxMilliSeconds = Int64.MaxValue / TicksPerMillisecond; - internal const long MinMilliSeconds = Int64.MinValue / TicksPerMillisecond; + internal const long MaxMilliSeconds = long.MaxValue / TicksPerMillisecond; + internal const long MinMilliSeconds = long.MinValue / TicksPerMillisecond; internal const int StringBuilderDefaultCapacity = 16; - internal const Int64 MaxOffset = TimeSpan.TicksPerHour * 14; - internal const Int64 MinOffset = -MaxOffset; + internal const long MaxOffset = TimeSpan.TicksPerHour * 14; + internal const long MinOffset = -MaxOffset; } } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs index 1d0180b00e89..f4787a6cb46c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.Win32.cs @@ -43,7 +43,7 @@ private static EraInfo[] GetJapaneseEras() if (key == null) return null; // Look up the values in our reg key - String[] valueNames = key.GetValueNames(); + string[] valueNames = key.GetValueNames(); if (valueNames != null && valueNames.Length > 0) { registryEraRanges = new EraInfo[valueNames.Length]; @@ -143,7 +143,7 @@ private static int CompareEraRanges(EraInfo a, EraInfo b) // . is a delimiter, but the value of . doesn't matter. // '_' marks the space between the japanese era name, japanese abbreviated era name // english name, and abbreviated english names. - private static EraInfo GetEraFromValue(String value, String data) + private static EraInfo GetEraFromValue(string value, string data) { // Need inputs if (value == null || data == null) return null; @@ -160,9 +160,9 @@ private static EraInfo GetEraFromValue(String value, String data) int day; ReadOnlySpan valueSpan = value.AsSpan(); - if (!Int32.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) || - !Int32.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) || - !Int32.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day)) + if (!int.TryParse(valueSpan.Slice(0, 4), NumberStyles.None, NumberFormatInfo.InvariantInfo, out year) || + !int.TryParse(valueSpan.Slice(5, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out month) || + !int.TryParse(valueSpan.Slice(8, 2), NumberStyles.None, NumberFormatInfo.InvariantInfo, out day)) { // Couldn't convert integer, fail return null; @@ -172,7 +172,7 @@ private static EraInfo GetEraFromValue(String value, String data) // Get Strings // // Needs to be a certain length e_a_E_A at least (7 chars, exactly 4 groups) - String[] names = data.Split('_'); + string[] names = data.Split('_'); // Should have exactly 4 parts // 0 - Era Name @@ -199,7 +199,7 @@ private static EraInfo GetEraFromValue(String value, String data) // PAL Layer ends here - private static string[] s_japaneseErasEnglishNames = new String[] { "M", "T", "S", "H" }; + private static string[] s_japaneseErasEnglishNames = new string[] { "M", "T", "S", "H" }; private static string GetJapaneseEnglishEraName(int era) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs index 6a9df9720092..818cb5b427da 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/JapaneseCalendar.WinRT.cs @@ -46,7 +46,7 @@ private static EraInfo[] GetJapaneseEras() // PAL Layer ends here - private static string[] JapaneseErasEnglishNames = new String[] { "M", "T", "S", "H" }; + private static string[] JapaneseErasEnglishNames = new string[] { "M", "T", "S", "H" }; private static string GetJapaneseEnglishEraName(int era) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs index 0f71b5f687ba..63636f5e3f4b 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/KoreanLunisolarCalendar.cs @@ -1248,7 +1248,7 @@ internal override int GetYearInfo(int lunarYear, int index) { throw new ArgumentOutOfRangeException( "year", - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, @@ -1271,7 +1271,7 @@ internal override int GetGregorianYear(int year, int era) { throw new ArgumentOutOfRangeException( nameof(year), - String.Format( + string.Format( CultureInfo.CurrentCulture, SR.ArgumentOutOfRange_Range, MIN_LUNISOLAR_YEAR, MAX_LUNISOLAR_YEAR)); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs index 33d50b3fc3cc..7afe09474828 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/NumberFormatInfo.cs @@ -237,7 +237,7 @@ NumberFormatInfo GetProviderNonNull(IFormatProvider provider) } } - public Object Clone() + public object Clone() { NumberFormatInfo n = (NumberFormatInfo)MemberwiseClone(); n.isReadOnly = false; @@ -325,7 +325,7 @@ public int[] CurrencyGroupSizes } VerifyWritable(); - Int32[] inputSizes = (Int32[])value.Clone(); + int[] inputSizes = (int[])value.Clone(); CheckGroupSize(nameof(CurrencyGroupSizes), inputSizes); currencyGroupSizes = inputSizes; } @@ -348,7 +348,7 @@ public int[] NumberGroupSizes } VerifyWritable(); - Int32[] inputSizes = (Int32[])value.Clone(); + int[] inputSizes = (int[])value.Clone(); CheckGroupSize(nameof(NumberGroupSizes), inputSizes); numberGroupSizes = inputSizes; } @@ -369,7 +369,7 @@ public int[] PercentGroupSizes SR.ArgumentNull_Obj); } VerifyWritable(); - Int32[] inputSizes = (Int32[])value.Clone(); + int[] inputSizes = (int[])value.Clone(); CheckGroupSize(nameof(PercentGroupSizes), inputSizes); percentGroupSizes = inputSizes; } @@ -774,7 +774,7 @@ public DigitShapes DigitSubstitution } } - public Object GetFormat(Type formatType) + public object GetFormat(Type formatType) { return formatType == typeof(NumberFormatInfo) ? this : null; } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs index b9daea3f9db3..8416257d919c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/RegionInfo.cs @@ -358,7 +358,7 @@ public virtual string ISOCurrencySymbol // (ie: en-US) // //////////////////////////////////////////////////////////////////////// - public override bool Equals(Object value) + public override bool Equals(object value) { RegionInfo that = value as RegionInfo; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/SortKey.cs b/src/System.Private.CoreLib/shared/System/Globalization/SortKey.cs index 647db75b63cb..962494625735 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/SortKey.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/SortKey.cs @@ -33,7 +33,7 @@ public partial class SortKey // The following constructor is designed to be called from CompareInfo to get the // the sort key of specific string for synthetic culture // - internal SortKey(String localeName, String str, CompareOptions options, byte[] keyData) + internal SortKey(string localeName, string str, CompareOptions options, byte[] keyData) { _keyData = keyData; _localeName = localeName; @@ -49,7 +49,7 @@ internal SortKey(String localeName, String str, CompareOptions options, byte[] k // of SortKey. // //////////////////////////////////////////////////////////////////////// - public virtual String OriginalString + public virtual string OriginalString { get { @@ -133,7 +133,7 @@ public static int Compare(SortKey sortkey1, SortKey sortkey2) // or not object refers to the same SortKey as the current instance. // //////////////////////////////////////////////////////////////////////// - public override bool Equals(Object value) + public override bool Equals(object value) { SortKey that = value as SortKey; @@ -167,7 +167,7 @@ public override int GetHashCode() // SortKey. // //////////////////////////////////////////////////////////////////////// - public override String ToString() + public override string ToString() { return ("SortKey - " + _localeName + ", " + _options + ", " + _string); } diff --git a/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs index 5b5cd939995b..f7be252bfe2c 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/StringInfo.cs @@ -32,7 +32,7 @@ public StringInfo(string value) this.String = value; } - public override bool Equals(Object value) + public override bool Equals(object value) { StringInfo that = value as StringInfo; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TextElementEnumerator.cs b/src/System.Private.CoreLib/shared/System/Globalization/TextElementEnumerator.cs index 8b0f102a7744..7d8ff64a38ff 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TextElementEnumerator.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TextElementEnumerator.cs @@ -21,7 +21,7 @@ namespace System.Globalization public class TextElementEnumerator : IEnumerator { - private String _str; + private string _str; private int _index; private int _startIndex; @@ -33,7 +33,7 @@ public class TextElementEnumerator : IEnumerator private int _charLen; // The next abstract char to look at after MoveNext() is called. It could be 1 or 2, depending on if it is a surrogate or not. - internal TextElementEnumerator(String str, int startIndex, int strLen) + internal TextElementEnumerator(string str, int startIndex, int strLen) { Debug.Assert(str != null, "TextElementEnumerator(): str != null"); Debug.Assert(startIndex >= 0 && strLen >= 0, "TextElementEnumerator(): startIndex >= 0 && strLen >= 0"); @@ -61,7 +61,7 @@ public bool MoveNext() // Get the current text element. // - public Object Current + public object Current { get { @@ -73,7 +73,7 @@ public Object Current // Get the current text element. // - public String GetTextElement() + public string GetTextElement() { if (_index == _startIndex) { diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs b/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs index 4906bedff499..8073b4b56bb8 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TextInfo.cs @@ -76,7 +76,7 @@ internal TextInfo(CultureData cultureData) FinishInitialization(); } - void IDeserializationCallback.OnDeserialization(Object sender) + void IDeserializationCallback.OnDeserialization(object sender) { throw new PlatformNotSupportedException(); } @@ -302,7 +302,7 @@ private unsafe string ChangeCase(string source, bool toUpper) source.AsSpan(0, sourcePos).CopyTo(new Span(pResult, sourcePos)); } - // And store the current character, upper-cased. + // And store the current character, lower-cased. char* d = pResult + sourcePos; *d++ = (char)(c | 0x20); sourcePos++; @@ -612,7 +612,7 @@ private bool IsAsciiCasingSameAsInvariant // or not object refers to the same CultureInfo as the current instance. // //////////////////////////////////////////////////////////////////////// - public override bool Equals(Object obj) + public override bool Equals(object obj) { TextInfo that = obj as TextInfo; diff --git a/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanFormat.cs b/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanFormat.cs index a66e4600aa1f..169e12f599bf 100644 --- a/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanFormat.cs +++ b/src/System.Private.CoreLib/shared/System/Globalization/TimeSpanFormat.cs @@ -2,8 +2,10 @@ // 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.Buffers.Text; using System.Text; using System.Diagnostics; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace System.Globalization @@ -35,66 +37,53 @@ private static unsafe void AppendNonNegativeInt32(StringBuilder sb, int n, int d internal static readonly FormatLiterals PositiveInvariantFormatLiterals = TimeSpanFormat.FormatLiterals.InitInvariant(isNegative: false); internal static readonly FormatLiterals NegativeInvariantFormatLiterals = TimeSpanFormat.FormatLiterals.InitInvariant(isNegative: true); - internal enum Pattern - { - None = 0, - Minimum = 1, - Full = 2, - } /// Main method called from TimeSpan.ToString. - internal static string Format(TimeSpan value, string format, IFormatProvider formatProvider) => - StringBuilderCache.GetStringAndRelease(FormatToBuilder(value, format, formatProvider)); + internal static string Format(TimeSpan value, string format, IFormatProvider formatProvider) + { + return IsFormatC(format) ? // special-case to optimize the default TimeSpan format + FormatC(value) : // formatProvider ignored, as "c" is invariant + StringBuilderCache.GetStringAndRelease(FormatToBuilder(value, format, formatProvider)); + } /// Main method called from TimeSpan.TryFormat. internal static bool TryFormat(TimeSpan value, Span destination, out int charsWritten, ReadOnlySpan format, IFormatProvider formatProvider) { + if (IsFormatC(format)) // special-case to optimize the default TimeSpan format + { + return TryFormatC(value, destination, out charsWritten); // formatProvider ignored, as "c" is invariant + } + StringBuilder sb = FormatToBuilder(value, format, formatProvider); + if (sb.Length <= destination.Length) { - charsWritten = sb.Length; sb.CopyTo(0, destination, sb.Length); + charsWritten = sb.Length; StringBuilderCache.Release(sb); return true; } - else - { - StringBuilderCache.Release(sb); - charsWritten = 0; - return false; - } + + charsWritten = 0; + StringBuilderCache.Release(sb); + return false; } private static StringBuilder FormatToBuilder(TimeSpan value, ReadOnlySpan format, IFormatProvider formatProvider) { - if (format.Length == 0) - { - format = "c"; - } - - // Standard formats + // Standard formats other than 'c'/'t'/'T', which should have already been handled. if (format.Length == 1) { char f = format[0]; switch (f) { - case 'c': - case 't': - case 'T': - return FormatStandard( - value, - isInvariant: true, - format: format, - pattern: Pattern.Minimum); - case 'g': case 'G': DateTimeFormatInfo dtfi = DateTimeFormatInfo.GetInstance(formatProvider); - return FormatStandard( + return FormatG( value, - isInvariant: false, format: value.Ticks < 0 ? dtfi.FullTimeSpanNegativePattern : dtfi.FullTimeSpanPositivePattern, - pattern: f == 'g' ? Pattern.Minimum : Pattern.Full); + full: f == 'G'); default: throw new FormatException(SR.Format_InvalidString); @@ -105,10 +94,166 @@ private static StringBuilder FormatToBuilder(TimeSpan value, ReadOnlySpan return FormatCustomized(value, format, DateTimeFormatInfo.GetInstance(formatProvider), result: null); } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static bool IsFormatC(ReadOnlySpan format) => + format.Length == 0 || + (format.Length == 1 && (format[0] == 'c' || (format[0] | 0x20) == 't')); + + internal static string FormatC(TimeSpan value) + { + Span destination = stackalloc char[26]; // large enough for any "c" TimeSpan + TryFormatC(value, destination, out int charsWritten); + return new string(destination.Slice(0, charsWritten)); + } + + private static bool TryFormatC(TimeSpan value, Span destination, out int charsWritten) + { + // First, calculate how large an output buffer is needed to hold the entire output. + int requiredOutputLength = 8; // start with "hh:mm:ss" and adjust as necessary + + uint fraction; + ulong totalSecondsRemaining; + { + // Turn this into a non-negative TimeSpan if possible. + long ticks = value.Ticks; + if (ticks < 0) + { + requiredOutputLength = 9; // requiredOutputLength + 1 for the leading '-' sign + ticks = -ticks; + if (ticks < 0) + { + Debug.Assert(ticks == long.MinValue /* -9223372036854775808 */); + + // We computed these ahead of time; they're straight from the decimal representation of Int64.MinValue. + fraction = 4775808; + totalSecondsRemaining = 922337203685; + goto AfterComputeFraction; + } + } + + totalSecondsRemaining = Math.DivRem((ulong)ticks, TimeSpan.TicksPerSecond, out ulong fraction64); + fraction = (uint)fraction64; + } + + AfterComputeFraction: + // Only write out the fraction if it's non-zero, and in that + // case write out the entire fraction (all digits). + int fractionDigits = 0; + if (fraction != 0) + { + Debug.Assert(fraction < 10_000_000); + fractionDigits = DateTimeFormat.MaxSecondsFractionDigits; + requiredOutputLength += fractionDigits + 1; // If we're going to write out a fraction, also need to write the leading decimal. + } + + ulong totalMinutesRemaining = 0, seconds = 0; + if (totalSecondsRemaining > 0) + { + // Only compute minutes if the TimeSpan has an absolute value of >= 1 minute. + totalMinutesRemaining = Math.DivRem(totalSecondsRemaining, 60 /* seconds per minute */, out seconds); + Debug.Assert(seconds < 60); + } + + ulong totalHoursRemaining = 0, minutes = 0; + if (totalMinutesRemaining > 0) + { + // Only compute hours if the TimeSpan has an absolute value of >= 1 hour. + totalHoursRemaining = Math.DivRem(totalMinutesRemaining, 60 /* minutes per hour */, out minutes); + Debug.Assert(minutes < 60); + } + + // At this point, we can switch over to 32-bit DivRem since the data has shrunk far enough. + Debug.Assert(totalHoursRemaining <= uint.MaxValue); + + uint days = 0, hours = 0; + if (totalHoursRemaining > 0) + { + // Only compute days if the TimeSpan has an absolute value of >= 1 day. + days = Math.DivRem((uint)totalHoursRemaining, 24 /* hours per day */, out hours); + Debug.Assert(hours < 24); + } + + int dayDigits = 0; + if (days > 0) + { + dayDigits = FormattingHelpers.CountDigits(days); + Debug.Assert(dayDigits <= 8); + requiredOutputLength += dayDigits + 1; // for the leading "d." + } + + if (destination.Length < requiredOutputLength) + { + charsWritten = 0; + return false; + } + + // Write leading '-' if necessary + int idx = 0; + if (value.Ticks < 0) + { + destination[idx++] = '-'; + } + + // Write day and separator, if necessary + if (dayDigits != 0) + { + WriteDigits(days, destination.Slice(idx, dayDigits)); + idx += dayDigits; + destination[idx++] = '.'; + } + + // Write "hh:mm:ss" + WriteTwoDigits(hours, destination.Slice(idx)); + idx += 2; + destination[idx++] = ':'; + WriteTwoDigits((uint)minutes, destination.Slice(idx)); + idx += 2; + destination[idx++] = ':'; + WriteTwoDigits((uint)seconds, destination.Slice(idx)); + idx += 2; + + // Write fraction and separator, if necessary + if (fractionDigits != 0) + { + destination[idx++] = '.'; + WriteDigits(fraction, destination.Slice(idx, fractionDigits)); + idx += fractionDigits; + } + + Debug.Assert(idx == requiredOutputLength); + charsWritten = requiredOutputLength; + return true; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void WriteTwoDigits(uint value, Span buffer) + { + Debug.Assert(buffer.Length >= 2); + uint temp = '0' + value; + value /= 10; + buffer[1] = (char)(temp - (value * 10)); + buffer[0] = (char)('0' + value); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static void WriteDigits(uint value, Span buffer) + { + Debug.Assert(buffer.Length > 0); + + for (int i = buffer.Length - 1; i >= 1; i--) + { + uint temp = '0' + value; + value /= 10; + buffer[i] = (char)(temp - (value * 10)); + } + + Debug.Assert(value < 10); + buffer[0] = (char)('0' + value); + } + /// Format the TimeSpan instance using the specified format. - private static StringBuilder FormatStandard(TimeSpan value, bool isInvariant, ReadOnlySpan format, Pattern pattern) + private static StringBuilder FormatG(TimeSpan value, ReadOnlySpan format, bool full) { - StringBuilder sb = StringBuilderCache.Acquire(InternalGlobalizationHelper.StringBuilderDefaultCapacity); int day = (int)(value.Ticks / TimeSpan.TicksPerDay); long time = value.Ticks % TimeSpan.TicksPerDay; @@ -122,18 +267,8 @@ private static StringBuilder FormatStandard(TimeSpan value, bool isInvariant, Re int seconds = (int)(time / TimeSpan.TicksPerSecond % 60); int fraction = (int)(time % TimeSpan.TicksPerSecond); - FormatLiterals literal; - if (isInvariant) - { - literal = value.Ticks < 0 ? - NegativeInvariantFormatLiterals : - PositiveInvariantFormatLiterals; - } - else - { - literal = new FormatLiterals(); - literal.Init(format, pattern == Pattern.Full); - } + FormatLiterals literal = new FormatLiterals(); + literal.Init(format, full); if (fraction != 0) { @@ -141,11 +276,12 @@ private static StringBuilder FormatStandard(TimeSpan value, bool isInvariant, Re fraction = (int)(fraction / TimeSpanParse.Pow10(DateTimeFormat.MaxSecondsFractionDigits - literal.ff)); } - // Pattern.Full: [-]dd.hh:mm:ss.fffffff - // Pattern.Minimum: [-][d.]hh:mm:ss[.fffffff] + // full: [-]dd.hh:mm:ss.fffffff + // !full: [-][d.]hh:mm:ss[.fffffff] + StringBuilder sb = StringBuilderCache.Acquire(InternalGlobalizationHelper.StringBuilderDefaultCapacity); sb.Append(literal.Start); // [-] - if (pattern == Pattern.Full || day != 0) + if (full || day != 0) { sb.Append(day); // [dd] sb.Append(literal.DayHourSep); // [.] @@ -155,20 +291,13 @@ private static StringBuilder FormatStandard(TimeSpan value, bool isInvariant, Re AppendNonNegativeInt32(sb, minutes, literal.mm); // mm sb.Append(literal.MinuteSecondSep); // : AppendNonNegativeInt32(sb, seconds, literal.ss); // ss - if (!isInvariant && pattern == Pattern.Minimum) + if (!full) { int effectiveDigits = literal.ff; - while (effectiveDigits > 0) + while (effectiveDigits > 0 && fraction % 10 == 0) { - if (fraction % 10 == 0) - { - fraction = fraction / 10; - effectiveDigits--; - } - else - { - break; - } + fraction = fraction / 10; + effectiveDigits--; } if (effectiveDigits > 0) { @@ -176,7 +305,7 @@ private static StringBuilder FormatStandard(TimeSpan value, bool isInvariant, Re sb.Append((fraction).ToString(DateTimeFormat.fixedNumberFormats[effectiveDigits - 1], CultureInfo.InvariantCulture)); } } - else if (pattern == Pattern.Full || fraction != 0) + else { sb.Append(literal.SecondFractionSep); // [.] AppendNonNegativeInt32(sb, fraction, literal.ff); // [fffffff] diff --git a/src/System.Private.CoreLib/shared/System/IAsyncResult.cs b/src/System.Private.CoreLib/shared/System/IAsyncResult.cs index 0abeaca5258a..56ebcdb2f519 100644 --- a/src/System.Private.CoreLib/shared/System/IAsyncResult.cs +++ b/src/System.Private.CoreLib/shared/System/IAsyncResult.cs @@ -23,7 +23,7 @@ public interface IAsyncResult WaitHandle AsyncWaitHandle { get; } - Object AsyncState { get; } + object AsyncState { get; } bool CompletedSynchronously { get; } } diff --git a/src/System.Private.CoreLib/shared/System/IComparable.cs b/src/System.Private.CoreLib/shared/System/IComparable.cs index 72aeeb027c05..cf71953e2552 100644 --- a/src/System.Private.CoreLib/shared/System/IComparable.cs +++ b/src/System.Private.CoreLib/shared/System/IComparable.cs @@ -18,7 +18,7 @@ public interface IComparable // if this is equal to object, or a value greater than zero // if this is greater than object. // - int CompareTo(Object obj); + int CompareTo(object obj); } // Generic version of IComparable. diff --git a/src/System.Private.CoreLib/shared/System/IConvertible.cs b/src/System.Private.CoreLib/shared/System/IConvertible.cs index 87351127f2ff..7abd0c45c3ac 100644 --- a/src/System.Private.CoreLib/shared/System/IConvertible.cs +++ b/src/System.Private.CoreLib/shared/System/IConvertible.cs @@ -54,10 +54,10 @@ public interface IConvertible ulong ToUInt64(IFormatProvider provider); float ToSingle(IFormatProvider provider); double ToDouble(IFormatProvider provider); - Decimal ToDecimal(IFormatProvider provider); + decimal ToDecimal(IFormatProvider provider); DateTime ToDateTime(IFormatProvider provider); - String ToString(IFormatProvider provider); - Object ToType(Type conversionType, IFormatProvider provider); + string ToString(IFormatProvider provider); + object ToType(Type conversionType, IFormatProvider provider); } } diff --git a/src/System.Private.CoreLib/shared/System/ICustomFormatter.cs b/src/System.Private.CoreLib/shared/System/ICustomFormatter.cs index 47340f30931b..cd798b4a1e27 100644 --- a/src/System.Private.CoreLib/shared/System/ICustomFormatter.cs +++ b/src/System.Private.CoreLib/shared/System/ICustomFormatter.cs @@ -19,6 +19,6 @@ namespace System public interface ICustomFormatter { // Interface does not need to be marked with the serializable attribute - String Format(String format, Object arg, IFormatProvider formatProvider); + string Format(string format, object arg, IFormatProvider formatProvider); } } diff --git a/src/System.Private.CoreLib/shared/System/IFormatProvider.cs b/src/System.Private.CoreLib/shared/System/IFormatProvider.cs index 0c17354af302..9369b074f98b 100644 --- a/src/System.Private.CoreLib/shared/System/IFormatProvider.cs +++ b/src/System.Private.CoreLib/shared/System/IFormatProvider.cs @@ -18,6 +18,6 @@ namespace System public interface IFormatProvider { // Interface does not need to be marked with the serializable attribute - Object GetFormat(Type formatType); + object GetFormat(Type formatType); } } diff --git a/src/System.Private.CoreLib/shared/System/IFormattable.cs b/src/System.Private.CoreLib/shared/System/IFormattable.cs index 1f2f7022ccb6..b5ed9bb45b6f 100644 --- a/src/System.Private.CoreLib/shared/System/IFormattable.cs +++ b/src/System.Private.CoreLib/shared/System/IFormattable.cs @@ -8,6 +8,6 @@ namespace System { public interface IFormattable { - String ToString(String format, IFormatProvider formatProvider); + string ToString(string format, IFormatProvider formatProvider); } } diff --git a/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs b/src/System.Private.CoreLib/shared/System/IO/BinaryReader.cs similarity index 94% rename from src/System.Private.CoreLib/src/System/IO/BinaryReader.cs rename to src/System.Private.CoreLib/shared/System/IO/BinaryReader.cs index 04fe45d3784e..1f1b9218f1e3 100644 --- a/src/System.Private.CoreLib/src/System/IO/BinaryReader.cs +++ b/src/System.Private.CoreLib/shared/System/IO/BinaryReader.cs @@ -14,13 +14,9 @@ ** ============================================================*/ -using System; -using System.Runtime; +using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; -using System.Globalization; -using System.Diagnostics; -using System.Security; namespace System.IO { @@ -151,7 +147,77 @@ public virtual int Read() { throw Error.GetFileNotOpen(); } - return InternalReadOneChar(); + + int charsRead = 0; + int numBytes = 0; + long posSav = posSav = 0; + + if (_stream.CanSeek) + { + posSav = _stream.Position; + } + + if (_charBytes == null) + { + _charBytes = new byte[MaxCharBytesSize]; //REVIEW: We need at most 2 bytes/char here? + } + if (_singleChar == null) + { + _singleChar = new char[1]; + } + + while (charsRead == 0) + { + // We really want to know what the minimum number of bytes per char + // is for our encoding. Otherwise for UnicodeEncoding we'd have to + // do ~1+log(n) reads to read n characters. + // Assume 1 byte can be 1 char unless _2BytesPerChar is true. + numBytes = _2BytesPerChar ? 2 : 1; + + int r = _stream.ReadByte(); + _charBytes[0] = (byte)r; + if (r == -1) + { + numBytes = 0; + } + if (numBytes == 2) + { + r = _stream.ReadByte(); + _charBytes[1] = (byte)r; + if (r == -1) + { + numBytes = 1; + } + } + + if (numBytes == 0) + { + return -1; + } + + Debug.Assert(numBytes == 1 || numBytes == 2, "BinaryReader::ReadOneChar assumes it's reading one or 2 bytes only."); + + try + { + charsRead = _decoder.GetChars(_charBytes, 0, numBytes, _singleChar, 0); + } + catch + { + // Handle surrogate char + + if (_stream.CanSeek) + { + _stream.Seek((posSav - _stream.Position), SeekOrigin.Current); + } + // else - we can't do much here + + throw; + } + + Debug.Assert(charsRead < 2, "BinaryReader::ReadOneChar - assuming we only got 0 or 1 char, not 2!"); + } + Debug.Assert(charsRead > 0); + return _singleChar[0]; } public virtual bool ReadBoolean() @@ -281,7 +347,7 @@ public virtual decimal ReadDecimal() FillBuffer(16); try { - return Decimal.ToDecimal(_buffer); + return decimal.ToDecimal(_buffer); } catch (ArgumentException e) { @@ -413,15 +479,10 @@ private int InternalReadChars(Span buffer) // do ~1+log(n) reads to read n characters. numBytes = charsRemaining; - // special case for DecoderNLS subclasses when there is a hanging byte from the previous loop - DecoderNLS decoder = _decoder as DecoderNLS; - if (decoder != null && decoder.HasState && numBytes > 1) - { - numBytes -= 1; - } - if (_2BytesPerChar) + { numBytes <<= 1; + } if (numBytes > MaxCharBytesSize) { numBytes = MaxCharBytesSize; @@ -482,87 +543,6 @@ private int InternalReadChars(Span buffer) return (buffer.Length - charsRemaining); } - private int InternalReadOneChar() - { - // I know having a separate InternalReadOneChar method seems a little - // redundant, but this makes a scenario like the security parser code - // 20% faster, in addition to the optimizations for UnicodeEncoding I - // put in InternalReadChars. - int charsRead = 0; - int numBytes = 0; - long posSav = posSav = 0; - - if (_stream.CanSeek) - { - posSav = _stream.Position; - } - - if (_charBytes == null) - { - _charBytes = new byte[MaxCharBytesSize]; //REVIEW: We need at most 2 bytes/char here? - } - if (_singleChar == null) - { - _singleChar = new char[1]; - } - - while (charsRead == 0) - { - // We really want to know what the minimum number of bytes per char - // is for our encoding. Otherwise for UnicodeEncoding we'd have to - // do ~1+log(n) reads to read n characters. - // Assume 1 byte can be 1 char unless _2BytesPerChar is true. - numBytes = _2BytesPerChar ? 2 : 1; - - int r = _stream.ReadByte(); - _charBytes[0] = (byte)r; - if (r == -1) - { - numBytes = 0; - } - if (numBytes == 2) - { - r = _stream.ReadByte(); - _charBytes[1] = (byte)r; - if (r == -1) - { - numBytes = 1; - } - } - - if (numBytes == 0) - { - // Console.WriteLine("Found no bytes. We're outta here."); - return -1; - } - - Debug.Assert(numBytes == 1 || numBytes == 2, "BinaryReader::InternalReadOneChar assumes it's reading one or 2 bytes only."); - - try - { - charsRead = _decoder.GetChars(_charBytes, 0, numBytes, _singleChar, 0); - } - catch - { - // Handle surrogate char - - if (_stream.CanSeek) - { - _stream.Seek((posSav - _stream.Position), SeekOrigin.Current); - } - // else - we can't do much here - - throw; - } - - Debug.Assert(charsRead < 2, "InternalReadOneChar - assuming we only got 0 or 1 char, not 2!"); - // Console.WriteLine("That became: " + charsRead + " characters."); - } - if (charsRead == 0) - return -1; - return _singleChar[0]; - } - public virtual char[] ReadChars(int count) { if (count < 0) diff --git a/src/System.Private.CoreLib/shared/System/IO/BinaryWriter.cs b/src/System.Private.CoreLib/shared/System/IO/BinaryWriter.cs index ad1d31f57717..d1a333f419f8 100644 --- a/src/System.Private.CoreLib/shared/System/IO/BinaryWriter.cs +++ b/src/System.Private.CoreLib/shared/System/IO/BinaryWriter.cs @@ -166,7 +166,7 @@ public virtual void Write(byte[] buffer, int index, int count) // public unsafe virtual void Write(char ch) { - if (Char.IsSurrogate(ch)) + if (char.IsSurrogate(ch)) throw new ArgumentException(SR.Arg_SurrogatesNotAllowedAsSingleChar); Debug.Assert(_encoding.GetMaxByteCount(1) <= 16, "_encoding.GetMaxByteCount(1) <= 16)"); @@ -223,7 +223,7 @@ public unsafe virtual void Write(double value) public virtual void Write(decimal value) { - Decimal.GetBytes(value, _buffer); + decimal.GetBytes(value, _buffer); OutStream.Write(_buffer, 0, 16); } @@ -325,7 +325,7 @@ public unsafe virtual void Write(float value) // a four-byte unsigned integer, and then writes that many characters // to the stream. // - public unsafe virtual void Write(String value) + public unsafe virtual void Write(string value) { if (value == null) throw new ArgumentNullException(nameof(value)); diff --git a/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs b/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs index 7ca6a8f8e403..257e853f9e41 100644 --- a/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/IO/FileStream.Windows.cs @@ -61,7 +61,14 @@ private void Init(FileMode mode, FileShare share) int fileType = Interop.Kernel32.GetFileType(_fileHandle); if (fileType != Interop.Kernel32.FileTypes.FILE_TYPE_DISK) { + int errorCode = fileType == Interop.Kernel32.FileTypes.FILE_TYPE_UNKNOWN ? Marshal.GetLastWin32Error() : Interop.Errors.ERROR_SUCCESS; + _fileHandle.Dispose(); + + if (errorCode != Interop.Errors.ERROR_SUCCESS) + { + throw Win32Marshal.GetExceptionForWin32Error(errorCode); + } throw new NotSupportedException(SR.NotSupported_FileStreamOnNonFiles); } diff --git a/src/System.Private.CoreLib/shared/System/IO/IOException.cs b/src/System.Private.CoreLib/shared/System/IO/IOException.cs index 89b25d51427b..04e653206137 100644 --- a/src/System.Private.CoreLib/shared/System/IO/IOException.cs +++ b/src/System.Private.CoreLib/shared/System/IO/IOException.cs @@ -17,19 +17,19 @@ public IOException() HResult = HResults.COR_E_IO; } - public IOException(String message) + public IOException(string message) : base(message) { HResult = HResults.COR_E_IO; } - public IOException(String message, int hresult) + public IOException(string message, int hresult) : base(message) { HResult = hresult; } - public IOException(String message, Exception innerException) + public IOException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_IO; diff --git a/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs b/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs index 173917f63553..9bac0d818b12 100644 --- a/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/MemoryStream.cs @@ -393,7 +393,7 @@ public override int Read(Span buffer) return n; } - public override Task ReadAsync(Byte[] buffer, int offset, int count, CancellationToken cancellationToken) + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); @@ -722,7 +722,7 @@ public override void Write(ReadOnlySpan buffer) _position = i; } - public override Task WriteAsync(Byte[] buffer, int offset, int count, CancellationToken cancellationToken) + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); diff --git a/src/System.Private.CoreLib/shared/System/IO/Path.cs b/src/System.Private.CoreLib/shared/System/IO/Path.cs index 1e40ab5e602f..e619ecd8ce07 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Path.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Path.cs @@ -409,6 +409,16 @@ public static string Join(ReadOnlySpan path1, ReadOnlySpan path2, Re return JoinInternal(path1, path2, path3); } + public static string Join(string path1, string path2) + { + return Join(path1.AsSpan(), path2.AsSpan()); + } + + public static string Join(string path1, string path2, string path3) + { + return Join(path1.AsSpan(), path2.AsSpan(), path3.AsSpan()); + } + public static bool TryJoin(ReadOnlySpan path1, ReadOnlySpan path2, Span destination, out int charsWritten) { charsWritten = 0; @@ -731,13 +741,14 @@ private static string GetRelativePath(string relativeTo, string path, StringComp // Add parent segments for segments past the common on the "from" path if (commonLength < relativeToLength) { - sb.Append(PathInternal.ParentDirectoryPrefix); + sb.Append(".."); - for (int i = commonLength; i < relativeToLength; i++) + for (int i = commonLength + 1; i < relativeToLength; i++) { if (PathInternal.IsDirectorySeparator(relativeTo[i])) { - sb.Append(PathInternal.ParentDirectoryPrefix); + sb.Append(DirectorySeparatorChar); + sb.Append(".."); } } } @@ -749,11 +760,20 @@ private static string GetRelativePath(string relativeTo, string path, StringComp } // Now add the rest of the "to" path, adding back the trailing separator - int count = pathLength - commonLength; + int differenceLength = pathLength - commonLength; if (pathEndsInSeparator) - count++; + differenceLength++; + + if (differenceLength > 0) + { + if (sb.Length > 0) + { + sb.Append(DirectorySeparatorChar); + } + + sb.Append(path, commonLength, differenceLength); + } - sb.Append(path, commonLength, count); return StringBuilderCache.GetStringAndRelease(sb); } diff --git a/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs b/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs index 00cb12e92015..c9defac1f93a 100644 --- a/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs +++ b/src/System.Private.CoreLib/shared/System/IO/PathInternal.cs @@ -115,6 +115,25 @@ internal static bool AreRootsEqual(string first, string second, StringComparison /// /// The length of the root of the given path internal static string RemoveRelativeSegments(string path, int rootLength) + { + Span initialBuffer = stackalloc char[260 /* PathInternal.MaxShortPath */]; + ValueStringBuilder sb = new ValueStringBuilder(initialBuffer); + + if (RemoveRelativeSegments(path.AsSpan(), rootLength, ref sb)) + { + path = sb.ToString(); + } + + sb.Dispose(); + return path; + } + + /// + /// Try to remove relative segments from the given path (without combining with a root). + /// + /// The length of the root of the given path + /// "true" if the path was modified + internal static bool RemoveRelativeSegments(ReadOnlySpan path, int rootLength, ref ValueStringBuilder sb) { Debug.Assert(rootLength > 0); bool flippedSeparator = false; @@ -126,15 +145,12 @@ internal static string RemoveRelativeSegments(string path, int rootLength) if (PathInternal.IsDirectorySeparator(path[skip - 1])) skip--; - Span initialBuffer = stackalloc char[260 /* PathInternal.MaxShortPath */]; - ValueStringBuilder sb = new ValueStringBuilder(initialBuffer); - // Remove "//", "/./", and "/../" from the path by copying each character to the output, // except the ones we're removing, such that the builder contains the normalized path // at the end. if (skip > 0) { - sb.Append(path.AsSpan(0, skip)); + sb.Append(path.Slice(0, skip)); } for (int i = skip; i < path.Length; i++) @@ -182,7 +198,7 @@ internal static string RemoveRelativeSegments(string path, int rootLength) i += 2; continue; - } + } } // Normalize the directory separator if needed @@ -198,11 +214,16 @@ internal static string RemoveRelativeSegments(string path, int rootLength) // If we haven't changed the source path, return the original if (!flippedSeparator && sb.Length == path.Length) { - sb.Dispose(); - return path; + return false; + } + + // We may have eaten the trailing separator from the root when we started and not replaced it + if (skip != rootLength && sb.Length < rootLength) + { + sb.Append(path[rootLength - 1]); } - return sb.Length < rootLength ? path.Substring(0, rootLength) : sb.ToString(); + return true; } } } diff --git a/src/System.Private.CoreLib/shared/System/IO/Stream.cs b/src/System.Private.CoreLib/shared/System/IO/Stream.cs index 6a091f2d9e9f..faeb69fb5418 100644 --- a/src/System.Private.CoreLib/shared/System/IO/Stream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/Stream.cs @@ -253,13 +253,13 @@ protected virtual WaitHandle CreateWaitHandle() return new ManualResetEvent(false); } - public virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public virtual IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return BeginReadInternal(buffer, offset, count, callback, state, serializeAsynchronously: false, apm: true); } internal IAsyncResult BeginReadInternal( - byte[] buffer, int offset, int count, AsyncCallback callback, Object state, + byte[] buffer, int offset, int count, AsyncCallback callback, object state, bool serializeAsynchronously, bool apm) { if (!CanRead) throw Error.GetReadNotSupported(); @@ -415,13 +415,13 @@ private Task BeginEndReadAsync(byte[] buffer, int offset, int count) - public virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public virtual IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return BeginWriteInternal(buffer, offset, count, callback, state, serializeAsynchronously: false, apm: true); } internal IAsyncResult BeginWriteInternal( - byte[] buffer, int offset, int count, AsyncCallback callback, Object state, + byte[] buffer, int offset, int count, AsyncCallback callback, object state, bool serializeAsynchronously, bool apm) { if (!CanWrite) throw Error.GetWriteNotSupported(); @@ -792,7 +792,7 @@ protected virtual void ObjectInvariant() { } - internal IAsyncResult BlockingBeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + internal IAsyncResult BlockingBeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // To avoid a race with a stream's position pointer & generating conditions // with internal buffer indexes in our own streams that @@ -824,7 +824,7 @@ internal static int BlockingEndRead(IAsyncResult asyncResult) return SynchronousAsyncResult.EndRead(asyncResult); } - internal IAsyncResult BlockingBeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + internal IAsyncResult BlockingBeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { // To avoid a race condition with a stream's position pointer & generating conditions // with internal buffer indexes in our own streams that @@ -910,7 +910,7 @@ public override Task FlushAsync(CancellationToken cancellationToken) Task.CompletedTask; } - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { if (!CanRead) throw Error.GetReadNotSupported(); @@ -925,7 +925,7 @@ public override int EndRead(IAsyncResult asyncResult) return BlockingEndRead(asyncResult); } - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { if (!CanWrite) throw Error.GetWriteNotSupported(); @@ -1005,7 +1005,7 @@ public override void SetLength(long length) /// Used as the IAsyncResult object when using asynchronous IO methods on the base Stream class. private sealed class SynchronousAsyncResult : IAsyncResult { - private readonly Object _stateObject; + private readonly object _stateObject; private readonly bool _isWrite; private ManualResetEvent _waitHandle; private ExceptionDispatchInfo _exceptionInfo; @@ -1013,20 +1013,20 @@ private sealed class SynchronousAsyncResult : IAsyncResult private bool _endXxxCalled; private int _bytesRead; - internal SynchronousAsyncResult(int bytesRead, Object asyncStateObject) + internal SynchronousAsyncResult(int bytesRead, object asyncStateObject) { _bytesRead = bytesRead; _stateObject = asyncStateObject; //_isWrite = false; } - internal SynchronousAsyncResult(Object asyncStateObject) + internal SynchronousAsyncResult(object asyncStateObject) { _stateObject = asyncStateObject; _isWrite = true; } - internal SynchronousAsyncResult(Exception ex, Object asyncStateObject, bool isWrite) + internal SynchronousAsyncResult(Exception ex, object asyncStateObject, bool isWrite) { _exceptionInfo = ExceptionDispatchInfo.Capture(ex); _stateObject = asyncStateObject; @@ -1047,7 +1047,7 @@ public WaitHandle AsyncWaitHandle } } - public Object AsyncState + public object AsyncState { get { return _stateObject; } } @@ -1226,7 +1226,7 @@ public override int ReadByte() return _stream.ReadByte(); } - public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { #if CORERT throw new NotImplementedException(); // TODO: https://github.com/dotnet/corert/issues/3251 @@ -1287,7 +1287,7 @@ public override void WriteByte(byte b) _stream.WriteByte(b); } - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, Object state) + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { #if CORERT throw new NotImplementedException(); // TODO: https://github.com/dotnet/corert/issues/3251 diff --git a/src/System.Private.CoreLib/shared/System/IO/StreamReader.cs b/src/System.Private.CoreLib/shared/System/IO/StreamReader.cs index ea30541f5aa4..5c3cc9157d1a 100644 --- a/src/System.Private.CoreLib/shared/System/IO/StreamReader.cs +++ b/src/System.Private.CoreLib/shared/System/IO/StreamReader.cs @@ -1059,7 +1059,7 @@ internal override async ValueTask ReadAsyncInternal(Memory buffer, Ca // data read in, let's try writing directly to the user's buffer. bool readToUserBuffer = false; - Byte[] tmpByteBuffer = _byteBuffer; + byte[] tmpByteBuffer = _byteBuffer; Stream tmpStream = _stream; int count = buffer.Length; @@ -1290,7 +1290,7 @@ private async Task ReadBufferAsync() { _charLen = 0; _charPos = 0; - Byte[] tmpByteBuffer = _byteBuffer; + byte[] tmpByteBuffer = _byteBuffer; Stream tmpStream = _stream; if (!_checkPreamble) diff --git a/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs b/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs index 06d94d238505..b510b6b28779 100644 --- a/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs +++ b/src/System.Private.CoreLib/shared/System/IO/StreamWriter.cs @@ -965,7 +965,7 @@ private Task FlushAsyncInternal(bool flushStream, bool flushEncoder, // to ensure performant access inside the state machine that corresponds this async method. private static async Task FlushAsyncInternal(StreamWriter _this, bool flushStream, bool flushEncoder, char[] charBuffer, int charPos, bool haveWrittenPreamble, - Encoding encoding, Encoder encoder, Byte[] byteBuffer, Stream stream, CancellationToken cancellationToken) + Encoding encoding, Encoder encoder, byte[] byteBuffer, Stream stream, CancellationToken cancellationToken) { if (!haveWrittenPreamble) { diff --git a/src/System.Private.CoreLib/shared/System/IO/TextReader.cs b/src/System.Private.CoreLib/shared/System/IO/TextReader.cs index 98e1e64cd5f5..bb5b142bde4f 100644 --- a/src/System.Private.CoreLib/shared/System/IO/TextReader.cs +++ b/src/System.Private.CoreLib/shared/System/IO/TextReader.cs @@ -207,7 +207,7 @@ public virtual string ReadLine() #region Task based Async APIs public virtual Task ReadLineAsync() { - return Task.Factory.StartNew(state => + return Task.Factory.StartNew(state => { return ((TextReader)state).ReadLine(); }, diff --git a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs index 2afe907afd1b..547c597f0334 100644 --- a/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs +++ b/src/System.Private.CoreLib/shared/System/IO/TextWriter.cs @@ -13,24 +13,24 @@ namespace System.IO { // This abstract base class represents a writer that can write a sequential - // stream of characters. A subclass must minimally implement the + // stream of characters. A subclass must minimally implement the // Write(char) method. // - // This class is intended for character output, not bytes. - // There are methods on the Stream class for writing bytes. + // This class is intended for character output, not bytes. + // There are methods on the Stream class for writing bytes. public abstract partial class TextWriter : MarshalByRefObject, IDisposable { public static readonly TextWriter Null = new NullTextWriter(); - // We don't want to allocate on every TextWriter creation, so cache the char array. + // We don't want to allocate on every TextWriter creation, so cache the char array. private static readonly char[] s_coreNewLine = Environment.NewLine.ToCharArray(); /// - /// This is the 'NewLine' property expressed as a char[]. + /// This is the 'NewLine' property expressed as a char[]. /// It is exposed to subclasses as a protected field for read-only - /// purposes. You should only modify it by using the 'NewLine' property. - /// In particular you should never modify the elements of the array - /// as they are shared among many instances of TextWriter. + /// purposes. You should only modify it by using the 'NewLine' property. + /// In particular you should never modify the elements of the array + /// as they are shared among many instances of TextWriter. /// protected char[] CoreNewLine = s_coreNewLine; private string CoreNewLineStr = Environment.NewLine; @@ -94,7 +94,7 @@ public abstract Encoding Encoding /// /// Returns the line terminator string used by this TextWriter. The default line - /// terminator string is Environment.NewLine, which is platform specific. + /// terminator string is Environment.NewLine, which is platform specific. /// On Windows this is a carriage return followed by a line feed ("\r\n"). /// On OSX and Linux this is a line feed ("\n"). /// @@ -184,7 +184,7 @@ public virtual void Write(ReadOnlySpan buffer) } // Writes the text representation of a boolean to the text stream. This - // method outputs either Boolean.TrueString or Boolean.FalseString. + // method outputs either bool.TrueString or bool.FalseString. // public virtual void Write(bool value) { @@ -193,7 +193,7 @@ public virtual void Write(bool value) // Writes the text representation of an integer to the text stream. The // text representation of the given value is produced by calling the - // Int32.ToString() method. + // int.ToString() method. // public virtual void Write(int value) { @@ -202,7 +202,7 @@ public virtual void Write(int value) // Writes the text representation of an integer to the text stream. The // text representation of the given value is produced by calling the - // UInt32.ToString() method. + // uint.ToString() method. // [CLSCompliant(false)] public virtual void Write(uint value) @@ -212,16 +212,16 @@ public virtual void Write(uint value) // Writes the text representation of a long to the text stream. The // text representation of the given value is produced by calling the - // Int64.ToString() method. + // long.ToString() method. // public virtual void Write(long value) { Write(value.ToString(FormatProvider)); } - // Writes the text representation of an unsigned long to the text - // stream. The text representation of the given value is produced - // by calling the UInt64.ToString() method. + // Writes the text representation of an unsigned long to the text + // stream. The text representation of the given value is produced + // by calling the ulong.ToString() method. // [CLSCompliant(false)] public virtual void Write(ulong value) @@ -231,7 +231,7 @@ public virtual void Write(ulong value) // Writes the text representation of a float to the text stream. The // text representation of the given value is produced by calling the - // Float.toString(float) method. + // float.ToString(float) method. // public virtual void Write(float value) { @@ -240,7 +240,7 @@ public virtual void Write(float value) // Writes the text representation of a double to the text stream. The // text representation of the given value is produced by calling the - // Double.toString(double) method. + // double.ToString(double) method. // public virtual void Write(double value) { @@ -283,33 +283,48 @@ public virtual void Write(object value) } } + /// + /// Equivalent to Write(stringBuilder.ToString()) however it uses the + /// StringBuilder.GetChunks() method to avoid creating the intermediate string + /// + /// The string (as a StringBuilder) to write to the stream + public virtual void Write(StringBuilder value) + { + if (value == null) + { + throw new ArgumentNullException(nameof(value)); + } + foreach (ReadOnlyMemory chunk in value.GetChunks()) + Write(chunk); + } + // Writes out a formatted string. Uses the same semantics as - // String.Format. - // + // string.Format. + // public virtual void Write(string format, object arg0) { Write(string.Format(FormatProvider, format, arg0)); } // Writes out a formatted string. Uses the same semantics as - // String.Format. - // + // string.Format. + // public virtual void Write(string format, object arg0, object arg1) { Write(string.Format(FormatProvider, format, arg0, arg1)); } // Writes out a formatted string. Uses the same semantics as - // String.Format. - // + // string.Format. + // public virtual void Write(string format, object arg0, object arg1, object arg2) { Write(string.Format(FormatProvider, format, arg0, arg1, arg2)); } // Writes out a formatted string. Uses the same semantics as - // String.Format. - // + // string.Format. + // public virtual void Write(string format, params object[] arg) { Write(string.Format(FormatProvider, format, arg)); @@ -383,7 +398,7 @@ public virtual void WriteLine(int value) WriteLine(); } - // Writes the text representation of an unsigned integer followed by + // Writes the text representation of an unsigned integer followed by // a line terminator to the text stream. // [CLSCompliant(false)] @@ -402,7 +417,7 @@ public virtual void WriteLine(long value) WriteLine(); } - // Writes the text representation of an unsigned long followed by + // Writes the text representation of an unsigned long followed by // a line terminator to the text stream. // [CLSCompliant(false)] @@ -447,6 +462,16 @@ public virtual void WriteLine(string value) Write(CoreNewLineStr); } + /// + /// Equivalent to WriteLine(stringBuilder.ToString()) however it uses the + /// StringBuilder.GetChunks() method to avoid creating the intermediate string + /// + public virtual void WriteLine(StringBuilder value) + { + Write(value); + WriteLine(); + } + // Writes the text representation of an object followed by a line // terminator to the text stream. // @@ -472,33 +497,33 @@ public virtual void WriteLine(object value) } } - // Writes out a formatted string and a new line. Uses the same - // semantics as String.Format. - // + // Writes out a formatted string and a new line. Uses the same + // semantics as string.Format. + // public virtual void WriteLine(string format, object arg0) { WriteLine(string.Format(FormatProvider, format, arg0)); } - // Writes out a formatted string and a new line. Uses the same - // semantics as String.Format. - // + // Writes out a formatted string and a new line. Uses the same + // semantics as string.Format. + // public virtual void WriteLine(string format, object arg0, object arg1) { WriteLine(string.Format(FormatProvider, format, arg0, arg1)); } - // Writes out a formatted string and a new line. Uses the same - // semantics as String.Format. - // + // Writes out a formatted string and a new line. Uses the same + // semantics as string.Format. + // public virtual void WriteLine(string format, object arg0, object arg1, object arg2) { WriteLine(string.Format(FormatProvider, format, arg0, arg1, arg2)); } - // Writes out a formatted string and a new line. Uses the same - // semantics as String.Format. - // + // Writes out a formatted string and a new line. Uses the same + // semantics as string.Format. + // public virtual void WriteLine(string format, params object[] arg) { WriteLine(string.Format(FormatProvider, format, arg)); @@ -527,6 +552,27 @@ public virtual Task WriteAsync(string value) tuple, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); } + /// + /// Equivalent to WriteAsync(stringBuilder.ToString()) however it uses the + /// StringBuilder.GetChunks() method to avoid creating the intermediate string + /// + /// The string (as a StringBuilder) to write to the stream + public virtual Task WriteAsync(StringBuilder value, CancellationToken cancellationToken = default) + { + return + cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : + value == null ? Task.CompletedTask : + WriteAsyncCore(value, cancellationToken); + + async Task WriteAsyncCore(StringBuilder sb, CancellationToken ct) + { + foreach (ReadOnlyMemory chunk in sb.GetChunks()) + { + await WriteAsync(chunk, ct).ConfigureAwait(false); + } + } + } + public Task WriteAsync(char[] buffer) { if (buffer == null) @@ -549,6 +595,7 @@ public virtual Task WriteAsync(char[] buffer, int index, int count) } public virtual Task WriteAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) => + cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? WriteAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => @@ -579,6 +626,28 @@ public virtual Task WriteLineAsync(string value) tuple, CancellationToken.None, TaskCreationOptions.DenyChildAttach, TaskScheduler.Default); } + /// + /// Equivalent to WriteLineAsync(stringBuilder.ToString()) however it uses the + /// StringBuilder.GetChunks() method to avoid creating the intermediate string + /// + /// The string (as a StringBuilder) to write to the stream + public virtual Task WriteLineAsync(StringBuilder value, CancellationToken cancellationToken = default) + { + return + cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : + value == null ? WriteAsync(CoreNewLine, cancellationToken) : + WriteLineAsyncCore(value, cancellationToken); + + async Task WriteLineAsyncCore(StringBuilder sb, CancellationToken ct) + { + foreach (ReadOnlyMemory chunk in sb.GetChunks()) + { + await WriteAsync(chunk, ct).ConfigureAwait(false); + } + await WriteAsync(CoreNewLine, ct).ConfigureAwait(false); + } + } + public Task WriteLineAsync(char[] buffer) { if (buffer == null) @@ -601,6 +670,7 @@ public virtual Task WriteLineAsync(char[] buffer, int index, int count) } public virtual Task WriteLineAsync(ReadOnlyMemory buffer, CancellationToken cancellationToken = default) => + cancellationToken.IsCancellationRequested ? Task.FromCanceled(cancellationToken) : MemoryMarshal.TryGetArray(buffer, out ArraySegment array) ? WriteLineAsync(array.Array, array.Offset, array.Count) : Task.Factory.StartNew(state => @@ -739,11 +809,14 @@ protected override void Dispose(bool disposing) public override void Write(double value) => _out.Write(value); [MethodImpl(MethodImplOptions.Synchronized)] - public override void Write(Decimal value) => _out.Write(value); + public override void Write(decimal value) => _out.Write(value); [MethodImpl(MethodImplOptions.Synchronized)] public override void Write(string value) => _out.Write(value); + [MethodImpl(MethodImplOptions.Synchronized)] + public override void Write(StringBuilder value) => _out.Write(value); + [MethodImpl(MethodImplOptions.Synchronized)] public override void Write(object value) => _out.Write(value); @@ -798,6 +871,9 @@ protected override void Dispose(bool disposing) [MethodImpl(MethodImplOptions.Synchronized)] public override void WriteLine(string value) => _out.WriteLine(value); + [MethodImpl(MethodImplOptions.Synchronized)] + public override void WriteLine(StringBuilder value) => _out.WriteLine(value); + [MethodImpl(MethodImplOptions.Synchronized)] public override void WriteLine(object value) => _out.WriteLine(value); @@ -831,6 +907,13 @@ public override Task WriteAsync(string value) return Task.CompletedTask; } + [MethodImpl(MethodImplOptions.Synchronized)] + public override Task WriteAsync(StringBuilder value, CancellationToken cancellationToken = default) + { + Write(value); + return Task.CompletedTask; + } + [MethodImpl(MethodImplOptions.Synchronized)] public override Task WriteAsync(char[] buffer, int index, int count) { @@ -852,6 +935,13 @@ public override Task WriteLineAsync(string value) return Task.CompletedTask; } + [MethodImpl(MethodImplOptions.Synchronized)] + public override Task WriteLineAsync(StringBuilder value, CancellationToken cancellationToken = default) + { + WriteLine(value); + return Task.CompletedTask; + } + [MethodImpl(MethodImplOptions.Synchronized)] public override Task WriteLineAsync(char[] buffer, int index, int count) { diff --git a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs index 70770e4a28cf..d4af4cfee370 100644 --- a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs +++ b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStream.cs @@ -47,7 +47,7 @@ public class UnmanagedMemoryStream : Stream private long _offset; private FileAccess _access; private bool _isOpen; - private Task _lastReadTask; // The last successful task returned from ReadAsync + private Task _lastReadTask; // The last successful task returned from ReadAsync /// /// Creates a closed stream. @@ -456,7 +456,7 @@ internal int ReadCore(Span buffer) /// Maximum number of bytes to read. /// Token that can be used to cancel this operation. /// Task that can be used to access the number of bytes actually read. - public override Task ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); @@ -468,18 +468,18 @@ public override Task ReadAsync(Byte[] buffer, Int32 offset, Int32 count, throw new ArgumentException(SR.Argument_InvalidOffLen); if (cancellationToken.IsCancellationRequested) - return Task.FromCanceled(cancellationToken); + return Task.FromCanceled(cancellationToken); try { - Int32 n = Read(buffer, offset, count); - Task t = _lastReadTask; + int n = Read(buffer, offset, count); + Task t = _lastReadTask; return (t != null && t.Result == n) ? t : (_lastReadTask = Task.FromResult(n)); } catch (Exception ex) { Debug.Assert(!(ex is OperationCanceledException)); - return Task.FromException(ex); + return Task.FromException(ex); } } @@ -752,7 +752,7 @@ internal unsafe void WriteCore(ReadOnlySpan buffer) /// Number of bytes to write. /// Token that can be used to cancel the operation. /// Task that can be awaited - public override Task WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { if (buffer == null) throw new ArgumentNullException(nameof(buffer), SR.ArgumentNull_Buffer); diff --git a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs index 104f5590a8b7..9a598951ee80 100644 --- a/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs +++ b/src/System.Private.CoreLib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs @@ -160,7 +160,7 @@ public unsafe override void WriteTo(Stream stream) stream.Write(buffer, 0, buffer.Length); } - public override void SetLength(Int64 value) + public override void SetLength(long value) { // This was probably meant to call _unmanagedStream.SetLength(value), but it was forgotten in V.4.0. // Now this results in a call to the base which touches the underlying array which is never actually used. @@ -169,7 +169,7 @@ public override void SetLength(Int64 value) } - public override Task CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken) + public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) { // The parameter checks must be in sync with the base version: if (destination == null) @@ -201,7 +201,7 @@ public override Task FlushAsync(CancellationToken cancellationToken) } - public override Task ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { return _unmanagedStream.ReadAsync(buffer, offset, count, cancellationToken); } @@ -212,7 +212,7 @@ public override ValueTask ReadAsync(Memory buffer, CancellationToken } - public override Task WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { return _unmanagedStream.WriteAsync(buffer, offset, count, cancellationToken); } diff --git a/src/System.Private.CoreLib/shared/System/IndexOutOfRangeException.cs b/src/System.Private.CoreLib/shared/System/IndexOutOfRangeException.cs index b6d93ef56831..aadc942314b0 100644 --- a/src/System.Private.CoreLib/shared/System/IndexOutOfRangeException.cs +++ b/src/System.Private.CoreLib/shared/System/IndexOutOfRangeException.cs @@ -25,13 +25,13 @@ public IndexOutOfRangeException() HResult = HResults.COR_E_INDEXOUTOFRANGE; } - public IndexOutOfRangeException(String message) + public IndexOutOfRangeException(string message) : base(message) { HResult = HResults.COR_E_INDEXOUTOFRANGE; } - public IndexOutOfRangeException(String message, Exception innerException) + public IndexOutOfRangeException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_INDEXOUTOFRANGE; diff --git a/src/System.Private.CoreLib/shared/System/InsufficientExecutionStackException.cs b/src/System.Private.CoreLib/shared/System/InsufficientExecutionStackException.cs index 4822028f8546..4c4bf242e189 100644 --- a/src/System.Private.CoreLib/shared/System/InsufficientExecutionStackException.cs +++ b/src/System.Private.CoreLib/shared/System/InsufficientExecutionStackException.cs @@ -16,13 +16,13 @@ public InsufficientExecutionStackException() HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; } - public InsufficientExecutionStackException(String message) + public InsufficientExecutionStackException(string message) : base(message) { HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; } - public InsufficientExecutionStackException(String message, Exception innerException) + public InsufficientExecutionStackException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_INSUFFICIENTEXECUTIONSTACK; diff --git a/src/System.Private.CoreLib/shared/System/InsufficientMemoryException.cs b/src/System.Private.CoreLib/shared/System/InsufficientMemoryException.cs index 4e90714c9268..68377540e6da 100644 --- a/src/System.Private.CoreLib/shared/System/InsufficientMemoryException.cs +++ b/src/System.Private.CoreLib/shared/System/InsufficientMemoryException.cs @@ -30,13 +30,13 @@ public InsufficientMemoryException() : base( HResult = HResults.COR_E_INSUFFICIENTMEMORY; } - public InsufficientMemoryException(String message) + public InsufficientMemoryException(string message) : base(message) { HResult = HResults.COR_E_INSUFFICIENTMEMORY; } - public InsufficientMemoryException(String message, Exception innerException) + public InsufficientMemoryException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_INSUFFICIENTMEMORY; diff --git a/src/System.Private.CoreLib/shared/System/Int16.cs b/src/System.Private.CoreLib/shared/System/Int16.cs index fecc87e9fe61..49732997639d 100644 --- a/src/System.Private.CoreLib/shared/System/Int16.cs +++ b/src/System.Private.CoreLib/shared/System/Int16.cs @@ -12,9 +12,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Int16 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct Int16 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private short m_value; // Do not rename (binary serialization) + private readonly short m_value; // Do not rename (binary serialization) public const short MaxValue = (short)0x7FFF; public const short MinValue = unchecked((short)0x8000); @@ -25,37 +25,37 @@ public struct Int16 : IComparable, IConvertible, IFormattable, IComparable 0 && (format[0] == 'X' || format[0] == 'x')) { @@ -103,26 +103,26 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return Number.TryFormatInt32(m_value, format, provider, destination, out charsWritten); } - public static short Parse(String s) + public static short Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } - public static short Parse(String s, NumberStyles style) + public static short Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, style, NumberFormatInfo.CurrentInfo); } - public static short Parse(String s, IFormatProvider provider) + public static short Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); } - public static short Parse(String s, NumberStyles style, IFormatProvider provider) + public static short Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -151,7 +151,7 @@ private static short Parse(ReadOnlySpan s, NumberStyles style, NumberForma // for negative numbers if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number - if ((i < 0) || (i > UInt16.MaxValue)) + if ((i < 0) || (i > ushort.MaxValue)) { throw new OverflowException(SR.Overflow_Int16); } @@ -162,7 +162,7 @@ private static short Parse(ReadOnlySpan s, NumberStyles style, NumberForma return (short)i; } - public static bool TryParse(String s, out Int16 result) + public static bool TryParse(string s, out short result) { if (s == null) { @@ -178,7 +178,7 @@ public static bool TryParse(ReadOnlySpan s, out short result) return TryParse(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result); } - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int16 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out short result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -197,7 +197,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro return TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result); } - private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out Int16 result) + private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out short result) { result = 0; int i; @@ -210,11 +210,11 @@ private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFor // for negative numbers if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number - if ((i < 0) || i > UInt16.MaxValue) + if ((i < 0) || i > ushort.MaxValue) { return false; } - result = (Int16)i; + result = (short)i; return true; } @@ -222,7 +222,7 @@ private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFor { return false; } - result = (Int16)i; + result = (short)i; return true; } @@ -296,7 +296,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -306,7 +306,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int16", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Int32.cs b/src/System.Private.CoreLib/shared/System/Int32.cs index b573e950e462..1d0aefe73cbf 100644 --- a/src/System.Private.CoreLib/shared/System/Int32.cs +++ b/src/System.Private.CoreLib/shared/System/Int32.cs @@ -12,9 +12,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Int32 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct Int32 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private int m_value; // Do not rename (binary serialization) + private readonly int m_value; // Do not rename (binary serialization) public const int MaxValue = 0x7fffffff; public const int MinValue = unchecked((int)0x80000000); @@ -28,13 +28,13 @@ public struct Int32 : IComparable, IConvertible, IFormattable, IComparable MaxValue. @@ -55,17 +55,17 @@ public int CompareTo(int value) return 0; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (!(obj is Int32)) + if (!(obj is int)) { return false; } - return m_value == ((Int32)obj).m_value; + return m_value == ((int)obj).m_value; } [NonVersionable] - public bool Equals(Int32 obj) + public bool Equals(int obj) { return m_value == obj; } @@ -76,22 +76,22 @@ public override int GetHashCode() return m_value; } - public override String ToString() + public override string ToString() { return Number.FormatInt32(m_value, null, null); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatInt32(m_value, format, null); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatInt32(m_value, null, provider); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatInt32(m_value, format, provider); } @@ -101,13 +101,13 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return Number.TryFormatInt32(m_value, format, provider, destination, out charsWritten); } - public static int Parse(String s) + public static int Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } - public static int Parse(String s, NumberStyles style) + public static int Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -118,7 +118,7 @@ public static int Parse(String s, NumberStyles style) // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. // - public static int Parse(String s, IFormatProvider provider) + public static int Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseInt32(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); @@ -128,7 +128,7 @@ public static int Parse(String s, IFormatProvider provider) // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. // - public static int Parse(String s, NumberStyles style, IFormatProvider provider) + public static int Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -144,7 +144,7 @@ public static int Parse(ReadOnlySpan s, NumberStyles style = NumberStyles. // Parses an integer from a String. Returns false rather // than throwing exceptin if input is invalid // - public static bool TryParse(String s, out Int32 result) + public static bool TryParse(string s, out int result) { if (s == null) { @@ -163,7 +163,7 @@ public static bool TryParse(ReadOnlySpan s, out int result) // Parses an integer from a String in the given style. Returns false rather // than throwing exceptin if input is invalid // - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out Int32 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out int result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -251,7 +251,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -261,7 +261,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int32", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Int64.cs b/src/System.Private.CoreLib/shared/System/Int64.cs index 0bcca87309b2..62c9ffd4fe64 100644 --- a/src/System.Private.CoreLib/shared/System/Int64.cs +++ b/src/System.Private.CoreLib/shared/System/Int64.cs @@ -12,9 +12,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Int64 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct Int64 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private long m_value; // Do not rename (binary serialization) + private readonly long m_value; // Do not rename (binary serialization) public const long MaxValue = 0x7fffffffffffffffL; public const long MinValue = unchecked((long)0x8000000000000000L); @@ -25,13 +25,13 @@ public struct Int64 : IComparable, IConvertible, IFormattable, IComparable> 32)); } - public override String ToString() + public override string ToString() { return Number.FormatInt64(m_value, null, null); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatInt64(m_value, null, provider); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatInt64(m_value, format, null); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatInt64(m_value, format, provider); } @@ -98,20 +98,20 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan return Number.TryFormatInt64(m_value, format, provider, destination, out charsWritten); } - public static long Parse(String s) + public static long Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } - public static long Parse(String s, NumberStyles style) + public static long Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseInt64(s, style, NumberFormatInfo.CurrentInfo); } - public static long Parse(String s, IFormatProvider provider) + public static long Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseInt64(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); @@ -122,7 +122,7 @@ public static long Parse(String s, IFormatProvider provider) // a NumberFormatInfo isn't specified, the current culture's // NumberFormatInfo is assumed. // - public static long Parse(String s, NumberStyles style, IFormatProvider provider) + public static long Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -135,7 +135,7 @@ public static long Parse(ReadOnlySpan s, NumberStyles style = NumberStyles return Number.ParseInt64(s, style, NumberFormatInfo.GetInstance(provider)); } - public static Boolean TryParse(String s, out Int64 result) + public static bool TryParse(string s, out long result) { if (s == null) { @@ -151,7 +151,7 @@ public static bool TryParse(ReadOnlySpan s, out long result) return Number.TryParseInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo, out result); } - public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out Int64 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out long result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -239,7 +239,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -249,7 +249,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Int64", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/IntPtr.cs b/src/System.Private.CoreLib/shared/System/IntPtr.cs index 44638ddd8ee9..f79334a96bef 100644 --- a/src/System.Private.CoreLib/shared/System/IntPtr.cs +++ b/src/System.Private.CoreLib/shared/System/IntPtr.cs @@ -17,13 +17,13 @@ namespace System { [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct IntPtr : IEquatable, ISerializable + public readonly struct IntPtr : IEquatable, ISerializable { // WARNING: We allow diagnostic tools to directly inspect this member (_value). // See https://github.com/dotnet/corert/blob/master/Documentation/design-docs/diagnostics/diagnostics-tools-contract.md for more details. // Please do not change the type, the name, or the semantic usage of this member without understanding the implication for tools. // Get in touch with the diagnostics team if you have questions. - private unsafe void* _value; // Do not rename (binary serialization) + private readonly unsafe void* _value; // Do not rename (binary serialization) [Intrinsic] public static readonly IntPtr Zero; @@ -72,7 +72,7 @@ unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext info.AddValue("value", ToInt64()); } - public unsafe override bool Equals(Object obj) + public unsafe override bool Equals(object obj) { if (obj is IntPtr) { diff --git a/src/System.Private.CoreLib/shared/System/InvalidCastException.cs b/src/System.Private.CoreLib/shared/System/InvalidCastException.cs index 055643278abc..cb6036aeb48b 100644 --- a/src/System.Private.CoreLib/shared/System/InvalidCastException.cs +++ b/src/System.Private.CoreLib/shared/System/InvalidCastException.cs @@ -22,19 +22,19 @@ public InvalidCastException() HResult = HResults.COR_E_INVALIDCAST; } - public InvalidCastException(String message) + public InvalidCastException(string message) : base(message) { HResult = HResults.COR_E_INVALIDCAST; } - public InvalidCastException(String message, Exception innerException) + public InvalidCastException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_INVALIDCAST; } - public InvalidCastException(String message, int errorCode) + public InvalidCastException(string message, int errorCode) : base(message) { HResult = errorCode; diff --git a/src/System.Private.CoreLib/shared/System/InvalidOperationException.cs b/src/System.Private.CoreLib/shared/System/InvalidOperationException.cs index 62c222af401a..9fffbec4337b 100644 --- a/src/System.Private.CoreLib/shared/System/InvalidOperationException.cs +++ b/src/System.Private.CoreLib/shared/System/InvalidOperationException.cs @@ -26,13 +26,13 @@ public InvalidOperationException() HResult = HResults.COR_E_INVALIDOPERATION; } - public InvalidOperationException(String message) + public InvalidOperationException(string message) : base(message) { HResult = HResults.COR_E_INVALIDOPERATION; } - public InvalidOperationException(String message, Exception innerException) + public InvalidOperationException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_INVALIDOPERATION; diff --git a/src/System.Private.CoreLib/shared/System/InvalidProgramException.cs b/src/System.Private.CoreLib/shared/System/InvalidProgramException.cs index c8047c548b3f..62a14f91168f 100644 --- a/src/System.Private.CoreLib/shared/System/InvalidProgramException.cs +++ b/src/System.Private.CoreLib/shared/System/InvalidProgramException.cs @@ -25,13 +25,13 @@ public InvalidProgramException() HResult = HResults.COR_E_INVALIDPROGRAM; } - public InvalidProgramException(String message) + public InvalidProgramException(string message) : base(message) { HResult = HResults.COR_E_INVALIDPROGRAM; } - public InvalidProgramException(String message, Exception inner) + public InvalidProgramException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_INVALIDPROGRAM; diff --git a/src/System.Private.CoreLib/shared/System/InvalidTimeZoneException.cs b/src/System.Private.CoreLib/shared/System/InvalidTimeZoneException.cs index 25b155e8d102..1bbb7e067bcd 100644 --- a/src/System.Private.CoreLib/shared/System/InvalidTimeZoneException.cs +++ b/src/System.Private.CoreLib/shared/System/InvalidTimeZoneException.cs @@ -14,12 +14,12 @@ public InvalidTimeZoneException() { } - public InvalidTimeZoneException(String message) + public InvalidTimeZoneException(string message) : base(message) { } - public InvalidTimeZoneException(String message, Exception innerException) + public InvalidTimeZoneException(string message, Exception innerException) : base(message, innerException) { } diff --git a/src/System.Private.CoreLib/shared/System/Math.cs b/src/System.Private.CoreLib/shared/System/Math.cs index a175103f81d7..ef46869e229a 100644 --- a/src/System.Private.CoreLib/shared/System/Math.cs +++ b/src/System.Private.CoreLib/shared/System/Math.cs @@ -123,15 +123,25 @@ public static int DivRem(int a, int b, out int result) public static long DivRem(long a, long b, out long 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 /. - long div = a / b; result = a - (div * b); return div; } + internal static uint DivRem(uint a, uint b, out uint result) + { + uint div = a / b; + result = a - (div * b); + return div; + } + + internal static ulong DivRem(ulong a, ulong b, out ulong result) + { + ulong div = a / b; + result = a - (div * b); + return div; + } + [MethodImpl(MethodImplOptions.AggressiveInlining)] public static decimal Ceiling(decimal d) { diff --git a/src/System.Private.CoreLib/shared/System/MemberAccessException.cs b/src/System.Private.CoreLib/shared/System/MemberAccessException.cs index dfea52dbed52..0cf1e0fbebea 100644 --- a/src/System.Private.CoreLib/shared/System/MemberAccessException.cs +++ b/src/System.Private.CoreLib/shared/System/MemberAccessException.cs @@ -31,13 +31,13 @@ public MemberAccessException() // message, its HRESULT set to COR_E_ACCESS, // and its ExceptionInfo reference set to null. // - public MemberAccessException(String message) + public MemberAccessException(string message) : base(message) { HResult = HResults.COR_E_MEMBERACCESS; } - public MemberAccessException(String message, Exception inner) + public MemberAccessException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_MEMBERACCESS; diff --git a/src/System.Private.CoreLib/shared/System/Memory.cs b/src/System.Private.CoreLib/shared/System/Memory.cs index 0abe3634ae71..1a7556720d62 100644 --- a/src/System.Private.CoreLib/shared/System/Memory.cs +++ b/src/System.Private.CoreLib/shared/System/Memory.cs @@ -8,9 +8,8 @@ using System.Runtime.InteropServices; using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; -#if !FEATURE_PORTABLE_SPAN + using Internal.Runtime.CompilerServices; -#endif // FEATURE_PORTABLE_SPAN namespace System { @@ -282,11 +281,7 @@ public Span Span // and then cast to a Memory. Such a cast can only be done with unsafe or marshaling code, // in which case that's the dangerous operation performed by the dev, and we're just following // suit here to make it work as best as possible. -#if FEATURE_PORTABLE_SPAN - return new Span(Unsafe.As>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length); -#else return new Span(ref Unsafe.As(ref s.GetRawStringData()), s.Length).Slice(_index, _length); -#endif // FEATURE_PORTABLE_SPAN } else if (_object != null) { @@ -345,11 +340,7 @@ public unsafe MemoryHandle Pin() // a readable ReadOnlyMemory or a writable Memory can still be pinned and // used for interop purposes. GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref s.GetRawStringData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } else if (_object is T[] array) @@ -357,21 +348,13 @@ public unsafe MemoryHandle Pin() // Array is already pre-pinned if (_length < 0) { -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add(Unsafe.AsPointer(ref MemoryMarshal.GetReference(array)), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer); } else { GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } } diff --git a/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs b/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs index f957e6db7dcc..4e84223b2044 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryExtensions.Fast.cs @@ -170,13 +170,51 @@ public static int IndexOf(this ReadOnlySpan span, ReadOnlySpan value case StringComparison.InvariantCultureIgnoreCase: return CompareInfo.Invariant.IndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType)); - case StringComparison.Ordinal: - case StringComparison.OrdinalIgnoreCase: + default: + Debug.Assert(comparisonType == StringComparison.Ordinal || comparisonType == StringComparison.OrdinalIgnoreCase); return CompareInfo.Invariant.IndexOfOrdinal(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType) != CompareOptions.None); } + } - Debug.Fail("StringComparison outside range"); - return -1; + /// + /// Reports the zero-based index of the last occurrence of the specified in the current . + /// The source span. + /// The value to seek within the source span. + /// One of the enumeration values that determines how the and are compared. + /// + public static int LastIndexOf(this ReadOnlySpan span, ReadOnlySpan value, StringComparison comparisonType) + { + string.CheckStringComparison(comparisonType); + + if (value.Length == 0) + { + return span.Length > 0 ? span.Length - 1 : 0; + } + + if (span.Length == 0) + { + return -1; + } + + if (GlobalizationMode.Invariant) + { + return CompareInfo.InvariantIndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType) != CompareOptions.None, fromBeginning: false); + } + + switch (comparisonType) + { + case StringComparison.CurrentCulture: + case StringComparison.CurrentCultureIgnoreCase: + return CultureInfo.CurrentCulture.CompareInfo.LastIndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType)); + + case StringComparison.InvariantCulture: + case StringComparison.InvariantCultureIgnoreCase: + return CompareInfo.Invariant.LastIndexOf(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType)); + + default: + Debug.Assert(comparisonType == StringComparison.Ordinal || comparisonType == StringComparison.OrdinalIgnoreCase); + return CompareInfo.Invariant.LastIndexOfOrdinal(span, value, string.GetCaseCompareOfComparisonCulture(comparisonType) != CompareOptions.None); + } } /// diff --git a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs index 639bf06e106a..739bc3145d1c 100644 --- a/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs +++ b/src/System.Private.CoreLib/shared/System/MemoryExtensions.cs @@ -6,19 +6,13 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif -#if netstandard -using nuint = System.NUInt; -#else #if BIT64 using nuint = System.UInt64; #else using nuint = System.UInt32; #endif // BIT64 -#endif // netstandard namespace System { @@ -1360,26 +1354,25 @@ private static bool IsTypeComparableAsBytes(out nuint size) { if (typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte)) { - // The cast to nuint is not redundant on netstandard. Do not remove it. - size = (nuint)sizeof(byte); + size = sizeof(byte); return true; } if (typeof(T) == typeof(char) || typeof(T) == typeof(short) || typeof(T) == typeof(ushort)) { - size = (nuint)sizeof(char); + size = sizeof(char); return true; } if (typeof(T) == typeof(int) || typeof(T) == typeof(uint)) { - size = (nuint)sizeof(int); + size = sizeof(int); return true; } if (typeof(T) == typeof(long) || typeof(T) == typeof(ulong)) { - size = (nuint)sizeof(long); + size = sizeof(long); return true; } diff --git a/src/System.Private.CoreLib/shared/System/MethodAccessException.cs b/src/System.Private.CoreLib/shared/System/MethodAccessException.cs index 1ca0297b9437..f329334b23a4 100644 --- a/src/System.Private.CoreLib/shared/System/MethodAccessException.cs +++ b/src/System.Private.CoreLib/shared/System/MethodAccessException.cs @@ -23,13 +23,13 @@ public MethodAccessException() HResult = HResults.COR_E_METHODACCESS; } - public MethodAccessException(String message) + public MethodAccessException(string message) : base(message) { HResult = HResults.COR_E_METHODACCESS; } - public MethodAccessException(String message, Exception inner) + public MethodAccessException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_METHODACCESS; diff --git a/src/System.Private.CoreLib/shared/System/MissingFieldException.cs b/src/System.Private.CoreLib/shared/System/MissingFieldException.cs index 38a8cc7eab1b..ba66bed0cd34 100644 --- a/src/System.Private.CoreLib/shared/System/MissingFieldException.cs +++ b/src/System.Private.CoreLib/shared/System/MissingFieldException.cs @@ -16,13 +16,13 @@ public MissingFieldException() HResult = HResults.COR_E_MISSINGFIELD; } - public MissingFieldException(String message) + public MissingFieldException(string message) : base(message) { HResult = HResults.COR_E_MISSINGFIELD; } - public MissingFieldException(String message, Exception inner) + public MissingFieldException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_MISSINGFIELD; diff --git a/src/System.Private.CoreLib/shared/System/MissingMemberException.cs b/src/System.Private.CoreLib/shared/System/MissingMemberException.cs index 36f6468a4722..a3da06017bf7 100644 --- a/src/System.Private.CoreLib/shared/System/MissingMemberException.cs +++ b/src/System.Private.CoreLib/shared/System/MissingMemberException.cs @@ -16,13 +16,13 @@ public MissingMemberException() HResult = HResults.COR_E_MISSINGMEMBER; } - public MissingMemberException(String message) + public MissingMemberException(string message) : base(message) { HResult = HResults.COR_E_MISSINGMEMBER; } - public MissingMemberException(String message, Exception inner) + public MissingMemberException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_MISSINGMEMBER; diff --git a/src/System.Private.CoreLib/shared/System/MulticastNotSupportedException.cs b/src/System.Private.CoreLib/shared/System/MulticastNotSupportedException.cs index cc6c77023e78..cb07ac7d0997 100644 --- a/src/System.Private.CoreLib/shared/System/MulticastNotSupportedException.cs +++ b/src/System.Private.CoreLib/shared/System/MulticastNotSupportedException.cs @@ -21,13 +21,13 @@ public MulticastNotSupportedException() HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; } - public MulticastNotSupportedException(String message) + public MulticastNotSupportedException(string message) : base(message) { HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; } - public MulticastNotSupportedException(String message, Exception inner) + public MulticastNotSupportedException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_MULTICASTNOTSUPPORTED; diff --git a/src/System.Private.CoreLib/shared/System/NotFiniteNumberException.cs b/src/System.Private.CoreLib/shared/System/NotFiniteNumberException.cs index b9c9af06d312..9afc10458880 100644 --- a/src/System.Private.CoreLib/shared/System/NotFiniteNumberException.cs +++ b/src/System.Private.CoreLib/shared/System/NotFiniteNumberException.cs @@ -55,13 +55,13 @@ public NotFiniteNumberException(string message, double offendingNumber, Exceptio protected NotFiniteNumberException(SerializationInfo info, StreamingContext context) : base(info, context) { - _offendingNumber = info.GetInt32("OffendingNumber"); + _offendingNumber = info.GetDouble("OffendingNumber"); // Do not rename (binary serialization) } public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); - info.AddValue("OffendingNumber", _offendingNumber, typeof(int)); + info.AddValue("OffendingNumber", _offendingNumber, typeof(double)); // Do not rename (binary serialization) } public double OffendingNumber diff --git a/src/System.Private.CoreLib/shared/System/NotImplementedException.cs b/src/System.Private.CoreLib/shared/System/NotImplementedException.cs index 1a3b6afcd471..e5f378fed394 100644 --- a/src/System.Private.CoreLib/shared/System/NotImplementedException.cs +++ b/src/System.Private.CoreLib/shared/System/NotImplementedException.cs @@ -25,12 +25,12 @@ public NotImplementedException() { HResult = HResults.E_NOTIMPL; } - public NotImplementedException(String message) + public NotImplementedException(string message) : base(message) { HResult = HResults.E_NOTIMPL; } - public NotImplementedException(String message, Exception inner) + public NotImplementedException(string message, Exception inner) : base(message, inner) { HResult = HResults.E_NOTIMPL; diff --git a/src/System.Private.CoreLib/shared/System/NotSupportedException.cs b/src/System.Private.CoreLib/shared/System/NotSupportedException.cs index 3180bc283727..e3191ea13e50 100644 --- a/src/System.Private.CoreLib/shared/System/NotSupportedException.cs +++ b/src/System.Private.CoreLib/shared/System/NotSupportedException.cs @@ -25,13 +25,13 @@ public NotSupportedException() HResult = HResults.COR_E_NOTSUPPORTED; } - public NotSupportedException(String message) + public NotSupportedException(string message) : base(message) { HResult = HResults.COR_E_NOTSUPPORTED; } - public NotSupportedException(String message, Exception innerException) + public NotSupportedException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_NOTSUPPORTED; diff --git a/src/System.Private.CoreLib/shared/System/NullReferenceException.cs b/src/System.Private.CoreLib/shared/System/NullReferenceException.cs index c2e722470cd9..cfbc0fb78e86 100644 --- a/src/System.Private.CoreLib/shared/System/NullReferenceException.cs +++ b/src/System.Private.CoreLib/shared/System/NullReferenceException.cs @@ -25,13 +25,13 @@ public NullReferenceException() HResult = HResults.COR_E_NULLREFERENCE; } - public NullReferenceException(String message) + public NullReferenceException(string message) : base(message) { HResult = HResults.COR_E_NULLREFERENCE; } - public NullReferenceException(String message, Exception innerException) + public NullReferenceException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_NULLREFERENCE; diff --git a/src/System.Private.CoreLib/shared/System/Nullable.cs b/src/System.Private.CoreLib/shared/System/Nullable.cs index 73ad6056c293..3c1cbd51013e 100644 --- a/src/System.Private.CoreLib/shared/System/Nullable.cs +++ b/src/System.Private.CoreLib/shared/System/Nullable.cs @@ -141,7 +141,7 @@ public static Type GetUnderlyingType(Type nullableType) { // instantiated generic type only Type genericType = nullableType.GetGenericTypeDefinition(); - if (Object.ReferenceEquals(genericType, typeof(Nullable<>))) + if (object.ReferenceEquals(genericType, typeof(Nullable<>))) { return nullableType.GetGenericArguments()[0]; } diff --git a/src/System.Private.CoreLib/shared/System/Number.Formatting.cs b/src/System.Private.CoreLib/shared/System/Number.Formatting.cs index 387fe0193c2b..689f146ed877 100644 --- a/src/System.Private.CoreLib/shared/System/Number.Formatting.cs +++ b/src/System.Private.CoreLib/shared/System/Number.Formatting.cs @@ -251,6 +251,8 @@ internal static partial class Number private const int CharStackBufferSize = 32; private const string PosNumberFormat = "#"; + private static readonly string[] s_singleDigitStringCache = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" }; + private static readonly string[] s_posCurrencyFormats = { "$#", "#$", "$ #", "# $" @@ -288,7 +290,7 @@ public static string FormatDecimal(decimal value, ReadOnlySpan format, Num char fmt = ParseFormatSpecifier(format, out int digits); NumberBuffer number = default; - DecimalToNumber(value, ref number); + DecimalToNumber(ref value, ref number); ValueStringBuilder sb; unsafe @@ -314,7 +316,7 @@ public static bool TryFormatDecimal(decimal value, ReadOnlySpan format, Nu char fmt = ParseFormatSpecifier(format, out int digits); NumberBuffer number = default; - DecimalToNumber(value, ref number); + DecimalToNumber(ref value, ref number); ValueStringBuilder sb; unsafe @@ -335,10 +337,8 @@ public static bool TryFormatDecimal(decimal value, ReadOnlySpan format, Nu return sb.TryCopyTo(destination, out charsWritten); } - private static unsafe void DecimalToNumber(decimal value, ref NumberBuffer number) + private static unsafe void DecimalToNumber(ref decimal d, ref NumberBuffer number) { - decimal d = value; - char* buffer = number.digits; number.precision = DecimalPrecision; number.sign = d.IsNegative; @@ -350,7 +350,7 @@ private static unsafe void DecimalToNumber(decimal value, ref NumberBuffer numbe } p = UInt32ToDecChars(p, d.Low, 0); - int i = (int)(buffer + DecimalPrecision - p); + int i = (int)((byte*)(buffer + DecimalPrecision) - (byte*)p) >> 1; number.scale = i - d.Scale; char* dst = number.digits; @@ -1095,6 +1095,13 @@ private static unsafe void UInt32ToNumber(uint value, ref NumberBuffer number) private static unsafe string UInt32ToDecStr(uint value, int digits) { int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value)); + + // For single-digit values that are very common, especially 0 and 1, just return cached strings. + if (bufferLength == 1) + { + return s_singleDigitStringCache[value]; + } + string result = string.FastAllocateString(bufferLength); fixed (char* buffer = result) { @@ -1339,6 +1346,13 @@ private static unsafe string UInt64ToDecStr(ulong value, int digits) digits = 1; int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value)); + + // For single-digit values that are very common, especially 0 and 1, just return cached strings. + if (bufferLength == 1) + { + return s_singleDigitStringCache[value]; + } + string result = string.FastAllocateString(bufferLength); fixed (char* buffer = result) { @@ -1449,20 +1463,17 @@ internal static unsafe char ParseFormatSpecifier(ReadOnlySpan format, out internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref NumberBuffer number, char format, int nMaxDigits, NumberFormatInfo info, bool isDecimal) { - int nMinDigits = -1; - switch (format) { case 'C': case 'c': { - nMinDigits = nMaxDigits >= 0 ? nMaxDigits : info.CurrencyDecimalDigits; if (nMaxDigits < 0) nMaxDigits = info.CurrencyDecimalDigits; RoundNumber(ref number, number.scale + nMaxDigits); // Don't change this line to use digPos since digCount could have its sign changed. - FormatCurrency(ref sb, ref number, nMinDigits, nMaxDigits, info); + FormatCurrency(ref sb, ref number, nMaxDigits, info); break; } @@ -1471,16 +1482,14 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number case 'f': { if (nMaxDigits < 0) - nMaxDigits = nMinDigits = info.NumberDecimalDigits; - else - nMinDigits = nMaxDigits; + nMaxDigits = info.NumberDecimalDigits; RoundNumber(ref number, number.scale + nMaxDigits); if (number.sign) sb.Append(info.NegativeSign); - FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits, info, null, info.NumberDecimalSeparator, null); + FormatFixed(ref sb, ref number, nMaxDigits, info, null, info.NumberDecimalSeparator, null); break; } @@ -1489,13 +1498,11 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number case 'n': { if (nMaxDigits < 0) - nMaxDigits = nMinDigits = info.NumberDecimalDigits; // Since we are using digits in our calculation - else - nMinDigits = nMaxDigits; + nMaxDigits = info.NumberDecimalDigits; // Since we are using digits in our calculation RoundNumber(ref number, number.scale + nMaxDigits); - FormatNumber(ref sb, ref number, nMinDigits, nMaxDigits, info); + FormatNumber(ref sb, ref number, nMaxDigits, info); break; } @@ -1504,9 +1511,7 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number case 'e': { if (nMaxDigits < 0) - nMaxDigits = nMinDigits = 6; - else - nMinDigits = nMaxDigits; + nMaxDigits = 6; nMaxDigits++; RoundNumber(ref number, nMaxDigits); @@ -1514,7 +1519,7 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number if (number.sign) sb.Append(info.NegativeSign); - FormatScientific(ref sb, ref number, nMinDigits, nMaxDigits, info, format); + FormatScientific(ref sb, ref number, nMaxDigits, info, format); break; } @@ -1522,40 +1527,34 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number case 'G': case 'g': { - bool enableRounding = true; + bool noRounding = false; if (nMaxDigits < 1) { if (isDecimal && (nMaxDigits == -1)) { - // Default to 29 digits precision only for G formatting without a precision specifier - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = DecimalPrecision; - enableRounding = false; // Turn off rounding for ECMA compliance to output trailing 0's after decimal as significant + noRounding = true; // Turn off rounding for ECMA compliance to output trailing 0's after decimal as significant + if (number.digits[0] == 0) + { + // Minus zero should be formatted as 0 + goto SkipSign; + } + goto SkipRounding; } else { // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = number.precision; + nMaxDigits = number.precision; } } - else - nMinDigits = nMaxDigits; - if (enableRounding) // Don't round for G formatting without precision - RoundNumber(ref number, nMaxDigits); // This also fixes up the minus zero case - else - { - if (isDecimal && (number.digits[0] == 0)) - { - // Minus zero should be formatted as 0 - number.sign = false; - } - } + RoundNumber(ref number, nMaxDigits); // This also fixes up the minus zero case +SkipRounding: if (number.sign) sb.Append(info.NegativeSign); - FormatGeneral(ref sb, ref number, nMinDigits, nMaxDigits, info, (char)(format - ('G' - 'E')), !enableRounding); +SkipSign: + FormatGeneral(ref sb, ref number, nMaxDigits, info, (char)(format - ('G' - 'E')), noRounding); break; } @@ -1564,14 +1563,12 @@ internal static unsafe void NumberToString(ref ValueStringBuilder sb, ref Number case 'p': { if (nMaxDigits < 0) - nMaxDigits = nMinDigits = info.PercentDecimalDigits; - else - nMinDigits = nMaxDigits; + nMaxDigits = info.PercentDecimalDigits; number.scale += 2; RoundNumber(ref number, number.scale + nMaxDigits); - FormatPercent(ref sb, ref number, nMinDigits, nMaxDigits, info); + FormatPercent(ref sb, ref number, nMaxDigits, info); break; } @@ -1938,7 +1935,7 @@ internal static unsafe void NumberToStringFormat(ref ValueStringBuilder sb, ref } } - private static void FormatCurrency(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info) + private static void FormatCurrency(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info) { string fmt = number.sign ? s_negCurrencyFormats[info.CurrencyNegativePattern] : @@ -1949,7 +1946,7 @@ private static void FormatCurrency(ref ValueStringBuilder sb, ref NumberBuffer n switch (ch) { case '#': - FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits, info, info.currencyGroupSizes, info.CurrencyDecimalSeparator, info.CurrencyGroupSeparator); + FormatFixed(ref sb, ref number, nMaxDigits, info, info.currencyGroupSizes, info.CurrencyDecimalSeparator, info.CurrencyGroupSeparator); break; case '-': sb.Append(info.NegativeSign); @@ -1964,7 +1961,7 @@ private static void FormatCurrency(ref ValueStringBuilder sb, ref NumberBuffer n } } - private static unsafe void FormatFixed(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info, int[] groupDigits, string sDecimal, string sGroup) + private static unsafe void FormatFixed(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info, int[] groupDigits, string sDecimal, string sGroup) { int digPos = number.scale; char* dig = number.digits; @@ -2066,7 +2063,7 @@ private static unsafe void FormatFixed(ref ValueStringBuilder sb, ref NumberBuff } } - private static void FormatNumber(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info) + private static void FormatNumber(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info) { string fmt = number.sign ? s_negNumberFormats[info.NumberNegativePattern] : @@ -2077,7 +2074,7 @@ private static void FormatNumber(ref ValueStringBuilder sb, ref NumberBuffer num switch (ch) { case '#': - FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits, info, info.numberGroupSizes, info.NumberDecimalSeparator, info.NumberGroupSeparator); + FormatFixed(ref sb, ref number, nMaxDigits, info, info.numberGroupSizes, info.NumberDecimalSeparator, info.NumberGroupSeparator); break; case '-': sb.Append(info.NegativeSign); @@ -2089,7 +2086,7 @@ private static void FormatNumber(ref ValueStringBuilder sb, ref NumberBuffer num } } - private static unsafe void FormatScientific(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info, char expChar) + private static unsafe void FormatScientific(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info, char expChar) { char* dig = number.digits; @@ -2126,7 +2123,7 @@ private static unsafe void FormatExponent(ref ValueStringBuilder sb, NumberForma sb.Append(p, (int)(digits + MaxUInt32DecDigits - p)); } - private static unsafe void FormatGeneral(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info, char expChar, bool bSuppressScientific) + private static unsafe void FormatGeneral(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info, char expChar, bool bSuppressScientific) { int digPos = number.scale; bool scientific = false; @@ -2173,7 +2170,7 @@ private static unsafe void FormatGeneral(ref ValueStringBuilder sb, ref NumberBu FormatExponent(ref sb, info, number.scale - 1, expChar, 2, true); } - private static void FormatPercent(ref ValueStringBuilder sb, ref NumberBuffer number, int nMinDigits, int nMaxDigits, NumberFormatInfo info) + private static void FormatPercent(ref ValueStringBuilder sb, ref NumberBuffer number, int nMaxDigits, NumberFormatInfo info) { string fmt = number.sign ? s_negPercentFormats[info.PercentNegativePattern] : @@ -2184,7 +2181,7 @@ private static void FormatPercent(ref ValueStringBuilder sb, ref NumberBuffer nu switch (ch) { case '#': - FormatFixed(ref sb, ref number, nMinDigits, nMaxDigits, info, info.percentGroupSizes, info.PercentDecimalSeparator, info.PercentGroupSeparator); + FormatFixed(ref sb, ref number, nMaxDigits, info, info.percentGroupSizes, info.PercentDecimalSeparator, info.PercentGroupSeparator); break; case '-': sb.Append(info.NegativeSign); diff --git a/src/System.Private.CoreLib/shared/System/Number.Parsing.cs b/src/System.Private.CoreLib/shared/System/Number.Parsing.cs index 936a826c937a..9b9bf66456c6 100644 --- a/src/System.Private.CoreLib/shared/System/Number.Parsing.cs +++ b/src/System.Private.CoreLib/shared/System/Number.Parsing.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Globalization; using System.Runtime.InteropServices; +using Internal.Runtime.CompilerServices; namespace System { @@ -30,129 +31,26 @@ internal partial class Number private const int Int64Precision = 19; private const int UInt64Precision = 20; - private static bool HexNumberToInt32(ref NumberBuffer number, ref int value) + /// 256-element map from an ASCII char to its hex value, e.g. arr['b'] == 11. 0xFF means it's not a hex digit. + private static readonly int[] s_charToHexLookup = { - uint passedValue = 0; - bool returnValue = HexNumberToUInt32(ref number, ref passedValue); - value = (int)passedValue; - return returnValue; - } - - private static bool HexNumberToInt64(ref NumberBuffer number, ref long value) - { - ulong passedValue = 0; - bool returnValue = HexNumberToUInt64(ref number, ref passedValue); - value = (long)passedValue; - return returnValue; - } - - private static unsafe bool HexNumberToUInt32(ref NumberBuffer number, ref uint value) - { - int i = number.scale; - if (i > UInt32Precision || i < number.precision) - { - return false; - } - char* p = number.digits; - Debug.Assert(p != null); - - uint n = 0; - while (--i >= 0) - { - if (n > ((uint)0xFFFFFFFF / 16)) - { - return false; - } - n *= 16; - if (*p != '\0') - { - uint newN = n; - if (*p != '\0') - { - if (*p >= '0' && *p <= '9') - { - newN += (uint)(*p - '0'); - } - else - { - if (*p >= 'A' && *p <= 'F') - { - newN += (uint)((*p - 'A') + 10); - } - else - { - Debug.Assert(*p >= 'a' && *p <= 'f'); - newN += (uint)((*p - 'a') + 10); - } - } - p++; - } - - // Detect an overflow here... - if (newN < n) - { - return false; - } - n = newN; - } - } - value = n; - return true; - } - - private static unsafe bool HexNumberToUInt64(ref NumberBuffer number, ref ulong value) - { - int i = number.scale; - if (i > UInt64Precision || i < number.precision) - { - return false; - } - char* p = number.digits; - Debug.Assert(p != null); - - ulong n = 0; - while (--i >= 0) - { - if (n > (0xFFFFFFFFFFFFFFFF / 16)) - { - return false; - } - n *= 16; - if (*p != '\0') - { - ulong newN = n; - if (*p != '\0') - { - if (*p >= '0' && *p <= '9') - { - newN += (ulong)(*p - '0'); - } - else - { - if (*p >= 'A' && *p <= 'F') - { - newN += (ulong)((*p - 'A') + 10); - } - else - { - Debug.Assert(*p >= 'a' && *p <= 'f'); - newN += (ulong)((*p - 'a') + 10); - } - } - p++; - } - - // Detect an overflow here... - if (newN < n) - { - return false; - } - n = newN; - } - } - value = n; - return true; - } + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 15 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 31 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 47 + 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 63 + 0xFF, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 79 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 95 + 0xFF, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 111 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 127 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 143 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 159 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 175 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 191 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 207 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 223 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, // 239 + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF // 255 + }; private static unsafe bool NumberToInt32(ref NumberBuffer number, ref int value) { @@ -173,7 +71,7 @@ private static unsafe bool NumberToInt32(ref NumberBuffer number, ref int value) n *= 10; if (*p != '\0') { - n += (int)(*p++ - '0'); + n += (*p++ - '0'); } } if (number.sign) @@ -214,7 +112,7 @@ private static unsafe bool NumberToInt64(ref NumberBuffer number, ref long value n *= 10; if (*p != '\0') { - n += (int)(*p++ - '0'); + n += (*p++ - '0'); } } if (number.sign) @@ -300,107 +198,146 @@ private static unsafe bool NumberToUInt64(ref NumberBuffer number, ref ulong val return true; } - internal static unsafe int ParseInt32(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info) + internal static int ParseInt32(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) { - NumberBuffer number = default; - int i = 0; - - StringToNumber(s, style, ref number, info, false); - - if ((style & NumberStyles.AllowHexSpecifier) != 0) + if ((styles & ~NumberStyles.Integer) == 0) { - if (!HexNumberToInt32(ref number, ref i)) + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + if (!TryParseInt32IntegerStyle(value, styles, info, out int intResult, ref overflow)) { - throw new OverflowException(SR.Overflow_Int32); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_Int32)); } + return intResult; } - else + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) { - if (!NumberToInt32(ref number, ref i)) + bool overflow = false; + if (!TryParseUInt32HexNumberStyle(value, styles, info, out uint hexResult, ref overflow)) { - throw new OverflowException(SR.Overflow_Int32); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_Int32)); } + return (int)hexResult; } - return i; - } - internal static unsafe long ParseInt64(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) - { NumberBuffer number = default; - long i = 0; - - StringToNumber(value, options, ref number, numfmt, false); + int result = 0; + StringToNumber(value, styles, ref number, info, false); + if (!NumberToInt32(ref number, ref result)) + { + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Int32)); + } + return result; + } - if ((options & NumberStyles.AllowHexSpecifier) != 0) + internal static long ParseInt64(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) + { + if ((styles & ~NumberStyles.Integer) == 0) { - if (!HexNumberToInt64(ref number, ref i)) + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + if (!TryParseInt64IntegerStyle(value, styles, info, out long intResult, ref overflow)) { - throw new OverflowException(SR.Overflow_Int64); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_Int64)); } + return intResult; } - else + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) { - if (!NumberToInt64(ref number, ref i)) + bool overflow = false; + if (!TryParseUInt64HexNumberStyle(value, styles, info, out ulong hexResult, ref overflow)) { - throw new OverflowException(SR.Overflow_Int64); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_Int64)); } + return (long)hexResult; } - return i; - } - internal static unsafe uint ParseUInt32(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) - { NumberBuffer number = default; - uint i = 0; + long result = 0; + StringToNumber(value, styles, ref number, info, false); + if (!NumberToInt64(ref number, ref result)) + { + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Int64)); + } + return result; + } - StringToNumber(value, options, ref number, numfmt, false); + internal static uint ParseUInt32(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) + { + uint result = 0; - if ((options & NumberStyles.AllowHexSpecifier) != 0) + if ((styles & ~NumberStyles.Integer) == 0) { - if (!HexNumberToUInt32(ref number, ref i)) + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + if (!TryParseUInt32IntegerStyle(value, styles, info, out result, ref overflow)) { - throw new OverflowException(SR.Overflow_UInt32); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_UInt32)); } + return result; } - else + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) { - if (!NumberToUInt32(ref number, ref i)) + bool overflow = false; + if (!TryParseUInt32HexNumberStyle(value, styles, info, out result, ref overflow)) { - throw new OverflowException(SR.Overflow_UInt32); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_UInt32)); } + return result; } - return i; + NumberBuffer number = default; + StringToNumber(value, styles, ref number, info, false); + if (!NumberToUInt32(ref number, ref result)) + { + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_UInt32)); + } + return result; } - internal static unsafe ulong ParseUInt64(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) + internal static ulong ParseUInt64(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) { - NumberBuffer number = default; - ulong i = 0; + ulong result = 0; - StringToNumber(value, options, ref number, numfmt, false); - if ((options & NumberStyles.AllowHexSpecifier) != 0) + if ((styles & ~NumberStyles.Integer) == 0) { - if (!HexNumberToUInt64(ref number, ref i)) + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + if (!TryParseUInt64IntegerStyle(value, styles, info, out result, ref overflow)) { - throw new OverflowException(SR.Overflow_UInt64); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_UInt64)); } + return result; } - else + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) { - if (!NumberToUInt64(ref number, ref i)) + bool overflow = false; + if (!TryParseUInt64HexNumberStyle(value, styles, info, out result, ref overflow)) { - throw new OverflowException(SR.Overflow_UInt64); + ThrowOverflowOrFormatException(overflow, nameof(SR.Overflow_UInt64)); } + return result; } - return i; + + NumberBuffer number = default; + StringToNumber(value, styles, ref number, info, false); + if (!NumberToUInt64(ref number, ref result)) + { + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_UInt64)); + } + return result; } - private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles options, ref NumberBuffer number, NumberFormatInfo numfmt, bool parseDecimal) + private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles styles, ref NumberBuffer number, NumberFormatInfo info, bool parseDecimal) { Debug.Assert(str != null); Debug.Assert(strEnd != null); Debug.Assert(str <= strEnd); + Debug.Assert((styles & NumberStyles.AllowHexSpecifier) == 0); const int StateSign = 0x0001; const int StateParens = 0x0002; @@ -416,20 +353,20 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles string currSymbol = null; // currency symbol from NumberFormatInfo. bool parsingCurrency = false; - if ((options & NumberStyles.AllowCurrencySymbol) != 0) + if ((styles & NumberStyles.AllowCurrencySymbol) != 0) { - currSymbol = numfmt.CurrencySymbol; + currSymbol = info.CurrencySymbol; // The idea here is to match the currency separators and on failure match the number separators to keep the perf of VB's IsNumeric fast. // The values of decSep are setup to use the correct relevant separator (currency in the if part and decimal in the else part). - decSep = numfmt.CurrencyDecimalSeparator; - groupSep = numfmt.CurrencyGroupSeparator; + decSep = info.CurrencyDecimalSeparator; + groupSep = info.CurrencyGroupSeparator; parsingCurrency = true; } else { - decSep = numfmt.NumberDecimalSeparator; - groupSep = numfmt.NumberGroupSeparator; + decSep = info.NumberDecimalSeparator; + groupSep = info.NumberGroupSeparator; } int state = 0; @@ -441,14 +378,14 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles { // Eat whitespace unless we've found a sign which isn't followed by a currency symbol. // "-Kr 1231.47" is legal but "- 1231.47" is not. - if (!IsWhite(ch) || (options & NumberStyles.AllowLeadingWhite) == 0 || ((state & StateSign) != 0 && ((state & StateCurrency) == 0 && numfmt.NumberNegativePattern != 2))) + if (!IsWhite(ch) || (styles & NumberStyles.AllowLeadingWhite) == 0 || ((state & StateSign) != 0 && ((state & StateCurrency) == 0 && info.NumberNegativePattern != 2))) { - if ((((options & NumberStyles.AllowLeadingSign) != 0) && (state & StateSign) == 0) && ((next = MatchChars(p, strEnd, numfmt.PositiveSign)) != null || ((next = MatchChars(p, strEnd, numfmt.NegativeSign)) != null && (number.sign = true)))) + if ((((styles & NumberStyles.AllowLeadingSign) != 0) && (state & StateSign) == 0) && ((next = MatchChars(p, strEnd, info.PositiveSign)) != null || ((next = MatchChars(p, strEnd, info.NegativeSign)) != null && (number.sign = true)))) { state |= StateSign; p = next - 1; } - else if (ch == '(' && ((options & NumberStyles.AllowParentheses) != 0) && ((state & StateSign) == 0)) + else if (ch == '(' && ((styles & NumberStyles.AllowParentheses) != 0) && ((state & StateSign) == 0)) { state |= StateSign | StateParens; number.sign = true; @@ -472,7 +409,7 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles int digEnd = 0; while (true) { - if ((ch >= '0' && ch <= '9') || (((options & NumberStyles.AllowHexSpecifier) != 0) && ((ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F')))) + if (IsDigit(ch)) { state |= StateDigits; @@ -497,12 +434,12 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles number.scale--; } } - else if (((options & NumberStyles.AllowDecimalPoint) != 0) && ((state & StateDecimal) == 0) && ((next = MatchChars(p, strEnd, decSep)) != null || ((parsingCurrency) && (state & StateCurrency) == 0) && (next = MatchChars(p, strEnd, numfmt.NumberDecimalSeparator)) != null)) + else if (((styles & NumberStyles.AllowDecimalPoint) != 0) && ((state & StateDecimal) == 0) && ((next = MatchChars(p, strEnd, decSep)) != null || ((parsingCurrency) && (state & StateCurrency) == 0) && (next = MatchChars(p, strEnd, info.NumberDecimalSeparator)) != null)) { state |= StateDecimal; p = next - 1; } - else if (((options & NumberStyles.AllowThousands) != 0) && ((state & StateDigits) != 0) && ((state & StateDecimal) == 0) && ((next = MatchChars(p, strEnd, groupSep)) != null || ((parsingCurrency) && (state & StateCurrency) == 0) && (next = MatchChars(p, strEnd, numfmt.NumberGroupSeparator)) != null)) + else if (((styles & NumberStyles.AllowThousands) != 0) && ((state & StateDigits) != 0) && ((state & StateDecimal) == 0) && ((next = MatchChars(p, strEnd, groupSep)) != null || ((parsingCurrency) && (state & StateCurrency) == 0) && (next = MatchChars(p, strEnd, info.NumberGroupSeparator)) != null)) { p = next - 1; } @@ -518,20 +455,20 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles number.digits[digEnd] = '\0'; if ((state & StateDigits) != 0) { - if ((ch == 'E' || ch == 'e') && ((options & NumberStyles.AllowExponent) != 0)) + if ((ch == 'E' || ch == 'e') && ((styles & NumberStyles.AllowExponent) != 0)) { char* temp = p; ch = ++p < strEnd ? *p : '\0'; - if ((next = MatchChars(p, strEnd, numfmt.positiveSign)) != null) + if ((next = MatchChars(p, strEnd, info.positiveSign)) != null) { ch = (p = next) < strEnd ? *p : '\0'; } - else if ((next = MatchChars(p, strEnd, numfmt.negativeSign)) != null) + else if ((next = MatchChars(p, strEnd, info.negativeSign)) != null) { ch = (p = next) < strEnd ? *p : '\0'; negExp = true; } - if (ch >= '0' && ch <= '9') + if (IsDigit(ch)) { int exp = 0; do @@ -541,12 +478,12 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles if (exp > 1000) { exp = 9999; - while (ch >= '0' && ch <= '9') + while (IsDigit(ch)) { ch = ++p < strEnd ? *p : '\0'; } } - } while (ch >= '0' && ch <= '9'); + } while (IsDigit(ch)); if (negExp) { exp = -exp; @@ -561,9 +498,9 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles } while (true) { - if (!IsWhite(ch) || (options & NumberStyles.AllowTrailingWhite) == 0) + if (!IsWhite(ch) || (styles & NumberStyles.AllowTrailingWhite) == 0) { - if (((options & NumberStyles.AllowTrailingSign) != 0 && ((state & StateSign) == 0)) && ((next = MatchChars(p, strEnd, numfmt.PositiveSign)) != null || (((next = MatchChars(p, strEnd, numfmt.NegativeSign)) != null) && (number.sign = true)))) + if (((styles & NumberStyles.AllowTrailingSign) != 0 && ((state & StateSign) == 0)) && ((next = MatchChars(p, strEnd, info.PositiveSign)) != null || (((next = MatchChars(p, strEnd, info.NegativeSign)) != null) && (number.sign = true)))) { state |= StateSign; p = next - 1; @@ -605,206 +542,1085 @@ private static unsafe bool ParseNumber(ref char* str, char* strEnd, NumberStyles return false; } - internal static unsafe bool TryParseInt32(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out int result) + internal static bool TryParseInt32(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out int result) { - NumberBuffer number = default; + if ((styles & ~NumberStyles.Integer) == 0) + { + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + return TryParseInt32IntegerStyle(value, styles, info, out result, ref overflow); + } + result = 0; - if (!TryStringToNumber(s, style, ref number, info, false)) + if ((styles & NumberStyles.AllowHexSpecifier) != 0) { - return false; + bool overflow = false; + return TryParseUInt32HexNumberStyle(value, styles, info, out Unsafe.As(ref result), ref overflow); } - if ((style & NumberStyles.AllowHexSpecifier) != 0) + NumberBuffer number = default; + return + TryStringToNumber(value, styles, ref number, info, false) && + NumberToInt32(ref number, ref result); + } + + /// Parses int limited to styles that make up NumberStyles.Integer. + private static bool TryParseInt32IntegerStyle(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out int result, ref bool failureIsOverflow) + { + Debug.Assert((styles & ~NumberStyles.Integer) == 0, "Only handles subsets of Integer format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); + + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + int sign = 1; + int index = 0; + int num = value[0]; + + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) { - if (!HexNumberToInt32(ref number, ref result)) + do { - return false; + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; } + while (IsWhite(num)); } - else + + // Parse leading sign. + if ((styles & NumberStyles.AllowLeadingSign) != 0) { - if (!NumberToInt32(ref number, ref result)) + string positiveSign = info.PositiveSign, negativeSign = info.NegativeSign; + + if (positiveSign == "+" && negativeSign == "-") { - return false; + if (num == '-') + { + sign = -1; + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (num == '+') + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + } + else + { + value = value.Slice(index); + index = 0; + if (!string.IsNullOrEmpty(positiveSign) && value.StartsWith(positiveSign)) + { + index += positiveSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (!string.IsNullOrEmpty(negativeSign) && value.StartsWith(negativeSign)) + { + sign = -1; + index += negativeSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } } } + + int answer = 0; + + if (IsDigit(num)) + { + // Skip past leading zeros. + if (num == '0') + { + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } while (num == '0'); + if (!IsDigit(num)) goto HasTrailingChars; + } + + // Parse most digits, up to the potential for overflow, which can't happen until after 9 digits. + answer = num - '0'; // first digit + index++; + for (int i = 0; i < 8; i++) // next 8 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + answer = 10 * answer + num - '0'; + } + + // Potential overflow now processing the 10th digit. + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + if (answer > int.MaxValue / 10) + { + overflow = true; + } + answer = answer * 10 + num - '0'; + if ((uint)answer > (uint)int.MaxValue + (-1 * sign + 1) / 2) + { + overflow = true; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. + num = value[index]; + while (IsDigit(num)) + { + overflow = true; + index++; + if ((uint)index >= (uint)value.Length) + goto DoneAtEndButPotentialOverflow; + num = value[index]; + } + goto HasTrailingChars; + } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow) + { + failureIsOverflow = true; + goto FalseExit; + } + result = answer * sign; return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; } - internal static unsafe bool TryParseInt64(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out long result) + /// Parses long inputs limited to styles that make up NumberStyles.Integer. + private static bool TryParseInt64IntegerStyle( + ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out long result, ref bool failureIsOverflow) { - NumberBuffer number = default; - result = 0; + Debug.Assert((styles & ~NumberStyles.Integer) == 0, "Only handles subsets of Integer format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); + + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + int sign = 1; + int index = 0; + int num = value[0]; - if (!TryStringToNumber(s, style, ref number, info, false)) + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + while (IsWhite(num)); } - if ((style & NumberStyles.AllowHexSpecifier) != 0) + // Parse leading sign. + if ((styles & NumberStyles.AllowLeadingSign) != 0) { - if (!HexNumberToInt64(ref number, ref result)) + string positiveSign = info.PositiveSign, negativeSign = info.NegativeSign; + + if (positiveSign == "+" && negativeSign == "-") { - return false; + if (num == '-') + { + sign = -1; + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (num == '+') + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + } + else + { + value = value.Slice(index); + index = 0; + if (!string.IsNullOrEmpty(positiveSign) && value.StartsWith(positiveSign)) + { + index += positiveSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (!string.IsNullOrEmpty(negativeSign) && value.StartsWith(negativeSign)) + { + sign = -1; + index += negativeSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } } } - else + + long answer = 0; + + if (IsDigit(num)) { - if (!NumberToInt64(ref number, ref result)) + // Skip past leading zeros. + if (num == '0') { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } while (num == '0'); + if (!IsDigit(num)) goto HasTrailingChars; + } + + // Parse most digits, up to the potential for overflow, which can't happen until after 18 digits. + answer = num - '0'; // first digit + index++; + for (int i = 0; i < 17; i++) // next 17 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + answer = 10 * answer + num - '0'; } + + // Potential overflow now processing the 19th digit. + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + if (answer > long.MaxValue / 10) + { + overflow = true; + } + answer = answer * 10 + num - '0'; + if ((ulong)answer > (ulong)long.MaxValue + (ulong)((-1 * sign + 1) / 2)) // + sign => 0, - sign => 1 + { + overflow = true; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. + num = value[index]; + while (IsDigit(num)) + { + overflow = true; + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } + goto HasTrailingChars; } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow) + { + failureIsOverflow = true; + goto FalseExit; + } + result = answer * sign; return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; } - internal static unsafe bool TryParseUInt32(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out uint result) + internal static bool TryParseInt64(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out long result) { + if ((styles & ~NumberStyles.Integer) == 0) + { + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + return TryParseInt64IntegerStyle(value, styles, info, out result, ref overflow); + } + + result = 0; + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) + { + bool overflow = false; + return TryParseUInt64HexNumberStyle(value, styles, info, out Unsafe.As(ref result), ref overflow); + } + + NumberBuffer number = default; + return + TryStringToNumber(value, styles, ref number, info, false) && + NumberToInt64(ref number, ref result); + } + + internal static bool TryParseUInt32(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out uint result) + { + if ((styles & ~NumberStyles.Integer) == 0) + { + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + return TryParseUInt32IntegerStyle(value, styles, info, out result, ref overflow); + } + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) + { + bool overflow = false; + return TryParseUInt32HexNumberStyle(value, styles, info, out result, ref overflow); + } + NumberBuffer number = default; result = 0; + return + TryStringToNumber(value, styles, ref number, info, false) && + NumberToUInt32(ref number, ref result); + } + + /// Parses uint limited to styles that make up NumberStyles.Integer. + private static bool TryParseUInt32IntegerStyle( + ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out uint result, ref bool failureIsOverflow) + { + Debug.Assert((styles & ~NumberStyles.Integer) == 0, "Only handles subsets of Integer format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); - if (!TryStringToNumber(s, style, ref number, info, false)) + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + bool hasNegativeSign = false; + int index = 0; + int num = value[0]; + + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + while (IsWhite(num)); } - if ((style & NumberStyles.AllowHexSpecifier) != 0) + // Parse leading sign. + if ((styles & NumberStyles.AllowLeadingSign) != 0) { - if (!HexNumberToUInt32(ref number, ref result)) + string positiveSign = info.PositiveSign, negativeSign = info.NegativeSign; + + if (positiveSign == "+" && negativeSign == "-") { - return false; + if (num == '+') + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (num == '-') + { + hasNegativeSign = true; + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + } + else + { + value = value.Slice(index); + index = 0; + if (!string.IsNullOrEmpty(positiveSign) && value.StartsWith(positiveSign)) + { + index += positiveSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (!string.IsNullOrEmpty(negativeSign) && value.StartsWith(negativeSign)) + { + hasNegativeSign = true; + index += negativeSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } } } - else + + int answer = 0; + + if (IsDigit(num)) { - if (!NumberToUInt32(ref number, ref result)) + // Skip past leading zeros. + if (num == '0') { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } while (num == '0'); + if (!IsDigit(num)) goto HasTrailingChars; } + + // Parse most digits, up to the potential for overflow, which can't happen until after 9 digits. + answer = num - '0'; // first digit + index++; + for (int i = 0; i < 8; i++) // next 8 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + answer = 10 * answer + num - '0'; + } + + // Potential overflow now processing the 10th digit. + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + if ((uint)answer > uint.MaxValue / 10 || ((uint)answer == uint.MaxValue / 10 && num > '5')) + { + overflow = true; + } + answer = answer * 10 + num - '0'; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. + num = value[index]; + while (IsDigit(num)) + { + overflow = true; + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } + goto HasTrailingChars; } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow || (hasNegativeSign && answer != 0)) + { + failureIsOverflow = true; + goto FalseExit; + } + result = (uint)answer; return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; } - internal static unsafe bool TryParseUInt64(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out ulong result) + /// Parses uint limited to styles that make up NumberStyles.HexNumber. + private static bool TryParseUInt32HexNumberStyle( + ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out uint result, ref bool failureIsOverflow) + { + Debug.Assert((styles & ~NumberStyles.HexNumber) == 0, "Only handles subsets of HexNumber format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); + + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + int index = 0; + int num = value[0]; + int numValue = 0; + + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) + { + do + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + while (IsWhite(num)); + } + + int answer = 0; + int[] charToHexLookup = s_charToHexLookup; + + if ((uint)num < (uint)charToHexLookup.Length && charToHexLookup[num] != 0xFF) + { + // Skip past leading zeros. + if (num == '0') + { + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + } while (num == '0'); + if ((uint)num >= (uint)charToHexLookup.Length || charToHexLookup[num] == 0xFF) goto HasTrailingChars; + } + + // Parse up through 8 digits, as no overflow is possible + answer = charToHexLookup[num]; // first digit + index++; + for (int i = 0; i < 7; i++) // next 7 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF) goto HasTrailingChars; + index++; + answer = 16 * answer + numValue; + } + + // If there's another digit, it's an overflow. + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF) goto HasTrailingChars; + index++; + overflow = true; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. Read through any remaining digits. + num = value[index]; + while ((uint)num < (uint)charToHexLookup.Length && charToHexLookup[num] != 0xFF) + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } + goto HasTrailingChars; + } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow) + { + failureIsOverflow = true; + goto FalseExit; + } + DoneAtEnd: + result = (uint)answer; + return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; + } + + internal static bool TryParseUInt64(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out ulong result) { + if ((styles & ~NumberStyles.Integer) == 0) + { + // Optimized path for the common case of anything that's allowed for integer style. + bool overflow = false; + return TryParseUInt64IntegerStyle(value, styles, info, out result, ref overflow); + } + + if ((styles & NumberStyles.AllowHexSpecifier) != 0) + { + bool overflow = false; + return TryParseUInt64HexNumberStyle(value, styles, info, out result, ref overflow); + } + NumberBuffer number = default; result = 0; + return + TryStringToNumber(value, styles, ref number, info, false) && + NumberToUInt64(ref number, ref result); + } + + /// Parses ulong limited to styles that make up NumberStyles.Integer. + private static bool TryParseUInt64IntegerStyle( + ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out ulong result, ref bool failureIsOverflow) + { + Debug.Assert((styles & ~NumberStyles.Integer) == 0, "Only handles subsets of Integer format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); - if (!TryStringToNumber(s, style, ref number, info, false)) + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + bool hasNegativeSign = false; + int index = 0; + int num = value[0]; + + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + while (IsWhite(num)); } - if ((style & NumberStyles.AllowHexSpecifier) != 0) + // Parse leading sign. + if ((styles & NumberStyles.AllowLeadingSign) != 0) { - if (!HexNumberToUInt64(ref number, ref result)) + string positiveSign = info.PositiveSign, negativeSign = info.NegativeSign; + + if (positiveSign == "+" && negativeSign == "-") { - return false; + if (num == '+') + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (num == '-') + { + hasNegativeSign = true; + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + } + else + { + value = value.Slice(index); + index = 0; + if (!string.IsNullOrEmpty(positiveSign) && value.StartsWith(positiveSign)) + { + index += positiveSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + else if (!string.IsNullOrEmpty(negativeSign) && value.StartsWith(negativeSign)) + { + hasNegativeSign = true; + index += negativeSign.Length; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } } } - else + + long answer = 0; + + if (IsDigit(num)) { - if (!NumberToUInt64(ref number, ref result)) + // Skip past leading zeros. + if (num == '0') { - return false; + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } while (num == '0'); + if (!IsDigit(num)) goto HasTrailingChars; + } + + // Parse most digits, up to the potential for overflow, which can't happen until after 19 digits. + answer = num - '0'; // first digit + index++; + for (int i = 0; i < 18; i++) // next 18 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + answer = 10 * answer + num - '0'; + } + + // Potential overflow now processing the 20th digit. + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + if (!IsDigit(num)) goto HasTrailingChars; + index++; + if ((ulong)answer > ulong.MaxValue / 10 || ((ulong)answer == ulong.MaxValue / 10 && num > '5')) + { + overflow = true; + } + answer = answer * 10 + num - '0'; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. + num = value[index]; + while (IsDigit(num)) + { + overflow = true; + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; } + goto HasTrailingChars; } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow || (hasNegativeSign && answer != 0)) + { + failureIsOverflow = true; + goto FalseExit; + } + result = (ulong)answer; return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; } - internal static unsafe decimal ParseDecimal(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) + /// Parses ulong limited to styles that make up NumberStyles.HexNumber. + private static bool TryParseUInt64HexNumberStyle( + ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out ulong result, ref bool failureIsOverflow) + { + Debug.Assert((styles & ~NumberStyles.HexNumber) == 0, "Only handles subsets of HexNumber format"); + Debug.Assert(!failureIsOverflow, $"failureIsOverflow should have been initialized to false"); + + if ((uint)value.Length < 1) goto FalseExit; + + bool overflow = false; + int index = 0; + int num = value[0]; + int numValue = 0; + + // Skip past any whitespace at the beginning. + if ((styles & NumberStyles.AllowLeadingWhite) != 0 && IsWhite(num)) + { + do + { + index++; + if ((uint)index >= (uint)value.Length) goto FalseExit; + num = value[index]; + } + while (IsWhite(num)); + } + + long answer = 0; + int[] charToHexLookup = s_charToHexLookup; + + if ((uint)num < (uint)charToHexLookup.Length && charToHexLookup[num] != 0xFF) + { + // Skip past leading zeros. + if (num == '0') + { + do + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + } while (num == '0'); + if ((uint)num >= (uint)charToHexLookup.Length || charToHexLookup[num] == 0xFF) goto HasTrailingChars; + } + + // Parse up through 16 digits, as no overflow is possible + answer = charToHexLookup[num]; // first digit + index++; + for (int i = 0; i < 15; i++) // next 15 digits can't overflow + { + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF) goto HasTrailingChars; + index++; + answer = 16 * answer + numValue; + } + + // If there's another digit, it's an overflow. + if ((uint)index >= (uint)value.Length) goto DoneAtEnd; + num = value[index]; + if ((uint)num >= (uint)charToHexLookup.Length || (numValue = charToHexLookup[num]) == 0xFF) goto HasTrailingChars; + index++; + overflow = true; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + + // At this point, we're either overflowing or hitting a formatting error. + // Format errors take precedence for compatibility. Read through any remaining digits. + num = value[index]; + while ((uint)num < (uint)charToHexLookup.Length && charToHexLookup[num] != 0xFF) + { + index++; + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + num = value[index]; + } + goto HasTrailingChars; + } + + FalseExit: // parsing failed + result = 0; + return false; + + DoneAtEndButPotentialOverflow: + if (overflow) + { + failureIsOverflow = true; + goto FalseExit; + } + DoneAtEnd: + result = (ulong)answer; + return true; + + HasTrailingChars: // we've successfully parsed, but there are still remaining characters in the span + // Skip past trailing whitespace, then past trailing zeros, and if anything else remains, fail. + if (IsWhite(num)) + { + if ((styles & NumberStyles.AllowTrailingWhite) == 0) goto FalseExit; + for (index++; index < value.Length; index++) + { + if (!IsWhite(value[index])) break; + } + if ((uint)index >= (uint)value.Length) goto DoneAtEndButPotentialOverflow; + } + + if (!TrailingZeros(value, index)) goto FalseExit; + + goto DoneAtEndButPotentialOverflow; + } + + internal static decimal ParseDecimal(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) { NumberBuffer number = default; decimal result = 0; - StringToNumber(value, options, ref number, numfmt, true); + StringToNumber(value, styles, ref number, info, true); if (!NumberBufferToDecimal(ref number, ref result)) { - throw new OverflowException(SR.Overflow_Decimal); + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Decimal)); } return result; } - internal static unsafe double ParseDouble(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) + private static unsafe bool NumberBufferToDecimal(ref NumberBuffer number, ref decimal value) + { + decimal d = new decimal(); + + char* p = number.digits; + int e = number.scale; + if (*p == 0) + { + // To avoid risking an app-compat issue with pre 4.5 (where some app was illegally using Reflection to examine the internal scale bits), we'll only force + // the scale to 0 if the scale was previously positive (previously, such cases were unparsable to a bug.) + if (e > 0) + { + e = 0; + } + } + else + { + if (e > DecimalPrecision) + return false; + + while (((e > 0) || ((*p != 0) && (e > -28))) && + ((d.High < 0x19999999) || ((d.High == 0x19999999) && + ((d.Mid < 0x99999999) || ((d.Mid == 0x99999999) && + ((d.Low < 0x99999999) || ((d.Low == 0x99999999) && + (*p <= '5')))))))) + { + decimal.DecMul10(ref d); + if (*p != 0) + decimal.DecAddInt32(ref d, (uint)(*p++ - '0')); + e--; + } + + if (*p++ >= '5') + { + bool round = true; + if ((*(p - 1) == '5') && ((*(p - 2) % 2) == 0)) + { + // Check if previous digit is even, only if the when we are unsure whether hows to do + // Banker's rounding. For digits > 5 we will be roundinp up anyway. + int count = 20; // Look at the next 20 digits to check to round + while ((*p == '0') && (count != 0)) + { + p++; + count--; + } + if ((*p == '\0') || (count == 0)) + round = false;// Do nothing + } + + if (round) + { + decimal.DecAddInt32(ref d, 1); + if ((d.High | d.Mid | d.Low) == 0) + { + d = new decimal(unchecked((int)0x9999999A), unchecked((int)0x99999999), 0x19999999, false, 0); + e++; + } + } + } + } + + if (e > 0) + return false; + + if (e <= -DecimalPrecision) + { + // Parsing a large scale zero can give you more precision than fits in the decimal. + // This should only happen for actual zeros or very small numbers that round to zero. + value = new decimal(0, 0, 0, number.sign, DecimalPrecision - 1); + } + else + { + value = new decimal((int)d.Low, (int)d.Mid, (int)d.High, number.sign, (byte)-e); + } + return true; + } + + internal static double ParseDouble(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) { NumberBuffer number = default; double d = 0; - if (!TryStringToNumber(value, options, ref number, numfmt, false)) + if (!TryStringToNumber(value, styles, ref number, info, false)) { //If we failed TryStringToNumber, it may be from one of our special strings. //Check the three with which we're concerned and rethrow if it's not one of //those strings. ReadOnlySpan sTrim = value.Trim(); - if (sTrim.EqualsOrdinal(numfmt.PositiveInfinitySymbol)) + if (sTrim.EqualsOrdinal(info.PositiveInfinitySymbol)) { return double.PositiveInfinity; } - if (sTrim.EqualsOrdinal(numfmt.NegativeInfinitySymbol)) + if (sTrim.EqualsOrdinal(info.NegativeInfinitySymbol)) { return double.NegativeInfinity; } - if (sTrim.EqualsOrdinal(numfmt.NaNSymbol)) + if (sTrim.EqualsOrdinal(info.NaNSymbol)) { return double.NaN; } - throw new FormatException(SR.Format_InvalidString); + ThrowOverflowOrFormatException(overflow: false, null); } if (!NumberBufferToDouble(ref number, ref d)) { - throw new OverflowException(SR.Overflow_Double); + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Double)); } return d; } - internal static unsafe float ParseSingle(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt) + internal static float ParseSingle(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info) { NumberBuffer number = default; double d = 0; - if (!TryStringToNumber(value, options, ref number, numfmt, false)) + if (!TryStringToNumber(value, styles, ref number, info, false)) { //If we failed TryStringToNumber, it may be from one of our special strings. //Check the three with which we're concerned and rethrow if it's not one of //those strings. ReadOnlySpan sTrim = value.Trim(); - if (sTrim.EqualsOrdinal(numfmt.PositiveInfinitySymbol)) + if (sTrim.EqualsOrdinal(info.PositiveInfinitySymbol)) { return float.PositiveInfinity; } - if (sTrim.EqualsOrdinal(numfmt.NegativeInfinitySymbol)) + if (sTrim.EqualsOrdinal(info.NegativeInfinitySymbol)) { return float.NegativeInfinity; } - if (sTrim.EqualsOrdinal(numfmt.NaNSymbol)) + if (sTrim.EqualsOrdinal(info.NaNSymbol)) { return float.NaN; } - throw new FormatException(SR.Format_InvalidString); + ThrowOverflowOrFormatException(overflow: false, null); } if (!NumberBufferToDouble(ref number, ref d)) { - throw new OverflowException(SR.Overflow_Single); + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Single)); } float castSingle = (float)d; if (float.IsInfinity(castSingle)) { - throw new OverflowException(SR.Overflow_Single); + ThrowOverflowOrFormatException(overflow: true, nameof(SR.Overflow_Single)); } return castSingle; } - internal static unsafe bool TryParseDecimal(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt, out decimal result) + internal static bool TryParseDecimal(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out decimal result) { NumberBuffer number = default; result = 0; - if (!TryStringToNumber(value, options, ref number, numfmt, true)) + if (!TryStringToNumber(value, styles, ref number, info, true)) { return false; } @@ -816,13 +1632,12 @@ internal static unsafe bool TryParseDecimal(ReadOnlySpan value, NumberStyl return true; } - internal static unsafe bool TryParseDouble(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt, out double result) + internal static bool TryParseDouble(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out double result) { NumberBuffer number = default; result = 0; - - if (!TryStringToNumber(value, options, ref number, numfmt, false)) + if (!TryStringToNumber(value, styles, ref number, info, false)) { return false; } @@ -833,13 +1648,13 @@ internal static unsafe bool TryParseDouble(ReadOnlySpan value, NumberStyle return true; } - internal static unsafe bool TryParseSingle(ReadOnlySpan value, NumberStyles options, NumberFormatInfo numfmt, out float result) + internal static bool TryParseSingle(ReadOnlySpan value, NumberStyles styles, NumberFormatInfo info, out float result) { NumberBuffer number = default; result = 0; double d = 0; - if (!TryStringToNumber(value, options, ref number, numfmt, false)) + if (!TryStringToNumber(value, styles, ref number, info, false)) { return false; } @@ -857,28 +1672,28 @@ internal static unsafe bool TryParseSingle(ReadOnlySpan value, NumberStyle return true; } - private static unsafe void StringToNumber(ReadOnlySpan str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo info, bool parseDecimal) + private static unsafe void StringToNumber(ReadOnlySpan value, NumberStyles styles, ref NumberBuffer number, NumberFormatInfo info, bool parseDecimal) { Debug.Assert(info != null); - fixed (char* stringPointer = &MemoryMarshal.GetReference(str)) + fixed (char* stringPointer = &MemoryMarshal.GetReference(value)) { char* p = stringPointer; - if (!ParseNumber(ref p, p + str.Length, options, ref number, info, parseDecimal) - || (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer)))) + if (!ParseNumber(ref p, p + value.Length, styles, ref number, info, parseDecimal) + || (p - stringPointer < value.Length && !TrailingZeros(value, (int)(p - stringPointer)))) { - throw new FormatException(SR.Format_InvalidString); + ThrowOverflowOrFormatException(overflow: false, null); } } } - internal static unsafe bool TryStringToNumber(ReadOnlySpan str, NumberStyles options, ref NumberBuffer number, NumberFormatInfo numfmt, bool parseDecimal) + internal static unsafe bool TryStringToNumber(ReadOnlySpan value, NumberStyles styles, ref NumberBuffer number, NumberFormatInfo info, bool parseDecimal) { - Debug.Assert(numfmt != null); - fixed (char* stringPointer = &MemoryMarshal.GetReference(str)) + Debug.Assert(info != null); + fixed (char* stringPointer = &MemoryMarshal.GetReference(value)) { char* p = stringPointer; - if (!ParseNumber(ref p, p + str.Length, options, ref number, numfmt, parseDecimal) - || (p - stringPointer < str.Length && !TrailingZeros(str, (int)(p - stringPointer)))) + if (!ParseNumber(ref p, p + value.Length, styles, ref number, info, parseDecimal) + || (p - stringPointer < value.Length && !TrailingZeros(value, (int)(p - stringPointer)))) { return false; } @@ -887,12 +1702,12 @@ internal static unsafe bool TryStringToNumber(ReadOnlySpan str, NumberStyl return true; } - private static bool TrailingZeros(ReadOnlySpan s, int index) + private static bool TrailingZeros(ReadOnlySpan value, int index) { // For compatibility, we need to allow trailing zeros at the end of a number string - for (int i = index; i < s.Length; i++) + for (int i = index; i < value.Length; i++) { - if (s[i] != '\0') + if (value[i] != '\0') { return false; } @@ -901,73 +1716,62 @@ private static bool TrailingZeros(ReadOnlySpan s, int index) return true; } - private static unsafe char* MatchChars(char* p, char* pEnd, string str) - { - fixed (char* stringPointer = str) - { - return MatchChars(p, pEnd, stringPointer); - } - } - - private static unsafe char* MatchChars(char* p, char* pEnd, char* str) + private static unsafe char* MatchChars(char* p, char* pEnd, string value) { - Debug.Assert(p != null && pEnd != null && p <= pEnd && str != null); - - if (*str == '\0') + Debug.Assert(p != null && pEnd != null && p <= pEnd && value != null); + fixed (char* stringPointer = value) { - return null; - } - - // We only hurt the failure case - // This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a - // space character we use 0x20 space character instead to mean the same. - while (true) - { - char cp = p < pEnd ? *p : '\0'; - if (cp != *str && !(*str == '\u00a0' && cp == '\u0020')) + char* str = stringPointer; + if (*str != '\0') { - break; + // We only hurt the failure case + // This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a + // space character we use 0x20 space character instead to mean the same. + while (true) + { + char cp = p < pEnd ? *p : '\0'; + if (cp != *str && !(*str == '\u00a0' && cp == '\u0020')) + { + break; + } + p++; + str++; + if (*str == '\0') return p; + } } - p++; - str++; - if (*str == '\0') return p; } return null; } - private static bool IsWhite(char ch) => ch == 0x20 || (ch >= 0x09 && ch <= 0x0D); + private static bool IsWhite(int ch) => ch == 0x20 || ((uint)(ch - 0x09) <= (0x0D - 0x09)); + + private static bool IsDigit(int ch) => ((uint)ch - '0') <= 9; + + private static void ThrowOverflowOrFormatException(bool overflow, string overflowResourceKey) + { + throw overflow ? + new OverflowException(SR.GetResourceString(overflowResourceKey)) : + (Exception)new FormatException(SR.Format_InvalidString); + } private static bool NumberBufferToDouble(ref NumberBuffer number, ref double value) { double d = NumberToDouble(ref number); - uint e = DoubleHelper.Exponent(d); - ulong m = DoubleHelper.Mantissa(d); - - if (e == 0x7FF) + if (!double.IsFinite(d)) { + value = default; return false; } - if (e == 0 && m == 0) + if (d == 0.0) { - d = 0; + // normalize -0.0 to 0.0 + d = 0.0; } value = d; return true; } - - private static class DoubleHelper - { - public static unsafe uint Exponent(double d) => - (*((uint*)&d + 1) >> 20) & 0x000007ff; - - public static unsafe ulong Mantissa(double d) => - *((ulong*)&d) & 0x000fffffffffffff; - - public static unsafe bool Sign(double d) => - (*((uint*)&d + 1) >> 31) != 0; - } } } diff --git a/src/System.Private.CoreLib/shared/System/Numerics/ConstantHelper.cs b/src/System.Private.CoreLib/shared/System/Numerics/ConstantHelper.cs index ea32ed3803f4..3fb3086b2dfa 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/ConstantHelper.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/ConstantHelper.cs @@ -9,131 +9,131 @@ namespace System.Numerics internal class ConstantHelper { [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Byte GetByteWithAllBitsSet() + public static byte GetByteWithAllBitsSet() { - Byte value = 0; + byte value = 0; unsafe { unchecked { - *((Byte*)&value) = (Byte)0xff; + *((byte*)&value) = (byte)0xff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static SByte GetSByteWithAllBitsSet() + public static sbyte GetSByteWithAllBitsSet() { - SByte value = 0; + sbyte value = 0; unsafe { unchecked { - *((SByte*)&value) = (SByte)0xff; + *((sbyte*)&value) = (sbyte)0xff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static UInt16 GetUInt16WithAllBitsSet() + public static ushort GetUInt16WithAllBitsSet() { - UInt16 value = 0; + ushort value = 0; unsafe { unchecked { - *((UInt16*)&value) = (UInt16)0xffff; + *((ushort*)&value) = (ushort)0xffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Int16 GetInt16WithAllBitsSet() + public static short GetInt16WithAllBitsSet() { - Int16 value = 0; + short value = 0; unsafe { unchecked { - *((Int16*)&value) = (Int16)0xffff; + *((short*)&value) = (short)0xffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static UInt32 GetUInt32WithAllBitsSet() + public static uint GetUInt32WithAllBitsSet() { - UInt32 value = 0; + uint value = 0; unsafe { unchecked { - *((UInt32*)&value) = (UInt32)0xffffffff; + *((uint*)&value) = (uint)0xffffffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Int32 GetInt32WithAllBitsSet() + public static int GetInt32WithAllBitsSet() { - Int32 value = 0; + int value = 0; unsafe { unchecked { - *((Int32*)&value) = (Int32)0xffffffff; + *((int*)&value) = (int)0xffffffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static UInt64 GetUInt64WithAllBitsSet() + public static ulong GetUInt64WithAllBitsSet() { - UInt64 value = 0; + ulong value = 0; unsafe { unchecked { - *((UInt64*)&value) = (UInt64)0xffffffffffffffff; + *((ulong*)&value) = (ulong)0xffffffffffffffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Int64 GetInt64WithAllBitsSet() + public static long GetInt64WithAllBitsSet() { - Int64 value = 0; + long value = 0; unsafe { unchecked { - *((Int64*)&value) = (Int64)0xffffffffffffffff; + *((long*)&value) = (long)0xffffffffffffffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Single GetSingleWithAllBitsSet() + public static float GetSingleWithAllBitsSet() { - Single value = 0; + float value = 0; unsafe { unchecked { - *((Int32*)&value) = (Int32)0xffffffff; + *((int*)&value) = (int)0xffffffff; } } return value; } [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Double GetDoubleWithAllBitsSet() + public static double GetDoubleWithAllBitsSet() { - Double value = 0; + double value = 0; unsafe { unchecked { - *((Int64*)&value) = (Int64)0xffffffffffffffff; + *((long*)&value) = (long)0xffffffffffffffff; } } return value; diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Register.cs b/src/System.Private.CoreLib/shared/System/Numerics/Register.cs index a27e922b9d81..8efa85b199ee 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Register.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/Register.cs @@ -17,155 +17,155 @@ internal struct Register #region Internal Storage Fields // Internal System.Byte Fields [FieldOffset(0)] - internal Byte byte_0; + internal byte byte_0; [FieldOffset(1)] - internal Byte byte_1; + internal byte byte_1; [FieldOffset(2)] - internal Byte byte_2; + internal byte byte_2; [FieldOffset(3)] - internal Byte byte_3; + internal byte byte_3; [FieldOffset(4)] - internal Byte byte_4; + internal byte byte_4; [FieldOffset(5)] - internal Byte byte_5; + internal byte byte_5; [FieldOffset(6)] - internal Byte byte_6; + internal byte byte_6; [FieldOffset(7)] - internal Byte byte_7; + internal byte byte_7; [FieldOffset(8)] - internal Byte byte_8; + internal byte byte_8; [FieldOffset(9)] - internal Byte byte_9; + internal byte byte_9; [FieldOffset(10)] - internal Byte byte_10; + internal byte byte_10; [FieldOffset(11)] - internal Byte byte_11; + internal byte byte_11; [FieldOffset(12)] - internal Byte byte_12; + internal byte byte_12; [FieldOffset(13)] - internal Byte byte_13; + internal byte byte_13; [FieldOffset(14)] - internal Byte byte_14; + internal byte byte_14; [FieldOffset(15)] - internal Byte byte_15; + internal byte byte_15; // Internal System.SByte Fields [FieldOffset(0)] - internal SByte sbyte_0; + internal sbyte sbyte_0; [FieldOffset(1)] - internal SByte sbyte_1; + internal sbyte sbyte_1; [FieldOffset(2)] - internal SByte sbyte_2; + internal sbyte sbyte_2; [FieldOffset(3)] - internal SByte sbyte_3; + internal sbyte sbyte_3; [FieldOffset(4)] - internal SByte sbyte_4; + internal sbyte sbyte_4; [FieldOffset(5)] - internal SByte sbyte_5; + internal sbyte sbyte_5; [FieldOffset(6)] - internal SByte sbyte_6; + internal sbyte sbyte_6; [FieldOffset(7)] - internal SByte sbyte_7; + internal sbyte sbyte_7; [FieldOffset(8)] - internal SByte sbyte_8; + internal sbyte sbyte_8; [FieldOffset(9)] - internal SByte sbyte_9; + internal sbyte sbyte_9; [FieldOffset(10)] - internal SByte sbyte_10; + internal sbyte sbyte_10; [FieldOffset(11)] - internal SByte sbyte_11; + internal sbyte sbyte_11; [FieldOffset(12)] - internal SByte sbyte_12; + internal sbyte sbyte_12; [FieldOffset(13)] - internal SByte sbyte_13; + internal sbyte sbyte_13; [FieldOffset(14)] - internal SByte sbyte_14; + internal sbyte sbyte_14; [FieldOffset(15)] - internal SByte sbyte_15; + internal sbyte sbyte_15; // Internal System.UInt16 Fields [FieldOffset(0)] - internal UInt16 uint16_0; + internal ushort uint16_0; [FieldOffset(2)] - internal UInt16 uint16_1; + internal ushort uint16_1; [FieldOffset(4)] - internal UInt16 uint16_2; + internal ushort uint16_2; [FieldOffset(6)] - internal UInt16 uint16_3; + internal ushort uint16_3; [FieldOffset(8)] - internal UInt16 uint16_4; + internal ushort uint16_4; [FieldOffset(10)] - internal UInt16 uint16_5; + internal ushort uint16_5; [FieldOffset(12)] - internal UInt16 uint16_6; + internal ushort uint16_6; [FieldOffset(14)] - internal UInt16 uint16_7; + internal ushort uint16_7; // Internal System.Int16 Fields [FieldOffset(0)] - internal Int16 int16_0; + internal short int16_0; [FieldOffset(2)] - internal Int16 int16_1; + internal short int16_1; [FieldOffset(4)] - internal Int16 int16_2; + internal short int16_2; [FieldOffset(6)] - internal Int16 int16_3; + internal short int16_3; [FieldOffset(8)] - internal Int16 int16_4; + internal short int16_4; [FieldOffset(10)] - internal Int16 int16_5; + internal short int16_5; [FieldOffset(12)] - internal Int16 int16_6; + internal short int16_6; [FieldOffset(14)] - internal Int16 int16_7; + internal short int16_7; // Internal System.UInt32 Fields [FieldOffset(0)] - internal UInt32 uint32_0; + internal uint uint32_0; [FieldOffset(4)] - internal UInt32 uint32_1; + internal uint uint32_1; [FieldOffset(8)] - internal UInt32 uint32_2; + internal uint uint32_2; [FieldOffset(12)] - internal UInt32 uint32_3; + internal uint uint32_3; // Internal System.Int32 Fields [FieldOffset(0)] - internal Int32 int32_0; + internal int int32_0; [FieldOffset(4)] - internal Int32 int32_1; + internal int int32_1; [FieldOffset(8)] - internal Int32 int32_2; + internal int int32_2; [FieldOffset(12)] - internal Int32 int32_3; + internal int int32_3; // Internal System.UInt64 Fields [FieldOffset(0)] - internal UInt64 uint64_0; + internal ulong uint64_0; [FieldOffset(8)] - internal UInt64 uint64_1; + internal ulong uint64_1; // Internal System.Int64 Fields [FieldOffset(0)] - internal Int64 int64_0; + internal long int64_0; [FieldOffset(8)] - internal Int64 int64_1; + internal long int64_1; // Internal System.Single Fields [FieldOffset(0)] - internal Single single_0; + internal float single_0; [FieldOffset(4)] - internal Single single_1; + internal float single_1; [FieldOffset(8)] - internal Single single_2; + internal float single_2; [FieldOffset(12)] - internal Single single_3; + internal float single_3; // Internal System.Double Fields [FieldOffset(0)] - internal Double double_0; + internal double double_0; [FieldOffset(8)] - internal Double double_1; + internal double double_1; #endregion Internal Storage Fields } diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs b/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs index 42f86d929770..1ac7bb3e72b3 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs @@ -109,45 +109,45 @@ private static unsafe int InitializeCount() int vectorSizeInBytes = (int)(byteBase - vectorBase); int typeSizeInBytes = -1; - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - typeSizeInBytes = sizeof(Byte); + typeSizeInBytes = sizeof(byte); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - typeSizeInBytes = sizeof(SByte); + typeSizeInBytes = sizeof(sbyte); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - typeSizeInBytes = sizeof(UInt16); + typeSizeInBytes = sizeof(ushort); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - typeSizeInBytes = sizeof(Int16); + typeSizeInBytes = sizeof(short); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - typeSizeInBytes = sizeof(UInt32); + typeSizeInBytes = sizeof(uint); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - typeSizeInBytes = sizeof(Int32); + typeSizeInBytes = sizeof(int); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - typeSizeInBytes = sizeof(UInt64); + typeSizeInBytes = sizeof(ulong); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - typeSizeInBytes = sizeof(Int64); + typeSizeInBytes = sizeof(long); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - typeSizeInBytes = sizeof(Single); + typeSizeInBytes = sizeof(float); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - typeSizeInBytes = sizeof(Double); + typeSizeInBytes = sizeof(double); } else { @@ -168,204 +168,204 @@ public unsafe Vector(T value) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - fixed (Byte* basePtr = &this.register.byte_0) + fixed (byte* basePtr = &this.register.byte_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Byte)(object)value; + *(basePtr + g) = (byte)(object)value; } } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - fixed (SByte* basePtr = &this.register.sbyte_0) + fixed (sbyte* basePtr = &this.register.sbyte_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (SByte)(object)value; + *(basePtr + g) = (sbyte)(object)value; } } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - fixed (UInt16* basePtr = &this.register.uint16_0) + fixed (ushort* basePtr = &this.register.uint16_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt16)(object)value; + *(basePtr + g) = (ushort)(object)value; } } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - fixed (Int16* basePtr = &this.register.int16_0) + fixed (short* basePtr = &this.register.int16_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int16)(object)value; + *(basePtr + g) = (short)(object)value; } } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - fixed (UInt32* basePtr = &this.register.uint32_0) + fixed (uint* basePtr = &this.register.uint32_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt32)(object)value; + *(basePtr + g) = (uint)(object)value; } } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - fixed (Int32* basePtr = &this.register.int32_0) + fixed (int* basePtr = &this.register.int32_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int32)(object)value; + *(basePtr + g) = (int)(object)value; } } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - fixed (UInt64* basePtr = &this.register.uint64_0) + fixed (ulong* basePtr = &this.register.uint64_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt64)(object)value; + *(basePtr + g) = (ulong)(object)value; } } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - fixed (Int64* basePtr = &this.register.int64_0) + fixed (long* basePtr = &this.register.int64_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int64)(object)value; + *(basePtr + g) = (long)(object)value; } } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - fixed (Single* basePtr = &this.register.single_0) + fixed (float* basePtr = &this.register.single_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Single)(object)value; + *(basePtr + g) = (float)(object)value; } } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - fixed (Double* basePtr = &this.register.double_0) + fixed (double* basePtr = &this.register.double_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Double)(object)value; + *(basePtr + g) = (double)(object)value; } } } } else { - if (typeof(T) == typeof(Byte)) - { - register.byte_0 = (Byte)(object)value; - register.byte_1 = (Byte)(object)value; - register.byte_2 = (Byte)(object)value; - register.byte_3 = (Byte)(object)value; - register.byte_4 = (Byte)(object)value; - register.byte_5 = (Byte)(object)value; - register.byte_6 = (Byte)(object)value; - register.byte_7 = (Byte)(object)value; - register.byte_8 = (Byte)(object)value; - register.byte_9 = (Byte)(object)value; - register.byte_10 = (Byte)(object)value; - register.byte_11 = (Byte)(object)value; - register.byte_12 = (Byte)(object)value; - register.byte_13 = (Byte)(object)value; - register.byte_14 = (Byte)(object)value; - register.byte_15 = (Byte)(object)value; - } - else if (typeof(T) == typeof(SByte)) - { - register.sbyte_0 = (SByte)(object)value; - register.sbyte_1 = (SByte)(object)value; - register.sbyte_2 = (SByte)(object)value; - register.sbyte_3 = (SByte)(object)value; - register.sbyte_4 = (SByte)(object)value; - register.sbyte_5 = (SByte)(object)value; - register.sbyte_6 = (SByte)(object)value; - register.sbyte_7 = (SByte)(object)value; - register.sbyte_8 = (SByte)(object)value; - register.sbyte_9 = (SByte)(object)value; - register.sbyte_10 = (SByte)(object)value; - register.sbyte_11 = (SByte)(object)value; - register.sbyte_12 = (SByte)(object)value; - register.sbyte_13 = (SByte)(object)value; - register.sbyte_14 = (SByte)(object)value; - register.sbyte_15 = (SByte)(object)value; - } - else if (typeof(T) == typeof(UInt16)) - { - register.uint16_0 = (UInt16)(object)value; - register.uint16_1 = (UInt16)(object)value; - register.uint16_2 = (UInt16)(object)value; - register.uint16_3 = (UInt16)(object)value; - register.uint16_4 = (UInt16)(object)value; - register.uint16_5 = (UInt16)(object)value; - register.uint16_6 = (UInt16)(object)value; - register.uint16_7 = (UInt16)(object)value; - } - else if (typeof(T) == typeof(Int16)) - { - register.int16_0 = (Int16)(object)value; - register.int16_1 = (Int16)(object)value; - register.int16_2 = (Int16)(object)value; - register.int16_3 = (Int16)(object)value; - register.int16_4 = (Int16)(object)value; - register.int16_5 = (Int16)(object)value; - register.int16_6 = (Int16)(object)value; - register.int16_7 = (Int16)(object)value; - } - else if (typeof(T) == typeof(UInt32)) - { - register.uint32_0 = (UInt32)(object)value; - register.uint32_1 = (UInt32)(object)value; - register.uint32_2 = (UInt32)(object)value; - register.uint32_3 = (UInt32)(object)value; - } - else if (typeof(T) == typeof(Int32)) - { - register.int32_0 = (Int32)(object)value; - register.int32_1 = (Int32)(object)value; - register.int32_2 = (Int32)(object)value; - register.int32_3 = (Int32)(object)value; - } - else if (typeof(T) == typeof(UInt64)) - { - register.uint64_0 = (UInt64)(object)value; - register.uint64_1 = (UInt64)(object)value; - } - else if (typeof(T) == typeof(Int64)) - { - register.int64_0 = (Int64)(object)value; - register.int64_1 = (Int64)(object)value; - } - else if (typeof(T) == typeof(Single)) - { - register.single_0 = (Single)(object)value; - register.single_1 = (Single)(object)value; - register.single_2 = (Single)(object)value; - register.single_3 = (Single)(object)value; - } - else if (typeof(T) == typeof(Double)) - { - register.double_0 = (Double)(object)value; - register.double_1 = (Double)(object)value; + if (typeof(T) == typeof(byte)) + { + register.byte_0 = (byte)(object)value; + register.byte_1 = (byte)(object)value; + register.byte_2 = (byte)(object)value; + register.byte_3 = (byte)(object)value; + register.byte_4 = (byte)(object)value; + register.byte_5 = (byte)(object)value; + register.byte_6 = (byte)(object)value; + register.byte_7 = (byte)(object)value; + register.byte_8 = (byte)(object)value; + register.byte_9 = (byte)(object)value; + register.byte_10 = (byte)(object)value; + register.byte_11 = (byte)(object)value; + register.byte_12 = (byte)(object)value; + register.byte_13 = (byte)(object)value; + register.byte_14 = (byte)(object)value; + register.byte_15 = (byte)(object)value; + } + else if (typeof(T) == typeof(sbyte)) + { + register.sbyte_0 = (sbyte)(object)value; + register.sbyte_1 = (sbyte)(object)value; + register.sbyte_2 = (sbyte)(object)value; + register.sbyte_3 = (sbyte)(object)value; + register.sbyte_4 = (sbyte)(object)value; + register.sbyte_5 = (sbyte)(object)value; + register.sbyte_6 = (sbyte)(object)value; + register.sbyte_7 = (sbyte)(object)value; + register.sbyte_8 = (sbyte)(object)value; + register.sbyte_9 = (sbyte)(object)value; + register.sbyte_10 = (sbyte)(object)value; + register.sbyte_11 = (sbyte)(object)value; + register.sbyte_12 = (sbyte)(object)value; + register.sbyte_13 = (sbyte)(object)value; + register.sbyte_14 = (sbyte)(object)value; + register.sbyte_15 = (sbyte)(object)value; + } + else if (typeof(T) == typeof(ushort)) + { + register.uint16_0 = (ushort)(object)value; + register.uint16_1 = (ushort)(object)value; + register.uint16_2 = (ushort)(object)value; + register.uint16_3 = (ushort)(object)value; + register.uint16_4 = (ushort)(object)value; + register.uint16_5 = (ushort)(object)value; + register.uint16_6 = (ushort)(object)value; + register.uint16_7 = (ushort)(object)value; + } + else if (typeof(T) == typeof(short)) + { + register.int16_0 = (short)(object)value; + register.int16_1 = (short)(object)value; + register.int16_2 = (short)(object)value; + register.int16_3 = (short)(object)value; + register.int16_4 = (short)(object)value; + register.int16_5 = (short)(object)value; + register.int16_6 = (short)(object)value; + register.int16_7 = (short)(object)value; + } + else if (typeof(T) == typeof(uint)) + { + register.uint32_0 = (uint)(object)value; + register.uint32_1 = (uint)(object)value; + register.uint32_2 = (uint)(object)value; + register.uint32_3 = (uint)(object)value; + } + else if (typeof(T) == typeof(int)) + { + register.int32_0 = (int)(object)value; + register.int32_1 = (int)(object)value; + register.int32_2 = (int)(object)value; + register.int32_3 = (int)(object)value; + } + else if (typeof(T) == typeof(ulong)) + { + register.uint64_0 = (ulong)(object)value; + register.uint64_1 = (ulong)(object)value; + } + else if (typeof(T) == typeof(long)) + { + register.int64_0 = (long)(object)value; + register.int64_1 = (long)(object)value; + } + else if (typeof(T) == typeof(float)) + { + register.single_0 = (float)(object)value; + register.single_1 = (float)(object)value; + register.single_2 = (float)(object)value; + register.single_3 = (float)(object)value; + } + else if (typeof(T) == typeof(double)) + { + register.double_0 = (double)(object)value; + register.double_1 = (double)(object)value; } } } @@ -395,233 +395,233 @@ public unsafe Vector(T[] values, int index) if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - fixed (Byte* basePtr = &this.register.byte_0) + fixed (byte* basePtr = &this.register.byte_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Byte)(object)values[g + index]; + *(basePtr + g) = (byte)(object)values[g + index]; } } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - fixed (SByte* basePtr = &this.register.sbyte_0) + fixed (sbyte* basePtr = &this.register.sbyte_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (SByte)(object)values[g + index]; + *(basePtr + g) = (sbyte)(object)values[g + index]; } } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - fixed (UInt16* basePtr = &this.register.uint16_0) + fixed (ushort* basePtr = &this.register.uint16_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt16)(object)values[g + index]; + *(basePtr + g) = (ushort)(object)values[g + index]; } } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - fixed (Int16* basePtr = &this.register.int16_0) + fixed (short* basePtr = &this.register.int16_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int16)(object)values[g + index]; + *(basePtr + g) = (short)(object)values[g + index]; } } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - fixed (UInt32* basePtr = &this.register.uint32_0) + fixed (uint* basePtr = &this.register.uint32_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt32)(object)values[g + index]; + *(basePtr + g) = (uint)(object)values[g + index]; } } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - fixed (Int32* basePtr = &this.register.int32_0) + fixed (int* basePtr = &this.register.int32_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int32)(object)values[g + index]; + *(basePtr + g) = (int)(object)values[g + index]; } } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - fixed (UInt64* basePtr = &this.register.uint64_0) + fixed (ulong* basePtr = &this.register.uint64_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (UInt64)(object)values[g + index]; + *(basePtr + g) = (ulong)(object)values[g + index]; } } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - fixed (Int64* basePtr = &this.register.int64_0) + fixed (long* basePtr = &this.register.int64_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Int64)(object)values[g + index]; + *(basePtr + g) = (long)(object)values[g + index]; } } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - fixed (Single* basePtr = &this.register.single_0) + fixed (float* basePtr = &this.register.single_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Single)(object)values[g + index]; + *(basePtr + g) = (float)(object)values[g + index]; } } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - fixed (Double* basePtr = &this.register.double_0) + fixed (double* basePtr = &this.register.double_0) { for (int g = 0; g < Count; g++) { - *(basePtr + g) = (Double)(object)values[g + index]; + *(basePtr + g) = (double)(object)values[g + index]; } } } } else { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - fixed (Byte* basePtr = &this.register.byte_0) + fixed (byte* basePtr = &this.register.byte_0) { - *(basePtr + 0) = (Byte)(object)values[0 + index]; - *(basePtr + 1) = (Byte)(object)values[1 + index]; - *(basePtr + 2) = (Byte)(object)values[2 + index]; - *(basePtr + 3) = (Byte)(object)values[3 + index]; - *(basePtr + 4) = (Byte)(object)values[4 + index]; - *(basePtr + 5) = (Byte)(object)values[5 + index]; - *(basePtr + 6) = (Byte)(object)values[6 + index]; - *(basePtr + 7) = (Byte)(object)values[7 + index]; - *(basePtr + 8) = (Byte)(object)values[8 + index]; - *(basePtr + 9) = (Byte)(object)values[9 + index]; - *(basePtr + 10) = (Byte)(object)values[10 + index]; - *(basePtr + 11) = (Byte)(object)values[11 + index]; - *(basePtr + 12) = (Byte)(object)values[12 + index]; - *(basePtr + 13) = (Byte)(object)values[13 + index]; - *(basePtr + 14) = (Byte)(object)values[14 + index]; - *(basePtr + 15) = (Byte)(object)values[15 + index]; + *(basePtr + 0) = (byte)(object)values[0 + index]; + *(basePtr + 1) = (byte)(object)values[1 + index]; + *(basePtr + 2) = (byte)(object)values[2 + index]; + *(basePtr + 3) = (byte)(object)values[3 + index]; + *(basePtr + 4) = (byte)(object)values[4 + index]; + *(basePtr + 5) = (byte)(object)values[5 + index]; + *(basePtr + 6) = (byte)(object)values[6 + index]; + *(basePtr + 7) = (byte)(object)values[7 + index]; + *(basePtr + 8) = (byte)(object)values[8 + index]; + *(basePtr + 9) = (byte)(object)values[9 + index]; + *(basePtr + 10) = (byte)(object)values[10 + index]; + *(basePtr + 11) = (byte)(object)values[11 + index]; + *(basePtr + 12) = (byte)(object)values[12 + index]; + *(basePtr + 13) = (byte)(object)values[13 + index]; + *(basePtr + 14) = (byte)(object)values[14 + index]; + *(basePtr + 15) = (byte)(object)values[15 + index]; } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - fixed (SByte* basePtr = &this.register.sbyte_0) + fixed (sbyte* basePtr = &this.register.sbyte_0) { - *(basePtr + 0) = (SByte)(object)values[0 + index]; - *(basePtr + 1) = (SByte)(object)values[1 + index]; - *(basePtr + 2) = (SByte)(object)values[2 + index]; - *(basePtr + 3) = (SByte)(object)values[3 + index]; - *(basePtr + 4) = (SByte)(object)values[4 + index]; - *(basePtr + 5) = (SByte)(object)values[5 + index]; - *(basePtr + 6) = (SByte)(object)values[6 + index]; - *(basePtr + 7) = (SByte)(object)values[7 + index]; - *(basePtr + 8) = (SByte)(object)values[8 + index]; - *(basePtr + 9) = (SByte)(object)values[9 + index]; - *(basePtr + 10) = (SByte)(object)values[10 + index]; - *(basePtr + 11) = (SByte)(object)values[11 + index]; - *(basePtr + 12) = (SByte)(object)values[12 + index]; - *(basePtr + 13) = (SByte)(object)values[13 + index]; - *(basePtr + 14) = (SByte)(object)values[14 + index]; - *(basePtr + 15) = (SByte)(object)values[15 + index]; + *(basePtr + 0) = (sbyte)(object)values[0 + index]; + *(basePtr + 1) = (sbyte)(object)values[1 + index]; + *(basePtr + 2) = (sbyte)(object)values[2 + index]; + *(basePtr + 3) = (sbyte)(object)values[3 + index]; + *(basePtr + 4) = (sbyte)(object)values[4 + index]; + *(basePtr + 5) = (sbyte)(object)values[5 + index]; + *(basePtr + 6) = (sbyte)(object)values[6 + index]; + *(basePtr + 7) = (sbyte)(object)values[7 + index]; + *(basePtr + 8) = (sbyte)(object)values[8 + index]; + *(basePtr + 9) = (sbyte)(object)values[9 + index]; + *(basePtr + 10) = (sbyte)(object)values[10 + index]; + *(basePtr + 11) = (sbyte)(object)values[11 + index]; + *(basePtr + 12) = (sbyte)(object)values[12 + index]; + *(basePtr + 13) = (sbyte)(object)values[13 + index]; + *(basePtr + 14) = (sbyte)(object)values[14 + index]; + *(basePtr + 15) = (sbyte)(object)values[15 + index]; } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - fixed (UInt16* basePtr = &this.register.uint16_0) + fixed (ushort* basePtr = &this.register.uint16_0) { - *(basePtr + 0) = (UInt16)(object)values[0 + index]; - *(basePtr + 1) = (UInt16)(object)values[1 + index]; - *(basePtr + 2) = (UInt16)(object)values[2 + index]; - *(basePtr + 3) = (UInt16)(object)values[3 + index]; - *(basePtr + 4) = (UInt16)(object)values[4 + index]; - *(basePtr + 5) = (UInt16)(object)values[5 + index]; - *(basePtr + 6) = (UInt16)(object)values[6 + index]; - *(basePtr + 7) = (UInt16)(object)values[7 + index]; + *(basePtr + 0) = (ushort)(object)values[0 + index]; + *(basePtr + 1) = (ushort)(object)values[1 + index]; + *(basePtr + 2) = (ushort)(object)values[2 + index]; + *(basePtr + 3) = (ushort)(object)values[3 + index]; + *(basePtr + 4) = (ushort)(object)values[4 + index]; + *(basePtr + 5) = (ushort)(object)values[5 + index]; + *(basePtr + 6) = (ushort)(object)values[6 + index]; + *(basePtr + 7) = (ushort)(object)values[7 + index]; } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - fixed (Int16* basePtr = &this.register.int16_0) + fixed (short* basePtr = &this.register.int16_0) { - *(basePtr + 0) = (Int16)(object)values[0 + index]; - *(basePtr + 1) = (Int16)(object)values[1 + index]; - *(basePtr + 2) = (Int16)(object)values[2 + index]; - *(basePtr + 3) = (Int16)(object)values[3 + index]; - *(basePtr + 4) = (Int16)(object)values[4 + index]; - *(basePtr + 5) = (Int16)(object)values[5 + index]; - *(basePtr + 6) = (Int16)(object)values[6 + index]; - *(basePtr + 7) = (Int16)(object)values[7 + index]; + *(basePtr + 0) = (short)(object)values[0 + index]; + *(basePtr + 1) = (short)(object)values[1 + index]; + *(basePtr + 2) = (short)(object)values[2 + index]; + *(basePtr + 3) = (short)(object)values[3 + index]; + *(basePtr + 4) = (short)(object)values[4 + index]; + *(basePtr + 5) = (short)(object)values[5 + index]; + *(basePtr + 6) = (short)(object)values[6 + index]; + *(basePtr + 7) = (short)(object)values[7 + index]; } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - fixed (UInt32* basePtr = &this.register.uint32_0) + fixed (uint* basePtr = &this.register.uint32_0) { - *(basePtr + 0) = (UInt32)(object)values[0 + index]; - *(basePtr + 1) = (UInt32)(object)values[1 + index]; - *(basePtr + 2) = (UInt32)(object)values[2 + index]; - *(basePtr + 3) = (UInt32)(object)values[3 + index]; + *(basePtr + 0) = (uint)(object)values[0 + index]; + *(basePtr + 1) = (uint)(object)values[1 + index]; + *(basePtr + 2) = (uint)(object)values[2 + index]; + *(basePtr + 3) = (uint)(object)values[3 + index]; } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - fixed (Int32* basePtr = &this.register.int32_0) + fixed (int* basePtr = &this.register.int32_0) { - *(basePtr + 0) = (Int32)(object)values[0 + index]; - *(basePtr + 1) = (Int32)(object)values[1 + index]; - *(basePtr + 2) = (Int32)(object)values[2 + index]; - *(basePtr + 3) = (Int32)(object)values[3 + index]; + *(basePtr + 0) = (int)(object)values[0 + index]; + *(basePtr + 1) = (int)(object)values[1 + index]; + *(basePtr + 2) = (int)(object)values[2 + index]; + *(basePtr + 3) = (int)(object)values[3 + index]; } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - fixed (UInt64* basePtr = &this.register.uint64_0) + fixed (ulong* basePtr = &this.register.uint64_0) { - *(basePtr + 0) = (UInt64)(object)values[0 + index]; - *(basePtr + 1) = (UInt64)(object)values[1 + index]; + *(basePtr + 0) = (ulong)(object)values[0 + index]; + *(basePtr + 1) = (ulong)(object)values[1 + index]; } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - fixed (Int64* basePtr = &this.register.int64_0) + fixed (long* basePtr = &this.register.int64_0) { - *(basePtr + 0) = (Int64)(object)values[0 + index]; - *(basePtr + 1) = (Int64)(object)values[1 + index]; + *(basePtr + 0) = (long)(object)values[0 + index]; + *(basePtr + 1) = (long)(object)values[1 + index]; } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - fixed (Single* basePtr = &this.register.single_0) + fixed (float* basePtr = &this.register.single_0) { - *(basePtr + 0) = (Single)(object)values[0 + index]; - *(basePtr + 1) = (Single)(object)values[1 + index]; - *(basePtr + 2) = (Single)(object)values[2 + index]; - *(basePtr + 3) = (Single)(object)values[3 + index]; + *(basePtr + 0) = (float)(object)values[0 + index]; + *(basePtr + 1) = (float)(object)values[1 + index]; + *(basePtr + 2) = (float)(object)values[2 + index]; + *(basePtr + 3) = (float)(object)values[3 + index]; } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - fixed (Double* basePtr = &this.register.double_0) + fixed (double* basePtr = &this.register.double_0) { - *(basePtr + 0) = (Double)(object)values[0 + index]; - *(basePtr + 1) = (Double)(object)values[1 + index]; + *(basePtr + 0) = (double)(object)values[0 + index]; + *(basePtr + 1) = (double)(object)values[1 + index]; } } } @@ -636,11 +636,11 @@ internal unsafe Vector(void* dataPointer) : this(dataPointer, 0) { } internal unsafe Vector(void* dataPointer, int offset) : this() { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* castedPtr = (Byte*)dataPointer; + byte* castedPtr = (byte*)dataPointer; castedPtr += offset; - fixed (Byte* registerBase = &this.register.byte_0) + fixed (byte* registerBase = &this.register.byte_0) { for (int g = 0; g < Count; g++) { @@ -648,11 +648,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* castedPtr = (SByte*)dataPointer; + sbyte* castedPtr = (sbyte*)dataPointer; castedPtr += offset; - fixed (SByte* registerBase = &this.register.sbyte_0) + fixed (sbyte* registerBase = &this.register.sbyte_0) { for (int g = 0; g < Count; g++) { @@ -660,11 +660,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* castedPtr = (UInt16*)dataPointer; + ushort* castedPtr = (ushort*)dataPointer; castedPtr += offset; - fixed (UInt16* registerBase = &this.register.uint16_0) + fixed (ushort* registerBase = &this.register.uint16_0) { for (int g = 0; g < Count; g++) { @@ -672,11 +672,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* castedPtr = (Int16*)dataPointer; + short* castedPtr = (short*)dataPointer; castedPtr += offset; - fixed (Int16* registerBase = &this.register.int16_0) + fixed (short* registerBase = &this.register.int16_0) { for (int g = 0; g < Count; g++) { @@ -684,11 +684,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* castedPtr = (UInt32*)dataPointer; + uint* castedPtr = (uint*)dataPointer; castedPtr += offset; - fixed (UInt32* registerBase = &this.register.uint32_0) + fixed (uint* registerBase = &this.register.uint32_0) { for (int g = 0; g < Count; g++) { @@ -696,11 +696,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* castedPtr = (Int32*)dataPointer; + int* castedPtr = (int*)dataPointer; castedPtr += offset; - fixed (Int32* registerBase = &this.register.int32_0) + fixed (int* registerBase = &this.register.int32_0) { for (int g = 0; g < Count; g++) { @@ -708,11 +708,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* castedPtr = (UInt64*)dataPointer; + ulong* castedPtr = (ulong*)dataPointer; castedPtr += offset; - fixed (UInt64* registerBase = &this.register.uint64_0) + fixed (ulong* registerBase = &this.register.uint64_0) { for (int g = 0; g < Count; g++) { @@ -720,11 +720,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* castedPtr = (Int64*)dataPointer; + long* castedPtr = (long*)dataPointer; castedPtr += offset; - fixed (Int64* registerBase = &this.register.int64_0) + fixed (long* registerBase = &this.register.int64_0) { for (int g = 0; g < Count; g++) { @@ -732,11 +732,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* castedPtr = (Single*)dataPointer; + float* castedPtr = (float*)dataPointer; castedPtr += offset; - fixed (Single* registerBase = &this.register.single_0) + fixed (float* registerBase = &this.register.single_0) { for (int g = 0; g < Count; g++) { @@ -744,11 +744,11 @@ internal unsafe Vector(void* dataPointer, int offset) } } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* castedPtr = (Double*)dataPointer; + double* castedPtr = (double*)dataPointer; castedPtr += offset; - fixed (Double* registerBase = &this.register.double_0) + fixed (double* registerBase = &this.register.double_0) { for (int g = 0; g < Count; g++) { @@ -775,16 +775,16 @@ private Vector(ref Register existingRegister) public Vector(Span values) : this() { - if ((typeof(T) == typeof(Byte)) - || (typeof(T) == typeof(SByte)) - || (typeof(T) == typeof(UInt16)) - || (typeof(T) == typeof(Int16)) - || (typeof(T) == typeof(UInt32)) - || (typeof(T) == typeof(Int32)) - || (typeof(T) == typeof(UInt64)) - || (typeof(T) == typeof(Int64)) - || (typeof(T) == typeof(Single)) - || (typeof(T) == typeof(Double))) + if ((typeof(T) == typeof(byte)) + || (typeof(T) == typeof(sbyte)) + || (typeof(T) == typeof(ushort)) + || (typeof(T) == typeof(short)) + || (typeof(T) == typeof(uint)) + || (typeof(T) == typeof(int)) + || (typeof(T) == typeof(ulong)) + || (typeof(T) == typeof(long)) + || (typeof(T) == typeof(float)) + || (typeof(T) == typeof(double))) { if (values.Length < Count) { @@ -840,123 +840,123 @@ public unsafe void CopyTo(T[] destination, int startIndex) if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte[] byteArray = (Byte[])(object)destination; - fixed (Byte* destinationBase = byteArray) + byte[] byteArray = (byte[])(object)destination; + fixed (byte* destinationBase = byteArray) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Byte)(object)this[g]; + destinationBase[startIndex + g] = (byte)(object)this[g]; } } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte[] sbyteArray = (SByte[])(object)destination; - fixed (SByte* destinationBase = sbyteArray) + sbyte[] sbyteArray = (sbyte[])(object)destination; + fixed (sbyte* destinationBase = sbyteArray) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (SByte)(object)this[g]; + destinationBase[startIndex + g] = (sbyte)(object)this[g]; } } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16[] uint16Array = (UInt16[])(object)destination; - fixed (UInt16* destinationBase = uint16Array) + ushort[] uint16Array = (ushort[])(object)destination; + fixed (ushort* destinationBase = uint16Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (UInt16)(object)this[g]; + destinationBase[startIndex + g] = (ushort)(object)this[g]; } } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16[] int16Array = (Int16[])(object)destination; - fixed (Int16* destinationBase = int16Array) + short[] int16Array = (short[])(object)destination; + fixed (short* destinationBase = int16Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Int16)(object)this[g]; + destinationBase[startIndex + g] = (short)(object)this[g]; } } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32[] uint32Array = (UInt32[])(object)destination; - fixed (UInt32* destinationBase = uint32Array) + uint[] uint32Array = (uint[])(object)destination; + fixed (uint* destinationBase = uint32Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (UInt32)(object)this[g]; + destinationBase[startIndex + g] = (uint)(object)this[g]; } } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32[] int32Array = (Int32[])(object)destination; - fixed (Int32* destinationBase = int32Array) + int[] int32Array = (int[])(object)destination; + fixed (int* destinationBase = int32Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Int32)(object)this[g]; + destinationBase[startIndex + g] = (int)(object)this[g]; } } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64[] uint64Array = (UInt64[])(object)destination; - fixed (UInt64* destinationBase = uint64Array) + ulong[] uint64Array = (ulong[])(object)destination; + fixed (ulong* destinationBase = uint64Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (UInt64)(object)this[g]; + destinationBase[startIndex + g] = (ulong)(object)this[g]; } } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64[] int64Array = (Int64[])(object)destination; - fixed (Int64* destinationBase = int64Array) + long[] int64Array = (long[])(object)destination; + fixed (long* destinationBase = int64Array) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Int64)(object)this[g]; + destinationBase[startIndex + g] = (long)(object)this[g]; } } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single[] singleArray = (Single[])(object)destination; - fixed (Single* destinationBase = singleArray) + float[] singleArray = (float[])(object)destination; + fixed (float* destinationBase = singleArray) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Single)(object)this[g]; + destinationBase[startIndex + g] = (float)(object)this[g]; } } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double[] doubleArray = (Double[])(object)destination; - fixed (Double* destinationBase = doubleArray) + double[] doubleArray = (double[])(object)destination; + fixed (double* destinationBase = doubleArray) { for (int g = 0; g < Count; g++) { - destinationBase[startIndex + g] = (Double)(object)this[g]; + destinationBase[startIndex + g] = (double)(object)this[g]; } } } } else { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte[] byteArray = (Byte[])(object)destination; - fixed (Byte* destinationBase = byteArray) + byte[] byteArray = (byte[])(object)destination; + fixed (byte* destinationBase = byteArray) { destinationBase[startIndex + 0] = this.register.byte_0; destinationBase[startIndex + 1] = this.register.byte_1; @@ -976,10 +976,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 15] = this.register.byte_15; } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte[] sbyteArray = (SByte[])(object)destination; - fixed (SByte* destinationBase = sbyteArray) + sbyte[] sbyteArray = (sbyte[])(object)destination; + fixed (sbyte* destinationBase = sbyteArray) { destinationBase[startIndex + 0] = this.register.sbyte_0; destinationBase[startIndex + 1] = this.register.sbyte_1; @@ -999,10 +999,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 15] = this.register.sbyte_15; } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16[] uint16Array = (UInt16[])(object)destination; - fixed (UInt16* destinationBase = uint16Array) + ushort[] uint16Array = (ushort[])(object)destination; + fixed (ushort* destinationBase = uint16Array) { destinationBase[startIndex + 0] = this.register.uint16_0; destinationBase[startIndex + 1] = this.register.uint16_1; @@ -1014,10 +1014,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 7] = this.register.uint16_7; } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16[] int16Array = (Int16[])(object)destination; - fixed (Int16* destinationBase = int16Array) + short[] int16Array = (short[])(object)destination; + fixed (short* destinationBase = int16Array) { destinationBase[startIndex + 0] = this.register.int16_0; destinationBase[startIndex + 1] = this.register.int16_1; @@ -1029,10 +1029,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 7] = this.register.int16_7; } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32[] uint32Array = (UInt32[])(object)destination; - fixed (UInt32* destinationBase = uint32Array) + uint[] uint32Array = (uint[])(object)destination; + fixed (uint* destinationBase = uint32Array) { destinationBase[startIndex + 0] = this.register.uint32_0; destinationBase[startIndex + 1] = this.register.uint32_1; @@ -1040,10 +1040,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 3] = this.register.uint32_3; } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32[] int32Array = (Int32[])(object)destination; - fixed (Int32* destinationBase = int32Array) + int[] int32Array = (int[])(object)destination; + fixed (int* destinationBase = int32Array) { destinationBase[startIndex + 0] = this.register.int32_0; destinationBase[startIndex + 1] = this.register.int32_1; @@ -1051,28 +1051,28 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 3] = this.register.int32_3; } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64[] uint64Array = (UInt64[])(object)destination; - fixed (UInt64* destinationBase = uint64Array) + ulong[] uint64Array = (ulong[])(object)destination; + fixed (ulong* destinationBase = uint64Array) { destinationBase[startIndex + 0] = this.register.uint64_0; destinationBase[startIndex + 1] = this.register.uint64_1; } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64[] int64Array = (Int64[])(object)destination; - fixed (Int64* destinationBase = int64Array) + long[] int64Array = (long[])(object)destination; + fixed (long* destinationBase = int64Array) { destinationBase[startIndex + 0] = this.register.int64_0; destinationBase[startIndex + 1] = this.register.int64_1; } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single[] singleArray = (Single[])(object)destination; - fixed (Single* destinationBase = singleArray) + float[] singleArray = (float[])(object)destination; + fixed (float* destinationBase = singleArray) { destinationBase[startIndex + 0] = this.register.single_0; destinationBase[startIndex + 1] = this.register.single_1; @@ -1080,10 +1080,10 @@ public unsafe void CopyTo(T[] destination, int startIndex) destinationBase[startIndex + 3] = this.register.single_3; } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double[] doubleArray = (Double[])(object)destination; - fixed (Double* destinationBase = doubleArray) + double[] doubleArray = (double[])(object)destination; + fixed (double* destinationBase = doubleArray) { destinationBase[startIndex + 0] = this.register.double_0; destinationBase[startIndex + 1] = this.register.double_1; @@ -1104,72 +1104,72 @@ public unsafe T this[int index] { throw new IndexOutOfRangeException(SR.Format(SR.Arg_ArgumentOutOfRangeException, index)); } - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - fixed (Byte* basePtr = &this.register.byte_0) + fixed (byte* basePtr = &this.register.byte_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - fixed (SByte* basePtr = &this.register.sbyte_0) + fixed (sbyte* basePtr = &this.register.sbyte_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - fixed (UInt16* basePtr = &this.register.uint16_0) + fixed (ushort* basePtr = &this.register.uint16_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - fixed (Int16* basePtr = &this.register.int16_0) + fixed (short* basePtr = &this.register.int16_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - fixed (UInt32* basePtr = &this.register.uint32_0) + fixed (uint* basePtr = &this.register.uint32_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - fixed (Int32* basePtr = &this.register.int32_0) + fixed (int* basePtr = &this.register.int32_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - fixed (UInt64* basePtr = &this.register.uint64_0) + fixed (ulong* basePtr = &this.register.uint64_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - fixed (Int64* basePtr = &this.register.int64_0) + fixed (long* basePtr = &this.register.int64_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - fixed (Single* basePtr = &this.register.single_0) + fixed (float* basePtr = &this.register.single_0) { return (T)(object)*(basePtr + index); } } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - fixed (Double* basePtr = &this.register.double_0) + fixed (double* basePtr = &this.register.double_0) { return (T)(object)*(basePtr + index); } @@ -1217,7 +1217,7 @@ public bool Equals(Vector other) } else { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { return this.register.byte_0 == other.register.byte_0 @@ -1237,7 +1237,7 @@ public bool Equals(Vector other) && this.register.byte_14 == other.register.byte_14 && this.register.byte_15 == other.register.byte_15; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { return this.register.sbyte_0 == other.register.sbyte_0 @@ -1257,7 +1257,7 @@ public bool Equals(Vector other) && this.register.sbyte_14 == other.register.sbyte_14 && this.register.sbyte_15 == other.register.sbyte_15; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { return this.register.uint16_0 == other.register.uint16_0 @@ -1269,7 +1269,7 @@ public bool Equals(Vector other) && this.register.uint16_6 == other.register.uint16_6 && this.register.uint16_7 == other.register.uint16_7; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { return this.register.int16_0 == other.register.int16_0 @@ -1281,7 +1281,7 @@ public bool Equals(Vector other) && this.register.int16_6 == other.register.int16_6 && this.register.int16_7 == other.register.int16_7; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { return this.register.uint32_0 == other.register.uint32_0 @@ -1289,7 +1289,7 @@ public bool Equals(Vector other) && this.register.uint32_2 == other.register.uint32_2 && this.register.uint32_3 == other.register.uint32_3; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { return this.register.int32_0 == other.register.int32_0 @@ -1297,19 +1297,19 @@ public bool Equals(Vector other) && this.register.int32_2 == other.register.int32_2 && this.register.int32_3 == other.register.int32_3; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { return this.register.uint64_0 == other.register.uint64_0 && this.register.uint64_1 == other.register.uint64_1; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { return this.register.int64_0 == other.register.int64_0 && this.register.int64_1 == other.register.int64_1; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { return this.register.single_0 == other.register.single_0 @@ -1317,7 +1317,7 @@ public bool Equals(Vector other) && this.register.single_2 == other.register.single_2 && this.register.single_3 == other.register.single_3; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { return this.register.double_0 == other.register.double_0 @@ -1340,83 +1340,83 @@ public override int GetHashCode() if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Byte)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((byte)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((SByte)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((sbyte)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((UInt16)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((ushort)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Int16)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((short)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((UInt32)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((uint)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Int32)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((int)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((UInt64)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((ulong)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Int64)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((long)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Single)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((float)(object)this[g]).GetHashCode()); } return hash; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { for (int g = 0; g < Count; g++) { - hash = HashHelpers.Combine(hash, ((Double)(object)this[g]).GetHashCode()); + hash = HashHelpers.Combine(hash, ((double)(object)this[g]).GetHashCode()); } return hash; } @@ -1427,7 +1427,7 @@ public override int GetHashCode() } else { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { hash = HashHelpers.Combine(hash, this.register.byte_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.byte_1.GetHashCode()); @@ -1447,7 +1447,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.byte_15.GetHashCode()); return hash; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { hash = HashHelpers.Combine(hash, this.register.sbyte_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.sbyte_1.GetHashCode()); @@ -1467,7 +1467,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.sbyte_15.GetHashCode()); return hash; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { hash = HashHelpers.Combine(hash, this.register.uint16_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.uint16_1.GetHashCode()); @@ -1479,7 +1479,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.uint16_7.GetHashCode()); return hash; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { hash = HashHelpers.Combine(hash, this.register.int16_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.int16_1.GetHashCode()); @@ -1491,7 +1491,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.int16_7.GetHashCode()); return hash; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { hash = HashHelpers.Combine(hash, this.register.uint32_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.uint32_1.GetHashCode()); @@ -1499,7 +1499,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.uint32_3.GetHashCode()); return hash; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { hash = HashHelpers.Combine(hash, this.register.int32_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.int32_1.GetHashCode()); @@ -1507,19 +1507,19 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.int32_3.GetHashCode()); return hash; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { hash = HashHelpers.Combine(hash, this.register.uint64_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.uint64_1.GetHashCode()); return hash; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { hash = HashHelpers.Combine(hash, this.register.int64_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.int64_1.GetHashCode()); return hash; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { hash = HashHelpers.Combine(hash, this.register.single_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.single_1.GetHashCode()); @@ -1527,7 +1527,7 @@ public override int GetHashCode() hash = HashHelpers.Combine(hash, this.register.single_3.GetHashCode()); return hash; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { hash = HashHelpers.Combine(hash, this.register.double_0.GetHashCode()); hash = HashHelpers.Combine(hash, this.register.double_1.GetHashCode()); @@ -1597,93 +1597,93 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Byte)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (byte)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (SByte)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (sbyte)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt16)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (ushort)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int16)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (short)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt32)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (uint)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int32)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (int)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt64)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (ulong)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int64)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (long)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Single)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (float)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Double)(object)ScalarAdd(left[g], right[g]); + dataPtr[g] = (double)(object)ScalarAdd(left[g], right[g]); } return new Vector(dataPtr); } @@ -1695,101 +1695,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector sum = new Vector(); - if (typeof(T) == typeof(Byte)) - { - sum.register.byte_0 = (Byte)(left.register.byte_0 + right.register.byte_0); - sum.register.byte_1 = (Byte)(left.register.byte_1 + right.register.byte_1); - sum.register.byte_2 = (Byte)(left.register.byte_2 + right.register.byte_2); - sum.register.byte_3 = (Byte)(left.register.byte_3 + right.register.byte_3); - sum.register.byte_4 = (Byte)(left.register.byte_4 + right.register.byte_4); - sum.register.byte_5 = (Byte)(left.register.byte_5 + right.register.byte_5); - sum.register.byte_6 = (Byte)(left.register.byte_6 + right.register.byte_6); - sum.register.byte_7 = (Byte)(left.register.byte_7 + right.register.byte_7); - sum.register.byte_8 = (Byte)(left.register.byte_8 + right.register.byte_8); - sum.register.byte_9 = (Byte)(left.register.byte_9 + right.register.byte_9); - sum.register.byte_10 = (Byte)(left.register.byte_10 + right.register.byte_10); - sum.register.byte_11 = (Byte)(left.register.byte_11 + right.register.byte_11); - sum.register.byte_12 = (Byte)(left.register.byte_12 + right.register.byte_12); - sum.register.byte_13 = (Byte)(left.register.byte_13 + right.register.byte_13); - sum.register.byte_14 = (Byte)(left.register.byte_14 + right.register.byte_14); - sum.register.byte_15 = (Byte)(left.register.byte_15 + right.register.byte_15); - } - else if (typeof(T) == typeof(SByte)) - { - sum.register.sbyte_0 = (SByte)(left.register.sbyte_0 + right.register.sbyte_0); - sum.register.sbyte_1 = (SByte)(left.register.sbyte_1 + right.register.sbyte_1); - sum.register.sbyte_2 = (SByte)(left.register.sbyte_2 + right.register.sbyte_2); - sum.register.sbyte_3 = (SByte)(left.register.sbyte_3 + right.register.sbyte_3); - sum.register.sbyte_4 = (SByte)(left.register.sbyte_4 + right.register.sbyte_4); - sum.register.sbyte_5 = (SByte)(left.register.sbyte_5 + right.register.sbyte_5); - sum.register.sbyte_6 = (SByte)(left.register.sbyte_6 + right.register.sbyte_6); - sum.register.sbyte_7 = (SByte)(left.register.sbyte_7 + right.register.sbyte_7); - sum.register.sbyte_8 = (SByte)(left.register.sbyte_8 + right.register.sbyte_8); - sum.register.sbyte_9 = (SByte)(left.register.sbyte_9 + right.register.sbyte_9); - sum.register.sbyte_10 = (SByte)(left.register.sbyte_10 + right.register.sbyte_10); - sum.register.sbyte_11 = (SByte)(left.register.sbyte_11 + right.register.sbyte_11); - sum.register.sbyte_12 = (SByte)(left.register.sbyte_12 + right.register.sbyte_12); - sum.register.sbyte_13 = (SByte)(left.register.sbyte_13 + right.register.sbyte_13); - sum.register.sbyte_14 = (SByte)(left.register.sbyte_14 + right.register.sbyte_14); - sum.register.sbyte_15 = (SByte)(left.register.sbyte_15 + right.register.sbyte_15); - } - else if (typeof(T) == typeof(UInt16)) - { - sum.register.uint16_0 = (UInt16)(left.register.uint16_0 + right.register.uint16_0); - sum.register.uint16_1 = (UInt16)(left.register.uint16_1 + right.register.uint16_1); - sum.register.uint16_2 = (UInt16)(left.register.uint16_2 + right.register.uint16_2); - sum.register.uint16_3 = (UInt16)(left.register.uint16_3 + right.register.uint16_3); - sum.register.uint16_4 = (UInt16)(left.register.uint16_4 + right.register.uint16_4); - sum.register.uint16_5 = (UInt16)(left.register.uint16_5 + right.register.uint16_5); - sum.register.uint16_6 = (UInt16)(left.register.uint16_6 + right.register.uint16_6); - sum.register.uint16_7 = (UInt16)(left.register.uint16_7 + right.register.uint16_7); - } - else if (typeof(T) == typeof(Int16)) - { - sum.register.int16_0 = (Int16)(left.register.int16_0 + right.register.int16_0); - sum.register.int16_1 = (Int16)(left.register.int16_1 + right.register.int16_1); - sum.register.int16_2 = (Int16)(left.register.int16_2 + right.register.int16_2); - sum.register.int16_3 = (Int16)(left.register.int16_3 + right.register.int16_3); - sum.register.int16_4 = (Int16)(left.register.int16_4 + right.register.int16_4); - sum.register.int16_5 = (Int16)(left.register.int16_5 + right.register.int16_5); - sum.register.int16_6 = (Int16)(left.register.int16_6 + right.register.int16_6); - sum.register.int16_7 = (Int16)(left.register.int16_7 + right.register.int16_7); - } - else if (typeof(T) == typeof(UInt32)) - { - sum.register.uint32_0 = (UInt32)(left.register.uint32_0 + right.register.uint32_0); - sum.register.uint32_1 = (UInt32)(left.register.uint32_1 + right.register.uint32_1); - sum.register.uint32_2 = (UInt32)(left.register.uint32_2 + right.register.uint32_2); - sum.register.uint32_3 = (UInt32)(left.register.uint32_3 + right.register.uint32_3); - } - else if (typeof(T) == typeof(Int32)) - { - sum.register.int32_0 = (Int32)(left.register.int32_0 + right.register.int32_0); - sum.register.int32_1 = (Int32)(left.register.int32_1 + right.register.int32_1); - sum.register.int32_2 = (Int32)(left.register.int32_2 + right.register.int32_2); - sum.register.int32_3 = (Int32)(left.register.int32_3 + right.register.int32_3); - } - else if (typeof(T) == typeof(UInt64)) - { - sum.register.uint64_0 = (UInt64)(left.register.uint64_0 + right.register.uint64_0); - sum.register.uint64_1 = (UInt64)(left.register.uint64_1 + right.register.uint64_1); - } - else if (typeof(T) == typeof(Int64)) - { - sum.register.int64_0 = (Int64)(left.register.int64_0 + right.register.int64_0); - sum.register.int64_1 = (Int64)(left.register.int64_1 + right.register.int64_1); - } - else if (typeof(T) == typeof(Single)) - { - sum.register.single_0 = (Single)(left.register.single_0 + right.register.single_0); - sum.register.single_1 = (Single)(left.register.single_1 + right.register.single_1); - sum.register.single_2 = (Single)(left.register.single_2 + right.register.single_2); - sum.register.single_3 = (Single)(left.register.single_3 + right.register.single_3); - } - else if (typeof(T) == typeof(Double)) - { - sum.register.double_0 = (Double)(left.register.double_0 + right.register.double_0); - sum.register.double_1 = (Double)(left.register.double_1 + right.register.double_1); + if (typeof(T) == typeof(byte)) + { + sum.register.byte_0 = (byte)(left.register.byte_0 + right.register.byte_0); + sum.register.byte_1 = (byte)(left.register.byte_1 + right.register.byte_1); + sum.register.byte_2 = (byte)(left.register.byte_2 + right.register.byte_2); + sum.register.byte_3 = (byte)(left.register.byte_3 + right.register.byte_3); + sum.register.byte_4 = (byte)(left.register.byte_4 + right.register.byte_4); + sum.register.byte_5 = (byte)(left.register.byte_5 + right.register.byte_5); + sum.register.byte_6 = (byte)(left.register.byte_6 + right.register.byte_6); + sum.register.byte_7 = (byte)(left.register.byte_7 + right.register.byte_7); + sum.register.byte_8 = (byte)(left.register.byte_8 + right.register.byte_8); + sum.register.byte_9 = (byte)(left.register.byte_9 + right.register.byte_9); + sum.register.byte_10 = (byte)(left.register.byte_10 + right.register.byte_10); + sum.register.byte_11 = (byte)(left.register.byte_11 + right.register.byte_11); + sum.register.byte_12 = (byte)(left.register.byte_12 + right.register.byte_12); + sum.register.byte_13 = (byte)(left.register.byte_13 + right.register.byte_13); + sum.register.byte_14 = (byte)(left.register.byte_14 + right.register.byte_14); + sum.register.byte_15 = (byte)(left.register.byte_15 + right.register.byte_15); + } + else if (typeof(T) == typeof(sbyte)) + { + sum.register.sbyte_0 = (sbyte)(left.register.sbyte_0 + right.register.sbyte_0); + sum.register.sbyte_1 = (sbyte)(left.register.sbyte_1 + right.register.sbyte_1); + sum.register.sbyte_2 = (sbyte)(left.register.sbyte_2 + right.register.sbyte_2); + sum.register.sbyte_3 = (sbyte)(left.register.sbyte_3 + right.register.sbyte_3); + sum.register.sbyte_4 = (sbyte)(left.register.sbyte_4 + right.register.sbyte_4); + sum.register.sbyte_5 = (sbyte)(left.register.sbyte_5 + right.register.sbyte_5); + sum.register.sbyte_6 = (sbyte)(left.register.sbyte_6 + right.register.sbyte_6); + sum.register.sbyte_7 = (sbyte)(left.register.sbyte_7 + right.register.sbyte_7); + sum.register.sbyte_8 = (sbyte)(left.register.sbyte_8 + right.register.sbyte_8); + sum.register.sbyte_9 = (sbyte)(left.register.sbyte_9 + right.register.sbyte_9); + sum.register.sbyte_10 = (sbyte)(left.register.sbyte_10 + right.register.sbyte_10); + sum.register.sbyte_11 = (sbyte)(left.register.sbyte_11 + right.register.sbyte_11); + sum.register.sbyte_12 = (sbyte)(left.register.sbyte_12 + right.register.sbyte_12); + sum.register.sbyte_13 = (sbyte)(left.register.sbyte_13 + right.register.sbyte_13); + sum.register.sbyte_14 = (sbyte)(left.register.sbyte_14 + right.register.sbyte_14); + sum.register.sbyte_15 = (sbyte)(left.register.sbyte_15 + right.register.sbyte_15); + } + else if (typeof(T) == typeof(ushort)) + { + sum.register.uint16_0 = (ushort)(left.register.uint16_0 + right.register.uint16_0); + sum.register.uint16_1 = (ushort)(left.register.uint16_1 + right.register.uint16_1); + sum.register.uint16_2 = (ushort)(left.register.uint16_2 + right.register.uint16_2); + sum.register.uint16_3 = (ushort)(left.register.uint16_3 + right.register.uint16_3); + sum.register.uint16_4 = (ushort)(left.register.uint16_4 + right.register.uint16_4); + sum.register.uint16_5 = (ushort)(left.register.uint16_5 + right.register.uint16_5); + sum.register.uint16_6 = (ushort)(left.register.uint16_6 + right.register.uint16_6); + sum.register.uint16_7 = (ushort)(left.register.uint16_7 + right.register.uint16_7); + } + else if (typeof(T) == typeof(short)) + { + sum.register.int16_0 = (short)(left.register.int16_0 + right.register.int16_0); + sum.register.int16_1 = (short)(left.register.int16_1 + right.register.int16_1); + sum.register.int16_2 = (short)(left.register.int16_2 + right.register.int16_2); + sum.register.int16_3 = (short)(left.register.int16_3 + right.register.int16_3); + sum.register.int16_4 = (short)(left.register.int16_4 + right.register.int16_4); + sum.register.int16_5 = (short)(left.register.int16_5 + right.register.int16_5); + sum.register.int16_6 = (short)(left.register.int16_6 + right.register.int16_6); + sum.register.int16_7 = (short)(left.register.int16_7 + right.register.int16_7); + } + else if (typeof(T) == typeof(uint)) + { + sum.register.uint32_0 = (uint)(left.register.uint32_0 + right.register.uint32_0); + sum.register.uint32_1 = (uint)(left.register.uint32_1 + right.register.uint32_1); + sum.register.uint32_2 = (uint)(left.register.uint32_2 + right.register.uint32_2); + sum.register.uint32_3 = (uint)(left.register.uint32_3 + right.register.uint32_3); + } + else if (typeof(T) == typeof(int)) + { + sum.register.int32_0 = (int)(left.register.int32_0 + right.register.int32_0); + sum.register.int32_1 = (int)(left.register.int32_1 + right.register.int32_1); + sum.register.int32_2 = (int)(left.register.int32_2 + right.register.int32_2); + sum.register.int32_3 = (int)(left.register.int32_3 + right.register.int32_3); + } + else if (typeof(T) == typeof(ulong)) + { + sum.register.uint64_0 = (ulong)(left.register.uint64_0 + right.register.uint64_0); + sum.register.uint64_1 = (ulong)(left.register.uint64_1 + right.register.uint64_1); + } + else if (typeof(T) == typeof(long)) + { + sum.register.int64_0 = (long)(left.register.int64_0 + right.register.int64_0); + sum.register.int64_1 = (long)(left.register.int64_1 + right.register.int64_1); + } + else if (typeof(T) == typeof(float)) + { + sum.register.single_0 = (float)(left.register.single_0 + right.register.single_0); + sum.register.single_1 = (float)(left.register.single_1 + right.register.single_1); + sum.register.single_2 = (float)(left.register.single_2 + right.register.single_2); + sum.register.single_3 = (float)(left.register.single_3 + right.register.single_3); + } + else if (typeof(T) == typeof(double)) + { + sum.register.double_0 = (double)(left.register.double_0 + right.register.double_0); + sum.register.double_1 = (double)(left.register.double_1 + right.register.double_1); } return sum; } @@ -1808,93 +1808,93 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Byte)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (byte)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (SByte)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (sbyte)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt16)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (ushort)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int16)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (short)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt32)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (uint)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int32)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (int)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt64)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (ulong)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int64)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (long)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Single)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (float)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Double)(object)ScalarSubtract(left[g], right[g]); + dataPtr[g] = (double)(object)ScalarSubtract(left[g], right[g]); } return new Vector(dataPtr); } @@ -1906,101 +1906,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector difference = new Vector(); - if (typeof(T) == typeof(Byte)) - { - difference.register.byte_0 = (Byte)(left.register.byte_0 - right.register.byte_0); - difference.register.byte_1 = (Byte)(left.register.byte_1 - right.register.byte_1); - difference.register.byte_2 = (Byte)(left.register.byte_2 - right.register.byte_2); - difference.register.byte_3 = (Byte)(left.register.byte_3 - right.register.byte_3); - difference.register.byte_4 = (Byte)(left.register.byte_4 - right.register.byte_4); - difference.register.byte_5 = (Byte)(left.register.byte_5 - right.register.byte_5); - difference.register.byte_6 = (Byte)(left.register.byte_6 - right.register.byte_6); - difference.register.byte_7 = (Byte)(left.register.byte_7 - right.register.byte_7); - difference.register.byte_8 = (Byte)(left.register.byte_8 - right.register.byte_8); - difference.register.byte_9 = (Byte)(left.register.byte_9 - right.register.byte_9); - difference.register.byte_10 = (Byte)(left.register.byte_10 - right.register.byte_10); - difference.register.byte_11 = (Byte)(left.register.byte_11 - right.register.byte_11); - difference.register.byte_12 = (Byte)(left.register.byte_12 - right.register.byte_12); - difference.register.byte_13 = (Byte)(left.register.byte_13 - right.register.byte_13); - difference.register.byte_14 = (Byte)(left.register.byte_14 - right.register.byte_14); - difference.register.byte_15 = (Byte)(left.register.byte_15 - right.register.byte_15); - } - else if (typeof(T) == typeof(SByte)) - { - difference.register.sbyte_0 = (SByte)(left.register.sbyte_0 - right.register.sbyte_0); - difference.register.sbyte_1 = (SByte)(left.register.sbyte_1 - right.register.sbyte_1); - difference.register.sbyte_2 = (SByte)(left.register.sbyte_2 - right.register.sbyte_2); - difference.register.sbyte_3 = (SByte)(left.register.sbyte_3 - right.register.sbyte_3); - difference.register.sbyte_4 = (SByte)(left.register.sbyte_4 - right.register.sbyte_4); - difference.register.sbyte_5 = (SByte)(left.register.sbyte_5 - right.register.sbyte_5); - difference.register.sbyte_6 = (SByte)(left.register.sbyte_6 - right.register.sbyte_6); - difference.register.sbyte_7 = (SByte)(left.register.sbyte_7 - right.register.sbyte_7); - difference.register.sbyte_8 = (SByte)(left.register.sbyte_8 - right.register.sbyte_8); - difference.register.sbyte_9 = (SByte)(left.register.sbyte_9 - right.register.sbyte_9); - difference.register.sbyte_10 = (SByte)(left.register.sbyte_10 - right.register.sbyte_10); - difference.register.sbyte_11 = (SByte)(left.register.sbyte_11 - right.register.sbyte_11); - difference.register.sbyte_12 = (SByte)(left.register.sbyte_12 - right.register.sbyte_12); - difference.register.sbyte_13 = (SByte)(left.register.sbyte_13 - right.register.sbyte_13); - difference.register.sbyte_14 = (SByte)(left.register.sbyte_14 - right.register.sbyte_14); - difference.register.sbyte_15 = (SByte)(left.register.sbyte_15 - right.register.sbyte_15); - } - else if (typeof(T) == typeof(UInt16)) - { - difference.register.uint16_0 = (UInt16)(left.register.uint16_0 - right.register.uint16_0); - difference.register.uint16_1 = (UInt16)(left.register.uint16_1 - right.register.uint16_1); - difference.register.uint16_2 = (UInt16)(left.register.uint16_2 - right.register.uint16_2); - difference.register.uint16_3 = (UInt16)(left.register.uint16_3 - right.register.uint16_3); - difference.register.uint16_4 = (UInt16)(left.register.uint16_4 - right.register.uint16_4); - difference.register.uint16_5 = (UInt16)(left.register.uint16_5 - right.register.uint16_5); - difference.register.uint16_6 = (UInt16)(left.register.uint16_6 - right.register.uint16_6); - difference.register.uint16_7 = (UInt16)(left.register.uint16_7 - right.register.uint16_7); - } - else if (typeof(T) == typeof(Int16)) - { - difference.register.int16_0 = (Int16)(left.register.int16_0 - right.register.int16_0); - difference.register.int16_1 = (Int16)(left.register.int16_1 - right.register.int16_1); - difference.register.int16_2 = (Int16)(left.register.int16_2 - right.register.int16_2); - difference.register.int16_3 = (Int16)(left.register.int16_3 - right.register.int16_3); - difference.register.int16_4 = (Int16)(left.register.int16_4 - right.register.int16_4); - difference.register.int16_5 = (Int16)(left.register.int16_5 - right.register.int16_5); - difference.register.int16_6 = (Int16)(left.register.int16_6 - right.register.int16_6); - difference.register.int16_7 = (Int16)(left.register.int16_7 - right.register.int16_7); - } - else if (typeof(T) == typeof(UInt32)) - { - difference.register.uint32_0 = (UInt32)(left.register.uint32_0 - right.register.uint32_0); - difference.register.uint32_1 = (UInt32)(left.register.uint32_1 - right.register.uint32_1); - difference.register.uint32_2 = (UInt32)(left.register.uint32_2 - right.register.uint32_2); - difference.register.uint32_3 = (UInt32)(left.register.uint32_3 - right.register.uint32_3); - } - else if (typeof(T) == typeof(Int32)) - { - difference.register.int32_0 = (Int32)(left.register.int32_0 - right.register.int32_0); - difference.register.int32_1 = (Int32)(left.register.int32_1 - right.register.int32_1); - difference.register.int32_2 = (Int32)(left.register.int32_2 - right.register.int32_2); - difference.register.int32_3 = (Int32)(left.register.int32_3 - right.register.int32_3); - } - else if (typeof(T) == typeof(UInt64)) - { - difference.register.uint64_0 = (UInt64)(left.register.uint64_0 - right.register.uint64_0); - difference.register.uint64_1 = (UInt64)(left.register.uint64_1 - right.register.uint64_1); - } - else if (typeof(T) == typeof(Int64)) - { - difference.register.int64_0 = (Int64)(left.register.int64_0 - right.register.int64_0); - difference.register.int64_1 = (Int64)(left.register.int64_1 - right.register.int64_1); - } - else if (typeof(T) == typeof(Single)) - { - difference.register.single_0 = (Single)(left.register.single_0 - right.register.single_0); - difference.register.single_1 = (Single)(left.register.single_1 - right.register.single_1); - difference.register.single_2 = (Single)(left.register.single_2 - right.register.single_2); - difference.register.single_3 = (Single)(left.register.single_3 - right.register.single_3); - } - else if (typeof(T) == typeof(Double)) - { - difference.register.double_0 = (Double)(left.register.double_0 - right.register.double_0); - difference.register.double_1 = (Double)(left.register.double_1 - right.register.double_1); + if (typeof(T) == typeof(byte)) + { + difference.register.byte_0 = (byte)(left.register.byte_0 - right.register.byte_0); + difference.register.byte_1 = (byte)(left.register.byte_1 - right.register.byte_1); + difference.register.byte_2 = (byte)(left.register.byte_2 - right.register.byte_2); + difference.register.byte_3 = (byte)(left.register.byte_3 - right.register.byte_3); + difference.register.byte_4 = (byte)(left.register.byte_4 - right.register.byte_4); + difference.register.byte_5 = (byte)(left.register.byte_5 - right.register.byte_5); + difference.register.byte_6 = (byte)(left.register.byte_6 - right.register.byte_6); + difference.register.byte_7 = (byte)(left.register.byte_7 - right.register.byte_7); + difference.register.byte_8 = (byte)(left.register.byte_8 - right.register.byte_8); + difference.register.byte_9 = (byte)(left.register.byte_9 - right.register.byte_9); + difference.register.byte_10 = (byte)(left.register.byte_10 - right.register.byte_10); + difference.register.byte_11 = (byte)(left.register.byte_11 - right.register.byte_11); + difference.register.byte_12 = (byte)(left.register.byte_12 - right.register.byte_12); + difference.register.byte_13 = (byte)(left.register.byte_13 - right.register.byte_13); + difference.register.byte_14 = (byte)(left.register.byte_14 - right.register.byte_14); + difference.register.byte_15 = (byte)(left.register.byte_15 - right.register.byte_15); + } + else if (typeof(T) == typeof(sbyte)) + { + difference.register.sbyte_0 = (sbyte)(left.register.sbyte_0 - right.register.sbyte_0); + difference.register.sbyte_1 = (sbyte)(left.register.sbyte_1 - right.register.sbyte_1); + difference.register.sbyte_2 = (sbyte)(left.register.sbyte_2 - right.register.sbyte_2); + difference.register.sbyte_3 = (sbyte)(left.register.sbyte_3 - right.register.sbyte_3); + difference.register.sbyte_4 = (sbyte)(left.register.sbyte_4 - right.register.sbyte_4); + difference.register.sbyte_5 = (sbyte)(left.register.sbyte_5 - right.register.sbyte_5); + difference.register.sbyte_6 = (sbyte)(left.register.sbyte_6 - right.register.sbyte_6); + difference.register.sbyte_7 = (sbyte)(left.register.sbyte_7 - right.register.sbyte_7); + difference.register.sbyte_8 = (sbyte)(left.register.sbyte_8 - right.register.sbyte_8); + difference.register.sbyte_9 = (sbyte)(left.register.sbyte_9 - right.register.sbyte_9); + difference.register.sbyte_10 = (sbyte)(left.register.sbyte_10 - right.register.sbyte_10); + difference.register.sbyte_11 = (sbyte)(left.register.sbyte_11 - right.register.sbyte_11); + difference.register.sbyte_12 = (sbyte)(left.register.sbyte_12 - right.register.sbyte_12); + difference.register.sbyte_13 = (sbyte)(left.register.sbyte_13 - right.register.sbyte_13); + difference.register.sbyte_14 = (sbyte)(left.register.sbyte_14 - right.register.sbyte_14); + difference.register.sbyte_15 = (sbyte)(left.register.sbyte_15 - right.register.sbyte_15); + } + else if (typeof(T) == typeof(ushort)) + { + difference.register.uint16_0 = (ushort)(left.register.uint16_0 - right.register.uint16_0); + difference.register.uint16_1 = (ushort)(left.register.uint16_1 - right.register.uint16_1); + difference.register.uint16_2 = (ushort)(left.register.uint16_2 - right.register.uint16_2); + difference.register.uint16_3 = (ushort)(left.register.uint16_3 - right.register.uint16_3); + difference.register.uint16_4 = (ushort)(left.register.uint16_4 - right.register.uint16_4); + difference.register.uint16_5 = (ushort)(left.register.uint16_5 - right.register.uint16_5); + difference.register.uint16_6 = (ushort)(left.register.uint16_6 - right.register.uint16_6); + difference.register.uint16_7 = (ushort)(left.register.uint16_7 - right.register.uint16_7); + } + else if (typeof(T) == typeof(short)) + { + difference.register.int16_0 = (short)(left.register.int16_0 - right.register.int16_0); + difference.register.int16_1 = (short)(left.register.int16_1 - right.register.int16_1); + difference.register.int16_2 = (short)(left.register.int16_2 - right.register.int16_2); + difference.register.int16_3 = (short)(left.register.int16_3 - right.register.int16_3); + difference.register.int16_4 = (short)(left.register.int16_4 - right.register.int16_4); + difference.register.int16_5 = (short)(left.register.int16_5 - right.register.int16_5); + difference.register.int16_6 = (short)(left.register.int16_6 - right.register.int16_6); + difference.register.int16_7 = (short)(left.register.int16_7 - right.register.int16_7); + } + else if (typeof(T) == typeof(uint)) + { + difference.register.uint32_0 = (uint)(left.register.uint32_0 - right.register.uint32_0); + difference.register.uint32_1 = (uint)(left.register.uint32_1 - right.register.uint32_1); + difference.register.uint32_2 = (uint)(left.register.uint32_2 - right.register.uint32_2); + difference.register.uint32_3 = (uint)(left.register.uint32_3 - right.register.uint32_3); + } + else if (typeof(T) == typeof(int)) + { + difference.register.int32_0 = (int)(left.register.int32_0 - right.register.int32_0); + difference.register.int32_1 = (int)(left.register.int32_1 - right.register.int32_1); + difference.register.int32_2 = (int)(left.register.int32_2 - right.register.int32_2); + difference.register.int32_3 = (int)(left.register.int32_3 - right.register.int32_3); + } + else if (typeof(T) == typeof(ulong)) + { + difference.register.uint64_0 = (ulong)(left.register.uint64_0 - right.register.uint64_0); + difference.register.uint64_1 = (ulong)(left.register.uint64_1 - right.register.uint64_1); + } + else if (typeof(T) == typeof(long)) + { + difference.register.int64_0 = (long)(left.register.int64_0 - right.register.int64_0); + difference.register.int64_1 = (long)(left.register.int64_1 - right.register.int64_1); + } + else if (typeof(T) == typeof(float)) + { + difference.register.single_0 = (float)(left.register.single_0 - right.register.single_0); + difference.register.single_1 = (float)(left.register.single_1 - right.register.single_1); + difference.register.single_2 = (float)(left.register.single_2 - right.register.single_2); + difference.register.single_3 = (float)(left.register.single_3 - right.register.single_3); + } + else if (typeof(T) == typeof(double)) + { + difference.register.double_0 = (double)(left.register.double_0 - right.register.double_0); + difference.register.double_1 = (double)(left.register.double_1 - right.register.double_1); } return difference; } @@ -2020,93 +2020,93 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Byte)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (byte)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (SByte)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (sbyte)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt16)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (ushort)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int16)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (short)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt32)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (uint)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int32)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (int)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt64)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (ulong)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int64)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (long)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Single)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (float)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Double)(object)ScalarMultiply(left[g], right[g]); + dataPtr[g] = (double)(object)ScalarMultiply(left[g], right[g]); } return new Vector(dataPtr); } @@ -2118,101 +2118,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector product = new Vector(); - if (typeof(T) == typeof(Byte)) - { - product.register.byte_0 = (Byte)(left.register.byte_0 * right.register.byte_0); - product.register.byte_1 = (Byte)(left.register.byte_1 * right.register.byte_1); - product.register.byte_2 = (Byte)(left.register.byte_2 * right.register.byte_2); - product.register.byte_3 = (Byte)(left.register.byte_3 * right.register.byte_3); - product.register.byte_4 = (Byte)(left.register.byte_4 * right.register.byte_4); - product.register.byte_5 = (Byte)(left.register.byte_5 * right.register.byte_5); - product.register.byte_6 = (Byte)(left.register.byte_6 * right.register.byte_6); - product.register.byte_7 = (Byte)(left.register.byte_7 * right.register.byte_7); - product.register.byte_8 = (Byte)(left.register.byte_8 * right.register.byte_8); - product.register.byte_9 = (Byte)(left.register.byte_9 * right.register.byte_9); - product.register.byte_10 = (Byte)(left.register.byte_10 * right.register.byte_10); - product.register.byte_11 = (Byte)(left.register.byte_11 * right.register.byte_11); - product.register.byte_12 = (Byte)(left.register.byte_12 * right.register.byte_12); - product.register.byte_13 = (Byte)(left.register.byte_13 * right.register.byte_13); - product.register.byte_14 = (Byte)(left.register.byte_14 * right.register.byte_14); - product.register.byte_15 = (Byte)(left.register.byte_15 * right.register.byte_15); - } - else if (typeof(T) == typeof(SByte)) - { - product.register.sbyte_0 = (SByte)(left.register.sbyte_0 * right.register.sbyte_0); - product.register.sbyte_1 = (SByte)(left.register.sbyte_1 * right.register.sbyte_1); - product.register.sbyte_2 = (SByte)(left.register.sbyte_2 * right.register.sbyte_2); - product.register.sbyte_3 = (SByte)(left.register.sbyte_3 * right.register.sbyte_3); - product.register.sbyte_4 = (SByte)(left.register.sbyte_4 * right.register.sbyte_4); - product.register.sbyte_5 = (SByte)(left.register.sbyte_5 * right.register.sbyte_5); - product.register.sbyte_6 = (SByte)(left.register.sbyte_6 * right.register.sbyte_6); - product.register.sbyte_7 = (SByte)(left.register.sbyte_7 * right.register.sbyte_7); - product.register.sbyte_8 = (SByte)(left.register.sbyte_8 * right.register.sbyte_8); - product.register.sbyte_9 = (SByte)(left.register.sbyte_9 * right.register.sbyte_9); - product.register.sbyte_10 = (SByte)(left.register.sbyte_10 * right.register.sbyte_10); - product.register.sbyte_11 = (SByte)(left.register.sbyte_11 * right.register.sbyte_11); - product.register.sbyte_12 = (SByte)(left.register.sbyte_12 * right.register.sbyte_12); - product.register.sbyte_13 = (SByte)(left.register.sbyte_13 * right.register.sbyte_13); - product.register.sbyte_14 = (SByte)(left.register.sbyte_14 * right.register.sbyte_14); - product.register.sbyte_15 = (SByte)(left.register.sbyte_15 * right.register.sbyte_15); - } - else if (typeof(T) == typeof(UInt16)) - { - product.register.uint16_0 = (UInt16)(left.register.uint16_0 * right.register.uint16_0); - product.register.uint16_1 = (UInt16)(left.register.uint16_1 * right.register.uint16_1); - product.register.uint16_2 = (UInt16)(left.register.uint16_2 * right.register.uint16_2); - product.register.uint16_3 = (UInt16)(left.register.uint16_3 * right.register.uint16_3); - product.register.uint16_4 = (UInt16)(left.register.uint16_4 * right.register.uint16_4); - product.register.uint16_5 = (UInt16)(left.register.uint16_5 * right.register.uint16_5); - product.register.uint16_6 = (UInt16)(left.register.uint16_6 * right.register.uint16_6); - product.register.uint16_7 = (UInt16)(left.register.uint16_7 * right.register.uint16_7); - } - else if (typeof(T) == typeof(Int16)) - { - product.register.int16_0 = (Int16)(left.register.int16_0 * right.register.int16_0); - product.register.int16_1 = (Int16)(left.register.int16_1 * right.register.int16_1); - product.register.int16_2 = (Int16)(left.register.int16_2 * right.register.int16_2); - product.register.int16_3 = (Int16)(left.register.int16_3 * right.register.int16_3); - product.register.int16_4 = (Int16)(left.register.int16_4 * right.register.int16_4); - product.register.int16_5 = (Int16)(left.register.int16_5 * right.register.int16_5); - product.register.int16_6 = (Int16)(left.register.int16_6 * right.register.int16_6); - product.register.int16_7 = (Int16)(left.register.int16_7 * right.register.int16_7); - } - else if (typeof(T) == typeof(UInt32)) - { - product.register.uint32_0 = (UInt32)(left.register.uint32_0 * right.register.uint32_0); - product.register.uint32_1 = (UInt32)(left.register.uint32_1 * right.register.uint32_1); - product.register.uint32_2 = (UInt32)(left.register.uint32_2 * right.register.uint32_2); - product.register.uint32_3 = (UInt32)(left.register.uint32_3 * right.register.uint32_3); - } - else if (typeof(T) == typeof(Int32)) - { - product.register.int32_0 = (Int32)(left.register.int32_0 * right.register.int32_0); - product.register.int32_1 = (Int32)(left.register.int32_1 * right.register.int32_1); - product.register.int32_2 = (Int32)(left.register.int32_2 * right.register.int32_2); - product.register.int32_3 = (Int32)(left.register.int32_3 * right.register.int32_3); - } - else if (typeof(T) == typeof(UInt64)) - { - product.register.uint64_0 = (UInt64)(left.register.uint64_0 * right.register.uint64_0); - product.register.uint64_1 = (UInt64)(left.register.uint64_1 * right.register.uint64_1); - } - else if (typeof(T) == typeof(Int64)) - { - product.register.int64_0 = (Int64)(left.register.int64_0 * right.register.int64_0); - product.register.int64_1 = (Int64)(left.register.int64_1 * right.register.int64_1); - } - else if (typeof(T) == typeof(Single)) - { - product.register.single_0 = (Single)(left.register.single_0 * right.register.single_0); - product.register.single_1 = (Single)(left.register.single_1 * right.register.single_1); - product.register.single_2 = (Single)(left.register.single_2 * right.register.single_2); - product.register.single_3 = (Single)(left.register.single_3 * right.register.single_3); - } - else if (typeof(T) == typeof(Double)) - { - product.register.double_0 = (Double)(left.register.double_0 * right.register.double_0); - product.register.double_1 = (Double)(left.register.double_1 * right.register.double_1); + if (typeof(T) == typeof(byte)) + { + product.register.byte_0 = (byte)(left.register.byte_0 * right.register.byte_0); + product.register.byte_1 = (byte)(left.register.byte_1 * right.register.byte_1); + product.register.byte_2 = (byte)(left.register.byte_2 * right.register.byte_2); + product.register.byte_3 = (byte)(left.register.byte_3 * right.register.byte_3); + product.register.byte_4 = (byte)(left.register.byte_4 * right.register.byte_4); + product.register.byte_5 = (byte)(left.register.byte_5 * right.register.byte_5); + product.register.byte_6 = (byte)(left.register.byte_6 * right.register.byte_6); + product.register.byte_7 = (byte)(left.register.byte_7 * right.register.byte_7); + product.register.byte_8 = (byte)(left.register.byte_8 * right.register.byte_8); + product.register.byte_9 = (byte)(left.register.byte_9 * right.register.byte_9); + product.register.byte_10 = (byte)(left.register.byte_10 * right.register.byte_10); + product.register.byte_11 = (byte)(left.register.byte_11 * right.register.byte_11); + product.register.byte_12 = (byte)(left.register.byte_12 * right.register.byte_12); + product.register.byte_13 = (byte)(left.register.byte_13 * right.register.byte_13); + product.register.byte_14 = (byte)(left.register.byte_14 * right.register.byte_14); + product.register.byte_15 = (byte)(left.register.byte_15 * right.register.byte_15); + } + else if (typeof(T) == typeof(sbyte)) + { + product.register.sbyte_0 = (sbyte)(left.register.sbyte_0 * right.register.sbyte_0); + product.register.sbyte_1 = (sbyte)(left.register.sbyte_1 * right.register.sbyte_1); + product.register.sbyte_2 = (sbyte)(left.register.sbyte_2 * right.register.sbyte_2); + product.register.sbyte_3 = (sbyte)(left.register.sbyte_3 * right.register.sbyte_3); + product.register.sbyte_4 = (sbyte)(left.register.sbyte_4 * right.register.sbyte_4); + product.register.sbyte_5 = (sbyte)(left.register.sbyte_5 * right.register.sbyte_5); + product.register.sbyte_6 = (sbyte)(left.register.sbyte_6 * right.register.sbyte_6); + product.register.sbyte_7 = (sbyte)(left.register.sbyte_7 * right.register.sbyte_7); + product.register.sbyte_8 = (sbyte)(left.register.sbyte_8 * right.register.sbyte_8); + product.register.sbyte_9 = (sbyte)(left.register.sbyte_9 * right.register.sbyte_9); + product.register.sbyte_10 = (sbyte)(left.register.sbyte_10 * right.register.sbyte_10); + product.register.sbyte_11 = (sbyte)(left.register.sbyte_11 * right.register.sbyte_11); + product.register.sbyte_12 = (sbyte)(left.register.sbyte_12 * right.register.sbyte_12); + product.register.sbyte_13 = (sbyte)(left.register.sbyte_13 * right.register.sbyte_13); + product.register.sbyte_14 = (sbyte)(left.register.sbyte_14 * right.register.sbyte_14); + product.register.sbyte_15 = (sbyte)(left.register.sbyte_15 * right.register.sbyte_15); + } + else if (typeof(T) == typeof(ushort)) + { + product.register.uint16_0 = (ushort)(left.register.uint16_0 * right.register.uint16_0); + product.register.uint16_1 = (ushort)(left.register.uint16_1 * right.register.uint16_1); + product.register.uint16_2 = (ushort)(left.register.uint16_2 * right.register.uint16_2); + product.register.uint16_3 = (ushort)(left.register.uint16_3 * right.register.uint16_3); + product.register.uint16_4 = (ushort)(left.register.uint16_4 * right.register.uint16_4); + product.register.uint16_5 = (ushort)(left.register.uint16_5 * right.register.uint16_5); + product.register.uint16_6 = (ushort)(left.register.uint16_6 * right.register.uint16_6); + product.register.uint16_7 = (ushort)(left.register.uint16_7 * right.register.uint16_7); + } + else if (typeof(T) == typeof(short)) + { + product.register.int16_0 = (short)(left.register.int16_0 * right.register.int16_0); + product.register.int16_1 = (short)(left.register.int16_1 * right.register.int16_1); + product.register.int16_2 = (short)(left.register.int16_2 * right.register.int16_2); + product.register.int16_3 = (short)(left.register.int16_3 * right.register.int16_3); + product.register.int16_4 = (short)(left.register.int16_4 * right.register.int16_4); + product.register.int16_5 = (short)(left.register.int16_5 * right.register.int16_5); + product.register.int16_6 = (short)(left.register.int16_6 * right.register.int16_6); + product.register.int16_7 = (short)(left.register.int16_7 * right.register.int16_7); + } + else if (typeof(T) == typeof(uint)) + { + product.register.uint32_0 = (uint)(left.register.uint32_0 * right.register.uint32_0); + product.register.uint32_1 = (uint)(left.register.uint32_1 * right.register.uint32_1); + product.register.uint32_2 = (uint)(left.register.uint32_2 * right.register.uint32_2); + product.register.uint32_3 = (uint)(left.register.uint32_3 * right.register.uint32_3); + } + else if (typeof(T) == typeof(int)) + { + product.register.int32_0 = (int)(left.register.int32_0 * right.register.int32_0); + product.register.int32_1 = (int)(left.register.int32_1 * right.register.int32_1); + product.register.int32_2 = (int)(left.register.int32_2 * right.register.int32_2); + product.register.int32_3 = (int)(left.register.int32_3 * right.register.int32_3); + } + else if (typeof(T) == typeof(ulong)) + { + product.register.uint64_0 = (ulong)(left.register.uint64_0 * right.register.uint64_0); + product.register.uint64_1 = (ulong)(left.register.uint64_1 * right.register.uint64_1); + } + else if (typeof(T) == typeof(long)) + { + product.register.int64_0 = (long)(left.register.int64_0 * right.register.int64_0); + product.register.int64_1 = (long)(left.register.int64_1 * right.register.int64_1); + } + else if (typeof(T) == typeof(float)) + { + product.register.single_0 = (float)(left.register.single_0 * right.register.single_0); + product.register.single_1 = (float)(left.register.single_1 * right.register.single_1); + product.register.single_2 = (float)(left.register.single_2 * right.register.single_2); + product.register.single_3 = (float)(left.register.single_3 * right.register.single_3); + } + else if (typeof(T) == typeof(double)) + { + product.register.double_0 = (double)(left.register.double_0 * right.register.double_0); + product.register.double_1 = (double)(left.register.double_1 * right.register.double_1); } return product; } @@ -2237,101 +2237,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector product = new Vector(); - if (typeof(T) == typeof(Byte)) - { - product.register.byte_0 = (Byte)(value.register.byte_0 * (Byte)(object)factor); - product.register.byte_1 = (Byte)(value.register.byte_1 * (Byte)(object)factor); - product.register.byte_2 = (Byte)(value.register.byte_2 * (Byte)(object)factor); - product.register.byte_3 = (Byte)(value.register.byte_3 * (Byte)(object)factor); - product.register.byte_4 = (Byte)(value.register.byte_4 * (Byte)(object)factor); - product.register.byte_5 = (Byte)(value.register.byte_5 * (Byte)(object)factor); - product.register.byte_6 = (Byte)(value.register.byte_6 * (Byte)(object)factor); - product.register.byte_7 = (Byte)(value.register.byte_7 * (Byte)(object)factor); - product.register.byte_8 = (Byte)(value.register.byte_8 * (Byte)(object)factor); - product.register.byte_9 = (Byte)(value.register.byte_9 * (Byte)(object)factor); - product.register.byte_10 = (Byte)(value.register.byte_10 * (Byte)(object)factor); - product.register.byte_11 = (Byte)(value.register.byte_11 * (Byte)(object)factor); - product.register.byte_12 = (Byte)(value.register.byte_12 * (Byte)(object)factor); - product.register.byte_13 = (Byte)(value.register.byte_13 * (Byte)(object)factor); - product.register.byte_14 = (Byte)(value.register.byte_14 * (Byte)(object)factor); - product.register.byte_15 = (Byte)(value.register.byte_15 * (Byte)(object)factor); - } - else if (typeof(T) == typeof(SByte)) - { - product.register.sbyte_0 = (SByte)(value.register.sbyte_0 * (SByte)(object)factor); - product.register.sbyte_1 = (SByte)(value.register.sbyte_1 * (SByte)(object)factor); - product.register.sbyte_2 = (SByte)(value.register.sbyte_2 * (SByte)(object)factor); - product.register.sbyte_3 = (SByte)(value.register.sbyte_3 * (SByte)(object)factor); - product.register.sbyte_4 = (SByte)(value.register.sbyte_4 * (SByte)(object)factor); - product.register.sbyte_5 = (SByte)(value.register.sbyte_5 * (SByte)(object)factor); - product.register.sbyte_6 = (SByte)(value.register.sbyte_6 * (SByte)(object)factor); - product.register.sbyte_7 = (SByte)(value.register.sbyte_7 * (SByte)(object)factor); - product.register.sbyte_8 = (SByte)(value.register.sbyte_8 * (SByte)(object)factor); - product.register.sbyte_9 = (SByte)(value.register.sbyte_9 * (SByte)(object)factor); - product.register.sbyte_10 = (SByte)(value.register.sbyte_10 * (SByte)(object)factor); - product.register.sbyte_11 = (SByte)(value.register.sbyte_11 * (SByte)(object)factor); - product.register.sbyte_12 = (SByte)(value.register.sbyte_12 * (SByte)(object)factor); - product.register.sbyte_13 = (SByte)(value.register.sbyte_13 * (SByte)(object)factor); - product.register.sbyte_14 = (SByte)(value.register.sbyte_14 * (SByte)(object)factor); - product.register.sbyte_15 = (SByte)(value.register.sbyte_15 * (SByte)(object)factor); - } - else if (typeof(T) == typeof(UInt16)) - { - product.register.uint16_0 = (UInt16)(value.register.uint16_0 * (UInt16)(object)factor); - product.register.uint16_1 = (UInt16)(value.register.uint16_1 * (UInt16)(object)factor); - product.register.uint16_2 = (UInt16)(value.register.uint16_2 * (UInt16)(object)factor); - product.register.uint16_3 = (UInt16)(value.register.uint16_3 * (UInt16)(object)factor); - product.register.uint16_4 = (UInt16)(value.register.uint16_4 * (UInt16)(object)factor); - product.register.uint16_5 = (UInt16)(value.register.uint16_5 * (UInt16)(object)factor); - product.register.uint16_6 = (UInt16)(value.register.uint16_6 * (UInt16)(object)factor); - product.register.uint16_7 = (UInt16)(value.register.uint16_7 * (UInt16)(object)factor); - } - else if (typeof(T) == typeof(Int16)) - { - product.register.int16_0 = (Int16)(value.register.int16_0 * (Int16)(object)factor); - product.register.int16_1 = (Int16)(value.register.int16_1 * (Int16)(object)factor); - product.register.int16_2 = (Int16)(value.register.int16_2 * (Int16)(object)factor); - product.register.int16_3 = (Int16)(value.register.int16_3 * (Int16)(object)factor); - product.register.int16_4 = (Int16)(value.register.int16_4 * (Int16)(object)factor); - product.register.int16_5 = (Int16)(value.register.int16_5 * (Int16)(object)factor); - product.register.int16_6 = (Int16)(value.register.int16_6 * (Int16)(object)factor); - product.register.int16_7 = (Int16)(value.register.int16_7 * (Int16)(object)factor); - } - else if (typeof(T) == typeof(UInt32)) - { - product.register.uint32_0 = (UInt32)(value.register.uint32_0 * (UInt32)(object)factor); - product.register.uint32_1 = (UInt32)(value.register.uint32_1 * (UInt32)(object)factor); - product.register.uint32_2 = (UInt32)(value.register.uint32_2 * (UInt32)(object)factor); - product.register.uint32_3 = (UInt32)(value.register.uint32_3 * (UInt32)(object)factor); - } - else if (typeof(T) == typeof(Int32)) - { - product.register.int32_0 = (Int32)(value.register.int32_0 * (Int32)(object)factor); - product.register.int32_1 = (Int32)(value.register.int32_1 * (Int32)(object)factor); - product.register.int32_2 = (Int32)(value.register.int32_2 * (Int32)(object)factor); - product.register.int32_3 = (Int32)(value.register.int32_3 * (Int32)(object)factor); - } - else if (typeof(T) == typeof(UInt64)) - { - product.register.uint64_0 = (UInt64)(value.register.uint64_0 * (UInt64)(object)factor); - product.register.uint64_1 = (UInt64)(value.register.uint64_1 * (UInt64)(object)factor); - } - else if (typeof(T) == typeof(Int64)) - { - product.register.int64_0 = (Int64)(value.register.int64_0 * (Int64)(object)factor); - product.register.int64_1 = (Int64)(value.register.int64_1 * (Int64)(object)factor); - } - else if (typeof(T) == typeof(Single)) - { - product.register.single_0 = (Single)(value.register.single_0 * (Single)(object)factor); - product.register.single_1 = (Single)(value.register.single_1 * (Single)(object)factor); - product.register.single_2 = (Single)(value.register.single_2 * (Single)(object)factor); - product.register.single_3 = (Single)(value.register.single_3 * (Single)(object)factor); - } - else if (typeof(T) == typeof(Double)) - { - product.register.double_0 = (Double)(value.register.double_0 * (Double)(object)factor); - product.register.double_1 = (Double)(value.register.double_1 * (Double)(object)factor); + if (typeof(T) == typeof(byte)) + { + product.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); + product.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); + product.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); + product.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); + product.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); + product.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); + product.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); + product.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); + product.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); + product.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); + product.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); + product.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); + product.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); + product.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); + product.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); + product.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); + } + else if (typeof(T) == typeof(sbyte)) + { + product.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); + product.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); + product.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); + product.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); + product.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); + product.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); + product.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); + product.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); + product.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); + product.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); + product.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); + product.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); + product.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); + product.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); + product.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); + product.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); + } + else if (typeof(T) == typeof(ushort)) + { + product.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); + product.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); + product.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); + product.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); + product.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); + product.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); + product.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); + product.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); + } + else if (typeof(T) == typeof(short)) + { + product.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); + product.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); + product.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); + product.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); + product.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); + product.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); + product.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); + product.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); + } + else if (typeof(T) == typeof(uint)) + { + product.register.uint32_0 = (uint)(value.register.uint32_0 * (uint)(object)factor); + product.register.uint32_1 = (uint)(value.register.uint32_1 * (uint)(object)factor); + product.register.uint32_2 = (uint)(value.register.uint32_2 * (uint)(object)factor); + product.register.uint32_3 = (uint)(value.register.uint32_3 * (uint)(object)factor); + } + else if (typeof(T) == typeof(int)) + { + product.register.int32_0 = (int)(value.register.int32_0 * (int)(object)factor); + product.register.int32_1 = (int)(value.register.int32_1 * (int)(object)factor); + product.register.int32_2 = (int)(value.register.int32_2 * (int)(object)factor); + product.register.int32_3 = (int)(value.register.int32_3 * (int)(object)factor); + } + else if (typeof(T) == typeof(ulong)) + { + product.register.uint64_0 = (ulong)(value.register.uint64_0 * (ulong)(object)factor); + product.register.uint64_1 = (ulong)(value.register.uint64_1 * (ulong)(object)factor); + } + else if (typeof(T) == typeof(long)) + { + product.register.int64_0 = (long)(value.register.int64_0 * (long)(object)factor); + product.register.int64_1 = (long)(value.register.int64_1 * (long)(object)factor); + } + else if (typeof(T) == typeof(float)) + { + product.register.single_0 = (float)(value.register.single_0 * (float)(object)factor); + product.register.single_1 = (float)(value.register.single_1 * (float)(object)factor); + product.register.single_2 = (float)(value.register.single_2 * (float)(object)factor); + product.register.single_3 = (float)(value.register.single_3 * (float)(object)factor); + } + else if (typeof(T) == typeof(double)) + { + product.register.double_0 = (double)(value.register.double_0 * (double)(object)factor); + product.register.double_1 = (double)(value.register.double_1 * (double)(object)factor); } return product; } @@ -2356,101 +2356,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector product = new Vector(); - if (typeof(T) == typeof(Byte)) - { - product.register.byte_0 = (Byte)(value.register.byte_0 * (Byte)(object)factor); - product.register.byte_1 = (Byte)(value.register.byte_1 * (Byte)(object)factor); - product.register.byte_2 = (Byte)(value.register.byte_2 * (Byte)(object)factor); - product.register.byte_3 = (Byte)(value.register.byte_3 * (Byte)(object)factor); - product.register.byte_4 = (Byte)(value.register.byte_4 * (Byte)(object)factor); - product.register.byte_5 = (Byte)(value.register.byte_5 * (Byte)(object)factor); - product.register.byte_6 = (Byte)(value.register.byte_6 * (Byte)(object)factor); - product.register.byte_7 = (Byte)(value.register.byte_7 * (Byte)(object)factor); - product.register.byte_8 = (Byte)(value.register.byte_8 * (Byte)(object)factor); - product.register.byte_9 = (Byte)(value.register.byte_9 * (Byte)(object)factor); - product.register.byte_10 = (Byte)(value.register.byte_10 * (Byte)(object)factor); - product.register.byte_11 = (Byte)(value.register.byte_11 * (Byte)(object)factor); - product.register.byte_12 = (Byte)(value.register.byte_12 * (Byte)(object)factor); - product.register.byte_13 = (Byte)(value.register.byte_13 * (Byte)(object)factor); - product.register.byte_14 = (Byte)(value.register.byte_14 * (Byte)(object)factor); - product.register.byte_15 = (Byte)(value.register.byte_15 * (Byte)(object)factor); - } - else if (typeof(T) == typeof(SByte)) - { - product.register.sbyte_0 = (SByte)(value.register.sbyte_0 * (SByte)(object)factor); - product.register.sbyte_1 = (SByte)(value.register.sbyte_1 * (SByte)(object)factor); - product.register.sbyte_2 = (SByte)(value.register.sbyte_2 * (SByte)(object)factor); - product.register.sbyte_3 = (SByte)(value.register.sbyte_3 * (SByte)(object)factor); - product.register.sbyte_4 = (SByte)(value.register.sbyte_4 * (SByte)(object)factor); - product.register.sbyte_5 = (SByte)(value.register.sbyte_5 * (SByte)(object)factor); - product.register.sbyte_6 = (SByte)(value.register.sbyte_6 * (SByte)(object)factor); - product.register.sbyte_7 = (SByte)(value.register.sbyte_7 * (SByte)(object)factor); - product.register.sbyte_8 = (SByte)(value.register.sbyte_8 * (SByte)(object)factor); - product.register.sbyte_9 = (SByte)(value.register.sbyte_9 * (SByte)(object)factor); - product.register.sbyte_10 = (SByte)(value.register.sbyte_10 * (SByte)(object)factor); - product.register.sbyte_11 = (SByte)(value.register.sbyte_11 * (SByte)(object)factor); - product.register.sbyte_12 = (SByte)(value.register.sbyte_12 * (SByte)(object)factor); - product.register.sbyte_13 = (SByte)(value.register.sbyte_13 * (SByte)(object)factor); - product.register.sbyte_14 = (SByte)(value.register.sbyte_14 * (SByte)(object)factor); - product.register.sbyte_15 = (SByte)(value.register.sbyte_15 * (SByte)(object)factor); - } - else if (typeof(T) == typeof(UInt16)) - { - product.register.uint16_0 = (UInt16)(value.register.uint16_0 * (UInt16)(object)factor); - product.register.uint16_1 = (UInt16)(value.register.uint16_1 * (UInt16)(object)factor); - product.register.uint16_2 = (UInt16)(value.register.uint16_2 * (UInt16)(object)factor); - product.register.uint16_3 = (UInt16)(value.register.uint16_3 * (UInt16)(object)factor); - product.register.uint16_4 = (UInt16)(value.register.uint16_4 * (UInt16)(object)factor); - product.register.uint16_5 = (UInt16)(value.register.uint16_5 * (UInt16)(object)factor); - product.register.uint16_6 = (UInt16)(value.register.uint16_6 * (UInt16)(object)factor); - product.register.uint16_7 = (UInt16)(value.register.uint16_7 * (UInt16)(object)factor); - } - else if (typeof(T) == typeof(Int16)) - { - product.register.int16_0 = (Int16)(value.register.int16_0 * (Int16)(object)factor); - product.register.int16_1 = (Int16)(value.register.int16_1 * (Int16)(object)factor); - product.register.int16_2 = (Int16)(value.register.int16_2 * (Int16)(object)factor); - product.register.int16_3 = (Int16)(value.register.int16_3 * (Int16)(object)factor); - product.register.int16_4 = (Int16)(value.register.int16_4 * (Int16)(object)factor); - product.register.int16_5 = (Int16)(value.register.int16_5 * (Int16)(object)factor); - product.register.int16_6 = (Int16)(value.register.int16_6 * (Int16)(object)factor); - product.register.int16_7 = (Int16)(value.register.int16_7 * (Int16)(object)factor); - } - else if (typeof(T) == typeof(UInt32)) - { - product.register.uint32_0 = (UInt32)(value.register.uint32_0 * (UInt32)(object)factor); - product.register.uint32_1 = (UInt32)(value.register.uint32_1 * (UInt32)(object)factor); - product.register.uint32_2 = (UInt32)(value.register.uint32_2 * (UInt32)(object)factor); - product.register.uint32_3 = (UInt32)(value.register.uint32_3 * (UInt32)(object)factor); - } - else if (typeof(T) == typeof(Int32)) - { - product.register.int32_0 = (Int32)(value.register.int32_0 * (Int32)(object)factor); - product.register.int32_1 = (Int32)(value.register.int32_1 * (Int32)(object)factor); - product.register.int32_2 = (Int32)(value.register.int32_2 * (Int32)(object)factor); - product.register.int32_3 = (Int32)(value.register.int32_3 * (Int32)(object)factor); - } - else if (typeof(T) == typeof(UInt64)) - { - product.register.uint64_0 = (UInt64)(value.register.uint64_0 * (UInt64)(object)factor); - product.register.uint64_1 = (UInt64)(value.register.uint64_1 * (UInt64)(object)factor); - } - else if (typeof(T) == typeof(Int64)) - { - product.register.int64_0 = (Int64)(value.register.int64_0 * (Int64)(object)factor); - product.register.int64_1 = (Int64)(value.register.int64_1 * (Int64)(object)factor); - } - else if (typeof(T) == typeof(Single)) - { - product.register.single_0 = (Single)(value.register.single_0 * (Single)(object)factor); - product.register.single_1 = (Single)(value.register.single_1 * (Single)(object)factor); - product.register.single_2 = (Single)(value.register.single_2 * (Single)(object)factor); - product.register.single_3 = (Single)(value.register.single_3 * (Single)(object)factor); - } - else if (typeof(T) == typeof(Double)) - { - product.register.double_0 = (Double)(value.register.double_0 * (Double)(object)factor); - product.register.double_1 = (Double)(value.register.double_1 * (Double)(object)factor); + if (typeof(T) == typeof(byte)) + { + product.register.byte_0 = (byte)(value.register.byte_0 * (byte)(object)factor); + product.register.byte_1 = (byte)(value.register.byte_1 * (byte)(object)factor); + product.register.byte_2 = (byte)(value.register.byte_2 * (byte)(object)factor); + product.register.byte_3 = (byte)(value.register.byte_3 * (byte)(object)factor); + product.register.byte_4 = (byte)(value.register.byte_4 * (byte)(object)factor); + product.register.byte_5 = (byte)(value.register.byte_5 * (byte)(object)factor); + product.register.byte_6 = (byte)(value.register.byte_6 * (byte)(object)factor); + product.register.byte_7 = (byte)(value.register.byte_7 * (byte)(object)factor); + product.register.byte_8 = (byte)(value.register.byte_8 * (byte)(object)factor); + product.register.byte_9 = (byte)(value.register.byte_9 * (byte)(object)factor); + product.register.byte_10 = (byte)(value.register.byte_10 * (byte)(object)factor); + product.register.byte_11 = (byte)(value.register.byte_11 * (byte)(object)factor); + product.register.byte_12 = (byte)(value.register.byte_12 * (byte)(object)factor); + product.register.byte_13 = (byte)(value.register.byte_13 * (byte)(object)factor); + product.register.byte_14 = (byte)(value.register.byte_14 * (byte)(object)factor); + product.register.byte_15 = (byte)(value.register.byte_15 * (byte)(object)factor); + } + else if (typeof(T) == typeof(sbyte)) + { + product.register.sbyte_0 = (sbyte)(value.register.sbyte_0 * (sbyte)(object)factor); + product.register.sbyte_1 = (sbyte)(value.register.sbyte_1 * (sbyte)(object)factor); + product.register.sbyte_2 = (sbyte)(value.register.sbyte_2 * (sbyte)(object)factor); + product.register.sbyte_3 = (sbyte)(value.register.sbyte_3 * (sbyte)(object)factor); + product.register.sbyte_4 = (sbyte)(value.register.sbyte_4 * (sbyte)(object)factor); + product.register.sbyte_5 = (sbyte)(value.register.sbyte_5 * (sbyte)(object)factor); + product.register.sbyte_6 = (sbyte)(value.register.sbyte_6 * (sbyte)(object)factor); + product.register.sbyte_7 = (sbyte)(value.register.sbyte_7 * (sbyte)(object)factor); + product.register.sbyte_8 = (sbyte)(value.register.sbyte_8 * (sbyte)(object)factor); + product.register.sbyte_9 = (sbyte)(value.register.sbyte_9 * (sbyte)(object)factor); + product.register.sbyte_10 = (sbyte)(value.register.sbyte_10 * (sbyte)(object)factor); + product.register.sbyte_11 = (sbyte)(value.register.sbyte_11 * (sbyte)(object)factor); + product.register.sbyte_12 = (sbyte)(value.register.sbyte_12 * (sbyte)(object)factor); + product.register.sbyte_13 = (sbyte)(value.register.sbyte_13 * (sbyte)(object)factor); + product.register.sbyte_14 = (sbyte)(value.register.sbyte_14 * (sbyte)(object)factor); + product.register.sbyte_15 = (sbyte)(value.register.sbyte_15 * (sbyte)(object)factor); + } + else if (typeof(T) == typeof(ushort)) + { + product.register.uint16_0 = (ushort)(value.register.uint16_0 * (ushort)(object)factor); + product.register.uint16_1 = (ushort)(value.register.uint16_1 * (ushort)(object)factor); + product.register.uint16_2 = (ushort)(value.register.uint16_2 * (ushort)(object)factor); + product.register.uint16_3 = (ushort)(value.register.uint16_3 * (ushort)(object)factor); + product.register.uint16_4 = (ushort)(value.register.uint16_4 * (ushort)(object)factor); + product.register.uint16_5 = (ushort)(value.register.uint16_5 * (ushort)(object)factor); + product.register.uint16_6 = (ushort)(value.register.uint16_6 * (ushort)(object)factor); + product.register.uint16_7 = (ushort)(value.register.uint16_7 * (ushort)(object)factor); + } + else if (typeof(T) == typeof(short)) + { + product.register.int16_0 = (short)(value.register.int16_0 * (short)(object)factor); + product.register.int16_1 = (short)(value.register.int16_1 * (short)(object)factor); + product.register.int16_2 = (short)(value.register.int16_2 * (short)(object)factor); + product.register.int16_3 = (short)(value.register.int16_3 * (short)(object)factor); + product.register.int16_4 = (short)(value.register.int16_4 * (short)(object)factor); + product.register.int16_5 = (short)(value.register.int16_5 * (short)(object)factor); + product.register.int16_6 = (short)(value.register.int16_6 * (short)(object)factor); + product.register.int16_7 = (short)(value.register.int16_7 * (short)(object)factor); + } + else if (typeof(T) == typeof(uint)) + { + product.register.uint32_0 = (uint)(value.register.uint32_0 * (uint)(object)factor); + product.register.uint32_1 = (uint)(value.register.uint32_1 * (uint)(object)factor); + product.register.uint32_2 = (uint)(value.register.uint32_2 * (uint)(object)factor); + product.register.uint32_3 = (uint)(value.register.uint32_3 * (uint)(object)factor); + } + else if (typeof(T) == typeof(int)) + { + product.register.int32_0 = (int)(value.register.int32_0 * (int)(object)factor); + product.register.int32_1 = (int)(value.register.int32_1 * (int)(object)factor); + product.register.int32_2 = (int)(value.register.int32_2 * (int)(object)factor); + product.register.int32_3 = (int)(value.register.int32_3 * (int)(object)factor); + } + else if (typeof(T) == typeof(ulong)) + { + product.register.uint64_0 = (ulong)(value.register.uint64_0 * (ulong)(object)factor); + product.register.uint64_1 = (ulong)(value.register.uint64_1 * (ulong)(object)factor); + } + else if (typeof(T) == typeof(long)) + { + product.register.int64_0 = (long)(value.register.int64_0 * (long)(object)factor); + product.register.int64_1 = (long)(value.register.int64_1 * (long)(object)factor); + } + else if (typeof(T) == typeof(float)) + { + product.register.single_0 = (float)(value.register.single_0 * (float)(object)factor); + product.register.single_1 = (float)(value.register.single_1 * (float)(object)factor); + product.register.single_2 = (float)(value.register.single_2 * (float)(object)factor); + product.register.single_3 = (float)(value.register.single_3 * (float)(object)factor); + } + else if (typeof(T) == typeof(double)) + { + product.register.double_0 = (double)(value.register.double_0 * (double)(object)factor); + product.register.double_1 = (double)(value.register.double_1 * (double)(object)factor); } return product; } @@ -2470,93 +2470,93 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Byte)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (byte)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (SByte)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (sbyte)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt16)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (ushort)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int16)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (short)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt32)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (uint)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int32)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (int)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (UInt64)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (ulong)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int64)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (long)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Single)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (float)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Double)(object)ScalarDivide(left[g], right[g]); + dataPtr[g] = (double)(object)ScalarDivide(left[g], right[g]); } return new Vector(dataPtr); } @@ -2568,101 +2568,101 @@ public string ToString(string format, IFormatProvider formatProvider) else { Vector quotient = new Vector(); - if (typeof(T) == typeof(Byte)) - { - quotient.register.byte_0 = (Byte)(left.register.byte_0 / right.register.byte_0); - quotient.register.byte_1 = (Byte)(left.register.byte_1 / right.register.byte_1); - quotient.register.byte_2 = (Byte)(left.register.byte_2 / right.register.byte_2); - quotient.register.byte_3 = (Byte)(left.register.byte_3 / right.register.byte_3); - quotient.register.byte_4 = (Byte)(left.register.byte_4 / right.register.byte_4); - quotient.register.byte_5 = (Byte)(left.register.byte_5 / right.register.byte_5); - quotient.register.byte_6 = (Byte)(left.register.byte_6 / right.register.byte_6); - quotient.register.byte_7 = (Byte)(left.register.byte_7 / right.register.byte_7); - quotient.register.byte_8 = (Byte)(left.register.byte_8 / right.register.byte_8); - quotient.register.byte_9 = (Byte)(left.register.byte_9 / right.register.byte_9); - quotient.register.byte_10 = (Byte)(left.register.byte_10 / right.register.byte_10); - quotient.register.byte_11 = (Byte)(left.register.byte_11 / right.register.byte_11); - quotient.register.byte_12 = (Byte)(left.register.byte_12 / right.register.byte_12); - quotient.register.byte_13 = (Byte)(left.register.byte_13 / right.register.byte_13); - quotient.register.byte_14 = (Byte)(left.register.byte_14 / right.register.byte_14); - quotient.register.byte_15 = (Byte)(left.register.byte_15 / right.register.byte_15); - } - else if (typeof(T) == typeof(SByte)) - { - quotient.register.sbyte_0 = (SByte)(left.register.sbyte_0 / right.register.sbyte_0); - quotient.register.sbyte_1 = (SByte)(left.register.sbyte_1 / right.register.sbyte_1); - quotient.register.sbyte_2 = (SByte)(left.register.sbyte_2 / right.register.sbyte_2); - quotient.register.sbyte_3 = (SByte)(left.register.sbyte_3 / right.register.sbyte_3); - quotient.register.sbyte_4 = (SByte)(left.register.sbyte_4 / right.register.sbyte_4); - quotient.register.sbyte_5 = (SByte)(left.register.sbyte_5 / right.register.sbyte_5); - quotient.register.sbyte_6 = (SByte)(left.register.sbyte_6 / right.register.sbyte_6); - quotient.register.sbyte_7 = (SByte)(left.register.sbyte_7 / right.register.sbyte_7); - quotient.register.sbyte_8 = (SByte)(left.register.sbyte_8 / right.register.sbyte_8); - quotient.register.sbyte_9 = (SByte)(left.register.sbyte_9 / right.register.sbyte_9); - quotient.register.sbyte_10 = (SByte)(left.register.sbyte_10 / right.register.sbyte_10); - quotient.register.sbyte_11 = (SByte)(left.register.sbyte_11 / right.register.sbyte_11); - quotient.register.sbyte_12 = (SByte)(left.register.sbyte_12 / right.register.sbyte_12); - quotient.register.sbyte_13 = (SByte)(left.register.sbyte_13 / right.register.sbyte_13); - quotient.register.sbyte_14 = (SByte)(left.register.sbyte_14 / right.register.sbyte_14); - quotient.register.sbyte_15 = (SByte)(left.register.sbyte_15 / right.register.sbyte_15); - } - else if (typeof(T) == typeof(UInt16)) - { - quotient.register.uint16_0 = (UInt16)(left.register.uint16_0 / right.register.uint16_0); - quotient.register.uint16_1 = (UInt16)(left.register.uint16_1 / right.register.uint16_1); - quotient.register.uint16_2 = (UInt16)(left.register.uint16_2 / right.register.uint16_2); - quotient.register.uint16_3 = (UInt16)(left.register.uint16_3 / right.register.uint16_3); - quotient.register.uint16_4 = (UInt16)(left.register.uint16_4 / right.register.uint16_4); - quotient.register.uint16_5 = (UInt16)(left.register.uint16_5 / right.register.uint16_5); - quotient.register.uint16_6 = (UInt16)(left.register.uint16_6 / right.register.uint16_6); - quotient.register.uint16_7 = (UInt16)(left.register.uint16_7 / right.register.uint16_7); - } - else if (typeof(T) == typeof(Int16)) - { - quotient.register.int16_0 = (Int16)(left.register.int16_0 / right.register.int16_0); - quotient.register.int16_1 = (Int16)(left.register.int16_1 / right.register.int16_1); - quotient.register.int16_2 = (Int16)(left.register.int16_2 / right.register.int16_2); - quotient.register.int16_3 = (Int16)(left.register.int16_3 / right.register.int16_3); - quotient.register.int16_4 = (Int16)(left.register.int16_4 / right.register.int16_4); - quotient.register.int16_5 = (Int16)(left.register.int16_5 / right.register.int16_5); - quotient.register.int16_6 = (Int16)(left.register.int16_6 / right.register.int16_6); - quotient.register.int16_7 = (Int16)(left.register.int16_7 / right.register.int16_7); - } - else if (typeof(T) == typeof(UInt32)) - { - quotient.register.uint32_0 = (UInt32)(left.register.uint32_0 / right.register.uint32_0); - quotient.register.uint32_1 = (UInt32)(left.register.uint32_1 / right.register.uint32_1); - quotient.register.uint32_2 = (UInt32)(left.register.uint32_2 / right.register.uint32_2); - quotient.register.uint32_3 = (UInt32)(left.register.uint32_3 / right.register.uint32_3); - } - else if (typeof(T) == typeof(Int32)) - { - quotient.register.int32_0 = (Int32)(left.register.int32_0 / right.register.int32_0); - quotient.register.int32_1 = (Int32)(left.register.int32_1 / right.register.int32_1); - quotient.register.int32_2 = (Int32)(left.register.int32_2 / right.register.int32_2); - quotient.register.int32_3 = (Int32)(left.register.int32_3 / right.register.int32_3); - } - else if (typeof(T) == typeof(UInt64)) - { - quotient.register.uint64_0 = (UInt64)(left.register.uint64_0 / right.register.uint64_0); - quotient.register.uint64_1 = (UInt64)(left.register.uint64_1 / right.register.uint64_1); - } - else if (typeof(T) == typeof(Int64)) - { - quotient.register.int64_0 = (Int64)(left.register.int64_0 / right.register.int64_0); - quotient.register.int64_1 = (Int64)(left.register.int64_1 / right.register.int64_1); - } - else if (typeof(T) == typeof(Single)) - { - quotient.register.single_0 = (Single)(left.register.single_0 / right.register.single_0); - quotient.register.single_1 = (Single)(left.register.single_1 / right.register.single_1); - quotient.register.single_2 = (Single)(left.register.single_2 / right.register.single_2); - quotient.register.single_3 = (Single)(left.register.single_3 / right.register.single_3); - } - else if (typeof(T) == typeof(Double)) - { - quotient.register.double_0 = (Double)(left.register.double_0 / right.register.double_0); - quotient.register.double_1 = (Double)(left.register.double_1 / right.register.double_1); + if (typeof(T) == typeof(byte)) + { + quotient.register.byte_0 = (byte)(left.register.byte_0 / right.register.byte_0); + quotient.register.byte_1 = (byte)(left.register.byte_1 / right.register.byte_1); + quotient.register.byte_2 = (byte)(left.register.byte_2 / right.register.byte_2); + quotient.register.byte_3 = (byte)(left.register.byte_3 / right.register.byte_3); + quotient.register.byte_4 = (byte)(left.register.byte_4 / right.register.byte_4); + quotient.register.byte_5 = (byte)(left.register.byte_5 / right.register.byte_5); + quotient.register.byte_6 = (byte)(left.register.byte_6 / right.register.byte_6); + quotient.register.byte_7 = (byte)(left.register.byte_7 / right.register.byte_7); + quotient.register.byte_8 = (byte)(left.register.byte_8 / right.register.byte_8); + quotient.register.byte_9 = (byte)(left.register.byte_9 / right.register.byte_9); + quotient.register.byte_10 = (byte)(left.register.byte_10 / right.register.byte_10); + quotient.register.byte_11 = (byte)(left.register.byte_11 / right.register.byte_11); + quotient.register.byte_12 = (byte)(left.register.byte_12 / right.register.byte_12); + quotient.register.byte_13 = (byte)(left.register.byte_13 / right.register.byte_13); + quotient.register.byte_14 = (byte)(left.register.byte_14 / right.register.byte_14); + quotient.register.byte_15 = (byte)(left.register.byte_15 / right.register.byte_15); + } + else if (typeof(T) == typeof(sbyte)) + { + quotient.register.sbyte_0 = (sbyte)(left.register.sbyte_0 / right.register.sbyte_0); + quotient.register.sbyte_1 = (sbyte)(left.register.sbyte_1 / right.register.sbyte_1); + quotient.register.sbyte_2 = (sbyte)(left.register.sbyte_2 / right.register.sbyte_2); + quotient.register.sbyte_3 = (sbyte)(left.register.sbyte_3 / right.register.sbyte_3); + quotient.register.sbyte_4 = (sbyte)(left.register.sbyte_4 / right.register.sbyte_4); + quotient.register.sbyte_5 = (sbyte)(left.register.sbyte_5 / right.register.sbyte_5); + quotient.register.sbyte_6 = (sbyte)(left.register.sbyte_6 / right.register.sbyte_6); + quotient.register.sbyte_7 = (sbyte)(left.register.sbyte_7 / right.register.sbyte_7); + quotient.register.sbyte_8 = (sbyte)(left.register.sbyte_8 / right.register.sbyte_8); + quotient.register.sbyte_9 = (sbyte)(left.register.sbyte_9 / right.register.sbyte_9); + quotient.register.sbyte_10 = (sbyte)(left.register.sbyte_10 / right.register.sbyte_10); + quotient.register.sbyte_11 = (sbyte)(left.register.sbyte_11 / right.register.sbyte_11); + quotient.register.sbyte_12 = (sbyte)(left.register.sbyte_12 / right.register.sbyte_12); + quotient.register.sbyte_13 = (sbyte)(left.register.sbyte_13 / right.register.sbyte_13); + quotient.register.sbyte_14 = (sbyte)(left.register.sbyte_14 / right.register.sbyte_14); + quotient.register.sbyte_15 = (sbyte)(left.register.sbyte_15 / right.register.sbyte_15); + } + else if (typeof(T) == typeof(ushort)) + { + quotient.register.uint16_0 = (ushort)(left.register.uint16_0 / right.register.uint16_0); + quotient.register.uint16_1 = (ushort)(left.register.uint16_1 / right.register.uint16_1); + quotient.register.uint16_2 = (ushort)(left.register.uint16_2 / right.register.uint16_2); + quotient.register.uint16_3 = (ushort)(left.register.uint16_3 / right.register.uint16_3); + quotient.register.uint16_4 = (ushort)(left.register.uint16_4 / right.register.uint16_4); + quotient.register.uint16_5 = (ushort)(left.register.uint16_5 / right.register.uint16_5); + quotient.register.uint16_6 = (ushort)(left.register.uint16_6 / right.register.uint16_6); + quotient.register.uint16_7 = (ushort)(left.register.uint16_7 / right.register.uint16_7); + } + else if (typeof(T) == typeof(short)) + { + quotient.register.int16_0 = (short)(left.register.int16_0 / right.register.int16_0); + quotient.register.int16_1 = (short)(left.register.int16_1 / right.register.int16_1); + quotient.register.int16_2 = (short)(left.register.int16_2 / right.register.int16_2); + quotient.register.int16_3 = (short)(left.register.int16_3 / right.register.int16_3); + quotient.register.int16_4 = (short)(left.register.int16_4 / right.register.int16_4); + quotient.register.int16_5 = (short)(left.register.int16_5 / right.register.int16_5); + quotient.register.int16_6 = (short)(left.register.int16_6 / right.register.int16_6); + quotient.register.int16_7 = (short)(left.register.int16_7 / right.register.int16_7); + } + else if (typeof(T) == typeof(uint)) + { + quotient.register.uint32_0 = (uint)(left.register.uint32_0 / right.register.uint32_0); + quotient.register.uint32_1 = (uint)(left.register.uint32_1 / right.register.uint32_1); + quotient.register.uint32_2 = (uint)(left.register.uint32_2 / right.register.uint32_2); + quotient.register.uint32_3 = (uint)(left.register.uint32_3 / right.register.uint32_3); + } + else if (typeof(T) == typeof(int)) + { + quotient.register.int32_0 = (int)(left.register.int32_0 / right.register.int32_0); + quotient.register.int32_1 = (int)(left.register.int32_1 / right.register.int32_1); + quotient.register.int32_2 = (int)(left.register.int32_2 / right.register.int32_2); + quotient.register.int32_3 = (int)(left.register.int32_3 / right.register.int32_3); + } + else if (typeof(T) == typeof(ulong)) + { + quotient.register.uint64_0 = (ulong)(left.register.uint64_0 / right.register.uint64_0); + quotient.register.uint64_1 = (ulong)(left.register.uint64_1 / right.register.uint64_1); + } + else if (typeof(T) == typeof(long)) + { + quotient.register.int64_0 = (long)(left.register.int64_0 / right.register.int64_0); + quotient.register.int64_1 = (long)(left.register.int64_1 / right.register.int64_1); + } + else if (typeof(T) == typeof(float)) + { + quotient.register.single_0 = (float)(left.register.single_0 / right.register.single_0); + quotient.register.single_1 = (float)(left.register.single_1 / right.register.single_1); + quotient.register.single_2 = (float)(left.register.single_2 / right.register.single_2); + quotient.register.single_3 = (float)(left.register.single_3 / right.register.single_3); + } + else if (typeof(T) == typeof(double)) + { + quotient.register.double_0 = (double)(left.register.double_0 / right.register.double_0); + quotient.register.double_1 = (double)(left.register.double_1 / right.register.double_1); } return quotient; } @@ -2695,10 +2695,10 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - Int64* resultBase = &result.register.int64_0; - Int64* leftBase = &left.register.int64_0; - Int64* rightBase = &right.register.int64_0; - for (int g = 0; g < Vector.Count; g++) + long* resultBase = &result.register.int64_0; + long* leftBase = &left.register.int64_0; + long* rightBase = &right.register.int64_0; + for (int g = 0; g < Vector.Count; g++) { resultBase[g] = leftBase[g] & rightBase[g]; } @@ -2726,10 +2726,10 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - Int64* resultBase = &result.register.int64_0; - Int64* leftBase = &left.register.int64_0; - Int64* rightBase = &right.register.int64_0; - for (int g = 0; g < Vector.Count; g++) + long* resultBase = &result.register.int64_0; + long* leftBase = &left.register.int64_0; + long* rightBase = &right.register.int64_0; + for (int g = 0; g < Vector.Count; g++) { resultBase[g] = leftBase[g] | rightBase[g]; } @@ -2757,10 +2757,10 @@ public string ToString(string format, IFormatProvider formatProvider) { if (Vector.IsHardwareAccelerated) { - Int64* resultBase = &result.register.int64_0; - Int64* leftBase = &left.register.int64_0; - Int64* rightBase = &right.register.int64_0; - for (int g = 0; g < Vector.Count; g++) + long* resultBase = &result.register.int64_0; + long* leftBase = &left.register.int64_0; + long* rightBase = &right.register.int64_0; + for (int g = 0; g < Vector.Count; g++) { resultBase[g] = leftBase[g] ^ rightBase[g]; } @@ -2819,9 +2819,9 @@ public string ToString(string format, IFormatProvider formatProvider) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2831,9 +2831,9 @@ public static explicit operator Vector(Vector value) /// The reinterpreted vector. [CLSCompliant(false)] [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2843,9 +2843,9 @@ public static explicit operator Vector(Vector value) /// The reinterpreted vector. [CLSCompliant(false)] [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2854,9 +2854,9 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2866,9 +2866,9 @@ public static explicit operator Vector(Vector value) /// The reinterpreted vector. [CLSCompliant(false)] [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2877,9 +2877,9 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2889,9 +2889,9 @@ public static explicit operator Vector(Vector value) /// The reinterpreted vector. [CLSCompliant(false)] [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2900,9 +2900,9 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2911,9 +2911,9 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } /// @@ -2922,9 +2922,9 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [Intrinsic] - public static explicit operator Vector(Vector value) + public static explicit operator Vector(Vector value) { - return new Vector(ref value.register); + return new Vector(ref value.register); } #endregion Conversions @@ -2936,93 +2936,93 @@ internal static unsafe Vector Equals(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + dataPtr[g] = ScalarEquals(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; } return new Vector(dataPtr); } @@ -3034,110 +3034,110 @@ internal static unsafe Vector Equals(Vector left, Vector right) else { Register register = new Register(); - if (typeof(T) == typeof(Byte)) - { - register.byte_0 = left.register.byte_0 == right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_1 = left.register.byte_1 == right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_2 = left.register.byte_2 == right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_3 = left.register.byte_3 == right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_4 = left.register.byte_4 == right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_5 = left.register.byte_5 == right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_6 = left.register.byte_6 == right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_7 = left.register.byte_7 == right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_8 = left.register.byte_8 == right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_9 = left.register.byte_9 == right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_10 = left.register.byte_10 == right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_11 = left.register.byte_11 == right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_12 = left.register.byte_12 == right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_13 = left.register.byte_13 == right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_14 = left.register.byte_14 == right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_15 = left.register.byte_15 == right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + if (typeof(T) == typeof(byte)) + { + register.byte_0 = left.register.byte_0 == right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_1 = left.register.byte_1 == right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_2 = left.register.byte_2 == right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_3 = left.register.byte_3 == right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_4 = left.register.byte_4 == right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_5 = left.register.byte_5 == right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_6 = left.register.byte_6 == right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_7 = left.register.byte_7 == right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_8 = left.register.byte_8 == right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_9 = left.register.byte_9 == right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_10 = left.register.byte_10 == right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_11 = left.register.byte_11 == right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_12 = left.register.byte_12 == right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_13 = left.register.byte_13 == right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_14 = left.register.byte_14 == right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_15 = left.register.byte_15 == right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(SByte)) - { - register.sbyte_0 = left.register.sbyte_0 == right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_1 = left.register.sbyte_1 == right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_2 = left.register.sbyte_2 == right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_3 = left.register.sbyte_3 == right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_4 = left.register.sbyte_4 == right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_5 = left.register.sbyte_5 == right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_6 = left.register.sbyte_6 == right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_7 = left.register.sbyte_7 == right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_8 = left.register.sbyte_8 == right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_9 = left.register.sbyte_9 == right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_10 = left.register.sbyte_10 == right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_11 = left.register.sbyte_11 == right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_12 = left.register.sbyte_12 == right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_13 = left.register.sbyte_13 == right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_14 = left.register.sbyte_14 == right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_15 = left.register.sbyte_15 == right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + else if (typeof(T) == typeof(sbyte)) + { + register.sbyte_0 = left.register.sbyte_0 == right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_1 = left.register.sbyte_1 == right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_2 = left.register.sbyte_2 == right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_3 = left.register.sbyte_3 == right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_4 = left.register.sbyte_4 == right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_5 = left.register.sbyte_5 == right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_6 = left.register.sbyte_6 == right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_7 = left.register.sbyte_7 == right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_8 = left.register.sbyte_8 == right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_9 = left.register.sbyte_9 == right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_10 = left.register.sbyte_10 == right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_11 = left.register.sbyte_11 == right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_12 = left.register.sbyte_12 == right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_13 = left.register.sbyte_13 == right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_14 = left.register.sbyte_14 == right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_15 = left.register.sbyte_15 == right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - register.uint16_0 = left.register.uint16_0 == right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_1 = left.register.uint16_1 == right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_2 = left.register.uint16_2 == right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_3 = left.register.uint16_3 == right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_4 = left.register.uint16_4 == right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_5 = left.register.uint16_5 == right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_6 = left.register.uint16_6 == right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_7 = left.register.uint16_7 == right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + register.uint16_0 = left.register.uint16_0 == right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_1 = left.register.uint16_1 == right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_2 = left.register.uint16_2 == right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_3 = left.register.uint16_3 == right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_4 = left.register.uint16_4 == right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_5 = left.register.uint16_5 == right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_6 = left.register.uint16_6 == right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_7 = left.register.uint16_7 == right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - register.int16_0 = left.register.int16_0 == right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_1 = left.register.int16_1 == right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_2 = left.register.int16_2 == right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_3 = left.register.int16_3 == right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_4 = left.register.int16_4 == right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_5 = left.register.int16_5 == right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_6 = left.register.int16_6 == right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_7 = left.register.int16_7 == right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + register.int16_0 = left.register.int16_0 == right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_1 = left.register.int16_1 == right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_2 = left.register.int16_2 == right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_3 = left.register.int16_3 == right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_4 = left.register.int16_4 == right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_5 = left.register.int16_5 == right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_6 = left.register.int16_6 == right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_7 = left.register.int16_7 == right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - register.uint32_0 = left.register.uint32_0 == right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_1 = left.register.uint32_1 == right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_2 = left.register.uint32_2 == right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_3 = left.register.uint32_3 == right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + register.uint32_0 = left.register.uint32_0 == right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_1 = left.register.uint32_1 == right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_2 = left.register.uint32_2 == right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_3 = left.register.uint32_3 == right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - register.int32_0 = left.register.int32_0 == right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_1 = left.register.int32_1 == right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_2 = left.register.int32_2 == right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_3 = left.register.int32_3 == right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + register.int32_0 = left.register.int32_0 == right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_1 = left.register.int32_1 == right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_2 = left.register.int32_2 == right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_3 = left.register.int32_3 == right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - register.uint64_0 = left.register.uint64_0 == right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; - register.uint64_1 = left.register.uint64_1 == right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + register.uint64_0 = left.register.uint64_0 == right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; + register.uint64_1 = left.register.uint64_1 == right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - register.int64_0 = left.register.int64_0 == right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; - register.int64_1 = left.register.int64_1 == right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + register.int64_0 = left.register.int64_0 == right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; + register.int64_1 = left.register.int64_1 == right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - register.single_0 = left.register.single_0 == right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_1 = left.register.single_1 == right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_2 = left.register.single_2 == right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_3 = left.register.single_3 == right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + register.single_0 = left.register.single_0 == right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_1 = left.register.single_1 == right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_2 = left.register.single_2 == right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_3 = left.register.single_3 == right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - register.double_0 = left.register.double_0 == right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; - register.double_1 = left.register.double_1 == right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + register.double_0 = left.register.double_0 == right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; + register.double_1 = left.register.double_1 == right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; return new Vector(ref register); } else @@ -3153,93 +3153,93 @@ internal static unsafe Vector LessThan(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; } return new Vector(dataPtr); } @@ -3251,110 +3251,110 @@ internal static unsafe Vector LessThan(Vector left, Vector right) else { Register register = new Register(); - if (typeof(T) == typeof(Byte)) - { - register.byte_0 = left.register.byte_0 < right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_1 = left.register.byte_1 < right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_2 = left.register.byte_2 < right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_3 = left.register.byte_3 < right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_4 = left.register.byte_4 < right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_5 = left.register.byte_5 < right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_6 = left.register.byte_6 < right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_7 = left.register.byte_7 < right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_8 = left.register.byte_8 < right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_9 = left.register.byte_9 < right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_10 = left.register.byte_10 < right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_11 = left.register.byte_11 < right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_12 = left.register.byte_12 < right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_13 = left.register.byte_13 < right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_14 = left.register.byte_14 < right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_15 = left.register.byte_15 < right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + if (typeof(T) == typeof(byte)) + { + register.byte_0 = left.register.byte_0 < right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_1 = left.register.byte_1 < right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_2 = left.register.byte_2 < right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_3 = left.register.byte_3 < right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_4 = left.register.byte_4 < right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_5 = left.register.byte_5 < right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_6 = left.register.byte_6 < right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_7 = left.register.byte_7 < right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_8 = left.register.byte_8 < right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_9 = left.register.byte_9 < right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_10 = left.register.byte_10 < right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_11 = left.register.byte_11 < right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_12 = left.register.byte_12 < right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_13 = left.register.byte_13 < right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_14 = left.register.byte_14 < right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_15 = left.register.byte_15 < right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(SByte)) - { - register.sbyte_0 = left.register.sbyte_0 < right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_1 = left.register.sbyte_1 < right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_2 = left.register.sbyte_2 < right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_3 = left.register.sbyte_3 < right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_4 = left.register.sbyte_4 < right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_5 = left.register.sbyte_5 < right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_6 = left.register.sbyte_6 < right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_7 = left.register.sbyte_7 < right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_8 = left.register.sbyte_8 < right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_9 = left.register.sbyte_9 < right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_10 = left.register.sbyte_10 < right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_11 = left.register.sbyte_11 < right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_12 = left.register.sbyte_12 < right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_13 = left.register.sbyte_13 < right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_14 = left.register.sbyte_14 < right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_15 = left.register.sbyte_15 < right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + else if (typeof(T) == typeof(sbyte)) + { + register.sbyte_0 = left.register.sbyte_0 < right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_1 = left.register.sbyte_1 < right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_2 = left.register.sbyte_2 < right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_3 = left.register.sbyte_3 < right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_4 = left.register.sbyte_4 < right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_5 = left.register.sbyte_5 < right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_6 = left.register.sbyte_6 < right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_7 = left.register.sbyte_7 < right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_8 = left.register.sbyte_8 < right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_9 = left.register.sbyte_9 < right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_10 = left.register.sbyte_10 < right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_11 = left.register.sbyte_11 < right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_12 = left.register.sbyte_12 < right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_13 = left.register.sbyte_13 < right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_14 = left.register.sbyte_14 < right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_15 = left.register.sbyte_15 < right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - register.uint16_0 = left.register.uint16_0 < right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_1 = left.register.uint16_1 < right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_2 = left.register.uint16_2 < right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_3 = left.register.uint16_3 < right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_4 = left.register.uint16_4 < right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_5 = left.register.uint16_5 < right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_6 = left.register.uint16_6 < right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_7 = left.register.uint16_7 < right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + register.uint16_0 = left.register.uint16_0 < right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_1 = left.register.uint16_1 < right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_2 = left.register.uint16_2 < right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_3 = left.register.uint16_3 < right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_4 = left.register.uint16_4 < right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_5 = left.register.uint16_5 < right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_6 = left.register.uint16_6 < right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_7 = left.register.uint16_7 < right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - register.int16_0 = left.register.int16_0 < right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_1 = left.register.int16_1 < right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_2 = left.register.int16_2 < right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_3 = left.register.int16_3 < right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_4 = left.register.int16_4 < right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_5 = left.register.int16_5 < right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_6 = left.register.int16_6 < right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_7 = left.register.int16_7 < right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + register.int16_0 = left.register.int16_0 < right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_1 = left.register.int16_1 < right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_2 = left.register.int16_2 < right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_3 = left.register.int16_3 < right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_4 = left.register.int16_4 < right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_5 = left.register.int16_5 < right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_6 = left.register.int16_6 < right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_7 = left.register.int16_7 < right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - register.uint32_0 = left.register.uint32_0 < right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_1 = left.register.uint32_1 < right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_2 = left.register.uint32_2 < right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_3 = left.register.uint32_3 < right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + register.uint32_0 = left.register.uint32_0 < right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_1 = left.register.uint32_1 < right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_2 = left.register.uint32_2 < right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_3 = left.register.uint32_3 < right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - register.int32_0 = left.register.int32_0 < right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_1 = left.register.int32_1 < right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_2 = left.register.int32_2 < right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_3 = left.register.int32_3 < right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + register.int32_0 = left.register.int32_0 < right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_1 = left.register.int32_1 < right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_2 = left.register.int32_2 < right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_3 = left.register.int32_3 < right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - register.uint64_0 = left.register.uint64_0 < right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; - register.uint64_1 = left.register.uint64_1 < right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + register.uint64_0 = left.register.uint64_0 < right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; + register.uint64_1 = left.register.uint64_1 < right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - register.int64_0 = left.register.int64_0 < right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; - register.int64_1 = left.register.int64_1 < right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + register.int64_0 = left.register.int64_0 < right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; + register.int64_1 = left.register.int64_1 < right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - register.single_0 = left.register.single_0 < right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_1 = left.register.single_1 < right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_2 = left.register.single_2 < right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_3 = left.register.single_3 < right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + register.single_0 = left.register.single_0 < right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_1 = left.register.single_1 < right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_2 = left.register.single_2 < right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_3 = left.register.single_3 < right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - register.double_0 = left.register.double_0 < right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; - register.double_1 = left.register.double_1 < right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + register.double_0 = left.register.double_0 < right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; + register.double_1 = left.register.double_1 < right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; return new Vector(ref register); } else @@ -3370,93 +3370,93 @@ internal static unsafe Vector GreaterThan(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; } return new Vector(dataPtr); } @@ -3468,110 +3468,110 @@ internal static unsafe Vector GreaterThan(Vector left, Vector right) else { Register register = new Register(); - if (typeof(T) == typeof(Byte)) - { - register.byte_0 = left.register.byte_0 > right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_1 = left.register.byte_1 > right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_2 = left.register.byte_2 > right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_3 = left.register.byte_3 > right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_4 = left.register.byte_4 > right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_5 = left.register.byte_5 > right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_6 = left.register.byte_6 > right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_7 = left.register.byte_7 > right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_8 = left.register.byte_8 > right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_9 = left.register.byte_9 > right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_10 = left.register.byte_10 > right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_11 = left.register.byte_11 > right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_12 = left.register.byte_12 > right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_13 = left.register.byte_13 > right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_14 = left.register.byte_14 > right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; - register.byte_15 = left.register.byte_15 > right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (Byte)0; + if (typeof(T) == typeof(byte)) + { + register.byte_0 = left.register.byte_0 > right.register.byte_0 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_1 = left.register.byte_1 > right.register.byte_1 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_2 = left.register.byte_2 > right.register.byte_2 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_3 = left.register.byte_3 > right.register.byte_3 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_4 = left.register.byte_4 > right.register.byte_4 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_5 = left.register.byte_5 > right.register.byte_5 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_6 = left.register.byte_6 > right.register.byte_6 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_7 = left.register.byte_7 > right.register.byte_7 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_8 = left.register.byte_8 > right.register.byte_8 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_9 = left.register.byte_9 > right.register.byte_9 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_10 = left.register.byte_10 > right.register.byte_10 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_11 = left.register.byte_11 > right.register.byte_11 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_12 = left.register.byte_12 > right.register.byte_12 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_13 = left.register.byte_13 > right.register.byte_13 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_14 = left.register.byte_14 > right.register.byte_14 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; + register.byte_15 = left.register.byte_15 > right.register.byte_15 ? ConstantHelper.GetByteWithAllBitsSet() : (byte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(SByte)) - { - register.sbyte_0 = left.register.sbyte_0 > right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_1 = left.register.sbyte_1 > right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_2 = left.register.sbyte_2 > right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_3 = left.register.sbyte_3 > right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_4 = left.register.sbyte_4 > right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_5 = left.register.sbyte_5 > right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_6 = left.register.sbyte_6 > right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_7 = left.register.sbyte_7 > right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_8 = left.register.sbyte_8 > right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_9 = left.register.sbyte_9 > right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_10 = left.register.sbyte_10 > right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_11 = left.register.sbyte_11 > right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_12 = left.register.sbyte_12 > right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_13 = left.register.sbyte_13 > right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_14 = left.register.sbyte_14 > right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; - register.sbyte_15 = left.register.sbyte_15 > right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (SByte)0; + else if (typeof(T) == typeof(sbyte)) + { + register.sbyte_0 = left.register.sbyte_0 > right.register.sbyte_0 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_1 = left.register.sbyte_1 > right.register.sbyte_1 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_2 = left.register.sbyte_2 > right.register.sbyte_2 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_3 = left.register.sbyte_3 > right.register.sbyte_3 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_4 = left.register.sbyte_4 > right.register.sbyte_4 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_5 = left.register.sbyte_5 > right.register.sbyte_5 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_6 = left.register.sbyte_6 > right.register.sbyte_6 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_7 = left.register.sbyte_7 > right.register.sbyte_7 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_8 = left.register.sbyte_8 > right.register.sbyte_8 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_9 = left.register.sbyte_9 > right.register.sbyte_9 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_10 = left.register.sbyte_10 > right.register.sbyte_10 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_11 = left.register.sbyte_11 > right.register.sbyte_11 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_12 = left.register.sbyte_12 > right.register.sbyte_12 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_13 = left.register.sbyte_13 > right.register.sbyte_13 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_14 = left.register.sbyte_14 > right.register.sbyte_14 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; + register.sbyte_15 = left.register.sbyte_15 > right.register.sbyte_15 ? ConstantHelper.GetSByteWithAllBitsSet() : (sbyte)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - register.uint16_0 = left.register.uint16_0 > right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_1 = left.register.uint16_1 > right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_2 = left.register.uint16_2 > right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_3 = left.register.uint16_3 > right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_4 = left.register.uint16_4 > right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_5 = left.register.uint16_5 > right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_6 = left.register.uint16_6 > right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; - register.uint16_7 = left.register.uint16_7 > right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (UInt16)0; + register.uint16_0 = left.register.uint16_0 > right.register.uint16_0 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_1 = left.register.uint16_1 > right.register.uint16_1 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_2 = left.register.uint16_2 > right.register.uint16_2 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_3 = left.register.uint16_3 > right.register.uint16_3 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_4 = left.register.uint16_4 > right.register.uint16_4 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_5 = left.register.uint16_5 > right.register.uint16_5 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_6 = left.register.uint16_6 > right.register.uint16_6 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; + register.uint16_7 = left.register.uint16_7 > right.register.uint16_7 ? ConstantHelper.GetUInt16WithAllBitsSet() : (ushort)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - register.int16_0 = left.register.int16_0 > right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_1 = left.register.int16_1 > right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_2 = left.register.int16_2 > right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_3 = left.register.int16_3 > right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_4 = left.register.int16_4 > right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_5 = left.register.int16_5 > right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_6 = left.register.int16_6 > right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; - register.int16_7 = left.register.int16_7 > right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (Int16)0; + register.int16_0 = left.register.int16_0 > right.register.int16_0 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_1 = left.register.int16_1 > right.register.int16_1 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_2 = left.register.int16_2 > right.register.int16_2 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_3 = left.register.int16_3 > right.register.int16_3 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_4 = left.register.int16_4 > right.register.int16_4 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_5 = left.register.int16_5 > right.register.int16_5 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_6 = left.register.int16_6 > right.register.int16_6 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; + register.int16_7 = left.register.int16_7 > right.register.int16_7 ? ConstantHelper.GetInt16WithAllBitsSet() : (short)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - register.uint32_0 = left.register.uint32_0 > right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_1 = left.register.uint32_1 > right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_2 = left.register.uint32_2 > right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; - register.uint32_3 = left.register.uint32_3 > right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (UInt32)0; + register.uint32_0 = left.register.uint32_0 > right.register.uint32_0 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_1 = left.register.uint32_1 > right.register.uint32_1 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_2 = left.register.uint32_2 > right.register.uint32_2 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; + register.uint32_3 = left.register.uint32_3 > right.register.uint32_3 ? ConstantHelper.GetUInt32WithAllBitsSet() : (uint)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - register.int32_0 = left.register.int32_0 > right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_1 = left.register.int32_1 > right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_2 = left.register.int32_2 > right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; - register.int32_3 = left.register.int32_3 > right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (Int32)0; + register.int32_0 = left.register.int32_0 > right.register.int32_0 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_1 = left.register.int32_1 > right.register.int32_1 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_2 = left.register.int32_2 > right.register.int32_2 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; + register.int32_3 = left.register.int32_3 > right.register.int32_3 ? ConstantHelper.GetInt32WithAllBitsSet() : (int)0; return new Vector(ref register); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - register.uint64_0 = left.register.uint64_0 > right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; - register.uint64_1 = left.register.uint64_1 > right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (UInt64)0; + register.uint64_0 = left.register.uint64_0 > right.register.uint64_0 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; + register.uint64_1 = left.register.uint64_1 > right.register.uint64_1 ? ConstantHelper.GetUInt64WithAllBitsSet() : (ulong)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - register.int64_0 = left.register.int64_0 > right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; - register.int64_1 = left.register.int64_1 > right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (Int64)0; + register.int64_0 = left.register.int64_0 > right.register.int64_0 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; + register.int64_1 = left.register.int64_1 > right.register.int64_1 ? ConstantHelper.GetInt64WithAllBitsSet() : (long)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - register.single_0 = left.register.single_0 > right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_1 = left.register.single_1 > right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_2 = left.register.single_2 > right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; - register.single_3 = left.register.single_3 > right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (Single)0; + register.single_0 = left.register.single_0 > right.register.single_0 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_1 = left.register.single_1 > right.register.single_1 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_2 = left.register.single_2 > right.register.single_2 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; + register.single_3 = left.register.single_3 > right.register.single_3 ? ConstantHelper.GetSingleWithAllBitsSet() : (float)0; return new Vector(ref register); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - register.double_0 = left.register.double_0 > right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; - register.double_1 = left.register.double_1 > right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (Double)0; + register.double_0 = left.register.double_0 > right.register.double_0 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; + register.double_1 = left.register.double_1 > right.register.double_1 ? ConstantHelper.GetDoubleWithAllBitsSet() : (double)0; return new Vector(ref register); } else @@ -3604,75 +3604,75 @@ internal static Vector ConditionalSelect(Vector condition, Vector left, [Intrinsic] internal static unsafe Vector Abs(Vector value) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { return value; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { return value; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { return value; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { return value; } if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(SByte)) + if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (SByte)(object)(Math.Abs((SByte)(object)value[g])); + dataPtr[g] = (sbyte)(object)(Math.Abs((sbyte)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int16)(object)(Math.Abs((Int16)(object)value[g])); + dataPtr[g] = (short)(object)(Math.Abs((short)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int32)(object)(Math.Abs((Int32)(object)value[g])); + dataPtr[g] = (int)(object)(Math.Abs((int)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Int64)(object)(Math.Abs((Int64)(object)value[g])); + dataPtr[g] = (long)(object)(Math.Abs((long)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Single)(object)(Math.Abs((Single)(object)value[g])); + dataPtr[g] = (float)(object)(Math.Abs((float)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = (Double)(object)(Math.Abs((Double)(object)value[g])); + dataPtr[g] = (double)(object)(Math.Abs((double)(object)value[g])); } return new Vector(dataPtr); } @@ -3683,64 +3683,64 @@ internal static unsafe Vector Abs(Vector value) } else { - if (typeof(T) == typeof(SByte)) - { - value.register.sbyte_0 = (SByte)(Math.Abs(value.register.sbyte_0)); - value.register.sbyte_1 = (SByte)(Math.Abs(value.register.sbyte_1)); - value.register.sbyte_2 = (SByte)(Math.Abs(value.register.sbyte_2)); - value.register.sbyte_3 = (SByte)(Math.Abs(value.register.sbyte_3)); - value.register.sbyte_4 = (SByte)(Math.Abs(value.register.sbyte_4)); - value.register.sbyte_5 = (SByte)(Math.Abs(value.register.sbyte_5)); - value.register.sbyte_6 = (SByte)(Math.Abs(value.register.sbyte_6)); - value.register.sbyte_7 = (SByte)(Math.Abs(value.register.sbyte_7)); - value.register.sbyte_8 = (SByte)(Math.Abs(value.register.sbyte_8)); - value.register.sbyte_9 = (SByte)(Math.Abs(value.register.sbyte_9)); - value.register.sbyte_10 = (SByte)(Math.Abs(value.register.sbyte_10)); - value.register.sbyte_11 = (SByte)(Math.Abs(value.register.sbyte_11)); - value.register.sbyte_12 = (SByte)(Math.Abs(value.register.sbyte_12)); - value.register.sbyte_13 = (SByte)(Math.Abs(value.register.sbyte_13)); - value.register.sbyte_14 = (SByte)(Math.Abs(value.register.sbyte_14)); - value.register.sbyte_15 = (SByte)(Math.Abs(value.register.sbyte_15)); + if (typeof(T) == typeof(sbyte)) + { + value.register.sbyte_0 = (sbyte)(Math.Abs(value.register.sbyte_0)); + value.register.sbyte_1 = (sbyte)(Math.Abs(value.register.sbyte_1)); + value.register.sbyte_2 = (sbyte)(Math.Abs(value.register.sbyte_2)); + value.register.sbyte_3 = (sbyte)(Math.Abs(value.register.sbyte_3)); + value.register.sbyte_4 = (sbyte)(Math.Abs(value.register.sbyte_4)); + value.register.sbyte_5 = (sbyte)(Math.Abs(value.register.sbyte_5)); + value.register.sbyte_6 = (sbyte)(Math.Abs(value.register.sbyte_6)); + value.register.sbyte_7 = (sbyte)(Math.Abs(value.register.sbyte_7)); + value.register.sbyte_8 = (sbyte)(Math.Abs(value.register.sbyte_8)); + value.register.sbyte_9 = (sbyte)(Math.Abs(value.register.sbyte_9)); + value.register.sbyte_10 = (sbyte)(Math.Abs(value.register.sbyte_10)); + value.register.sbyte_11 = (sbyte)(Math.Abs(value.register.sbyte_11)); + value.register.sbyte_12 = (sbyte)(Math.Abs(value.register.sbyte_12)); + value.register.sbyte_13 = (sbyte)(Math.Abs(value.register.sbyte_13)); + value.register.sbyte_14 = (sbyte)(Math.Abs(value.register.sbyte_14)); + value.register.sbyte_15 = (sbyte)(Math.Abs(value.register.sbyte_15)); return value; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - value.register.int16_0 = (Int16)(Math.Abs(value.register.int16_0)); - value.register.int16_1 = (Int16)(Math.Abs(value.register.int16_1)); - value.register.int16_2 = (Int16)(Math.Abs(value.register.int16_2)); - value.register.int16_3 = (Int16)(Math.Abs(value.register.int16_3)); - value.register.int16_4 = (Int16)(Math.Abs(value.register.int16_4)); - value.register.int16_5 = (Int16)(Math.Abs(value.register.int16_5)); - value.register.int16_6 = (Int16)(Math.Abs(value.register.int16_6)); - value.register.int16_7 = (Int16)(Math.Abs(value.register.int16_7)); + value.register.int16_0 = (short)(Math.Abs(value.register.int16_0)); + value.register.int16_1 = (short)(Math.Abs(value.register.int16_1)); + value.register.int16_2 = (short)(Math.Abs(value.register.int16_2)); + value.register.int16_3 = (short)(Math.Abs(value.register.int16_3)); + value.register.int16_4 = (short)(Math.Abs(value.register.int16_4)); + value.register.int16_5 = (short)(Math.Abs(value.register.int16_5)); + value.register.int16_6 = (short)(Math.Abs(value.register.int16_6)); + value.register.int16_7 = (short)(Math.Abs(value.register.int16_7)); return value; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - value.register.int32_0 = (Int32)(Math.Abs(value.register.int32_0)); - value.register.int32_1 = (Int32)(Math.Abs(value.register.int32_1)); - value.register.int32_2 = (Int32)(Math.Abs(value.register.int32_2)); - value.register.int32_3 = (Int32)(Math.Abs(value.register.int32_3)); + value.register.int32_0 = (int)(Math.Abs(value.register.int32_0)); + value.register.int32_1 = (int)(Math.Abs(value.register.int32_1)); + value.register.int32_2 = (int)(Math.Abs(value.register.int32_2)); + value.register.int32_3 = (int)(Math.Abs(value.register.int32_3)); return value; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - value.register.int64_0 = (Int64)(Math.Abs(value.register.int64_0)); - value.register.int64_1 = (Int64)(Math.Abs(value.register.int64_1)); + value.register.int64_0 = (long)(Math.Abs(value.register.int64_0)); + value.register.int64_1 = (long)(Math.Abs(value.register.int64_1)); return value; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - value.register.single_0 = (Single)(Math.Abs(value.register.single_0)); - value.register.single_1 = (Single)(Math.Abs(value.register.single_1)); - value.register.single_2 = (Single)(Math.Abs(value.register.single_2)); - value.register.single_3 = (Single)(Math.Abs(value.register.single_3)); + value.register.single_0 = (float)(Math.Abs(value.register.single_0)); + value.register.single_1 = (float)(Math.Abs(value.register.single_1)); + value.register.single_2 = (float)(Math.Abs(value.register.single_2)); + value.register.single_3 = (float)(Math.Abs(value.register.single_3)); return value; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - value.register.double_0 = (Double)(Math.Abs(value.register.double_0)); - value.register.double_1 = (Double)(Math.Abs(value.register.double_1)); + value.register.double_0 = (double)(Math.Abs(value.register.double_0)); + value.register.double_1 = (double)(Math.Abs(value.register.double_1)); return value; } else @@ -3755,93 +3755,93 @@ internal static unsafe Vector Min(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Byte)(object)left[g] : (Byte)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (byte)(object)left[g] : (byte)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (SByte)(object)left[g] : (SByte)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (sbyte)(object)left[g] : (sbyte)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (UInt16)(object)left[g] : (UInt16)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (ushort)(object)left[g] : (ushort)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Int16)(object)left[g] : (Int16)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (short)(object)left[g] : (short)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (UInt32)(object)left[g] : (UInt32)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (uint)(object)left[g] : (uint)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Int32)(object)left[g] : (Int32)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (int)(object)left[g] : (int)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (UInt64)(object)left[g] : (UInt64)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (ulong)(object)left[g] : (ulong)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Int64)(object)left[g] : (Int64)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (long)(object)left[g] : (long)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Single)(object)left[g] : (Single)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (float)(object)left[g] : (float)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (Double)(object)left[g] : (Double)(object)right[g]; + dataPtr[g] = ScalarLessThan(left[g], right[g]) ? (double)(object)left[g] : (double)(object)right[g]; } return new Vector(dataPtr); } @@ -3853,7 +3853,7 @@ internal static unsafe Vector Min(Vector left, Vector right) else { Vector vec = new Vector(); - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { vec.register.byte_0 = left.register.byte_0 < right.register.byte_0 ? left.register.byte_0 : right.register.byte_0; vec.register.byte_1 = left.register.byte_1 < right.register.byte_1 ? left.register.byte_1 : right.register.byte_1; @@ -3873,7 +3873,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.byte_15 = left.register.byte_15 < right.register.byte_15 ? left.register.byte_15 : right.register.byte_15; return vec; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { vec.register.sbyte_0 = left.register.sbyte_0 < right.register.sbyte_0 ? left.register.sbyte_0 : right.register.sbyte_0; vec.register.sbyte_1 = left.register.sbyte_1 < right.register.sbyte_1 ? left.register.sbyte_1 : right.register.sbyte_1; @@ -3893,7 +3893,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.sbyte_15 = left.register.sbyte_15 < right.register.sbyte_15 ? left.register.sbyte_15 : right.register.sbyte_15; return vec; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { vec.register.uint16_0 = left.register.uint16_0 < right.register.uint16_0 ? left.register.uint16_0 : right.register.uint16_0; vec.register.uint16_1 = left.register.uint16_1 < right.register.uint16_1 ? left.register.uint16_1 : right.register.uint16_1; @@ -3905,7 +3905,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.uint16_7 = left.register.uint16_7 < right.register.uint16_7 ? left.register.uint16_7 : right.register.uint16_7; return vec; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { vec.register.int16_0 = left.register.int16_0 < right.register.int16_0 ? left.register.int16_0 : right.register.int16_0; vec.register.int16_1 = left.register.int16_1 < right.register.int16_1 ? left.register.int16_1 : right.register.int16_1; @@ -3917,7 +3917,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.int16_7 = left.register.int16_7 < right.register.int16_7 ? left.register.int16_7 : right.register.int16_7; return vec; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { vec.register.uint32_0 = left.register.uint32_0 < right.register.uint32_0 ? left.register.uint32_0 : right.register.uint32_0; vec.register.uint32_1 = left.register.uint32_1 < right.register.uint32_1 ? left.register.uint32_1 : right.register.uint32_1; @@ -3925,7 +3925,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.uint32_3 = left.register.uint32_3 < right.register.uint32_3 ? left.register.uint32_3 : right.register.uint32_3; return vec; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { vec.register.int32_0 = left.register.int32_0 < right.register.int32_0 ? left.register.int32_0 : right.register.int32_0; vec.register.int32_1 = left.register.int32_1 < right.register.int32_1 ? left.register.int32_1 : right.register.int32_1; @@ -3933,19 +3933,19 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.int32_3 = left.register.int32_3 < right.register.int32_3 ? left.register.int32_3 : right.register.int32_3; return vec; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { vec.register.uint64_0 = left.register.uint64_0 < right.register.uint64_0 ? left.register.uint64_0 : right.register.uint64_0; vec.register.uint64_1 = left.register.uint64_1 < right.register.uint64_1 ? left.register.uint64_1 : right.register.uint64_1; return vec; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { vec.register.int64_0 = left.register.int64_0 < right.register.int64_0 ? left.register.int64_0 : right.register.int64_0; vec.register.int64_1 = left.register.int64_1 < right.register.int64_1 ? left.register.int64_1 : right.register.int64_1; return vec; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { vec.register.single_0 = left.register.single_0 < right.register.single_0 ? left.register.single_0 : right.register.single_0; vec.register.single_1 = left.register.single_1 < right.register.single_1 ? left.register.single_1 : right.register.single_1; @@ -3953,7 +3953,7 @@ internal static unsafe Vector Min(Vector left, Vector right) vec.register.single_3 = left.register.single_3 < right.register.single_3 ? left.register.single_3 : right.register.single_3; return vec; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { vec.register.double_0 = left.register.double_0 < right.register.double_0 ? left.register.double_0 : right.register.double_0; vec.register.double_1 = left.register.double_1 < right.register.double_1 ? left.register.double_1 : right.register.double_1; @@ -3971,93 +3971,93 @@ internal static unsafe Vector Max(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Byte)(object)left[g] : (Byte)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (byte)(object)left[g] : (byte)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (SByte)(object)left[g] : (SByte)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (sbyte)(object)left[g] : (sbyte)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (UInt16)(object)left[g] : (UInt16)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (ushort)(object)left[g] : (ushort)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Int16)(object)left[g] : (Int16)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (short)(object)left[g] : (short)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (UInt32)(object)left[g] : (UInt32)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (uint)(object)left[g] : (uint)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Int32)(object)left[g] : (Int32)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (int)(object)left[g] : (int)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (UInt64)(object)left[g] : (UInt64)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (ulong)(object)left[g] : (ulong)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Int64)(object)left[g] : (Int64)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (long)(object)left[g] : (long)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Single)(object)left[g] : (Single)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (float)(object)left[g] : (float)(object)right[g]; } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (Double)(object)left[g] : (Double)(object)right[g]; + dataPtr[g] = ScalarGreaterThan(left[g], right[g]) ? (double)(object)left[g] : (double)(object)right[g]; } return new Vector(dataPtr); } @@ -4069,7 +4069,7 @@ internal static unsafe Vector Max(Vector left, Vector right) else { Vector vec = new Vector(); - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { vec.register.byte_0 = left.register.byte_0 > right.register.byte_0 ? left.register.byte_0 : right.register.byte_0; vec.register.byte_1 = left.register.byte_1 > right.register.byte_1 ? left.register.byte_1 : right.register.byte_1; @@ -4089,7 +4089,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.byte_15 = left.register.byte_15 > right.register.byte_15 ? left.register.byte_15 : right.register.byte_15; return vec; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { vec.register.sbyte_0 = left.register.sbyte_0 > right.register.sbyte_0 ? left.register.sbyte_0 : right.register.sbyte_0; vec.register.sbyte_1 = left.register.sbyte_1 > right.register.sbyte_1 ? left.register.sbyte_1 : right.register.sbyte_1; @@ -4109,7 +4109,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.sbyte_15 = left.register.sbyte_15 > right.register.sbyte_15 ? left.register.sbyte_15 : right.register.sbyte_15; return vec; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { vec.register.uint16_0 = left.register.uint16_0 > right.register.uint16_0 ? left.register.uint16_0 : right.register.uint16_0; vec.register.uint16_1 = left.register.uint16_1 > right.register.uint16_1 ? left.register.uint16_1 : right.register.uint16_1; @@ -4121,7 +4121,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.uint16_7 = left.register.uint16_7 > right.register.uint16_7 ? left.register.uint16_7 : right.register.uint16_7; return vec; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { vec.register.int16_0 = left.register.int16_0 > right.register.int16_0 ? left.register.int16_0 : right.register.int16_0; vec.register.int16_1 = left.register.int16_1 > right.register.int16_1 ? left.register.int16_1 : right.register.int16_1; @@ -4133,7 +4133,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.int16_7 = left.register.int16_7 > right.register.int16_7 ? left.register.int16_7 : right.register.int16_7; return vec; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { vec.register.uint32_0 = left.register.uint32_0 > right.register.uint32_0 ? left.register.uint32_0 : right.register.uint32_0; vec.register.uint32_1 = left.register.uint32_1 > right.register.uint32_1 ? left.register.uint32_1 : right.register.uint32_1; @@ -4141,7 +4141,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.uint32_3 = left.register.uint32_3 > right.register.uint32_3 ? left.register.uint32_3 : right.register.uint32_3; return vec; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { vec.register.int32_0 = left.register.int32_0 > right.register.int32_0 ? left.register.int32_0 : right.register.int32_0; vec.register.int32_1 = left.register.int32_1 > right.register.int32_1 ? left.register.int32_1 : right.register.int32_1; @@ -4149,19 +4149,19 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.int32_3 = left.register.int32_3 > right.register.int32_3 ? left.register.int32_3 : right.register.int32_3; return vec; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { vec.register.uint64_0 = left.register.uint64_0 > right.register.uint64_0 ? left.register.uint64_0 : right.register.uint64_0; vec.register.uint64_1 = left.register.uint64_1 > right.register.uint64_1 ? left.register.uint64_1 : right.register.uint64_1; return vec; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { vec.register.int64_0 = left.register.int64_0 > right.register.int64_0 ? left.register.int64_0 : right.register.int64_0; vec.register.int64_1 = left.register.int64_1 > right.register.int64_1 ? left.register.int64_1 : right.register.int64_1; return vec; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { vec.register.single_0 = left.register.single_0 > right.register.single_0 ? left.register.single_0 : right.register.single_0; vec.register.single_1 = left.register.single_1 > right.register.single_1 ? left.register.single_1 : right.register.single_1; @@ -4169,7 +4169,7 @@ internal static unsafe Vector Max(Vector left, Vector right) vec.register.single_3 = left.register.single_3 > right.register.single_3 ? left.register.single_3 : right.register.single_3; return vec; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { vec.register.double_0 = left.register.double_0 > right.register.double_0 ? left.register.double_0 : right.register.double_0; vec.register.double_1 = left.register.double_1 > right.register.double_1 ? left.register.double_1 : right.register.double_1; @@ -4196,120 +4196,120 @@ internal static T DotProduct(Vector left, Vector right) } else { - if (typeof(T) == typeof(Byte)) - { - Byte product = 0; - product += (Byte)(left.register.byte_0 * right.register.byte_0); - product += (Byte)(left.register.byte_1 * right.register.byte_1); - product += (Byte)(left.register.byte_2 * right.register.byte_2); - product += (Byte)(left.register.byte_3 * right.register.byte_3); - product += (Byte)(left.register.byte_4 * right.register.byte_4); - product += (Byte)(left.register.byte_5 * right.register.byte_5); - product += (Byte)(left.register.byte_6 * right.register.byte_6); - product += (Byte)(left.register.byte_7 * right.register.byte_7); - product += (Byte)(left.register.byte_8 * right.register.byte_8); - product += (Byte)(left.register.byte_9 * right.register.byte_9); - product += (Byte)(left.register.byte_10 * right.register.byte_10); - product += (Byte)(left.register.byte_11 * right.register.byte_11); - product += (Byte)(left.register.byte_12 * right.register.byte_12); - product += (Byte)(left.register.byte_13 * right.register.byte_13); - product += (Byte)(left.register.byte_14 * right.register.byte_14); - product += (Byte)(left.register.byte_15 * right.register.byte_15); + if (typeof(T) == typeof(byte)) + { + byte product = 0; + product += (byte)(left.register.byte_0 * right.register.byte_0); + product += (byte)(left.register.byte_1 * right.register.byte_1); + product += (byte)(left.register.byte_2 * right.register.byte_2); + product += (byte)(left.register.byte_3 * right.register.byte_3); + product += (byte)(left.register.byte_4 * right.register.byte_4); + product += (byte)(left.register.byte_5 * right.register.byte_5); + product += (byte)(left.register.byte_6 * right.register.byte_6); + product += (byte)(left.register.byte_7 * right.register.byte_7); + product += (byte)(left.register.byte_8 * right.register.byte_8); + product += (byte)(left.register.byte_9 * right.register.byte_9); + product += (byte)(left.register.byte_10 * right.register.byte_10); + product += (byte)(left.register.byte_11 * right.register.byte_11); + product += (byte)(left.register.byte_12 * right.register.byte_12); + product += (byte)(left.register.byte_13 * right.register.byte_13); + product += (byte)(left.register.byte_14 * right.register.byte_14); + product += (byte)(left.register.byte_15 * right.register.byte_15); return (T)(object)product; } - else if (typeof(T) == typeof(SByte)) - { - SByte product = 0; - product += (SByte)(left.register.sbyte_0 * right.register.sbyte_0); - product += (SByte)(left.register.sbyte_1 * right.register.sbyte_1); - product += (SByte)(left.register.sbyte_2 * right.register.sbyte_2); - product += (SByte)(left.register.sbyte_3 * right.register.sbyte_3); - product += (SByte)(left.register.sbyte_4 * right.register.sbyte_4); - product += (SByte)(left.register.sbyte_5 * right.register.sbyte_5); - product += (SByte)(left.register.sbyte_6 * right.register.sbyte_6); - product += (SByte)(left.register.sbyte_7 * right.register.sbyte_7); - product += (SByte)(left.register.sbyte_8 * right.register.sbyte_8); - product += (SByte)(left.register.sbyte_9 * right.register.sbyte_9); - product += (SByte)(left.register.sbyte_10 * right.register.sbyte_10); - product += (SByte)(left.register.sbyte_11 * right.register.sbyte_11); - product += (SByte)(left.register.sbyte_12 * right.register.sbyte_12); - product += (SByte)(left.register.sbyte_13 * right.register.sbyte_13); - product += (SByte)(left.register.sbyte_14 * right.register.sbyte_14); - product += (SByte)(left.register.sbyte_15 * right.register.sbyte_15); + else if (typeof(T) == typeof(sbyte)) + { + sbyte product = 0; + product += (sbyte)(left.register.sbyte_0 * right.register.sbyte_0); + product += (sbyte)(left.register.sbyte_1 * right.register.sbyte_1); + product += (sbyte)(left.register.sbyte_2 * right.register.sbyte_2); + product += (sbyte)(left.register.sbyte_3 * right.register.sbyte_3); + product += (sbyte)(left.register.sbyte_4 * right.register.sbyte_4); + product += (sbyte)(left.register.sbyte_5 * right.register.sbyte_5); + product += (sbyte)(left.register.sbyte_6 * right.register.sbyte_6); + product += (sbyte)(left.register.sbyte_7 * right.register.sbyte_7); + product += (sbyte)(left.register.sbyte_8 * right.register.sbyte_8); + product += (sbyte)(left.register.sbyte_9 * right.register.sbyte_9); + product += (sbyte)(left.register.sbyte_10 * right.register.sbyte_10); + product += (sbyte)(left.register.sbyte_11 * right.register.sbyte_11); + product += (sbyte)(left.register.sbyte_12 * right.register.sbyte_12); + product += (sbyte)(left.register.sbyte_13 * right.register.sbyte_13); + product += (sbyte)(left.register.sbyte_14 * right.register.sbyte_14); + product += (sbyte)(left.register.sbyte_15 * right.register.sbyte_15); return (T)(object)product; } - else if (typeof(T) == typeof(UInt16)) - { - UInt16 product = 0; - product += (UInt16)(left.register.uint16_0 * right.register.uint16_0); - product += (UInt16)(left.register.uint16_1 * right.register.uint16_1); - product += (UInt16)(left.register.uint16_2 * right.register.uint16_2); - product += (UInt16)(left.register.uint16_3 * right.register.uint16_3); - product += (UInt16)(left.register.uint16_4 * right.register.uint16_4); - product += (UInt16)(left.register.uint16_5 * right.register.uint16_5); - product += (UInt16)(left.register.uint16_6 * right.register.uint16_6); - product += (UInt16)(left.register.uint16_7 * right.register.uint16_7); + else if (typeof(T) == typeof(ushort)) + { + ushort product = 0; + product += (ushort)(left.register.uint16_0 * right.register.uint16_0); + product += (ushort)(left.register.uint16_1 * right.register.uint16_1); + product += (ushort)(left.register.uint16_2 * right.register.uint16_2); + product += (ushort)(left.register.uint16_3 * right.register.uint16_3); + product += (ushort)(left.register.uint16_4 * right.register.uint16_4); + product += (ushort)(left.register.uint16_5 * right.register.uint16_5); + product += (ushort)(left.register.uint16_6 * right.register.uint16_6); + product += (ushort)(left.register.uint16_7 * right.register.uint16_7); return (T)(object)product; } - else if (typeof(T) == typeof(Int16)) - { - Int16 product = 0; - product += (Int16)(left.register.int16_0 * right.register.int16_0); - product += (Int16)(left.register.int16_1 * right.register.int16_1); - product += (Int16)(left.register.int16_2 * right.register.int16_2); - product += (Int16)(left.register.int16_3 * right.register.int16_3); - product += (Int16)(left.register.int16_4 * right.register.int16_4); - product += (Int16)(left.register.int16_5 * right.register.int16_5); - product += (Int16)(left.register.int16_6 * right.register.int16_6); - product += (Int16)(left.register.int16_7 * right.register.int16_7); + else if (typeof(T) == typeof(short)) + { + short product = 0; + product += (short)(left.register.int16_0 * right.register.int16_0); + product += (short)(left.register.int16_1 * right.register.int16_1); + product += (short)(left.register.int16_2 * right.register.int16_2); + product += (short)(left.register.int16_3 * right.register.int16_3); + product += (short)(left.register.int16_4 * right.register.int16_4); + product += (short)(left.register.int16_5 * right.register.int16_5); + product += (short)(left.register.int16_6 * right.register.int16_6); + product += (short)(left.register.int16_7 * right.register.int16_7); return (T)(object)product; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32 product = 0; - product += (UInt32)(left.register.uint32_0 * right.register.uint32_0); - product += (UInt32)(left.register.uint32_1 * right.register.uint32_1); - product += (UInt32)(left.register.uint32_2 * right.register.uint32_2); - product += (UInt32)(left.register.uint32_3 * right.register.uint32_3); + uint product = 0; + product += (uint)(left.register.uint32_0 * right.register.uint32_0); + product += (uint)(left.register.uint32_1 * right.register.uint32_1); + product += (uint)(left.register.uint32_2 * right.register.uint32_2); + product += (uint)(left.register.uint32_3 * right.register.uint32_3); return (T)(object)product; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32 product = 0; - product += (Int32)(left.register.int32_0 * right.register.int32_0); - product += (Int32)(left.register.int32_1 * right.register.int32_1); - product += (Int32)(left.register.int32_2 * right.register.int32_2); - product += (Int32)(left.register.int32_3 * right.register.int32_3); + int product = 0; + product += (int)(left.register.int32_0 * right.register.int32_0); + product += (int)(left.register.int32_1 * right.register.int32_1); + product += (int)(left.register.int32_2 * right.register.int32_2); + product += (int)(left.register.int32_3 * right.register.int32_3); return (T)(object)product; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64 product = 0; - product += (UInt64)(left.register.uint64_0 * right.register.uint64_0); - product += (UInt64)(left.register.uint64_1 * right.register.uint64_1); + ulong product = 0; + product += (ulong)(left.register.uint64_0 * right.register.uint64_0); + product += (ulong)(left.register.uint64_1 * right.register.uint64_1); return (T)(object)product; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64 product = 0; - product += (Int64)(left.register.int64_0 * right.register.int64_0); - product += (Int64)(left.register.int64_1 * right.register.int64_1); + long product = 0; + product += (long)(left.register.int64_0 * right.register.int64_0); + product += (long)(left.register.int64_1 * right.register.int64_1); return (T)(object)product; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single product = 0; - product += (Single)(left.register.single_0 * right.register.single_0); - product += (Single)(left.register.single_1 * right.register.single_1); - product += (Single)(left.register.single_2 * right.register.single_2); - product += (Single)(left.register.single_3 * right.register.single_3); + float product = 0; + product += (float)(left.register.single_0 * right.register.single_0); + product += (float)(left.register.single_1 * right.register.single_1); + product += (float)(left.register.single_2 * right.register.single_2); + product += (float)(left.register.single_3 * right.register.single_3); return (T)(object)product; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double product = 0; - product += (Double)(left.register.double_0 * right.register.double_0); - product += (Double)(left.register.double_1 * right.register.double_1); + double product = 0; + product += (double)(left.register.double_0 * right.register.double_0); + product += (double)(left.register.double_1 * right.register.double_1); return (T)(object)product; } else @@ -4324,93 +4324,93 @@ internal static unsafe Vector SquareRoot(Vector value) { if (Vector.IsHardwareAccelerated) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte* dataPtr = stackalloc Byte[Count]; + byte* dataPtr = stackalloc byte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Byte)Math.Sqrt((Byte)(object)value[g])); + dataPtr[g] = unchecked((byte)Math.Sqrt((byte)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte* dataPtr = stackalloc SByte[Count]; + sbyte* dataPtr = stackalloc sbyte[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((SByte)Math.Sqrt((SByte)(object)value[g])); + dataPtr[g] = unchecked((sbyte)Math.Sqrt((sbyte)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16* dataPtr = stackalloc UInt16[Count]; + ushort* dataPtr = stackalloc ushort[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((UInt16)Math.Sqrt((UInt16)(object)value[g])); + dataPtr[g] = unchecked((ushort)Math.Sqrt((ushort)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16* dataPtr = stackalloc Int16[Count]; + short* dataPtr = stackalloc short[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Int16)Math.Sqrt((Int16)(object)value[g])); + dataPtr[g] = unchecked((short)Math.Sqrt((short)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32* dataPtr = stackalloc UInt32[Count]; + uint* dataPtr = stackalloc uint[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((UInt32)Math.Sqrt((UInt32)(object)value[g])); + dataPtr[g] = unchecked((uint)Math.Sqrt((uint)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32* dataPtr = stackalloc Int32[Count]; + int* dataPtr = stackalloc int[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Int32)Math.Sqrt((Int32)(object)value[g])); + dataPtr[g] = unchecked((int)Math.Sqrt((int)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64* dataPtr = stackalloc UInt64[Count]; + ulong* dataPtr = stackalloc ulong[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((UInt64)Math.Sqrt((UInt64)(object)value[g])); + dataPtr[g] = unchecked((ulong)Math.Sqrt((ulong)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64* dataPtr = stackalloc Int64[Count]; + long* dataPtr = stackalloc long[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Int64)Math.Sqrt((Int64)(object)value[g])); + dataPtr[g] = unchecked((long)Math.Sqrt((long)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single* dataPtr = stackalloc Single[Count]; + float* dataPtr = stackalloc float[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Single)Math.Sqrt((Single)(object)value[g])); + dataPtr[g] = unchecked((float)Math.Sqrt((float)(object)value[g])); } return new Vector(dataPtr); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double* dataPtr = stackalloc Double[Count]; + double* dataPtr = stackalloc double[Count]; for (int g = 0; g < Count; g++) { - dataPtr[g] = unchecked((Double)Math.Sqrt((Double)(object)value[g])); + dataPtr[g] = unchecked((double)Math.Sqrt((double)(object)value[g])); } return new Vector(dataPtr); } @@ -4421,110 +4421,110 @@ internal static unsafe Vector SquareRoot(Vector value) } else { - if (typeof(T) == typeof(Byte)) - { - value.register.byte_0 = (Byte)Math.Sqrt(value.register.byte_0); - value.register.byte_1 = (Byte)Math.Sqrt(value.register.byte_1); - value.register.byte_2 = (Byte)Math.Sqrt(value.register.byte_2); - value.register.byte_3 = (Byte)Math.Sqrt(value.register.byte_3); - value.register.byte_4 = (Byte)Math.Sqrt(value.register.byte_4); - value.register.byte_5 = (Byte)Math.Sqrt(value.register.byte_5); - value.register.byte_6 = (Byte)Math.Sqrt(value.register.byte_6); - value.register.byte_7 = (Byte)Math.Sqrt(value.register.byte_7); - value.register.byte_8 = (Byte)Math.Sqrt(value.register.byte_8); - value.register.byte_9 = (Byte)Math.Sqrt(value.register.byte_9); - value.register.byte_10 = (Byte)Math.Sqrt(value.register.byte_10); - value.register.byte_11 = (Byte)Math.Sqrt(value.register.byte_11); - value.register.byte_12 = (Byte)Math.Sqrt(value.register.byte_12); - value.register.byte_13 = (Byte)Math.Sqrt(value.register.byte_13); - value.register.byte_14 = (Byte)Math.Sqrt(value.register.byte_14); - value.register.byte_15 = (Byte)Math.Sqrt(value.register.byte_15); + if (typeof(T) == typeof(byte)) + { + value.register.byte_0 = (byte)Math.Sqrt(value.register.byte_0); + value.register.byte_1 = (byte)Math.Sqrt(value.register.byte_1); + value.register.byte_2 = (byte)Math.Sqrt(value.register.byte_2); + value.register.byte_3 = (byte)Math.Sqrt(value.register.byte_3); + value.register.byte_4 = (byte)Math.Sqrt(value.register.byte_4); + value.register.byte_5 = (byte)Math.Sqrt(value.register.byte_5); + value.register.byte_6 = (byte)Math.Sqrt(value.register.byte_6); + value.register.byte_7 = (byte)Math.Sqrt(value.register.byte_7); + value.register.byte_8 = (byte)Math.Sqrt(value.register.byte_8); + value.register.byte_9 = (byte)Math.Sqrt(value.register.byte_9); + value.register.byte_10 = (byte)Math.Sqrt(value.register.byte_10); + value.register.byte_11 = (byte)Math.Sqrt(value.register.byte_11); + value.register.byte_12 = (byte)Math.Sqrt(value.register.byte_12); + value.register.byte_13 = (byte)Math.Sqrt(value.register.byte_13); + value.register.byte_14 = (byte)Math.Sqrt(value.register.byte_14); + value.register.byte_15 = (byte)Math.Sqrt(value.register.byte_15); return value; } - else if (typeof(T) == typeof(SByte)) - { - value.register.sbyte_0 = (SByte)Math.Sqrt(value.register.sbyte_0); - value.register.sbyte_1 = (SByte)Math.Sqrt(value.register.sbyte_1); - value.register.sbyte_2 = (SByte)Math.Sqrt(value.register.sbyte_2); - value.register.sbyte_3 = (SByte)Math.Sqrt(value.register.sbyte_3); - value.register.sbyte_4 = (SByte)Math.Sqrt(value.register.sbyte_4); - value.register.sbyte_5 = (SByte)Math.Sqrt(value.register.sbyte_5); - value.register.sbyte_6 = (SByte)Math.Sqrt(value.register.sbyte_6); - value.register.sbyte_7 = (SByte)Math.Sqrt(value.register.sbyte_7); - value.register.sbyte_8 = (SByte)Math.Sqrt(value.register.sbyte_8); - value.register.sbyte_9 = (SByte)Math.Sqrt(value.register.sbyte_9); - value.register.sbyte_10 = (SByte)Math.Sqrt(value.register.sbyte_10); - value.register.sbyte_11 = (SByte)Math.Sqrt(value.register.sbyte_11); - value.register.sbyte_12 = (SByte)Math.Sqrt(value.register.sbyte_12); - value.register.sbyte_13 = (SByte)Math.Sqrt(value.register.sbyte_13); - value.register.sbyte_14 = (SByte)Math.Sqrt(value.register.sbyte_14); - value.register.sbyte_15 = (SByte)Math.Sqrt(value.register.sbyte_15); + else if (typeof(T) == typeof(sbyte)) + { + value.register.sbyte_0 = (sbyte)Math.Sqrt(value.register.sbyte_0); + value.register.sbyte_1 = (sbyte)Math.Sqrt(value.register.sbyte_1); + value.register.sbyte_2 = (sbyte)Math.Sqrt(value.register.sbyte_2); + value.register.sbyte_3 = (sbyte)Math.Sqrt(value.register.sbyte_3); + value.register.sbyte_4 = (sbyte)Math.Sqrt(value.register.sbyte_4); + value.register.sbyte_5 = (sbyte)Math.Sqrt(value.register.sbyte_5); + value.register.sbyte_6 = (sbyte)Math.Sqrt(value.register.sbyte_6); + value.register.sbyte_7 = (sbyte)Math.Sqrt(value.register.sbyte_7); + value.register.sbyte_8 = (sbyte)Math.Sqrt(value.register.sbyte_8); + value.register.sbyte_9 = (sbyte)Math.Sqrt(value.register.sbyte_9); + value.register.sbyte_10 = (sbyte)Math.Sqrt(value.register.sbyte_10); + value.register.sbyte_11 = (sbyte)Math.Sqrt(value.register.sbyte_11); + value.register.sbyte_12 = (sbyte)Math.Sqrt(value.register.sbyte_12); + value.register.sbyte_13 = (sbyte)Math.Sqrt(value.register.sbyte_13); + value.register.sbyte_14 = (sbyte)Math.Sqrt(value.register.sbyte_14); + value.register.sbyte_15 = (sbyte)Math.Sqrt(value.register.sbyte_15); return value; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - value.register.uint16_0 = (UInt16)Math.Sqrt(value.register.uint16_0); - value.register.uint16_1 = (UInt16)Math.Sqrt(value.register.uint16_1); - value.register.uint16_2 = (UInt16)Math.Sqrt(value.register.uint16_2); - value.register.uint16_3 = (UInt16)Math.Sqrt(value.register.uint16_3); - value.register.uint16_4 = (UInt16)Math.Sqrt(value.register.uint16_4); - value.register.uint16_5 = (UInt16)Math.Sqrt(value.register.uint16_5); - value.register.uint16_6 = (UInt16)Math.Sqrt(value.register.uint16_6); - value.register.uint16_7 = (UInt16)Math.Sqrt(value.register.uint16_7); + value.register.uint16_0 = (ushort)Math.Sqrt(value.register.uint16_0); + value.register.uint16_1 = (ushort)Math.Sqrt(value.register.uint16_1); + value.register.uint16_2 = (ushort)Math.Sqrt(value.register.uint16_2); + value.register.uint16_3 = (ushort)Math.Sqrt(value.register.uint16_3); + value.register.uint16_4 = (ushort)Math.Sqrt(value.register.uint16_4); + value.register.uint16_5 = (ushort)Math.Sqrt(value.register.uint16_5); + value.register.uint16_6 = (ushort)Math.Sqrt(value.register.uint16_6); + value.register.uint16_7 = (ushort)Math.Sqrt(value.register.uint16_7); return value; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - value.register.int16_0 = (Int16)Math.Sqrt(value.register.int16_0); - value.register.int16_1 = (Int16)Math.Sqrt(value.register.int16_1); - value.register.int16_2 = (Int16)Math.Sqrt(value.register.int16_2); - value.register.int16_3 = (Int16)Math.Sqrt(value.register.int16_3); - value.register.int16_4 = (Int16)Math.Sqrt(value.register.int16_4); - value.register.int16_5 = (Int16)Math.Sqrt(value.register.int16_5); - value.register.int16_6 = (Int16)Math.Sqrt(value.register.int16_6); - value.register.int16_7 = (Int16)Math.Sqrt(value.register.int16_7); + value.register.int16_0 = (short)Math.Sqrt(value.register.int16_0); + value.register.int16_1 = (short)Math.Sqrt(value.register.int16_1); + value.register.int16_2 = (short)Math.Sqrt(value.register.int16_2); + value.register.int16_3 = (short)Math.Sqrt(value.register.int16_3); + value.register.int16_4 = (short)Math.Sqrt(value.register.int16_4); + value.register.int16_5 = (short)Math.Sqrt(value.register.int16_5); + value.register.int16_6 = (short)Math.Sqrt(value.register.int16_6); + value.register.int16_7 = (short)Math.Sqrt(value.register.int16_7); return value; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - value.register.uint32_0 = (UInt32)Math.Sqrt(value.register.uint32_0); - value.register.uint32_1 = (UInt32)Math.Sqrt(value.register.uint32_1); - value.register.uint32_2 = (UInt32)Math.Sqrt(value.register.uint32_2); - value.register.uint32_3 = (UInt32)Math.Sqrt(value.register.uint32_3); + value.register.uint32_0 = (uint)Math.Sqrt(value.register.uint32_0); + value.register.uint32_1 = (uint)Math.Sqrt(value.register.uint32_1); + value.register.uint32_2 = (uint)Math.Sqrt(value.register.uint32_2); + value.register.uint32_3 = (uint)Math.Sqrt(value.register.uint32_3); return value; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - value.register.int32_0 = (Int32)Math.Sqrt(value.register.int32_0); - value.register.int32_1 = (Int32)Math.Sqrt(value.register.int32_1); - value.register.int32_2 = (Int32)Math.Sqrt(value.register.int32_2); - value.register.int32_3 = (Int32)Math.Sqrt(value.register.int32_3); + value.register.int32_0 = (int)Math.Sqrt(value.register.int32_0); + value.register.int32_1 = (int)Math.Sqrt(value.register.int32_1); + value.register.int32_2 = (int)Math.Sqrt(value.register.int32_2); + value.register.int32_3 = (int)Math.Sqrt(value.register.int32_3); return value; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - value.register.uint64_0 = (UInt64)Math.Sqrt(value.register.uint64_0); - value.register.uint64_1 = (UInt64)Math.Sqrt(value.register.uint64_1); + value.register.uint64_0 = (ulong)Math.Sqrt(value.register.uint64_0); + value.register.uint64_1 = (ulong)Math.Sqrt(value.register.uint64_1); return value; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - value.register.int64_0 = (Int64)Math.Sqrt(value.register.int64_0); - value.register.int64_1 = (Int64)Math.Sqrt(value.register.int64_1); + value.register.int64_0 = (long)Math.Sqrt(value.register.int64_0); + value.register.int64_1 = (long)Math.Sqrt(value.register.int64_1); return value; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - value.register.single_0 = (Single)Math.Sqrt(value.register.single_0); - value.register.single_1 = (Single)Math.Sqrt(value.register.single_1); - value.register.single_2 = (Single)Math.Sqrt(value.register.single_2); - value.register.single_3 = (Single)Math.Sqrt(value.register.single_3); + value.register.single_0 = (float)Math.Sqrt(value.register.single_0); + value.register.single_1 = (float)Math.Sqrt(value.register.single_1); + value.register.single_2 = (float)Math.Sqrt(value.register.single_2); + value.register.single_3 = (float)Math.Sqrt(value.register.single_3); return value; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - value.register.double_0 = (Double)Math.Sqrt(value.register.double_0); - value.register.double_1 = (Double)Math.Sqrt(value.register.double_1); + value.register.double_0 = (double)Math.Sqrt(value.register.double_0); + value.register.double_1 = (double)Math.Sqrt(value.register.double_1); return value; } else @@ -4539,45 +4539,45 @@ internal static unsafe Vector SquareRoot(Vector value) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarEquals(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (Byte)(object)left == (Byte)(object)right; + return (byte)(object)left == (byte)(object)right; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (SByte)(object)left == (SByte)(object)right; + return (sbyte)(object)left == (sbyte)(object)right; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (UInt16)(object)left == (UInt16)(object)right; + return (ushort)(object)left == (ushort)(object)right; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (Int16)(object)left == (Int16)(object)right; + return (short)(object)left == (short)(object)right; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (UInt32)(object)left == (UInt32)(object)right; + return (uint)(object)left == (uint)(object)right; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (Int32)(object)left == (Int32)(object)right; + return (int)(object)left == (int)(object)right; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (UInt64)(object)left == (UInt64)(object)right; + return (ulong)(object)left == (ulong)(object)right; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (Int64)(object)left == (Int64)(object)right; + return (long)(object)left == (long)(object)right; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (Single)(object)left == (Single)(object)right; + return (float)(object)left == (float)(object)right; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (Double)(object)left == (Double)(object)right; + return (double)(object)left == (double)(object)right; } else { @@ -4588,45 +4588,45 @@ private static bool ScalarEquals(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarLessThan(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (Byte)(object)left < (Byte)(object)right; + return (byte)(object)left < (byte)(object)right; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (SByte)(object)left < (SByte)(object)right; + return (sbyte)(object)left < (sbyte)(object)right; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (UInt16)(object)left < (UInt16)(object)right; + return (ushort)(object)left < (ushort)(object)right; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (Int16)(object)left < (Int16)(object)right; + return (short)(object)left < (short)(object)right; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (UInt32)(object)left < (UInt32)(object)right; + return (uint)(object)left < (uint)(object)right; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (Int32)(object)left < (Int32)(object)right; + return (int)(object)left < (int)(object)right; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (UInt64)(object)left < (UInt64)(object)right; + return (ulong)(object)left < (ulong)(object)right; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (Int64)(object)left < (Int64)(object)right; + return (long)(object)left < (long)(object)right; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (Single)(object)left < (Single)(object)right; + return (float)(object)left < (float)(object)right; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (Double)(object)left < (Double)(object)right; + return (double)(object)left < (double)(object)right; } else { @@ -4637,45 +4637,45 @@ private static bool ScalarLessThan(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static bool ScalarGreaterThan(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (Byte)(object)left > (Byte)(object)right; + return (byte)(object)left > (byte)(object)right; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (SByte)(object)left > (SByte)(object)right; + return (sbyte)(object)left > (sbyte)(object)right; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (UInt16)(object)left > (UInt16)(object)right; + return (ushort)(object)left > (ushort)(object)right; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (Int16)(object)left > (Int16)(object)right; + return (short)(object)left > (short)(object)right; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (UInt32)(object)left > (UInt32)(object)right; + return (uint)(object)left > (uint)(object)right; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (Int32)(object)left > (Int32)(object)right; + return (int)(object)left > (int)(object)right; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (UInt64)(object)left > (UInt64)(object)right; + return (ulong)(object)left > (ulong)(object)right; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (Int64)(object)left > (Int64)(object)right; + return (long)(object)left > (long)(object)right; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (Single)(object)left > (Single)(object)right; + return (float)(object)left > (float)(object)right; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (Double)(object)left > (Double)(object)right; + return (double)(object)left > (double)(object)right; } else { @@ -4686,45 +4686,45 @@ private static bool ScalarGreaterThan(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarAdd(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (T)(object)unchecked((Byte)((Byte)(object)left + (Byte)(object)right)); + return (T)(object)unchecked((byte)((byte)(object)left + (byte)(object)right)); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (T)(object)unchecked((SByte)((SByte)(object)left + (SByte)(object)right)); + return (T)(object)unchecked((sbyte)((sbyte)(object)left + (sbyte)(object)right)); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (T)(object)unchecked((UInt16)((UInt16)(object)left + (UInt16)(object)right)); + return (T)(object)unchecked((ushort)((ushort)(object)left + (ushort)(object)right)); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (T)(object)unchecked((Int16)((Int16)(object)left + (Int16)(object)right)); + return (T)(object)unchecked((short)((short)(object)left + (short)(object)right)); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (T)(object)unchecked((UInt32)((UInt32)(object)left + (UInt32)(object)right)); + return (T)(object)unchecked((uint)((uint)(object)left + (uint)(object)right)); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (T)(object)unchecked((Int32)((Int32)(object)left + (Int32)(object)right)); + return (T)(object)unchecked((int)((int)(object)left + (int)(object)right)); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (T)(object)unchecked((UInt64)((UInt64)(object)left + (UInt64)(object)right)); + return (T)(object)unchecked((ulong)((ulong)(object)left + (ulong)(object)right)); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (T)(object)unchecked((Int64)((Int64)(object)left + (Int64)(object)right)); + return (T)(object)unchecked((long)((long)(object)left + (long)(object)right)); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (T)(object)unchecked((Single)((Single)(object)left + (Single)(object)right)); + return (T)(object)unchecked((float)((float)(object)left + (float)(object)right)); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (T)(object)unchecked((Double)((Double)(object)left + (Double)(object)right)); + return (T)(object)unchecked((double)((double)(object)left + (double)(object)right)); } else { @@ -4735,45 +4735,45 @@ private static T ScalarAdd(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarSubtract(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (T)(object)(Byte)((Byte)(object)left - (Byte)(object)right); + return (T)(object)(byte)((byte)(object)left - (byte)(object)right); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (T)(object)(SByte)((SByte)(object)left - (SByte)(object)right); + return (T)(object)(sbyte)((sbyte)(object)left - (sbyte)(object)right); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (T)(object)(UInt16)((UInt16)(object)left - (UInt16)(object)right); + return (T)(object)(ushort)((ushort)(object)left - (ushort)(object)right); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (T)(object)(Int16)((Int16)(object)left - (Int16)(object)right); + return (T)(object)(short)((short)(object)left - (short)(object)right); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (T)(object)(UInt32)((UInt32)(object)left - (UInt32)(object)right); + return (T)(object)(uint)((uint)(object)left - (uint)(object)right); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (T)(object)(Int32)((Int32)(object)left - (Int32)(object)right); + return (T)(object)(int)((int)(object)left - (int)(object)right); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (T)(object)(UInt64)((UInt64)(object)left - (UInt64)(object)right); + return (T)(object)(ulong)((ulong)(object)left - (ulong)(object)right); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (T)(object)(Int64)((Int64)(object)left - (Int64)(object)right); + return (T)(object)(long)((long)(object)left - (long)(object)right); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (T)(object)(Single)((Single)(object)left - (Single)(object)right); + return (T)(object)(float)((float)(object)left - (float)(object)right); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (T)(object)(Double)((Double)(object)left - (Double)(object)right); + return (T)(object)(double)((double)(object)left - (double)(object)right); } else { @@ -4784,45 +4784,45 @@ private static T ScalarSubtract(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarMultiply(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (T)(object)unchecked((Byte)((Byte)(object)left * (Byte)(object)right)); + return (T)(object)unchecked((byte)((byte)(object)left * (byte)(object)right)); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (T)(object)unchecked((SByte)((SByte)(object)left * (SByte)(object)right)); + return (T)(object)unchecked((sbyte)((sbyte)(object)left * (sbyte)(object)right)); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (T)(object)unchecked((UInt16)((UInt16)(object)left * (UInt16)(object)right)); + return (T)(object)unchecked((ushort)((ushort)(object)left * (ushort)(object)right)); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (T)(object)unchecked((Int16)((Int16)(object)left * (Int16)(object)right)); + return (T)(object)unchecked((short)((short)(object)left * (short)(object)right)); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (T)(object)unchecked((UInt32)((UInt32)(object)left * (UInt32)(object)right)); + return (T)(object)unchecked((uint)((uint)(object)left * (uint)(object)right)); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (T)(object)unchecked((Int32)((Int32)(object)left * (Int32)(object)right)); + return (T)(object)unchecked((int)((int)(object)left * (int)(object)right)); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (T)(object)unchecked((UInt64)((UInt64)(object)left * (UInt64)(object)right)); + return (T)(object)unchecked((ulong)((ulong)(object)left * (ulong)(object)right)); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (T)(object)unchecked((Int64)((Int64)(object)left * (Int64)(object)right)); + return (T)(object)unchecked((long)((long)(object)left * (long)(object)right)); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (T)(object)unchecked((Single)((Single)(object)left * (Single)(object)right)); + return (T)(object)unchecked((float)((float)(object)left * (float)(object)right)); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (T)(object)unchecked((Double)((Double)(object)left * (Double)(object)right)); + return (T)(object)unchecked((double)((double)(object)left * (double)(object)right)); } else { @@ -4833,45 +4833,45 @@ private static T ScalarMultiply(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T ScalarDivide(T left, T right) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - return (T)(object)(Byte)((Byte)(object)left / (Byte)(object)right); + return (T)(object)(byte)((byte)(object)left / (byte)(object)right); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - return (T)(object)(SByte)((SByte)(object)left / (SByte)(object)right); + return (T)(object)(sbyte)((sbyte)(object)left / (sbyte)(object)right); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - return (T)(object)(UInt16)((UInt16)(object)left / (UInt16)(object)right); + return (T)(object)(ushort)((ushort)(object)left / (ushort)(object)right); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - return (T)(object)(Int16)((Int16)(object)left / (Int16)(object)right); + return (T)(object)(short)((short)(object)left / (short)(object)right); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - return (T)(object)(UInt32)((UInt32)(object)left / (UInt32)(object)right); + return (T)(object)(uint)((uint)(object)left / (uint)(object)right); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - return (T)(object)(Int32)((Int32)(object)left / (Int32)(object)right); + return (T)(object)(int)((int)(object)left / (int)(object)right); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - return (T)(object)(UInt64)((UInt64)(object)left / (UInt64)(object)right); + return (T)(object)(ulong)((ulong)(object)left / (ulong)(object)right); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - return (T)(object)(Int64)((Int64)(object)left / (Int64)(object)right); + return (T)(object)(long)((long)(object)left / (long)(object)right); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - return (T)(object)(Single)((Single)(object)left / (Single)(object)right); + return (T)(object)(float)((float)(object)left / (float)(object)right); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - return (T)(object)(Double)((Double)(object)left / (Double)(object)right); + return (T)(object)(double)((double)(object)left / (double)(object)right); } else { @@ -4882,54 +4882,54 @@ private static T ScalarDivide(T left, T right) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetOneValue() { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { - Byte value = 1; + byte value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { - SByte value = 1; + sbyte value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { - UInt16 value = 1; + ushort value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { - Int16 value = 1; + short value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { - UInt32 value = 1; + uint value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { - Int32 value = 1; + int value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { - UInt64 value = 1; + ulong value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { - Int64 value = 1; + long value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { - Single value = 1; + float value = 1; return (T)(object)value; } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { - Double value = 1; + double value = 1; return (T)(object)value; } else @@ -4941,43 +4941,43 @@ private static T GetOneValue() [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetAllBitsSetValue() { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { return (T)(object)ConstantHelper.GetByteWithAllBitsSet(); } - else if (typeof(T) == typeof(SByte)) + else if (typeof(T) == typeof(sbyte)) { return (T)(object)ConstantHelper.GetSByteWithAllBitsSet(); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { return (T)(object)ConstantHelper.GetUInt16WithAllBitsSet(); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { return (T)(object)ConstantHelper.GetInt16WithAllBitsSet(); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { return (T)(object)ConstantHelper.GetUInt32WithAllBitsSet(); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { return (T)(object)ConstantHelper.GetInt32WithAllBitsSet(); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { return (T)(object)ConstantHelper.GetUInt64WithAllBitsSet(); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { return (T)(object)ConstantHelper.GetInt64WithAllBitsSet(); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { return (T)(object)ConstantHelper.GetSingleWithAllBitsSet(); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { return (T)(object)ConstantHelper.GetDoubleWithAllBitsSet(); } @@ -5001,22 +5001,22 @@ public static partial class Vector /// [CLSCompliant(false)] [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - UInt16* lowPtr = stackalloc UInt16[elements / 2]; + int elements = Vector.Count; + ushort* lowPtr = stackalloc ushort[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (UInt16)source[i]; + lowPtr[i] = (ushort)source[i]; } - UInt16* highPtr = stackalloc UInt16[elements / 2]; + ushort* highPtr = stackalloc ushort[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (UInt16)source[i + (elements / 2)]; + highPtr[i] = (ushort)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5027,22 +5027,22 @@ public static unsafe void Widen(Vector source, out Vector low, out /// [CLSCompliant(false)] [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - UInt32* lowPtr = stackalloc UInt32[elements / 2]; + int elements = Vector.Count; + uint* lowPtr = stackalloc uint[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (UInt32)source[i]; + lowPtr[i] = (uint)source[i]; } - UInt32* highPtr = stackalloc UInt32[elements / 2]; + uint* highPtr = stackalloc uint[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (UInt32)source[i + (elements / 2)]; + highPtr[i] = (uint)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5053,22 +5053,22 @@ public static unsafe void Widen(Vector source, out Vector low, o /// [CLSCompliant(false)] [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - UInt64* lowPtr = stackalloc UInt64[elements / 2]; + int elements = Vector.Count; + ulong* lowPtr = stackalloc ulong[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (UInt64)source[i]; + lowPtr[i] = (ulong)source[i]; } - UInt64* highPtr = stackalloc UInt64[elements / 2]; + ulong* highPtr = stackalloc ulong[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (UInt64)source[i + (elements / 2)]; + highPtr[i] = (ulong)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5079,22 +5079,22 @@ public static unsafe void Widen(Vector source, out Vector low, o /// [CLSCompliant(false)] [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - Int16* lowPtr = stackalloc Int16[elements / 2]; + int elements = Vector.Count; + short* lowPtr = stackalloc short[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (Int16)source[i]; + lowPtr[i] = (short)source[i]; } - Int16* highPtr = stackalloc Int16[elements / 2]; + short* highPtr = stackalloc short[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (Int16)source[i + (elements / 2)]; + highPtr[i] = (short)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5104,22 +5104,22 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - Int32* lowPtr = stackalloc Int32[elements / 2]; + int elements = Vector.Count; + int* lowPtr = stackalloc int[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (Int32)source[i]; + lowPtr[i] = (int)source[i]; } - Int32* highPtr = stackalloc Int32[elements / 2]; + int* highPtr = stackalloc int[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (Int32)source[i + (elements / 2)]; + highPtr[i] = (int)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5129,22 +5129,22 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - Int64* lowPtr = stackalloc Int64[elements / 2]; + int elements = Vector.Count; + long* lowPtr = stackalloc long[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (Int64)source[i]; + lowPtr[i] = (long)source[i]; } - Int64* highPtr = stackalloc Int64[elements / 2]; + long* highPtr = stackalloc long[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (Int64)source[i + (elements / 2)]; + highPtr[i] = (long)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5154,22 +5154,22 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [Intrinsic] - public static unsafe void Widen(Vector source, out Vector low, out Vector high) + public static unsafe void Widen(Vector source, out Vector low, out Vector high) { - int elements = Vector.Count; - Double* lowPtr = stackalloc Double[elements / 2]; + int elements = Vector.Count; + double* lowPtr = stackalloc double[elements / 2]; for (int i = 0; i < elements / 2; i++) { - lowPtr[i] = (Double)source[i]; + lowPtr[i] = (double)source[i]; } - Double* highPtr = stackalloc Double[elements / 2]; + double* highPtr = stackalloc double[elements / 2]; for (int i = 0; i < elements / 2; i++) { - highPtr[i] = (Double)source[i + (elements / 2)]; + highPtr[i] = (double)source[i + (elements / 2)]; } - low = new Vector(lowPtr); - high = new Vector(highPtr); + low = new Vector(lowPtr); + high = new Vector(highPtr); } /// @@ -5180,22 +5180,22 @@ public static unsafe void Widen(Vector source, out Vector low, o /// [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - Byte* retPtr = stackalloc Byte[elements]; + int elements = Vector.Count; + byte* retPtr = stackalloc byte[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (Byte)low[i]; + retPtr[i] = (byte)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (Byte)high[i]; + retPtr[i + (elements / 2)] = (byte)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5207,22 +5207,22 @@ public static unsafe Vector Narrow(Vector low, Vector high /// [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - UInt16* retPtr = stackalloc UInt16[elements]; + int elements = Vector.Count; + ushort* retPtr = stackalloc ushort[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (UInt16)low[i]; + retPtr[i] = (ushort)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (UInt16)high[i]; + retPtr[i + (elements / 2)] = (ushort)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5234,22 +5234,22 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - UInt32* retPtr = stackalloc UInt32[elements]; + int elements = Vector.Count; + uint* retPtr = stackalloc uint[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (UInt32)low[i]; + retPtr[i] = (uint)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (UInt32)high[i]; + retPtr[i + (elements / 2)] = (uint)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5261,22 +5261,22 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - SByte* retPtr = stackalloc SByte[elements]; + int elements = Vector.Count; + sbyte* retPtr = stackalloc sbyte[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (SByte)low[i]; + retPtr[i] = (sbyte)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (SByte)high[i]; + retPtr[i + (elements / 2)] = (sbyte)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5287,22 +5287,22 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// A Vector{Int16} containing elements narrowed from the source vectors. /// [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - Int16* retPtr = stackalloc Int16[elements]; + int elements = Vector.Count; + short* retPtr = stackalloc short[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (Int16)low[i]; + retPtr[i] = (short)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (Int16)high[i]; + retPtr[i + (elements / 2)] = (short)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5313,22 +5313,22 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// A Vector{Int32} containing elements narrowed from the source vectors. /// [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - Int32* retPtr = stackalloc Int32[elements]; + int elements = Vector.Count; + int* retPtr = stackalloc int[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (Int32)low[i]; + retPtr[i] = (int)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (Int32)high[i]; + retPtr[i + (elements / 2)] = (int)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5339,22 +5339,22 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// A Vector{Single} containing elements narrowed from the source vectors. /// [Intrinsic] - public static unsafe Vector Narrow(Vector low, Vector high) + public static unsafe Vector Narrow(Vector low, Vector high) { unchecked { - int elements = Vector.Count; - Single* retPtr = stackalloc Single[elements]; + int elements = Vector.Count; + float* retPtr = stackalloc float[elements]; for (int i = 0; i < elements / 2; i++) { - retPtr[i] = (Single)low[i]; + retPtr[i] = (float)low[i]; } for (int i = 0; i < elements / 2; i++) { - retPtr[i + (elements / 2)] = (Single)high[i]; + retPtr[i + (elements / 2)] = (float)high[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5367,18 +5367,18 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// The source vector. /// The converted vector. [Intrinsic] - public static unsafe Vector ConvertToSingle(Vector value) + public static unsafe Vector ConvertToSingle(Vector value) { unchecked { - int elements = Vector.Count; - Single* retPtr = stackalloc Single[elements]; + int elements = Vector.Count; + float* retPtr = stackalloc float[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Single)value[i]; + retPtr[i] = (float)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5389,18 +5389,18 @@ public static unsafe Vector ConvertToSingle(Vector value) /// The converted vector. [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector ConvertToSingle(Vector value) + public static unsafe Vector ConvertToSingle(Vector value) { unchecked { - int elements = Vector.Count; - Single* retPtr = stackalloc Single[elements]; + int elements = Vector.Count; + float* retPtr = stackalloc float[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Single)value[i]; + retPtr[i] = (float)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5410,18 +5410,18 @@ public static unsafe Vector ConvertToSingle(Vector value) /// The source vector. /// The converted vector. [Intrinsic] - public static unsafe Vector ConvertToDouble(Vector value) + public static unsafe Vector ConvertToDouble(Vector value) { unchecked { - int elements = Vector.Count; - Double* retPtr = stackalloc Double[elements]; + int elements = Vector.Count; + double* retPtr = stackalloc double[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Double)value[i]; + retPtr[i] = (double)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5432,18 +5432,18 @@ public static unsafe Vector ConvertToDouble(Vector value) /// The converted vector. [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector ConvertToDouble(Vector value) + public static unsafe Vector ConvertToDouble(Vector value) { unchecked { - int elements = Vector.Count; - Double* retPtr = stackalloc Double[elements]; + int elements = Vector.Count; + double* retPtr = stackalloc double[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Double)value[i]; + retPtr[i] = (double)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5453,18 +5453,18 @@ public static unsafe Vector ConvertToDouble(Vector value) /// The source vector. /// The converted vector. [Intrinsic] - public static unsafe Vector ConvertToInt32(Vector value) + public static unsafe Vector ConvertToInt32(Vector value) { unchecked { - int elements = Vector.Count; - Int32* retPtr = stackalloc Int32[elements]; + int elements = Vector.Count; + int* retPtr = stackalloc int[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Int32)value[i]; + retPtr[i] = (int)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5475,18 +5475,18 @@ public static unsafe Vector ConvertToInt32(Vector value) /// The converted vector. [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector ConvertToUInt32(Vector value) + public static unsafe Vector ConvertToUInt32(Vector value) { unchecked { - int elements = Vector.Count; - UInt32* retPtr = stackalloc UInt32[elements]; + int elements = Vector.Count; + uint* retPtr = stackalloc uint[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (UInt32)value[i]; + retPtr[i] = (uint)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5496,18 +5496,18 @@ public static unsafe Vector ConvertToUInt32(Vector value) /// The source vector. /// The converted vector. [Intrinsic] - public static unsafe Vector ConvertToInt64(Vector value) + public static unsafe Vector ConvertToInt64(Vector value) { unchecked { - int elements = Vector.Count; - Int64* retPtr = stackalloc Int64[elements]; + int elements = Vector.Count; + long* retPtr = stackalloc long[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (Int64)value[i]; + retPtr[i] = (long)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } @@ -5518,18 +5518,18 @@ public static unsafe Vector ConvertToInt64(Vector value) /// The converted vector. [CLSCompliant(false)] [Intrinsic] - public static unsafe Vector ConvertToUInt64(Vector value) + public static unsafe Vector ConvertToUInt64(Vector value) { unchecked { - int elements = Vector.Count; - UInt64* retPtr = stackalloc UInt64[elements]; + int elements = Vector.Count; + ulong* retPtr = stackalloc ulong[elements]; for (int i = 0; i < elements; i++) { - retPtr[i] = (UInt64)value[i]; + retPtr[i] = (ulong)value[i]; } - return new Vector(retPtr); + return new Vector(retPtr); } } diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs b/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs index b69b058be94d..d3ed2509d872 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs @@ -22,9 +22,9 @@ public static partial class Vector /// The second source vector. /// The new vector with elements selected based on the mask. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector ConditionalSelect(Vector condition, Vector left, Vector right) + public static Vector ConditionalSelect(Vector condition, Vector left, Vector right) { - return (Vector)Vector.ConditionalSelect((Vector)condition, left, right); + return (Vector)Vector.ConditionalSelect((Vector)condition, left, right); } /// @@ -75,9 +75,9 @@ public static Vector Equals(Vector left, Vector right) where T : str /// The second vector to compare. /// The resultant vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector Equals(Vector left, Vector right) + public static Vector Equals(Vector left, Vector right) { - return (Vector)Vector.Equals(left, right); + return (Vector)Vector.Equals(left, right); } /// @@ -163,9 +163,9 @@ public static Vector LessThan(Vector left, Vector right) where T : s /// The second vector to compare. /// The resultant integral vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector LessThan(Vector left, Vector right) + public static Vector LessThan(Vector left, Vector right) { - return (Vector)Vector.LessThan(left, right); + return (Vector)Vector.LessThan(left, right); } /// @@ -256,9 +256,9 @@ public static Vector LessThanOrEqual(Vector left, Vector right) wher /// The second vector to compare. /// The resultant integral vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector LessThanOrEqual(Vector left, Vector right) + public static Vector LessThanOrEqual(Vector left, Vector right) { - return (Vector)Vector.LessThanOrEqual(left, right); + return (Vector)Vector.LessThanOrEqual(left, right); } /// @@ -349,9 +349,9 @@ public static Vector GreaterThan(Vector left, Vector right) where T /// The second vector to compare. /// The resultant integral vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector GreaterThan(Vector left, Vector right) + public static Vector GreaterThan(Vector left, Vector right) { - return (Vector)Vector.GreaterThan(left, right); + return (Vector)Vector.GreaterThan(left, right); } /// @@ -443,9 +443,9 @@ public static Vector GreaterThanOrEqual(Vector left, Vector right) w /// The second vector to compare. /// The resultant integral vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector GreaterThanOrEqual(Vector left, Vector right) + public static Vector GreaterThanOrEqual(Vector left, Vector right) { - return (Vector)Vector.GreaterThanOrEqual(left, right); + return (Vector)Vector.GreaterThanOrEqual(left, right); } /// @@ -752,9 +752,9 @@ public static Vector AndNot(Vector left, Vector right) where T : str /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorByte(Vector value) where T : struct + public static Vector AsVectorByte(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -764,9 +764,9 @@ public static Vector AsVectorByte(Vector value) where T : struct /// The reinterpreted vector. [CLSCompliant(false)] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorSByte(Vector value) where T : struct + public static Vector AsVectorSByte(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -776,9 +776,9 @@ public static Vector AsVectorSByte(Vector value) where T : struct /// The reinterpreted vector. [CLSCompliant(false)] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorUInt16(Vector value) where T : struct + public static Vector AsVectorUInt16(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -787,9 +787,9 @@ public static Vector AsVectorUInt16(Vector value) where T : struct /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorInt16(Vector value) where T : struct + public static Vector AsVectorInt16(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -799,9 +799,9 @@ public static Vector AsVectorInt16(Vector value) where T : struct /// The reinterpreted vector. [CLSCompliant(false)] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorUInt32(Vector value) where T : struct + public static Vector AsVectorUInt32(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -810,9 +810,9 @@ public static Vector AsVectorUInt32(Vector value) where T : struct /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorInt32(Vector value) where T : struct + public static Vector AsVectorInt32(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -822,9 +822,9 @@ public static Vector AsVectorInt32(Vector value) where T : struct /// The reinterpreted vector. [CLSCompliant(false)] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorUInt64(Vector value) where T : struct + public static Vector AsVectorUInt64(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } @@ -834,9 +834,9 @@ public static Vector AsVectorUInt64(Vector value) where T : struct /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorInt64(Vector value) where T : struct + public static Vector AsVectorInt64(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -845,9 +845,9 @@ public static Vector AsVectorInt64(Vector value) where T : struct /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorSingle(Vector value) where T : struct + public static Vector AsVectorSingle(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } /// @@ -856,9 +856,9 @@ public static Vector AsVectorSingle(Vector value) where T : struct /// The source vector /// The reinterpreted vector. [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - public static Vector AsVectorDouble(Vector value) where T : struct + public static Vector AsVectorDouble(Vector value) where T : struct { - return (Vector)value; + return (Vector)value; } #endregion Conversion Methods } diff --git a/src/System.Private.CoreLib/shared/System/ObsoleteAttribute.cs b/src/System.Private.CoreLib/shared/System/ObsoleteAttribute.cs index a63db137f878..748681756db9 100644 --- a/src/System.Private.CoreLib/shared/System/ObsoleteAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/ObsoleteAttribute.cs @@ -26,7 +26,7 @@ namespace System , Inherited = false)] public sealed class ObsoleteAttribute : Attribute { - private String _message; + private string _message; private bool _error; public ObsoleteAttribute() @@ -35,19 +35,19 @@ public ObsoleteAttribute() _error = false; } - public ObsoleteAttribute(String message) + public ObsoleteAttribute(string message) { _message = message; _error = false; } - public ObsoleteAttribute(String message, bool error) + public ObsoleteAttribute(string message, bool error) { _message = message; _error = error; } - public String Message + public string Message { get { return _message; } } diff --git a/src/System.Private.CoreLib/shared/System/OperationCanceledException.cs b/src/System.Private.CoreLib/shared/System/OperationCanceledException.cs index 8a472c9ff03e..0c311afd7d8e 100644 --- a/src/System.Private.CoreLib/shared/System/OperationCanceledException.cs +++ b/src/System.Private.CoreLib/shared/System/OperationCanceledException.cs @@ -36,13 +36,13 @@ public OperationCanceledException() HResult = HResults.COR_E_OPERATIONCANCELED; } - public OperationCanceledException(String message) + public OperationCanceledException(string message) : base(message) { HResult = HResults.COR_E_OPERATIONCANCELED; } - public OperationCanceledException(String message, Exception innerException) + public OperationCanceledException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_OPERATIONCANCELED; @@ -55,13 +55,13 @@ public OperationCanceledException(CancellationToken token) CancellationToken = token; } - public OperationCanceledException(String message, CancellationToken token) + public OperationCanceledException(string message, CancellationToken token) : this(message) { CancellationToken = token; } - public OperationCanceledException(String message, Exception innerException, CancellationToken token) + public OperationCanceledException(string message, Exception innerException, CancellationToken token) : this(message, innerException) { CancellationToken = token; diff --git a/src/System.Private.CoreLib/shared/System/OutOfMemoryException.cs b/src/System.Private.CoreLib/shared/System/OutOfMemoryException.cs index 7a56c6d7afde..194f3bfdad8f 100644 --- a/src/System.Private.CoreLib/shared/System/OutOfMemoryException.cs +++ b/src/System.Private.CoreLib/shared/System/OutOfMemoryException.cs @@ -24,13 +24,13 @@ public OutOfMemoryException() : base( HResult = HResults.COR_E_OUTOFMEMORY; } - public OutOfMemoryException(String message) + public OutOfMemoryException(string message) : base(message) { HResult = HResults.COR_E_OUTOFMEMORY; } - public OutOfMemoryException(String message, Exception innerException) + public OutOfMemoryException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_OUTOFMEMORY; diff --git a/src/System.Private.CoreLib/shared/System/OverflowException.cs b/src/System.Private.CoreLib/shared/System/OverflowException.cs index e28dcb87ed5e..c18fe3f7b37a 100644 --- a/src/System.Private.CoreLib/shared/System/OverflowException.cs +++ b/src/System.Private.CoreLib/shared/System/OverflowException.cs @@ -25,13 +25,13 @@ public OverflowException() HResult = HResults.COR_E_OVERFLOW; } - public OverflowException(String message) + public OverflowException(string message) : base(message) { HResult = HResults.COR_E_OVERFLOW; } - public OverflowException(String message, Exception innerException) + public OverflowException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_OVERFLOW; diff --git a/src/System.Private.CoreLib/shared/System/PlatformNotSupportedException.cs b/src/System.Private.CoreLib/shared/System/PlatformNotSupportedException.cs index 5039f3f44103..f9e461ed0a37 100644 --- a/src/System.Private.CoreLib/shared/System/PlatformNotSupportedException.cs +++ b/src/System.Private.CoreLib/shared/System/PlatformNotSupportedException.cs @@ -25,13 +25,13 @@ public PlatformNotSupportedException() HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; } - public PlatformNotSupportedException(String message) + public PlatformNotSupportedException(string message) : base(message) { HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; } - public PlatformNotSupportedException(String message, Exception inner) + public PlatformNotSupportedException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_PLATFORMNOTSUPPORTED; diff --git a/src/System.Private.CoreLib/shared/System/Random.cs b/src/System.Private.CoreLib/shared/System/Random.cs index 20f035e2e82e..ed79732c25a1 100644 --- a/src/System.Private.CoreLib/shared/System/Random.cs +++ b/src/System.Private.CoreLib/shared/System/Random.cs @@ -156,7 +156,7 @@ private static unsafe int GenerateGlobalSeed() /*=====================================Next===================================== - **Returns: An int [0..Int32.MaxValue) + **Returns: An int [0..int.MaxValue) **Arguments: None **Exceptions: None. ==============================================================================*/ @@ -169,7 +169,7 @@ private double GetSampleForLargeRange() { // The distribution of double value returned by Sample // is not distributed well enough for a large range. - // If we use Sample for a range [Int32.MinValue..Int32.MaxValue) + // If we use Sample for a range [int.MinValue..int.MaxValue) // We will end up getting even numbers only. int result = InternalSample(); diff --git a/src/System.Private.CoreLib/shared/System/RankException.cs b/src/System.Private.CoreLib/shared/System/RankException.cs index bdd2cd51f1e2..e1e7d169b844 100644 --- a/src/System.Private.CoreLib/shared/System/RankException.cs +++ b/src/System.Private.CoreLib/shared/System/RankException.cs @@ -26,13 +26,13 @@ public RankException() HResult = HResults.COR_E_RANK; } - public RankException(String message) + public RankException(string message) : base(message) { HResult = HResults.COR_E_RANK; } - public RankException(String message, Exception innerException) + public RankException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_RANK; diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs b/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs index 78f328a88033..02445ec5c640 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlyMemory.cs @@ -8,9 +8,8 @@ using System.Runtime.InteropServices; using EditorBrowsableAttribute = System.ComponentModel.EditorBrowsableAttribute; using EditorBrowsableState = System.ComponentModel.EditorBrowsableState; -#if !FEATURE_PORTABLE_SPAN + using Internal.Runtime.CompilerServices; -#endif // FEATURE_PORTABLE_SPAN namespace System { @@ -199,11 +198,7 @@ public ReadOnlySpan Span else if (typeof(T) == typeof(char) && _object is string s) { Debug.Assert(_length >= 0); -#if FEATURE_PORTABLE_SPAN - return new ReadOnlySpan(Unsafe.As>(s), MemoryExtensions.StringAdjustment, s.Length).Slice(_index, _length); -#else return new ReadOnlySpan(ref Unsafe.As(ref s.GetRawStringData()), s.Length).Slice(_index, _length); -#endif // FEATURE_PORTABLE_SPAN } else if (_object != null) { @@ -257,11 +252,7 @@ public unsafe MemoryHandle Pin() else if (typeof(T) == typeof(char) && _object is string s) { GCHandle handle = GCHandle.Alloc(s, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref s.GetRawStringData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } else if (_object is T[] array) @@ -269,21 +260,13 @@ public unsafe MemoryHandle Pin() // Array is already pre-pinned if (_length < 0) { -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add(Unsafe.AsPointer(ref MemoryMarshal.GetReference(array)), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer); } else { GCHandle handle = GCHandle.Alloc(array, GCHandleType.Pinned); -#if FEATURE_PORTABLE_SPAN - void* pointer = Unsafe.Add((void*)handle.AddrOfPinnedObject(), _index); -#else void* pointer = Unsafe.Add(Unsafe.AsPointer(ref array.GetRawSzArrayData()), _index); -#endif // FEATURE_PORTABLE_SPAN return new MemoryHandle(pointer, handle); } } diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs index cabda7a022cd..4fb039a0fc85 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.Fast.cs @@ -23,8 +23,6 @@ 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. /// - [DebuggerTypeProxy(typeof(SpanDebugView<>))] - [DebuggerDisplay("{ToString(),raw}")] [NonVersionable] public readonly ref partial struct ReadOnlySpan { diff --git a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs index 52a160ddeda1..61af717836a5 100644 --- a/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs +++ b/src/System.Private.CoreLib/shared/System/ReadOnlySpan.cs @@ -5,9 +5,8 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -#if !FEATURE_PORTABLE_SPAN + using System.Runtime.Versioning; -#endif // !FEATURE_PORTABLE_SPAN #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -26,9 +25,7 @@ public readonly ref partial struct ReadOnlySpan /// public int Length { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length; @@ -40,9 +37,7 @@ public int Length /// public bool IsEmpty { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length == 0; diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs index 7280869c026a..f22c8c40efa7 100644 --- a/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Assembly.cs @@ -141,7 +141,7 @@ public override string ToString() Returns true if the assembly was loaded from the global assembly cache. */ public virtual bool GlobalAssemblyCache { get { throw NotImplemented.ByDesign; } } - public virtual Int64 HostContext { get { throw NotImplemented.ByDesign; } } + public virtual long HostContext { get { throw NotImplemented.ByDesign; } } public override bool Equals(object o) => base.Equals(o); public override int GetHashCode() => base.GetHashCode(); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/AssemblyBuilderAccess.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderAccess.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/AssemblyBuilderAccess.cs diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/FlowControl.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/FlowControl.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/FlowControl.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/FlowControl.cs diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/Label.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Label.cs similarity index 97% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/Label.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/Label.cs index d67c0e6a19b5..e49d471a99fe 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/Label.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Label.cs @@ -49,7 +49,7 @@ public override int GetHashCode() return m_label; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is Label) return Equals((Label)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/OpCodeType.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodeType.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/OpCodeType.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodeType.cs diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/OpCodes.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodes.cs similarity index 99% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/OpCodes.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodes.cs index 81257bdd4b77..7690005e2f18 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/OpCodes.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Emit/OpCodes.cs @@ -2,27 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================ -** -** Class: OpCodes -** -** Purpose: Exposes all of the IL instructions supported by the runtime. -** -** THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND! -** See $(RepoRoot)\src\inc\OpCodeGen.pl for more information.** -==============================================================*/ - -using System; - namespace System.Reflection.Emit { - /// - /// Internal enum OpCodeValues for opcode values. - /// - /// - /// Note that the value names are used to construct publicly visible - /// ilasm-compatible opcode names, so their exact form is important! - /// + // + // Internal enums for opcode values. Note that the value names are used to construct + // publicly visible ilasm-compatible opcode names, so their exact form is important! + // internal enum OpCodeValues { Nop = 0x00, @@ -251,12 +236,14 @@ internal enum OpCodeValues Sizeof = 0xfe1c, Refanytype = 0xfe1d, Readonly_ = 0xfe1e, + // If you add more opcodes here, modify OpCode.Name to handle them correctly } /// /// - /// The IL instruction opcodes supported by the runtime. - /// The Specification of IL Instruction describes each Opcode. + /// The IL instruction opcodes supported by the + /// runtime. The IL Instruction Specification describes each + /// Opcode. /// /// /// @@ -2545,7 +2532,7 @@ public static bool TakesSingleByteArgument(OpCode inst) case OperandType.ShortInlineI: case OperandType.ShortInlineVar: return true; - }; + } return false; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs similarity index 84% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.cs index 72967cdfca18..1a144fcf44b8 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/Opcode.cs +++ b/src/System.Private.CoreLib/shared/System/Reflection/Emit/Opcode.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; using System.Threading; namespace System.Reflection.Emit @@ -13,26 +12,26 @@ public struct OpCode // Use packed bitfield for flags to avoid code bloat // - internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX + internal const int OperandTypeMask = 0x1F; // 000000000000000000000000000XXXXX - internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000 + internal const int FlowControlShift = 5; // 00000000000000000000000XXXX00000 internal const int FlowControlMask = 0x0F; - internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000 + internal const int OpCodeTypeShift = 9; // 00000000000000000000XXX000000000 internal const int OpCodeTypeMask = 0x07; - internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000 - internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000 + internal const int StackBehaviourPopShift = 12; // 000000000000000XXXXX000000000000 + internal const int StackBehaviourPushShift = 17; // 0000000000XXXXX00000000000000000 internal const int StackBehaviourMask = 0x1F; - internal const int SizeShift = 22; // 00000000XX0000000000000000000000 + internal const int SizeShift = 22; // 00000000XX0000000000000000000000 internal const int SizeMask = 0x03; internal const int EndsUncondJmpBlkFlag = 0x01000000; // 0000000X000000000000000000000000 - // unused // 0000XXX0000000000000000000000000 + // unused // 0000XXX0000000000000000000000000 - internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000 + internal const int StackChangeShift = 28; // XXXX0000000000000000000000000000 private OpCodeValues m_value; private int m_flags; @@ -111,7 +110,7 @@ public short Value private static volatile string[] g_nameCache; - public String Name + public string Name { get { @@ -123,7 +122,7 @@ public String Name string[] nameCache = g_nameCache; if (nameCache == null) { - nameCache = new String[0x11f]; + nameCache = new string[0x11f]; g_nameCache = nameCache; } @@ -145,7 +144,7 @@ public String Name } } - String name = Volatile.Read(ref nameCache[idx]); + string name = Volatile.Read(ref nameCache[idx]); if (name != null) return name; @@ -156,7 +155,7 @@ public String Name } } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is OpCode) return Equals((OpCode)obj); @@ -184,7 +183,7 @@ public override int GetHashCode() return Value; } - public override String ToString() + public override string ToString() { return Name; } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/OperandType.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/OperandType.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/OperandType.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/OperandType.cs diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/PEFileKinds.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/PEFileKinds.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/PEFileKinds.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/PEFileKinds.cs diff --git a/src/System.Private.CoreLib/shared/System/Reflection/Emit/PackingSize.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/PackingSize.cs new file mode 100644 index 000000000000..f734e1a3423c --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Reflection/Emit/PackingSize.cs @@ -0,0 +1,19 @@ +// 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. + +namespace System.Reflection.Emit +{ + public enum PackingSize + { + Unspecified = 0, + Size1 = 1, + Size2 = 2, + Size4 = 4, + Size8 = 8, + Size16 = 16, + Size32 = 32, + Size64 = 64, + Size128 = 128, + } +} diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/StackBehaviour.cs b/src/System.Private.CoreLib/shared/System/Reflection/Emit/StackBehaviour.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Reflection/Emit/StackBehaviour.cs rename to src/System.Private.CoreLib/shared/System/Reflection/Emit/StackBehaviour.cs diff --git a/src/System.Private.CoreLib/shared/System/Resources/FastResourceComparer.cs b/src/System.Private.CoreLib/shared/System/Resources/FastResourceComparer.cs index 59ca9437d0ae..6b813a0cec32 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/FastResourceComparer.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/FastResourceComparer.cs @@ -26,7 +26,7 @@ internal sealed class FastResourceComparer : IComparer, IEqualityComparer, IComp internal static readonly FastResourceComparer Default = new FastResourceComparer(); // Implements IHashCodeProvider too, due to Hashtable requirements. - public int GetHashCode(Object key) + public int GetHashCode(object key) { string s = (string)key; return FastResourceComparer.HashFunction(s); @@ -52,7 +52,7 @@ internal static int HashFunction(string key) } // Compares Strings quickly in a case-sensitive way - public int Compare(Object a, Object b) + public int Compare(object a, object b) { if (a == b) return 0; string sa = (string)a; @@ -70,7 +70,7 @@ public bool Equals(string a, string b) return string.Equals(a, b); } - public new bool Equals(Object a, Object b) + public new bool Equals(object a, object b) { if (a == b) return true; string sa = (string)a; diff --git a/src/System.Private.CoreLib/shared/System/Resources/MissingSatelliteAssemblyException.cs b/src/System.Private.CoreLib/shared/System/Resources/MissingSatelliteAssemblyException.cs index af547b21f16c..0bbc62673456 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/MissingSatelliteAssemblyException.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/MissingSatelliteAssemblyException.cs @@ -24,7 +24,7 @@ namespace System.Resources [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class MissingSatelliteAssemblyException : SystemException { - private String _cultureName; + private string _cultureName; public MissingSatelliteAssemblyException() : base(SR.MissingSatelliteAssembly_Default) @@ -38,7 +38,7 @@ public MissingSatelliteAssemblyException(string message) HResult = System.HResults.COR_E_MISSINGSATELLITEASSEMBLY; } - public MissingSatelliteAssemblyException(string message, String cultureName) + public MissingSatelliteAssemblyException(string message, string cultureName) : base(message) { HResult = System.HResults.COR_E_MISSINGSATELLITEASSEMBLY; @@ -56,7 +56,7 @@ protected MissingSatelliteAssemblyException(SerializationInfo info, StreamingCon { } - public String CultureName + public string CultureName { get { return _cultureName; } } diff --git a/src/System.Private.CoreLib/shared/System/Resources/RuntimeResourceSet.cs b/src/System.Private.CoreLib/shared/System/Resources/RuntimeResourceSet.cs index a63e68c19d25..426e17bdba76 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/RuntimeResourceSet.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/RuntimeResourceSet.cs @@ -173,7 +173,7 @@ sealed class RuntimeResourceSet : ResourceSet, IEnumerable // for arbitrarily long times, since the object is usually a string // literal that will live for the lifetime of the appdomain. The // value is a ResourceLocator instance, which might cache the object. - private Dictionary _resCache; + private Dictionary _resCache; // For our special load-on-demand reader, cache the cast. The @@ -185,15 +185,15 @@ sealed class RuntimeResourceSet : ResourceSet, IEnumerable // want to fill this out if we can avoid it. The problem is resource // fallback will somewhat regularly cause us to look up resources that // don't exist. - private Dictionary _caseInsensitiveTable; + private Dictionary _caseInsensitiveTable; // If we're not using our custom reader, then enumerate through all // the resources once, adding them into the table. private bool _haveReadFromReader; - internal RuntimeResourceSet(String fileName) : base(false) + internal RuntimeResourceSet(string fileName) : base(false) { - _resCache = new Dictionary(FastResourceComparer.Default); + _resCache = new Dictionary(FastResourceComparer.Default); Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read); _defaultReader = new ResourceReader(stream, _resCache); Reader = _defaultReader; @@ -201,7 +201,7 @@ internal RuntimeResourceSet(String fileName) : base(false) internal RuntimeResourceSet(Stream stream) : base(false) { - _resCache = new Dictionary(FastResourceComparer.Default); + _resCache = new Dictionary(FastResourceComparer.Default); _defaultReader = new ResourceReader(stream, _resCache); Reader = _defaultReader; } @@ -256,36 +256,36 @@ private IDictionaryEnumerator GetEnumeratorHelper() } - public override String GetString(String key) + public override string GetString(string key) { - Object o = GetObject(key, false, true); - return (String)o; + object o = GetObject(key, false, true); + return (string)o; } - public override String GetString(String key, bool ignoreCase) + public override string GetString(string key, bool ignoreCase) { - Object o = GetObject(key, ignoreCase, true); - return (String)o; + object o = GetObject(key, ignoreCase, true); + return (string)o; } - public override Object GetObject(String key) + public override object GetObject(string key) { return GetObject(key, false, false); } - public override Object GetObject(String key, bool ignoreCase) + public override object GetObject(string key, bool ignoreCase) { return GetObject(key, ignoreCase, false); } - private Object GetObject(String key, bool ignoreCase, bool isString) + private object GetObject(string key, bool ignoreCase, bool isString) { if (key == null) throw new ArgumentNullException(nameof(key)); if (Reader == null || _resCache == null) throw new ObjectDisposedException(null, SR.ObjectDisposed_ResourceSet); - Object value = null; + object value = null; ResourceLocator resLocation; lock (Reader) @@ -348,7 +348,7 @@ private Object GetObject(String key, bool ignoreCase, bool isString) // If necessary, init our case insensitive hash table. if (ignoreCase && _caseInsensitiveTable == null) { - _caseInsensitiveTable = new Dictionary(StringComparer.OrdinalIgnoreCase); + _caseInsensitiveTable = new Dictionary(StringComparer.OrdinalIgnoreCase); } if (_defaultReader == null) @@ -357,7 +357,7 @@ private Object GetObject(String key, bool ignoreCase, bool isString) while (en.MoveNext()) { DictionaryEntry entry = en.Entry; - String readKey = (String)entry.Key; + string readKey = (string)entry.Key; ResourceLocator resLoc = new ResourceLocator(-1, entry.Value); _resCache.Add(readKey, resLoc); if (ignoreCase) @@ -375,7 +375,7 @@ private Object GetObject(String key, bool ignoreCase, bool isString) while (en.MoveNext()) { // Note: Always ask for the resource key before the data position. - String currentKey = (String)en.Key; + string currentKey = (string)en.Key; int dataPos = en.DataPosition; ResourceLocator resLoc = new ResourceLocator(dataPos, null); _caseInsensitiveTable.Add(currentKey, resLoc); @@ -383,7 +383,7 @@ private Object GetObject(String key, bool ignoreCase, bool isString) } _haveReadFromReader = true; } - Object obj = null; + object obj = null; bool found = false; bool keyInWrongCase = false; if (_defaultReader != null) @@ -410,11 +410,11 @@ private Object GetObject(String key, bool ignoreCase, bool isString) // The last parameter indicates whether the lookup required a // case-insensitive lookup to succeed, indicating we shouldn't add // the ResourceLocation to our case-sensitive cache. - private Object ResolveResourceLocator(ResourceLocator resLocation, String key, Dictionary copyOfCache, bool keyInWrongCase) + private object ResolveResourceLocator(ResourceLocator resLocation, string key, Dictionary copyOfCache, bool keyInWrongCase) { // We need to explicitly resolve loosely linked manifest // resources, and we need to resolve ResourceLocators with null objects. - Object value = resLocation.Value; + object value = resLocation.Value; if (value == null) { ResourceTypeCode typeCode; diff --git a/src/System.Private.CoreLib/shared/System/Resources/SatelliteContractVersionAttribute.cs b/src/System.Private.CoreLib/shared/System/Resources/SatelliteContractVersionAttribute.cs index 0707447677f4..aeccadca99bb 100644 --- a/src/System.Private.CoreLib/shared/System/Resources/SatelliteContractVersionAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Resources/SatelliteContractVersionAttribute.cs @@ -19,13 +19,13 @@ namespace System.Resources [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = false)] public sealed class SatelliteContractVersionAttribute : Attribute { - public SatelliteContractVersionAttribute(String version) + public SatelliteContractVersionAttribute(string version) { if (version == null) throw new ArgumentNullException(nameof(version)); Version = version; } - public String Version { get; } + public string Version { get; } } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CallerArgumentExpressionAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CallerArgumentExpressionAttribute.cs new file mode 100644 index 000000000000..6e1c4c56cd05 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CallerArgumentExpressionAttribute.cs @@ -0,0 +1,17 @@ +// 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. + +namespace System.Runtime.CompilerServices +{ + [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] + public sealed class CallerArgumentExpressionAttribute : Attribute + { + public CallerArgumentExpressionAttribute(string parameterName) + { + ParameterName = parameterName; + } + + public string ParameterName { get; } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs index f75693eb4057..d3116cc8ad85 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/CustomConstantAttribute.cs @@ -7,6 +7,6 @@ namespace System.Runtime.CompilerServices [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] public abstract class CustomConstantAttribute : Attribute { - public abstract Object Value { get; } + public abstract object Value { get; } } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs index 813e6803bfa4..44c497706e30 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DateTimeConstantAttribute.cs @@ -14,6 +14,6 @@ public DateTimeConstantAttribute(long ticks) _date = new DateTime(ticks); } - public override Object Value => _date; + public override object Value => _date; } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs index 19db84eb43be..521a3abe9cb6 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DecimalConstantAttribute.cs @@ -9,7 +9,7 @@ namespace System.Runtime.CompilerServices [AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] public sealed class DecimalConstantAttribute : Attribute { - private Decimal _dec; + private decimal _dec; [CLSCompliant(false)] public DecimalConstantAttribute( @@ -20,7 +20,7 @@ public DecimalConstantAttribute( uint low ) { - _dec = new Decimal((int)low, (int)mid, (int)hi, (sign != 0), scale); + _dec = new decimal((int)low, (int)mid, (int)hi, (sign != 0), scale); } public DecimalConstantAttribute( @@ -31,9 +31,9 @@ public DecimalConstantAttribute( int low ) { - _dec = new Decimal(low, mid, hi, (sign != 0), scale); + _dec = new decimal(low, mid, hi, (sign != 0), scale); } - public Decimal Value => _dec; + public decimal Value => _dec; } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs index 0fe07edc9e26..7bb7acec4171 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/DependencyAttribute.cs @@ -7,13 +7,13 @@ namespace System.Runtime.CompilerServices [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] public sealed class DependencyAttribute : Attribute { - public DependencyAttribute(String dependentAssemblyArgument, LoadHint loadHintArgument) + public DependencyAttribute(string dependentAssemblyArgument, LoadHint loadHintArgument) { DependentAssembly = dependentAssemblyArgument; LoadHint = loadHintArgument; } - public String DependentAssembly { get; } + public string DependentAssembly { get; } public LoadHint LoadHint { get; } } } \ No newline at end of file diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IndexerNameAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IndexerNameAttribute.cs index ea843b3daaa6..bc76250adc82 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IndexerNameAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/IndexerNameAttribute.cs @@ -7,7 +7,7 @@ namespace System.Runtime.CompilerServices [AttributeUsage(AttributeTargets.Property, Inherited = true)] public sealed class IndexerNameAttribute : Attribute { - public IndexerNameAttribute(String indexerName) + public IndexerNameAttribute(string indexerName) { } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ReferenceAssemblyAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ReferenceAssemblyAttribute.cs index f3842ec562df..6c6fe9e258c8 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ReferenceAssemblyAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/ReferenceAssemblyAttribute.cs @@ -22,11 +22,11 @@ public ReferenceAssemblyAttribute() { } - public ReferenceAssemblyAttribute(String description) + public ReferenceAssemblyAttribute(string description) { Description = description; } - public String Description { get; } + public string Description { get; } } } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs index 493d984155fd..030278dcf502 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/CompilerServices/TaskAwaiter.cs @@ -318,7 +318,7 @@ private static Action OutputWaitEtwEvents(Task task, Action continuation) 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). + // case the antecedent is a promise (in the other cases this is already the case). if (innerEtwLog.TasksSetActivityIds && (innerTask.Options & (TaskCreationOptions)InternalTaskOptions.PromiseTask) != 0) EventSource.SetCurrentThreadActivityId(TplEtwProvider.CreateGuidForTaskID(innerTask.Id), out prevActivityId); } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MarshalDirectiveException.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MarshalDirectiveException.cs index 1d0d59fab6fa..3bb1140f5e91 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MarshalDirectiveException.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MarshalDirectiveException.cs @@ -27,13 +27,13 @@ public MarshalDirectiveException() HResult = HResults.COR_E_MARSHALDIRECTIVE; } - public MarshalDirectiveException(String message) + public MarshalDirectiveException(string message) : base(message) { HResult = HResults.COR_E_MARSHALDIRECTIVE; } - public MarshalDirectiveException(String message, Exception inner) + public MarshalDirectiveException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_MARSHALDIRECTIVE; diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs index e212f7d4b0bc..e3cf0a84e248 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs @@ -22,7 +22,7 @@ public static partial class MemoryMarshal /// Thrown when contains pointers. /// /// - /// Thrown if the Length property of the new Span would exceed Int32.MaxValue. + /// Thrown if the Length property of the new Span would exceed int.MaxValue. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span AsBytes(Span span) @@ -45,7 +45,7 @@ ref Unsafe.As(ref GetReference(span)), /// Thrown when contains pointers. /// /// - /// Thrown if the Length property of the new Span would exceed Int32.MaxValue. + /// Thrown if the Length property of the new Span would exceed int.MaxValue. /// [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan AsBytes(ReadOnlySpan span) @@ -102,7 +102,7 @@ public static Memory AsMemory(ReadOnlyMemory memory) => /// These types may not contain pointers or references. This is checked at runtime in order to preserve type safety. /// /// - /// Supported only for platforms that support misaligned memory access. + /// Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. /// /// The source slice, of type . /// @@ -157,7 +157,7 @@ ref Unsafe.As(ref span._pointer.Value), /// These types may not contain pointers or references. This is checked at runtime in order to preserve type safety. /// /// - /// Supported only for platforms that support misaligned memory access. + /// Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. /// /// The source slice, of type . /// @@ -214,6 +214,7 @@ ref Unsafe.As(ref MemoryMarshal.GetReference(span)), /// /// A reference to data. /// The number of elements the memory contains. + /// The lifetime of the returned span will not be validated for safety by span-aware languages. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span CreateSpan(ref T reference, int length) => new Span(ref reference, length); @@ -224,6 +225,7 @@ ref Unsafe.As(ref MemoryMarshal.GetReference(span)), /// /// A reference to data. /// The number of elements the memory contains. + /// The lifetime of the returned span will not be validated for safety by span-aware languages. [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan CreateReadOnlySpan(ref T reference, int length) => new ReadOnlySpan(ref reference, length); } diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs index 77f497512b7c..fcc9c4f41a5a 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/MemoryMarshal.cs @@ -7,9 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif namespace System.Runtime.InteropServices { @@ -43,11 +41,7 @@ public static bool TryGetArray(ReadOnlyMemory memory, out ArraySegment if ((length & ReadOnlyMemory.RemoveFlagsBitMask) == 0) { -#if FEATURE_PORTABLE_SPAN - segment = new ArraySegment(SpanHelpers.PerTypeValues.EmptyArray); -#else segment = ArraySegment.Empty; -#endif // FEATURE_PORTABLE_SPAN return true; } @@ -147,17 +141,10 @@ public static bool TryGetString(ReadOnlyMemory memory, out string text, ou public static T Read(ReadOnlySpan source) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > source.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); @@ -173,17 +160,10 @@ public static T Read(ReadOnlySpan source) public static bool TryRead(ReadOnlySpan source, out T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > (uint)source.Length) { value = default; @@ -200,17 +180,10 @@ public static bool TryRead(ReadOnlySpan source, out T value) public static void Write(Span destination, ref T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if ((uint)Unsafe.SizeOf() > (uint)destination.Length) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); @@ -226,17 +199,10 @@ public static void Write(Span destination, ref T value) public static bool TryWrite(Span destination, ref T value) where T : struct { -#if netstandard - if (SpanHelpers.IsReferenceOrContainsReferences()) - { - ThrowHelper.ThrowArgumentException_InvalidTypeWithPointersNotSupported(typeof(T)); - } -#else if (RuntimeHelpers.IsReferenceOrContainsReferences()) { ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); } -#endif if (Unsafe.SizeOf() > (uint)destination.Length) { return false; @@ -245,6 +211,50 @@ public static bool TryWrite(Span destination, ref T value) return true; } + /// + /// Re-interprets a span of bytes as a reference to structure of type T. + /// The type may not contain pointers or references. This is checked at runtime in order to preserve type safety. + /// + /// + /// Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref T AsRef(Span span) + where T : struct + { + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); + } + if (Unsafe.SizeOf() > (uint)span.Length) + { + ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); + } + return ref Unsafe.As(ref GetReference(span)); + } + + /// + /// Re-interprets a span of bytes as a reference to structure of type T. + /// The type may not contain pointers or references. This is checked at runtime in order to preserve type safety. + /// + /// + /// Supported only for platforms that support misaligned memory access or when the memory block is aligned by other means. + /// + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static ref readonly T AsRef(ReadOnlySpan span) + where T : struct + { + if (RuntimeHelpers.IsReferenceOrContainsReferences()) + { + ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(T)); + } + if (Unsafe.SizeOf() > (uint)span.Length) + { + ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length); + } + return ref Unsafe.As(ref GetReference(span)); + } + /// /// Creates a new memory over the portion of the pre-pinned target array beginning /// at 'start' index and ending at 'end' index (exclusive). diff --git a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs index 5b72b0138642..661a7edceafa 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/InteropServices/SafeBuffer.cs @@ -77,7 +77,7 @@ public abstract unsafe class SafeBuffer : SafeHandleZeroOrMinusOneIsInvalid { // Steal UIntPtr.MaxValue as our uninitialized value. private static readonly UIntPtr Uninitialized = (UIntPtr.Size == 4) ? - ((UIntPtr)UInt32.MaxValue) : ((UIntPtr)UInt64.MaxValue); + ((UIntPtr)uint.MaxValue) : ((UIntPtr)ulong.MaxValue); private UIntPtr _numBytes; @@ -94,7 +94,7 @@ protected SafeBuffer(bool ownsHandle) : base(ownsHandle) [CLSCompliant(false)] public void Initialize(ulong numBytes) { - if (IntPtr.Size == 4 && numBytes > UInt32.MaxValue) + if (IntPtr.Size == 4 && numBytes > uint.MaxValue) throw new ArgumentOutOfRangeException(nameof(numBytes), SR.ArgumentOutOfRange_AddressSpace); if (numBytes >= (ulong)Uninitialized) @@ -110,7 +110,7 @@ public void Initialize(ulong numBytes) [CLSCompliant(false)] public void Initialize(uint numElements, uint sizeOfEachElement) { - if (IntPtr.Size == 4 && numElements * sizeOfEachElement > UInt32.MaxValue) + if (IntPtr.Size == 4 && numElements * sizeOfEachElement > uint.MaxValue) throw new ArgumentOutOfRangeException("numBytes", SR.ArgumentOutOfRange_AddressSpace); if (numElements * sizeOfEachElement >= (ulong)Uninitialized) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Aes.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Base.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Base.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Base.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha1.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Sha256.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Arm/Arm64/Simd.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128DebugView.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128DebugView.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128DebugView.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector128DebugView.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256DebugView.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256DebugView.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector256DebugView.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector256DebugView.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64DebugView.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64DebugView.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector64DebugView.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/Vector64DebugView.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs similarity index 53% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs index 5df8f266dfac..c31da3964d88 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.PlatformNotSupported.cs @@ -15,44 +15,24 @@ public static class Aes { public static bool IsSupported { get { return false; } } - /// - /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey) - /// AESDEC xmm, xmm/m128 - /// - public static Vector128 Decrypt(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey) /// AESDEC xmm, xmm/m128 /// public static Vector128 Decrypt(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey) - /// AESDECLAST xmm, xmm/m128 - /// - public static Vector128 DecryptLast(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey) /// AESDECLAST xmm, xmm/m128 /// public static Vector128 DecryptLast(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey) - /// AESENC xmm, xmm/m128 - /// - public static Vector128 Encrypt(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey) /// AESENC xmm, xmm/m128 /// public static Vector128 Encrypt(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey) - /// AESENCLAST xmm, xmm/m128 - /// - public static Vector128 EncryptLast(Vector128 value, Vector128 roundKey) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey) /// AESENCLAST xmm, xmm/m128 @@ -63,18 +43,8 @@ public static class Aes /// __m128i _mm_aesimc_si128 (__m128i a) /// AESIMC xmm, xmm/m128 /// - public static Vector128 InvisibleMixColumn(Vector128 value) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm_aesimc_si128 (__m128i a) - /// AESIMC xmm, xmm/m128 - /// - public static Vector128 InvisibleMixColumn(Vector128 value) { throw new PlatformNotSupportedException(); } + public static Vector128 InverseMixColumns(Vector128 value) { throw new PlatformNotSupportedException(); } - /// - /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8) - /// AESKEYGENASSIST xmm, xmm/m128, imm8 - /// - public static Vector128 KeygenAssist(Vector128 value, byte control) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8) /// AESKEYGENASSIST xmm, xmm/m128, imm8 diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.cs similarity index 54% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.cs index 349919a21ca6..75db4b1979ed 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Aes.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Aes.cs @@ -15,44 +15,24 @@ public static class Aes { public static bool IsSupported { get => IsSupported; } - /// - /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey) - /// AESDEC xmm, xmm/m128 - /// - public static Vector128 Decrypt(Vector128 value, Vector128 roundKey) => Decrypt(value, roundKey); /// /// __m128i _mm_aesdec_si128 (__m128i a, __m128i RoundKey) /// AESDEC xmm, xmm/m128 /// public static Vector128 Decrypt(Vector128 value, Vector128 roundKey) => Decrypt(value, roundKey); - /// - /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey) - /// AESDECLAST xmm, xmm/m128 - /// - public static Vector128 DecryptLast(Vector128 value, Vector128 roundKey) => DecryptLast(value, roundKey); /// /// __m128i _mm_aesdeclast_si128 (__m128i a, __m128i RoundKey) /// AESDECLAST xmm, xmm/m128 /// public static Vector128 DecryptLast(Vector128 value, Vector128 roundKey) => DecryptLast(value, roundKey); - /// - /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey) - /// AESENC xmm, xmm/m128 - /// - public static Vector128 Encrypt(Vector128 value, Vector128 roundKey) => Encrypt(value, roundKey); /// /// __m128i _mm_aesenc_si128 (__m128i a, __m128i RoundKey) /// AESENC xmm, xmm/m128 /// public static Vector128 Encrypt(Vector128 value, Vector128 roundKey) => Encrypt(value, roundKey); - /// - /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey) - /// AESENCLAST xmm, xmm/m128 - /// - public static Vector128 EncryptLast(Vector128 value, Vector128 roundKey) => EncryptLast(value, roundKey); /// /// __m128i _mm_aesenclast_si128 (__m128i a, __m128i RoundKey) /// AESENCLAST xmm, xmm/m128 @@ -63,18 +43,8 @@ public static class Aes /// __m128i _mm_aesimc_si128 (__m128i a) /// AESIMC xmm, xmm/m128 /// - public static Vector128 InvisibleMixColumn(Vector128 value) => InvisibleMixColumn(value); - /// - /// __m128i _mm_aesimc_si128 (__m128i a) - /// AESIMC xmm, xmm/m128 - /// - public static Vector128 InvisibleMixColumn(Vector128 value) => InvisibleMixColumn(value); + public static Vector128 InverseMixColumns(Vector128 value) => InverseMixColumns(value); - /// - /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8) - /// AESKEYGENASSIST xmm, xmm/m128, imm8 - /// - public static Vector128 KeygenAssist(Vector128 value, byte control) => KeygenAssist(value, control); /// /// __m128i _mm_aeskeygenassist_si128 (__m128i a, const int imm8) /// AESKEYGENASSIST xmm, xmm/m128, imm8 diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs similarity index 98% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs index 1fd61ec3e1e1..03a33131c88c 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.PlatformNotSupported.cs @@ -234,11 +234,6 @@ public static class Avx /// public static Vector256 DuplicateOddIndexed(Vector256 value) { throw new PlatformNotSupportedException(); } - /// - /// __int8 _mm256_extract_epi8 (__m256i a, const int index) - /// HELPER - /// - public static sbyte Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __int8 _mm256_extract_epi8 (__m256i a, const int index) /// HELPER @@ -248,11 +243,6 @@ public static class Avx /// __int16 _mm256_extract_epi16 (__m256i a, const int index) /// HELPER /// - public static short Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } - /// - /// __int16 _mm256_extract_epi16 (__m256i a, const int index) - /// HELPER - /// public static ushort Extract(Vector256 value, byte index) { throw new PlatformNotSupportedException(); } /// /// __int32 _mm256_extract_epi32 (__m256i a, const int index) @@ -638,45 +628,45 @@ public static class Avx /// __m128 _mm_maskload_ps (float const * mem_addr, __m128i mask) /// VMASKMOVPS xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) { throw new PlatformNotSupportedException(); } /// /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask) /// VMASKMOVPD xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) { throw new PlatformNotSupportedException(); } /// /// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask) /// VMASKMOVPS ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) { throw new PlatformNotSupportedException(); } /// /// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask) /// VMASKMOVPD ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) { throw new PlatformNotSupportedException(); } + public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) { throw new PlatformNotSupportedException(); } /// /// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a) /// VMASKMOVPS m128, xmm, xmm /// - public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } /// /// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a) /// VMASKMOVPD m128, xmm, xmm /// - public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) { throw new PlatformNotSupportedException(); } /// /// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a) /// VMASKMOVPS m256, ymm, ymm /// - public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } /// /// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a) /// VMASKMOVPD m256, ymm, ymm /// - public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } + public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) { throw new PlatformNotSupportedException(); } /// /// __m256 _mm256_max_ps (__m256 a, __m256 b) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs similarity index 96% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs index fdb349b120ee..2115e9609b34 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx.cs @@ -4,7 +4,7 @@ using System; using System.Runtime.Intrinsics; -using System.Runtime.CompilerServices; +using Internal.Runtime.CompilerServices; namespace System.Runtime.Intrinsics.X86 { @@ -235,50 +235,19 @@ public static class Avx /// public static Vector256 DuplicateOddIndexed(Vector256 value) => DuplicateOddIndexed(value); - /// - /// __int8 _mm256_extract_epi8 (__m256i a, const int index) - /// HELPER - /// - public static sbyte Extract(Vector256 value, byte index) - { - unsafe - { - index &= 0x1F; - sbyte* buffer = stackalloc sbyte[32]; - Store(buffer, value); - return buffer[index]; - } - } - /// /// __int8 _mm256_extract_epi8 (__m256i a, const int index) /// HELPER /// public static byte Extract(Vector256 value, byte index) { - unsafe + if (!IsSupported) { - index &= 0x1F; - byte* buffer = stackalloc byte[32]; - Store(buffer, value); - return buffer[index]; + throw new PlatformNotSupportedException(); } + return Unsafe.Add(ref Unsafe.As, byte>(ref value), index & 0x1F); } - /// - /// __int16 _mm256_extract_epi16 (__m256i a, const int index) - /// HELPER - /// - public static short Extract(Vector256 value, byte index) - { - unsafe - { - index &= 0xF; - short* buffer = stackalloc short[16]; - Store(buffer, value); - return buffer[index]; - } - } /// /// __int16 _mm256_extract_epi16 (__m256i a, const int index) @@ -286,13 +255,11 @@ public static short Extract(Vector256 value, byte index) /// public static ushort Extract(Vector256 value, byte index) { - unsafe + if (!IsSupported) { - index &= 0xF; - ushort* buffer = stackalloc ushort[16]; - Store(buffer, value); - return buffer[index]; + throw new PlatformNotSupportedException(); } + return Unsafe.Add(ref Unsafe.As, ushort>(ref value), index & 0xF); } /// @@ -301,13 +268,11 @@ public static ushort Extract(Vector256 value, byte index) /// public static int Extract(Vector256 value, byte index) { - unsafe + if (!IsSupported) { - index &= 0x7; - int* buffer = stackalloc int[8]; - Store(buffer, value); - return buffer[index]; + throw new PlatformNotSupportedException(); } + return Unsafe.Add(ref Unsafe.As, int>(ref value), index & 0x7); } /// @@ -316,13 +281,11 @@ public static int Extract(Vector256 value, byte index) /// public static uint Extract(Vector256 value, byte index) { - unsafe + if (!IsSupported) { - index &= 0x7; - uint* buffer = stackalloc uint[8]; - Store(buffer, value); - return buffer[index]; + throw new PlatformNotSupportedException(); } + return Unsafe.Add(ref Unsafe.As, uint>(ref value), index & 0x7); } /// @@ -331,17 +294,11 @@ public static uint Extract(Vector256 value, byte index) /// public static long Extract(Vector256 value, byte index) { - if (IntPtr.Size != 8) + if (!IsSupported || (IntPtr.Size != 8)) { throw new PlatformNotSupportedException(); } - unsafe - { - index &= 0x3; - long* buffer = stackalloc long[4]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, long>(ref value), index & 0x3); } /// @@ -350,17 +307,11 @@ public static long Extract(Vector256 value, byte index) /// public static ulong Extract(Vector256 value, byte index) { - if (IntPtr.Size != 8) + if (!IsSupported || (IntPtr.Size != 8)) { throw new PlatformNotSupportedException(); } - unsafe - { - index &= 0x3; - ulong* buffer = stackalloc ulong[4]; - Store(buffer, value); - return buffer[index]; - } + return Unsafe.Add(ref Unsafe.As, ulong>(ref value), index & 0x3); } /// @@ -588,6 +539,11 @@ public static Vector256 Insert(Vector256 value, uint data, byte inde /// public static Vector256 Insert(Vector256 value, long data, byte index) { + if (IntPtr.Size != 8) + { + throw new PlatformNotSupportedException(); + } + unsafe { index &= 0x3; @@ -604,6 +560,11 @@ public static Vector256 Insert(Vector256 value, long data, byte inde /// public static Vector256 Insert(Vector256 value, ulong data, byte index) { + if (IntPtr.Size != 8) + { + throw new PlatformNotSupportedException(); + } + unsafe { index &= 0x3; @@ -825,45 +786,45 @@ public static Vector256 InsertVector128(Vector256 value, Vector128 d /// __m128 _mm_maskload_ps (float const * mem_addr, __m128i mask) /// VMASKMOVPS xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) => MaskLoad(address, mask); + public static unsafe Vector128 MaskLoad(float* address, Vector128 mask) => MaskLoad(address, mask); /// /// __m128d _mm_maskload_pd (double const * mem_addr, __m128i mask) /// VMASKMOVPD xmm, xmm, m128 /// - public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) => MaskLoad(address, mask); + public static unsafe Vector128 MaskLoad(double* address, Vector128 mask) => MaskLoad(address, mask); /// /// __m256 _mm256_maskload_ps (float const * mem_addr, __m256i mask) /// VMASKMOVPS ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) => MaskLoad(address, mask); + public static unsafe Vector256 MaskLoad(float* address, Vector256 mask) => MaskLoad(address, mask); /// /// __m256d _mm256_maskload_pd (double const * mem_addr, __m256i mask) /// VMASKMOVPD ymm, ymm, m256 /// - public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) => MaskLoad(address, mask); + public static unsafe Vector256 MaskLoad(double* address, Vector256 mask) => MaskLoad(address, mask); /// /// void _mm_maskstore_ps (float * mem_addr, __m128i mask, __m128 a) /// VMASKMOVPS m128, xmm, xmm /// - public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(float* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); /// /// void _mm_maskstore_pd (double * mem_addr, __m128i mask, __m128d a) /// VMASKMOVPD m128, xmm, xmm /// - public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(double* address, Vector128 mask, Vector128 source) => MaskStore(address, mask, source); /// /// void _mm256_maskstore_ps (float * mem_addr, __m256i mask, __m256 a) /// VMASKMOVPS m256, ymm, ymm /// - public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(float* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); /// /// void _mm256_maskstore_pd (double * mem_addr, __m256i mask, __m256d a) /// VMASKMOVPD m256, ymm, ymm /// - public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); + public static unsafe void MaskStore(double* address, Vector256 mask, Vector256 source) => MaskStore(address, mask, source); /// /// __m256 _mm256_max_ps (__m256 a, __m256 b) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Avx2.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Avx2.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs similarity index 85% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs index f74cc7b84f82..8c331bef4777 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.PlatformNotSupported.cs @@ -30,22 +30,22 @@ public static class Bmi1 /// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len) /// BEXTR r32a, reg/m32, r32b /// - public static uint BitFieldExtract(uint value, uint start, uint length) { throw new PlatformNotSupportedException(); } + public static uint BitFieldExtract(uint value, byte start, byte length) { throw new PlatformNotSupportedException(); } /// /// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len) /// BEXTR r64a, reg/m64, r64b /// - public static ulong BitFieldExtract(ulong value, ulong start, ulong length) { throw new PlatformNotSupportedException(); } + public static ulong BitFieldExtract(ulong value, byte start, byte length) { throw new PlatformNotSupportedException(); } /// /// unsigned int _bextr2_u32 (unsigned int a, unsigned int control) /// BEXTR r32a, reg/m32, r32b /// - public static uint BitFieldExtract(uint value, uint control) { throw new PlatformNotSupportedException(); } + public static uint BitFieldExtract(uint value, ushort control) { throw new PlatformNotSupportedException(); } /// /// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control) /// BEXTR r64a, reg/m64, r64b /// - public static ulong BitFieldExtract(ulong value, ulong control) { throw new PlatformNotSupportedException(); } + public static ulong BitFieldExtract(ulong value, ushort control) { throw new PlatformNotSupportedException(); } /// /// unsigned int _blsi_u32 (unsigned int a) @@ -62,12 +62,12 @@ public static class Bmi1 /// unsigned int _blsmsk_u32 (unsigned int a) /// BLSMSK reg, reg/m32 /// - public static uint GetMaskUptoLowestSetBit(uint value) { throw new PlatformNotSupportedException(); } + public static uint GetMaskUpToLowestSetBit(uint value) { throw new PlatformNotSupportedException(); } /// /// unsigned __int64 _blsmsk_u64 (unsigned __int64 a) /// BLSMSK reg, reg/m64 /// - public static ulong GetMaskUptoLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); } + public static ulong GetMaskUpToLowestSetBit(ulong value) { throw new PlatformNotSupportedException(); } /// /// unsigned int _blsr_u32 (unsigned int a) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.cs similarity index 83% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.cs index d8e41ea0a2c9..e1652ea4f749 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi1.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi1.cs @@ -30,22 +30,22 @@ public static class Bmi1 /// unsigned int _bextr_u32 (unsigned int a, unsigned int start, unsigned int len) /// BEXTR r32a, reg/m32, r32b /// - public static uint BitFieldExtract(uint value, uint start, uint length) => BitFieldExtract(value, start, length); + public static uint BitFieldExtract(uint value, byte start, byte length) => BitFieldExtract(value, start, length); /// /// unsigned __int64 _bextr_u64 (unsigned __int64 a, unsigned int start, unsigned int len) /// BEXTR r64a, reg/m64, r64b /// - public static ulong BitFieldExtract(ulong value, ulong start, ulong length) => BitFieldExtract(value, start, length); + public static ulong BitFieldExtract(ulong value, byte start, byte length) => BitFieldExtract(value, start, length); /// /// unsigned int _bextr2_u32 (unsigned int a, unsigned int control) /// BEXTR r32a, reg/m32, r32b /// - public static uint BitFieldExtract(uint value, uint control) => BitFieldExtract(value, control); + public static uint BitFieldExtract(uint value, ushort control) => BitFieldExtract(value, control); /// /// unsigned __int64 _bextr2_u64 (unsigned __int64 a, unsigned __int64 control) /// BEXTR r64a, reg/m64, r64b /// - public static ulong BitFieldExtract(ulong value, ulong control) => BitFieldExtract(value, control); + public static ulong BitFieldExtract(ulong value, ushort control) => BitFieldExtract(value, control); /// /// unsigned int _blsi_u32 (unsigned int a) @@ -62,12 +62,12 @@ public static class Bmi1 /// unsigned int _blsmsk_u32 (unsigned int a) /// BLSMSK reg, reg/m32 /// - public static uint GetMaskUptoLowestSetBit(uint value) => GetMaskUptoLowestSetBit(value); + public static uint GetMaskUpToLowestSetBit(uint value) => GetMaskUpToLowestSetBit(value); /// /// unsigned __int64 _blsmsk_u64 (unsigned __int64 a) /// BLSMSK reg, reg/m64 /// - public static ulong GetMaskUptoLowestSetBit(ulong value) => GetMaskUptoLowestSetBit(value); + public static ulong GetMaskUpToLowestSetBit(ulong value) => GetMaskUpToLowestSetBit(value); /// /// unsigned int _blsr_u32 (unsigned int a) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi2.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Bmi2.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Bmi2.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Enums.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Enums.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Enums.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Enums.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Fma.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Fma.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Fma.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Lzcnt.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Lzcnt.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Pclmulqdq.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Pclmulqdq.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Popcnt.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Popcnt.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Popcnt.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs similarity index 99% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs index 8aaa454eebca..0e2bb5d48b71 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.PlatformNotSupported.cs @@ -609,11 +609,6 @@ public static class Sse2 /// public static Vector128 DivideScalar(Vector128 left, Vector128 right) { throw new PlatformNotSupportedException(); } - /// - /// int _mm_extract_epi16 (__m128i a, int immediate) - /// PEXTRW reg, xmm, imm8 - /// - public static short Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// /// int _mm_extract_epi16 (__m128i a, int immediate) /// PEXTRW reg, xmm, imm8 diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs similarity index 99% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs index d0eb9ef4da9b..332bd7b8c936 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse2.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse2.cs @@ -610,11 +610,6 @@ public static class Sse2 /// public static Vector128 DivideScalar(Vector128 left, Vector128 right) => DivideScalar(left, right); - /// - /// int _mm_extract_epi16 (__m128i a, int immediate) - /// PEXTRW reg, xmm, imm8 - /// - public static short Extract(Vector128 value, byte index) => Extract(value, index); /// /// int _mm_extract_epi16 (__m128i a, int immediate) /// PEXTRW reg, xmm, imm8 diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse3.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse3.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse3.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs similarity index 99% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs index 063b8dc2cbf7..8ba73931c02d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.PlatformNotSupported.cs @@ -178,11 +178,6 @@ public static class Sse41 /// public static Vector128 DotProduct(Vector128 left, Vector128 right, byte control) { throw new PlatformNotSupportedException(); } - /// - /// int _mm_extract_epi8 (__m128i a, const int imm8) - /// PEXTRB reg/m8, xmm, imm8 - /// - public static sbyte Extract(Vector128 value, byte index) { throw new PlatformNotSupportedException(); } /// /// int _mm_extract_epi8 (__m128i a, const int imm8) /// PEXTRB reg/m8, xmm, imm8 @@ -283,7 +278,7 @@ public static class Sse41 /// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8) /// INSERTPS xmm, xmm/m32, imm8 /// - public static Vector128 Insert(Vector128 value, float data, byte index) { throw new PlatformNotSupportedException(); } + public static Vector128 Insert(Vector128 value, Vector128 data, byte index) { throw new PlatformNotSupportedException(); } /// /// __m128i _mm_max_epi8 (__m128i a, __m128i b) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs similarity index 99% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs index dd81168a2450..c3d9dcb1cd86 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse41.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse41.cs @@ -178,11 +178,6 @@ public static class Sse41 /// public static Vector128 DotProduct(Vector128 left, Vector128 right, byte control) => DotProduct(left, right, control); - /// - /// int _mm_extract_epi8 (__m128i a, const int imm8) - /// PEXTRB reg/m8, xmm, imm8 - /// - public static sbyte Extract(Vector128 value, byte index) => Extract(value, index); /// /// int _mm_extract_epi8 (__m128i a, const int imm8) /// PEXTRB reg/m8, xmm, imm8 @@ -283,7 +278,7 @@ public static class Sse41 /// __m128 _mm_insert_ps (__m128 a, __m128 b, const int imm8) /// INSERTPS xmm, xmm/m32, imm8 /// - public static Vector128 Insert(Vector128 value, float data, byte index) => Insert(value, data, index); + public static Vector128 Insert(Vector128 value, Vector128 data, byte index) => Insert(value, data, index); /// /// __m128i _mm_max_epi8 (__m128i a, __m128i b) diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.PlatformNotSupported.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse42.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.cs similarity index 100% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Sse42.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Sse42.cs diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs similarity index 94% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs index 20e9bbb8b75d..7a930c499a64 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.PlatformNotSupported.cs @@ -89,6 +89,12 @@ public static class Ssse3 /// public static Vector128 Shuffle(Vector128 value, Vector128 mask) { throw new PlatformNotSupportedException(); } + /// + /// __m128i _mm_shuffle_epi8 (__m128i a, __m128i b) + /// PSHUFB xmm, xmm/m128 + /// + public static Vector128 Shuffle(Vector128 value, Vector128 mask) { throw new PlatformNotSupportedException(); } + /// /// __m128i _mm_sign_epi8 (__m128i a, __m128i b) /// PSIGNB xmm, xmm/m128 diff --git a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.cs b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.cs similarity index 94% rename from src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.cs rename to src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.cs index 0403a0a4e270..fc32c29496a7 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Intrinsics/X86/Ssse3.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Intrinsics/X86/Ssse3.cs @@ -89,6 +89,12 @@ public static class Ssse3 /// public static Vector128 Shuffle(Vector128 value, Vector128 mask) => Shuffle(value, mask); + /// + /// __m128i _mm_shuffle_epi8 (__m128i a, __m128i b) + /// PSHUFB xmm, xmm/m128 + /// + public static Vector128 Shuffle(Vector128 value, Vector128 mask) => Shuffle(value, mask); + /// /// __m128i _mm_sign_epi8 (__m128i a, __m128i b) /// PSIGNB xmm, xmm/m128 diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Remoting/ObjectHandle.cs b/src/System.Private.CoreLib/shared/System/Runtime/Remoting/ObjectHandle.cs new file mode 100644 index 000000000000..a47aaf9ca19c --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Runtime/Remoting/ObjectHandle.cs @@ -0,0 +1,25 @@ +// 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. + +namespace System.Runtime.Remoting +{ + public class ObjectHandle : MarshalByRefObject + { + private object _wrappedObject; + + private ObjectHandle() + { + } + + public ObjectHandle(object o) + { + _wrappedObject = o; + } + + public object Unwrap() + { + return _wrappedObject; + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationException.cs b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationException.cs index 1c9c21eabbdd..92c01ee30f22 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationException.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Serialization/SerializationException.cs @@ -10,7 +10,7 @@ namespace System.Runtime.Serialization [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class SerializationException : SystemException { - private static String s_nullMessage = SR.SerializationException; + private static string s_nullMessage = SR.SerializationException; // Creates a new SerializationException with its message // string set to a default message. @@ -20,13 +20,13 @@ public SerializationException() HResult = HResults.COR_E_SERIALIZATION; } - public SerializationException(String message) + public SerializationException(string message) : base(message) { HResult = HResults.COR_E_SERIALIZATION; } - public SerializationException(String message, Exception innerException) + public SerializationException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_SERIALIZATION; diff --git a/src/System.Private.CoreLib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs b/src/System.Private.CoreLib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs index a8190663821f..dcb14f0efe91 100644 --- a/src/System.Private.CoreLib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs +++ b/src/System.Private.CoreLib/shared/System/Runtime/Versioning/TargetFrameworkAttribute.cs @@ -19,11 +19,11 @@ namespace System.Runtime.Versioning [AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = false, Inherited = false)] public sealed class TargetFrameworkAttribute : Attribute { - private String _frameworkName; // A target framework moniker - private String _frameworkDisplayName; + private string _frameworkName; // A target framework moniker + private string _frameworkDisplayName; // The frameworkName parameter is intended to be the string form of a FrameworkName instance. - public TargetFrameworkAttribute(String frameworkName) + public TargetFrameworkAttribute(string frameworkName) { if (frameworkName == null) throw new ArgumentNullException(nameof(frameworkName)); @@ -32,12 +32,12 @@ public TargetFrameworkAttribute(String frameworkName) // The target framework moniker that this assembly was compiled against. // Use the FrameworkName class to interpret target framework monikers. - public String FrameworkName + public string FrameworkName { get { return _frameworkName; } } - public String FrameworkDisplayName + public string FrameworkDisplayName { get { return _frameworkDisplayName; } set { _frameworkDisplayName = value; } diff --git a/src/System.Private.CoreLib/shared/System/SByte.cs b/src/System.Private.CoreLib/shared/System/SByte.cs index c7cee2adc24e..e347e3b32301 100644 --- a/src/System.Private.CoreLib/shared/System/SByte.cs +++ b/src/System.Private.CoreLib/shared/System/SByte.cs @@ -12,9 +12,9 @@ namespace System [Serializable] [CLSCompliant(false)] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct SByte : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct SByte : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private sbyte m_value; // Do not rename (binary serialization) + private readonly sbyte m_value; // Do not rename (binary serialization) // The maximum value that a Byte may represent: 127. public const sbyte MaxValue = (sbyte)0x7F; @@ -29,36 +29,36 @@ public struct SByte : IComparable, IConvertible, IFormattable, IComparable 0 && (format[0] == 'X' || format[0] == 'x')) { @@ -107,14 +107,14 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan } [CLSCompliant(false)] - public static sbyte Parse(String s) + public static sbyte Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } [CLSCompliant(false)] - public static sbyte Parse(String s, NumberStyles style) + public static sbyte Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -122,7 +122,7 @@ public static sbyte Parse(String s, NumberStyles style) } [CLSCompliant(false)] - public static sbyte Parse(String s, IFormatProvider provider) + public static sbyte Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); @@ -133,7 +133,7 @@ public static sbyte Parse(String s, IFormatProvider provider) // NumberFormatInfo is assumed. // [CLSCompliant(false)] - public static sbyte Parse(String s, NumberStyles style, IFormatProvider provider) + public static sbyte Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -147,7 +147,7 @@ public static sbyte Parse(ReadOnlySpan s, NumberStyles style = NumberStyle return Parse(s, style, NumberFormatInfo.GetInstance(provider)); } - private static sbyte Parse(String s, NumberStyles style, NumberFormatInfo info) + private static sbyte Parse(string s, NumberStyles style, NumberFormatInfo info) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, style, info); @@ -167,7 +167,7 @@ private static sbyte Parse(ReadOnlySpan s, NumberStyles style, NumberForma if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number - if ((i < 0) || i > Byte.MaxValue) + if ((i < 0) || i > byte.MaxValue) { throw new OverflowException(SR.Overflow_SByte); } @@ -179,7 +179,7 @@ private static sbyte Parse(ReadOnlySpan s, NumberStyles style, NumberForma } [CLSCompliant(false)] - public static bool TryParse(String s, out SByte result) + public static bool TryParse(string s, out sbyte result) { if (s == null) { @@ -197,7 +197,7 @@ public static bool TryParse(ReadOnlySpan s, out sbyte result) } [CLSCompliant(false)] - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out SByte result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out sbyte result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -217,7 +217,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro return TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result); } - private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out SByte result) + private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out sbyte result) { result = 0; int i; @@ -228,7 +228,7 @@ private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFor if ((style & NumberStyles.AllowHexSpecifier) != 0) { // We are parsing a hexadecimal number - if ((i < 0) || i > Byte.MaxValue) + if ((i < 0) || i > byte.MaxValue) { return false; } @@ -314,7 +314,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -324,7 +324,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "SByte", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Security/SecureString.Unix.cs b/src/System.Private.CoreLib/shared/System/Security/SecureString.Unix.cs index cfeebc1daf99..ad14bcd296ec 100644 --- a/src/System.Private.CoreLib/shared/System/Security/SecureString.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/Security/SecureString.Unix.cs @@ -70,14 +70,6 @@ private void DisposeCore() } } - private void EnsureNotDisposed() - { - if (_buffer == null) - { - throw new ObjectDisposedException(GetType().Name); - } - } - private void ClearCore() { _decryptedLength = 0; @@ -143,7 +135,7 @@ private void SetAtCore(int index, char c) _buffer.Write((ulong)(index * sizeof(char)), c); } - internal unsafe IntPtr MarshalToBSTR() + internal unsafe IntPtr MarshalToBSTRCore() { int length = _decryptedLength; IntPtr ptr = IntPtr.Zero; diff --git a/src/System.Private.CoreLib/shared/System/Security/SecureString.Windows.cs b/src/System.Private.CoreLib/shared/System/Security/SecureString.Windows.cs index 2a8008191253..a78fbc222c59 100644 --- a/src/System.Private.CoreLib/shared/System/Security/SecureString.Windows.cs +++ b/src/System.Private.CoreLib/shared/System/Security/SecureString.Windows.cs @@ -6,7 +6,6 @@ using System.Runtime; using System.Runtime.InteropServices; using System.Security.Cryptography; -using Microsoft.Win32; namespace System.Security { @@ -145,7 +144,7 @@ private void SetAtCore(int index, char c) } } - internal unsafe IntPtr MarshalToBSTR() + internal unsafe IntPtr MarshalToBSTRCore() { int length = _decryptedLength; IntPtr ptr = IntPtr.Zero; @@ -232,14 +231,6 @@ internal unsafe IntPtr MarshalToStringCore(bool globalAlloc, bool unicode) return result; } - private void EnsureNotDisposed() - { - if (_buffer == null) - { - throw new ObjectDisposedException(GetType().Name); - } - } - // ----------------------------- // ---- PAL layer ends here ---- // ----------------------------- diff --git a/src/System.Private.CoreLib/shared/System/Security/SecureString.cs b/src/System.Private.CoreLib/shared/System/Security/SecureString.cs index 22f15accaaf9..cdee9c907677 100644 --- a/src/System.Private.CoreLib/shared/System/Security/SecureString.cs +++ b/src/System.Private.CoreLib/shared/System/Security/SecureString.cs @@ -139,7 +139,7 @@ public void SetAt(int index, char c) { throw new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexString); } - Debug.Assert(index <= Int32.MaxValue / sizeof(char)); + Debug.Assert(index <= int.MaxValue / sizeof(char)); EnsureNotDisposed(); EnsureNotReadOnly(); @@ -156,6 +156,23 @@ private void EnsureNotReadOnly() } } + private void EnsureNotDisposed() + { + if (_buffer == null) + { + throw new ObjectDisposedException(GetType().Name); + } + } + + internal IntPtr MarshalToBSTR() + { + lock (_methodLock) + { + EnsureNotDisposed(); + return MarshalToBSTRCore(); + } + } + internal unsafe IntPtr MarshalToString(bool globalAlloc, bool unicode) { lock (_methodLock) diff --git a/src/System.Private.CoreLib/shared/System/Single.cs b/src/System.Private.CoreLib/shared/System/Single.cs index a74d3770fa22..6b8440d40bbf 100644 --- a/src/System.Private.CoreLib/shared/System/Single.cs +++ b/src/System.Private.CoreLib/shared/System/Single.cs @@ -23,9 +23,9 @@ namespace System [Serializable] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct Single : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public struct Single : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private float m_value; // Do not rename (binary serialization) + private readonly float m_value; // Do not rename (binary serialization) // // Public constants @@ -72,8 +72,7 @@ public static unsafe bool IsNaN(float f) [MethodImpl(MethodImplOptions.AggressiveInlining)] public static unsafe bool IsNegative(float f) { - var bits = unchecked((uint)BitConverter.SingleToInt32Bits(f)); - return (bits & 0x80000000) == 0x80000000; + return BitConverter.SingleToInt32Bits(f) < 0; } /// Determines whether the specified value is negative infinity. @@ -118,13 +117,13 @@ public static unsafe bool IsSubnormal(float f) // null is considered to be less than any instance. // If object is not of type Single, this method throws an ArgumentException. // - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) { return 1; } - if (value is Single) + if (value is float) { float f = (float)value; if (m_value < f) return -1; @@ -141,7 +140,7 @@ public int CompareTo(Object value) } - public int CompareTo(Single value) + public int CompareTo(float value) { if (m_value < value) return -1; if (m_value > value) return 1; @@ -155,48 +154,48 @@ public int CompareTo(Single value) } [NonVersionable] - public static bool operator ==(Single left, Single right) + public static bool operator ==(float left, float right) { return left == right; } [NonVersionable] - public static bool operator !=(Single left, Single right) + public static bool operator !=(float left, float right) { return left != right; } [NonVersionable] - public static bool operator <(Single left, Single right) + public static bool operator <(float left, float right) { return left < right; } [NonVersionable] - public static bool operator >(Single left, Single right) + public static bool operator >(float left, float right) { return left > right; } [NonVersionable] - public static bool operator <=(Single left, Single right) + public static bool operator <=(float left, float right) { return left <= right; } [NonVersionable] - public static bool operator >=(Single left, Single right) + public static bool operator >=(float left, float right) { return left >= right; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (!(obj is Single)) + if (!(obj is float)) { return false; } - float temp = ((Single)obj).m_value; + float temp = ((float)obj).m_value; if (temp == m_value) { return true; @@ -205,7 +204,7 @@ public override bool Equals(Object obj) return IsNaN(temp) && IsNaN(m_value); } - public bool Equals(Single obj) + public bool Equals(float obj) { if (obj == m_value) { @@ -217,7 +216,7 @@ public bool Equals(Single obj) public override int GetHashCode() { - var bits = Unsafe.As(ref m_value); + var bits = Unsafe.As(ref Unsafe.AsRef(in m_value)); // Optimized check for IsNan() || IsZero() if (((bits - 1) & 0x7FFFFFFF) >= 0x7F800000) @@ -229,22 +228,22 @@ public override int GetHashCode() return bits; } - public override String ToString() + public override string ToString() { return Number.FormatSingle(m_value, null, NumberFormatInfo.CurrentInfo); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatSingle(m_value, null, NumberFormatInfo.GetInstance(provider)); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatSingle(m_value, format, NumberFormatInfo.CurrentInfo); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatSingle(m_value, format, NumberFormatInfo.GetInstance(provider)); } @@ -262,26 +261,26 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan // PositiveInfinity or NegativeInfinity for a number that is too // large or too small. // - public static float Parse(String s) + public static float Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo); } - public static float Parse(String s, NumberStyles style) + public static float Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseSingle(s, style, NumberFormatInfo.CurrentInfo); } - public static float Parse(String s, IFormatProvider provider) + public static float Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseSingle(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider)); } - public static float Parse(String s, NumberStyles style, IFormatProvider provider) + public static float Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -294,7 +293,7 @@ public static float Parse(ReadOnlySpan s, NumberStyles style = NumberStyle return Number.ParseSingle(s, style, NumberFormatInfo.GetInstance(provider)); } - public static Boolean TryParse(String s, out Single result) + public static bool TryParse(string s, out float result) { if (s == null) { @@ -310,7 +309,7 @@ public static bool TryParse(ReadOnlySpan s, out float result) return TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.CurrentInfo, out result); } - public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out Single result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out float result) { NumberFormatInfo.ValidateParseStyleFloatingPoint(style); @@ -329,7 +328,7 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro return TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result); } - private static Boolean TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out Single result) + private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out float result) { bool success = Number.TryParseSingle(s, style, info, out result); if (!success) @@ -425,7 +424,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -435,7 +434,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Single", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/Span.Fast.cs b/src/System.Private.CoreLib/shared/System/Span.Fast.cs index 40b461eeff58..b3cfc8daff7b 100644 --- a/src/System.Private.CoreLib/shared/System/Span.Fast.cs +++ b/src/System.Private.CoreLib/shared/System/Span.Fast.cs @@ -23,8 +23,6 @@ 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. /// - [DebuggerTypeProxy(typeof(SpanDebugView<>))] - [DebuggerDisplay("{ToString(),raw}")] [NonVersionable] public readonly ref partial struct Span { diff --git a/src/System.Private.CoreLib/shared/System/Span.cs b/src/System.Private.CoreLib/shared/System/Span.cs index 2bafa1daf829..ddbdba1134bc 100644 --- a/src/System.Private.CoreLib/shared/System/Span.cs +++ b/src/System.Private.CoreLib/shared/System/Span.cs @@ -5,9 +5,8 @@ using System.ComponentModel; using System.Diagnostics; using System.Runtime.CompilerServices; -#if !FEATURE_PORTABLE_SPAN + using System.Runtime.Versioning; -#endif // !FEATURE_PORTABLE_SPAN #pragma warning disable 0809 //warning CS0809: Obsolete member 'Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)' @@ -26,9 +25,7 @@ public readonly ref partial struct Span /// public int Length { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length; @@ -40,9 +37,7 @@ public int Length /// public bool IsEmpty { -#if !FEATURE_PORTABLE_SPAN [NonVersionable] -#endif // !FEATURE_PORTABLE_SPAN get { return _length == 0; diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs index 00c491f37f4b..a81a5d3416f0 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.BinarySearch.cs @@ -6,9 +6,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif namespace System { diff --git a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs index 0c7309b5c526..2890adb568f4 100644 --- a/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs +++ b/src/System.Private.CoreLib/shared/System/SpanHelpers.Byte.cs @@ -4,24 +4,15 @@ using System.Diagnostics; using System.Runtime.CompilerServices; +using System.Numerics; -#if !netstandard using Internal.Runtime.CompilerServices; -#endif - -#if !netstandard11 -using System.Numerics; -#endif -#if netstandard -using nuint = System.NUInt; -#else #if BIT64 using nuint = System.UInt64; #else using nuint = System.UInt32; #endif // BIT64 -#endif // netstandard namespace System { @@ -112,14 +103,13 @@ public static unsafe int IndexOf(ref byte searchSpace, byte value, int length) uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif while ((byte*)nLength >= (byte*)8) { nLength -= 8; @@ -169,13 +159,13 @@ public static unsafe int IndexOf(ref byte searchSpace, byte value, int length) index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector vComparison = GetVector(value); + Vector vComparison = new Vector(value); while ((byte*)nLength > (byte*)index) { @@ -195,7 +185,6 @@ public static unsafe int IndexOf(ref byte searchSpace, byte value, int length) goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -256,14 +245,13 @@ public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int lengt uint uValue = value; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif while ((byte*)nLength >= (byte*)8) { nLength -= 8; @@ -310,13 +298,13 @@ public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int lengt if (uValue == Unsafe.AddByteOffset(ref searchSpace, index)) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector vComparison = GetVector(value); + Vector vComparison = new Vector(value); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -336,7 +324,6 @@ public static unsafe int LastIndexOf(ref byte searchSpace, byte value, int lengt goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -364,14 +351,13 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -435,14 +421,14 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); while ((byte*)nLength > (byte*)index) { @@ -465,7 +451,6 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -494,14 +479,13 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)((Vector.Count - unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -565,15 +549,15 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu index += 1; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((int)(byte*)index < length)) { nLength = (IntPtr)((length - (int)(byte*)index) & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); - Vector values2 = GetVector(value2); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); + Vector values2 = new Vector(value2); while ((byte*)nLength > (byte*)index) { @@ -600,7 +584,6 @@ public static unsafe int IndexOfAny(ref byte searchSpace, byte value0, byte valu goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -628,14 +611,13 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte uint uValue1 = value1; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -696,14 +678,14 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte if (uValue0 == lookUp || uValue1 == lookUp) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -727,7 +709,6 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -756,14 +737,13 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte uint uValue2 = value2; // Use uint for comparisons to avoid unnecessary 8->32 extensions IntPtr index = (IntPtr)length; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr nLength = (IntPtr)length; -#if !netstandard11 + if (Vector.IsHardwareAccelerated && length >= Vector.Count * 2) { int unaligned = (int)Unsafe.AsPointer(ref searchSpace) & (Vector.Count - 1); nLength = (IntPtr)(((length & (Vector.Count - 1)) + unaligned) & (Vector.Count - 1)); } SequentialScan: -#endif uint lookUp; while ((byte*)nLength >= (byte*)8) { @@ -824,15 +804,15 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte if (uValue0 == lookUp || uValue1 == lookUp || uValue2 == lookUp) goto Found; } -#if !netstandard11 + if (Vector.IsHardwareAccelerated && ((byte*)index > (byte*)0)) { nLength = (IntPtr)((int)(byte*)index & ~(Vector.Count - 1)); // Get comparison Vector - Vector values0 = GetVector(value0); - Vector values1 = GetVector(value1); - Vector values2 = GetVector(value2); + Vector values0 = new Vector(value0); + Vector values1 = new Vector(value1); + Vector values2 = new Vector(value2); while ((byte*)nLength > (byte*)(Vector.Count - 1)) { @@ -860,7 +840,6 @@ public static unsafe int LastIndexOfAny(ref byte searchSpace, byte value0, byte goto SequentialScan; } } -#endif return -1; Found: // Workaround for https://github.com/dotnet/coreclr/issues/13549 return (int)(byte*)index; @@ -890,7 +869,6 @@ public static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint l IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr n = (IntPtr)(void*)length; -#if !netstandard11 if (Vector.IsHardwareAccelerated && (byte*)n >= (byte*)Vector.Count) { n -= Vector.Count; @@ -906,7 +884,6 @@ public static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint l return Unsafe.ReadUnaligned>(ref Unsafe.AddByteOffset(ref first, n)) == Unsafe.ReadUnaligned>(ref Unsafe.AddByteOffset(ref second, n)); } -#endif if ((byte*)n >= (byte*)sizeof(UIntPtr)) { @@ -938,7 +915,6 @@ public static unsafe bool SequenceEqual(ref byte first, ref byte second, nuint l return false; } -#if !netstandard11 // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundByte(Vector match) @@ -959,7 +935,6 @@ private static int LocateFirstFoundByte(Vector match) // Single LEA instruction with jitted const (using function result) return i * 8 + LocateFirstFoundByte(candidate); } -#endif public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref byte second, int secondLength) { @@ -974,7 +949,6 @@ public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref IntPtr i = (IntPtr)0; // Use IntPtr for arithmetic to avoid unnecessary 64->32->64 truncations IntPtr n = (IntPtr)(void*)minLength; -#if !netstandard11 if (Vector.IsHardwareAccelerated && (byte*)n > (byte*)Vector.Count) { n -= Vector.Count; @@ -989,7 +963,6 @@ public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref } goto NotEqual; } -#endif if ((byte*)n > (byte*)sizeof(UIntPtr)) { @@ -1018,7 +991,6 @@ public static unsafe int SequenceCompareTo(ref byte first, int firstLength, ref return firstLength - secondLength; } -#if !netstandard11 // Vector sub-search adapted from https://github.com/aspnet/KestrelHttpServer/pull/1138 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundByte(Vector match) @@ -1039,9 +1011,7 @@ private static int LocateLastFoundByte(Vector match) // Single LEA instruction with jitted const (using function result) return i * 8 + LocateLastFoundByte(candidate); } -#endif -#if !netstandard11 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateFirstFoundByte(ulong match) { @@ -1050,9 +1020,7 @@ private static int LocateFirstFoundByte(ulong match) // Shift all powers of two into the high byte and extract return (int)((powerOfTwoFlag * XorPowerOfTwoToHighByte) >> 57); } -#endif -#if !netstandard11 [MethodImpl(MethodImplOptions.AggressiveInlining)] private static int LocateLastFoundByte(ulong match) { @@ -1065,24 +1033,7 @@ private static int LocateLastFoundByte(ulong match) } return index; } -#endif - -#if !netstandard11 - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static Vector GetVector(byte vectorByte) - { -#if !netcoreapp - // Vector .ctor doesn't become an intrinsic due to detection issue - // However this does cause it to become an intrinsic (with additional multiply and reg->reg copy) - // https://github.com/dotnet/coreclr/issues/7459#issuecomment-253965670 - return Vector.AsVectorByte(new Vector(vectorByte * 0x01010101u)); -#else - return new Vector(vectorByte); -#endif - } -#endif -#if !netstandard11 private const ulong XorPowerOfTwoToHighByte = (0x07ul | 0x06ul << 8 | 0x05ul << 16 | @@ -1090,6 +1041,5 @@ private static Vector GetVector(byte vectorByte) 0x03ul << 32 | 0x02ul << 40 | 0x01ul << 48) + 1; -#endif } } diff --git a/src/System.Private.CoreLib/shared/System/StackOverflowException.cs b/src/System.Private.CoreLib/shared/System/StackOverflowException.cs index 6f954cc75a6f..a603ea88b289 100644 --- a/src/System.Private.CoreLib/shared/System/StackOverflowException.cs +++ b/src/System.Private.CoreLib/shared/System/StackOverflowException.cs @@ -25,13 +25,13 @@ public StackOverflowException() HResult = HResults.COR_E_STACKOVERFLOW; } - public StackOverflowException(String message) + public StackOverflowException(string message) : base(message) { HResult = HResults.COR_E_STACKOVERFLOW; } - public StackOverflowException(String message, Exception innerException) + public StackOverflowException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_STACKOVERFLOW; diff --git a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs index 5face0764ab5..3359410a9324 100644 --- a/src/System.Private.CoreLib/shared/System/String.Manipulation.cs +++ b/src/System.Private.CoreLib/shared/System/String.Manipulation.cs @@ -1246,7 +1246,7 @@ public string[] Split(string separator, StringSplitOptions options = StringSplit return SplitInternal(separator ?? string.Empty, null, int.MaxValue, options); } - public string[] Split(string separator, Int32 count, StringSplitOptions options = StringSplitOptions.None) + public string[] Split(string separator, int count, StringSplitOptions options = StringSplitOptions.None) { return SplitInternal(separator ?? string.Empty, null, count, options); } @@ -1256,7 +1256,7 @@ public string[] Split(string[] separator, StringSplitOptions options) return SplitInternal(null, separator, int.MaxValue, options); } - public string[] Split(string[] separator, Int32 count, StringSplitOptions options) + public string[] Split(string[] separator, int count, StringSplitOptions options) { return SplitInternal(null, separator, count, options); } @@ -1682,7 +1682,7 @@ public string ToUpperInvariant() } // Trims the whitespace from both ends of the string. Whitespace is defined by - // Char.IsWhiteSpace. + // char.IsWhiteSpace. // public string Trim() => TrimWhiteSpaceHelper(TrimType.Both); diff --git a/src/System.Private.CoreLib/shared/System/String.cs b/src/System.Private.CoreLib/shared/System/String.cs index 85d0d4ef5df7..7050644d9aac 100644 --- a/src/System.Private.CoreLib/shared/System/String.cs +++ b/src/System.Private.CoreLib/shared/System/String.cs @@ -15,13 +15,13 @@ namespace System { // The String class represents a static string of characters. Many of - // the String methods perform some type of transformation on the current - // instance and return the result as a new String. As with arrays, character + // the string methods perform some type of transformation on the current + // instance and return the result as a new string. As with arrays, character // positions (indices) are zero-based. [Serializable] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public sealed partial class String : IComparable, IEnumerable, IConvertible, IEnumerable, IComparable, IEquatable, ICloneable + public sealed partial class String : IComparable, IEnumerable, IConvertible, IEnumerable, IComparable, IEquatable, ICloneable { // String constructors // These are special. The implementation methods for these have a different signature from the @@ -453,7 +453,7 @@ public static bool IsNullOrWhiteSpace(string value) for (int i = 0; i < value.Length; i++) { - if (!Char.IsWhiteSpace(value[i])) return false; + if (!char.IsWhiteSpace(value[i])) return false; } return true; @@ -704,7 +704,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(this, provider); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(this, provider); } @@ -714,7 +714,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) return Convert.ToDateTime(this, provider); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/StringComparer.cs b/src/System.Private.CoreLib/shared/System/StringComparer.cs index cb2d32fccba5..47731cb7826a 100644 --- a/src/System.Private.CoreLib/shared/System/StringComparer.cs +++ b/src/System.Private.CoreLib/shared/System/StringComparer.cs @@ -114,10 +114,10 @@ public int Compare(object x, object y) if (x == null) return -1; if (y == null) return 1; - String sa = x as String; + string sa = x as string; if (sa != null) { - String sb = y as String; + string sb = y as string; if (sb != null) { return Compare(sa, sb); @@ -133,15 +133,15 @@ public int Compare(object x, object y) throw new ArgumentException(SR.Argument_ImplementIComparable); } - public new bool Equals(Object x, Object y) + public new bool Equals(object x, object y) { if (x == y) return true; if (x == null || y == null) return false; - String sa = x as String; + string sa = x as string; if (sa != null) { - String sb = y as String; + string sb = y as string; if (sb != null) { return Equals(sa, sb); @@ -165,8 +165,8 @@ public int GetHashCode(object obj) return obj.GetHashCode(); } - public abstract int Compare(String x, String y); - public abstract bool Equals(String x, String y); + public abstract int Compare(string x, string y); + public abstract bool Equals(string x, string y); public abstract int GetHashCode(string obj); } @@ -293,7 +293,7 @@ public override bool Equals(string x, string y) { return false; } - return (string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); + return string.Equals(x, y, StringComparison.OrdinalIgnoreCase); } return x.Equals(y); } diff --git a/src/System.Private.CoreLib/shared/System/SystemException.cs b/src/System.Private.CoreLib/shared/System/SystemException.cs index b7e8e4217590..9a1daf2104b8 100644 --- a/src/System.Private.CoreLib/shared/System/SystemException.cs +++ b/src/System.Private.CoreLib/shared/System/SystemException.cs @@ -16,13 +16,13 @@ public SystemException() HResult = HResults.COR_E_SYSTEM; } - public SystemException(String message) + public SystemException(string message) : base(message) { HResult = HResults.COR_E_SYSTEM; } - public SystemException(String message, Exception innerException) + public SystemException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_SYSTEM; diff --git a/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs b/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs index 3d25228b0f58..217d93467767 100644 --- a/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/ASCIIEncoding.cs @@ -31,7 +31,7 @@ public ASCIIEncoding() : base(Encoding.CodePageASCII) { } - internal override void SetDefaultFallbacks() + internal sealed override void SetDefaultFallbacks() { // For ASCIIEncoding we just use default replacement fallback this.encoderFallback = EncoderFallback.ReplacementFallback; @@ -59,13 +59,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -81,11 +81,11 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe int GetByteCount(String chars) + public override unsafe int GetByteCount(string chars) { // Validate input if (chars==null) - throw new ArgumentNullException("chars"); + throw new ArgumentNullException(nameof(chars)); fixed (char* pChars = chars) return GetByteCount(pChars, chars.Length, null); @@ -100,34 +100,42 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); } + public override unsafe int GetByteCount(ReadOnlySpan chars) + { + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + { + return GetByteCount(charsPtr, chars.Length, encoder: null); + } + } + // Parent method is safe. // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - public override unsafe int GetBytes(String chars, int charIndex, int charCount, + public override unsafe int GetBytes(string chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -154,16 +162,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0 if (charCount == 0) @@ -186,14 +194,23 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } + public override unsafe int GetBytes(ReadOnlySpan chars, Span bytes) + { + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + { + return GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length, encoder: null); + } + } + // Returns the number of characters produced by decoding a range of bytes // in a byte array. // @@ -206,13 +223,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays if (count == 0) @@ -232,14 +249,22 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } + public override unsafe int GetCharCount(ReadOnlySpan bytes) + { + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + { + return GetCharCount(bytesPtr, bytes.Length, decoder: null); + } + } + // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding @@ -250,16 +275,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -282,14 +307,23 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } + public override unsafe int GetChars(ReadOnlySpan bytes, Span chars) + { + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + { + return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length, decoder: null); + } + } + // Returns a string containing the decoded representation of a range of // bytes in a byte array. // @@ -302,14 +336,14 @@ public override unsafe string GetString(byte[] bytes, int byteIndex, int byteCou { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (byteCount == 0) return string.Empty; @@ -326,7 +360,7 @@ public override unsafe string GetString(byte[] bytes, int byteIndex, int byteCou // GetByteCount // Note: We start by assuming that the output will be the same as count. Having // an encoder or fallback may change that assumption - internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS encoder) + internal sealed override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS encoder) { // Just need to ASSERT, this is called by something else internal that checked parameters already Debug.Assert(charCount >= 0, "[ASCIIEncoding.GetByteCount]count is negative"); @@ -348,7 +382,7 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS if (encoder != null) { charLeftOver = encoder._charLeftOver; - Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver), + Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver), "[ASCIIEncoding.GetByteCount]leftover character should be high surrogate"); fallback = encoder.Fallback as EncoderReplacementFallback; @@ -400,7 +434,7 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS // We may have a left over character from last time, try and process it. if (charLeftOver > 0) { - Debug.Assert(Char.IsHighSurrogate(charLeftOver), "[ASCIIEncoding.GetByteCount]leftover character should be high surrogate"); + Debug.Assert(char.IsHighSurrogate(charLeftOver), "[ASCIIEncoding.GetByteCount]leftover character should be high surrogate"); Debug.Assert(encoder != null, "[ASCIIEncoding.GetByteCount]Expected encoder"); // Since left over char was a surrogate, it'll have to be fallen back. @@ -460,8 +494,8 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS return byteCount; } - internal override unsafe int GetBytes(char* chars, int charCount, - byte* bytes, int byteCount, EncoderNLS encoder) + internal sealed override unsafe int GetBytes( + char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS encoder) { // Just need to ASSERT, this is called by something else internal that checked parameters already Debug.Assert(bytes != null, "[ASCIIEncoding.GetBytes]bytes is null"); @@ -502,7 +536,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, fallbackBuffer.InternalInitialize(charStart, charEnd, encoder, true); } - Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver), + Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver), "[ASCIIEncoding.GetBytes]leftover character should be high surrogate"); // Verify that we have no fallbackbuffer, for ASCII its always empty, so just assert @@ -676,7 +710,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, } // This is internal and called by something else, - internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS decoder) + internal sealed override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS decoder) { // Just assert, we're called internally so these should be safe, checked already Debug.Assert(bytes != null, "[ASCIIEncoding.GetCharCount]bytes is null"); @@ -748,8 +782,8 @@ internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS dec return charCount; } - internal override unsafe int GetChars(byte* bytes, int byteCount, - char* chars, int charCount, DecoderNLS decoder) + internal sealed override unsafe int GetChars( + byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS decoder) { // Just need to ASSERT, this is called by something else internal that checked parameters already Debug.Assert(bytes != null, "[ASCIIEncoding.GetChars]bytes is null"); diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderBestFitFallback.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderBestFitFallback.cs index 30c817c91a58..8c62730c26eb 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderBestFitFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderBestFitFallback.cs @@ -38,7 +38,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { InternalDecoderBestFitFallback that = value as InternalDecoderBestFitFallback; if (that != null) @@ -63,15 +63,15 @@ internal sealed class InternalDecoderBestFitFallbackBuffer : DecoderFallbackBuff private InternalDecoderBestFitFallback _oFallback; // Private object for locking instead of locking on a public type for SQL reliability work. - private static Object s_InternalSyncObject; - private static Object InternalSyncObject + private static object s_InternalSyncObject; + private static object InternalSyncObject { get { if (s_InternalSyncObject == null) { - Object o = new Object(); - Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); + object o = new object(); + Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); } return s_InternalSyncObject; } diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderExceptionFallback.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderExceptionFallback.cs index 8bfc1f32d319..56c004714f06 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderExceptionFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderExceptionFallback.cs @@ -29,7 +29,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { DecoderExceptionFallback that = value as DecoderExceptionFallback; if (that != null) @@ -112,19 +112,19 @@ public DecoderFallbackException() HResult = HResults.COR_E_ARGUMENT; } - public DecoderFallbackException(String message) + public DecoderFallbackException(string message) : base(message) { HResult = HResults.COR_E_ARGUMENT; } - public DecoderFallbackException(String message, Exception innerException) + public DecoderFallbackException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; } - public DecoderFallbackException(String message, byte[] bytesUnknown, int index) + public DecoderFallbackException(string message, byte[] bytesUnknown, int index) : base(message) { _bytesUnknown = bytesUnknown; diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderFallback.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderFallback.cs index 11b9539b5c37..fff8ad1d7bb3 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderFallback.cs @@ -104,9 +104,9 @@ internal unsafe virtual bool InternalFallback(byte[] bytes, byte* pBytes, ref ch while ((ch = GetNextChar()) != 0) { // Make sure no mixed up surrogates - if (Char.IsSurrogate(ch)) + if (char.IsSurrogate(ch)) { - if (Char.IsHighSurrogate(ch)) + if (char.IsHighSurrogate(ch)) { // High Surrogate if (bHighSurrogate) @@ -159,9 +159,9 @@ internal unsafe virtual int InternalFallback(byte[] bytes, byte* pBytes) while ((ch = GetNextChar()) != 0) { // Make sure no mixed up surrogates - if (Char.IsSurrogate(ch)) + if (char.IsSurrogate(ch)) { - if (Char.IsHighSurrogate(ch)) + if (char.IsHighSurrogate(ch)) { // High Surrogate if (bHighSurrogate) diff --git a/src/System.Private.CoreLib/shared/System/Text/DecoderReplacementFallback.cs b/src/System.Private.CoreLib/shared/System/Text/DecoderReplacementFallback.cs index 422b80bb2fcf..a97baf05cb0d 100644 --- a/src/System.Private.CoreLib/shared/System/Text/DecoderReplacementFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/DecoderReplacementFallback.cs @@ -9,14 +9,14 @@ namespace System.Text public sealed class DecoderReplacementFallback : DecoderFallback { // Our variables - private String _strDefault; + private string _strDefault; // Construction. Default replacement fallback uses no best fit and ? replacement string public DecoderReplacementFallback() : this("?") { } - public DecoderReplacementFallback(String replacement) + public DecoderReplacementFallback(string replacement) { if (replacement == null) throw new ArgumentNullException(nameof(replacement)); @@ -26,10 +26,10 @@ public DecoderReplacementFallback(String replacement) for (int i = 0; i < replacement.Length; i++) { // Found a surrogate? - if (Char.IsSurrogate(replacement, i)) + if (char.IsSurrogate(replacement, i)) { // High or Low? - if (Char.IsHighSurrogate(replacement, i)) + if (char.IsHighSurrogate(replacement, i)) { // if already had a high one, stop if (bFoundHigh) @@ -60,7 +60,7 @@ public DecoderReplacementFallback(String replacement) _strDefault = replacement; } - public String DefaultString + public string DefaultString { get { @@ -82,7 +82,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { DecoderReplacementFallback that = value as DecoderReplacementFallback; if (that != null) @@ -103,7 +103,7 @@ public override int GetHashCode() public sealed class DecoderReplacementFallbackBuffer : DecoderFallbackBuffer { // Store our default string - private String _strDefault; + private string _strDefault; private int _fallbackCount = -1; private int _fallbackIndex = -1; diff --git a/src/System.Private.CoreLib/shared/System/Text/EncoderBestFitFallback.cs b/src/System.Private.CoreLib/shared/System/Text/EncoderBestFitFallback.cs index 7f3be2a7a694..4aab3f62a332 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncoderBestFitFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncoderBestFitFallback.cs @@ -38,7 +38,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { InternalEncoderBestFitFallback that = value as InternalEncoderBestFitFallback; if (that != null) @@ -63,15 +63,15 @@ internal sealed class InternalEncoderBestFitFallbackBuffer : EncoderFallbackBuff private int _iSize; // Private object for locking instead of locking on a public type for SQL reliability work. - private static Object s_InternalSyncObject; - private static Object InternalSyncObject + private static object s_InternalSyncObject; + private static object InternalSyncObject { get { if (s_InternalSyncObject == null) { - Object o = new Object(); - Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); + object o = new object(); + Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); } return s_InternalSyncObject; } @@ -113,12 +113,12 @@ public override bool Fallback(char charUnknown, int index) public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) { // Double check input surrogate pair - if (!Char.IsHighSurrogate(charUnknownHigh)) + if (!char.IsHighSurrogate(charUnknownHigh)) throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); - if (!Char.IsLowSurrogate(charUnknownLow)) + if (!char.IsLowSurrogate(charUnknownLow)) throw new ArgumentOutOfRangeException(nameof(charUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); diff --git a/src/System.Private.CoreLib/shared/System/Text/EncoderExceptionFallback.cs b/src/System.Private.CoreLib/shared/System/Text/EncoderExceptionFallback.cs index 66de1940f649..92afcf701ac4 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncoderExceptionFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncoderExceptionFallback.cs @@ -28,7 +28,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { EncoderExceptionFallback that = value as EncoderExceptionFallback; if (that != null) @@ -57,18 +57,18 @@ public override bool Fallback(char charUnknown, int index) public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) { - if (!Char.IsHighSurrogate(charUnknownHigh)) + if (!char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); } - if (!Char.IsLowSurrogate(charUnknownLow)) + if (!char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException(nameof(charUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); } - int iTemp = Char.ConvertToUtf32(charUnknownHigh, charUnknownLow); + int iTemp = char.ConvertToUtf32(charUnknownHigh, charUnknownLow); // Fall back our char throw new EncoderFallbackException( @@ -111,34 +111,34 @@ public EncoderFallbackException() HResult = HResults.COR_E_ARGUMENT; } - public EncoderFallbackException(String message) + public EncoderFallbackException(string message) : base(message) { HResult = HResults.COR_E_ARGUMENT; } - public EncoderFallbackException(String message, Exception innerException) + public EncoderFallbackException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_ARGUMENT; } internal EncoderFallbackException( - String message, char charUnknown, int index) : base(message) + string message, char charUnknown, int index) : base(message) { _charUnknown = charUnknown; _index = index; } internal EncoderFallbackException( - String message, char charUnknownHigh, char charUnknownLow, int index) : base(message) + string message, char charUnknownHigh, char charUnknownLow, int index) : base(message) { - if (!Char.IsHighSurrogate(charUnknownHigh)) + if (!char.IsHighSurrogate(charUnknownHigh)) { throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); } - if (!Char.IsLowSurrogate(charUnknownLow)) + if (!char.IsLowSurrogate(charUnknownLow)) { throw new ArgumentOutOfRangeException(nameof(CharUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); diff --git a/src/System.Private.CoreLib/shared/System/Text/EncoderFallback.cs b/src/System.Private.CoreLib/shared/System/Text/EncoderFallback.cs index d860a02a76a7..f98b15e07866 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncoderFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncoderFallback.cs @@ -142,7 +142,7 @@ internal unsafe virtual bool InternalFallback(char ch, ref char* chars) int index = (int)(chars - charStart) - 1; // See if it was a high surrogate - if (Char.IsHighSurrogate(ch)) + if (char.IsHighSurrogate(ch)) { // See if there's a low surrogate to go with it if (chars >= this.charEnd) @@ -165,11 +165,11 @@ internal unsafe virtual bool InternalFallback(char ch, ref char* chars) { // Might have a low surrogate char cNext = *chars; - if (Char.IsLowSurrogate(cNext)) + if (char.IsLowSurrogate(cNext)) { // If already falling back then fail if (bFallingBack && iRecursionCount++ > iMaxRecursion) - ThrowLastCharRecursive(Char.ConvertToUtf32(ch, cNext)); + ThrowLastCharRecursive(char.ConvertToUtf32(ch, cNext)); // Next is a surrogate, add it as surrogate pair, and increment chars chars++; diff --git a/src/System.Private.CoreLib/shared/System/Text/EncoderReplacementFallback.cs b/src/System.Private.CoreLib/shared/System/Text/EncoderReplacementFallback.cs index a1d0bbcd95ae..760c280fde33 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncoderReplacementFallback.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncoderReplacementFallback.cs @@ -11,14 +11,14 @@ namespace System.Text public sealed class EncoderReplacementFallback : EncoderFallback { // Our variables - private String _strDefault; + private string _strDefault; // Construction. Default replacement fallback uses no best fit and ? replacement string public EncoderReplacementFallback() : this("?") { } - public EncoderReplacementFallback(String replacement) + public EncoderReplacementFallback(string replacement) { // Must not be null if (replacement == null) @@ -29,10 +29,10 @@ public EncoderReplacementFallback(String replacement) for (int i = 0; i < replacement.Length; i++) { // Found a surrogate? - if (Char.IsSurrogate(replacement, i)) + if (char.IsSurrogate(replacement, i)) { // High or Low? - if (Char.IsHighSurrogate(replacement, i)) + if (char.IsHighSurrogate(replacement, i)) { // if already had a high one, stop if (bFoundHigh) @@ -63,7 +63,7 @@ public EncoderReplacementFallback(String replacement) _strDefault = replacement; } - public String DefaultString + public string DefaultString { get { @@ -85,7 +85,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { EncoderReplacementFallback that = value as EncoderReplacementFallback; if (that != null) @@ -106,7 +106,7 @@ public override int GetHashCode() public sealed class EncoderReplacementFallbackBuffer : EncoderFallbackBuffer { // Store our default string - private String _strDefault; + private string _strDefault; private int _fallbackCount = -1; private int _fallbackIndex = -1; @@ -127,7 +127,7 @@ public override bool Fallback(char charUnknown, int index) // If we're recursive we may still have something in our buffer that makes this a surrogate if (char.IsHighSurrogate(charUnknown) && _fallbackCount >= 0 && char.IsLowSurrogate(_strDefault[_fallbackIndex + 1])) - ThrowLastCharRecursive(Char.ConvertToUtf32(charUnknown, _strDefault[_fallbackIndex + 1])); + ThrowLastCharRecursive(char.ConvertToUtf32(charUnknown, _strDefault[_fallbackIndex + 1])); // Nope, just one character ThrowLastCharRecursive(unchecked((int)charUnknown)); @@ -144,18 +144,18 @@ public override bool Fallback(char charUnknown, int index) public override bool Fallback(char charUnknownHigh, char charUnknownLow, int index) { // Double check input surrogate pair - if (!Char.IsHighSurrogate(charUnknownHigh)) + if (!char.IsHighSurrogate(charUnknownHigh)) throw new ArgumentOutOfRangeException(nameof(charUnknownHigh), SR.Format(SR.ArgumentOutOfRange_Range, 0xD800, 0xDBFF)); - if (!Char.IsLowSurrogate(charUnknownLow)) + if (!char.IsLowSurrogate(charUnknownLow)) throw new ArgumentOutOfRangeException(nameof(charUnknownLow), SR.Format(SR.ArgumentOutOfRange_Range, 0xDC00, 0xDFFF)); // If we had a buffer already we're being recursive, throw, it's probably at the suspect // character in our array. if (_fallbackCount >= 1) - ThrowLastCharRecursive(Char.ConvertToUtf32(charUnknownHigh, charUnknownLow)); + ThrowLastCharRecursive(char.ConvertToUtf32(charUnknownHigh, charUnknownLow)); // Go ahead and get our fallback _fallbackCount = _strDefault.Length; diff --git a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs index 90d03cb7bd3f..005f08afd7e7 100644 --- a/src/System.Private.CoreLib/shared/System/Text/Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Encoding.cs @@ -603,7 +603,7 @@ public DecoderFallback DecoderFallback } - public virtual Object Clone() + public virtual object Clone() { Encoding newEncoding = (Encoding)this.MemberwiseClone(); @@ -1089,7 +1089,7 @@ public unsafe string GetString(ReadOnlySpan bytes) { fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) { - return GetString(bytesPtr, bytes.Length); + return string.CreateStringFromEncoding(bytesPtr, bytes.Length, this); } } @@ -1241,7 +1241,7 @@ public virtual string GetString(byte[] bytes, int index, int count) private static Encoding BigEndianUTF32 => UTF32Encoding.s_bigEndianDefault; - public override bool Equals(Object value) + public override bool Equals(object value) { Encoding that = value as Encoding; if (that != null) @@ -1325,7 +1325,7 @@ public DefaultEncoder(Encoding encoding) _encoding = encoding; } - public Object GetRealObject(StreamingContext context) + public object GetRealObject(StreamingContext context) { throw new PlatformNotSupportedException(); } @@ -1390,7 +1390,7 @@ public DefaultDecoder(Encoding encoding) _encoding = encoding; } - public Object GetRealObject(StreamingContext context) + public object GetRealObject(StreamingContext context) { throw new PlatformNotSupportedException(); } diff --git a/src/System.Private.CoreLib/shared/System/Text/EncodingInfo.cs b/src/System.Private.CoreLib/shared/System/Text/EncodingInfo.cs index 99995f759b20..8e71e58fab42 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncodingInfo.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncodingInfo.cs @@ -53,7 +53,7 @@ public Encoding GetEncoding() return Encoding.GetEncoding(iCodePage); } - public override bool Equals(Object value) + public override bool Equals(object value) { EncodingInfo that = value as EncodingInfo; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs b/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs index ce333547b296..e6fa0627d3e0 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncodingNLS.cs @@ -40,13 +40,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -61,11 +61,11 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe int GetByteCount(String s) + public override unsafe int GetByteCount(string s) { // Validate input if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); fixed (char* pChars = s) return GetByteCount(pChars, s.Length, null); @@ -78,10 +78,10 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); @@ -91,20 +91,20 @@ public override unsafe int GetByteCount(char* chars, int count) // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - public override unsafe int GetBytes(String s, int charIndex, int charCount, + public override unsafe int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? "s" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("s", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -130,16 +130,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0, avoid fixed problem if (charCount == 0) @@ -160,10 +160,10 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } @@ -179,13 +179,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays if (count == 0) @@ -203,10 +203,10 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } @@ -220,16 +220,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -250,10 +250,10 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } @@ -269,13 +269,13 @@ public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (count == 0) return string.Empty; diff --git a/src/System.Private.CoreLib/shared/System/Text/EncodingProvider.cs b/src/System.Private.CoreLib/shared/System/Text/EncodingProvider.cs index ce8c3e020875..4d15eea01a24 100644 --- a/src/System.Private.CoreLib/shared/System/Text/EncodingProvider.cs +++ b/src/System.Private.CoreLib/shared/System/Text/EncodingProvider.cs @@ -130,7 +130,7 @@ internal static Encoding GetEncodingFromProvider(string encodingName, EncoderFal return null; } - private static Object s_InternalSyncObject = new Object(); + private static object s_InternalSyncObject = new object(); private static volatile EncodingProvider[] s_providers; } } diff --git a/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs index 335eb76e3cb2..736fff5d2608 100644 --- a/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/Latin1Encoding.cs @@ -11,7 +11,7 @@ namespace System.Text // Latin1Encoding is a simple override to optimize the GetString version of Latin1Encoding. // because of the best fit cases we can't do this when encoding the string, only when decoding // - internal class Latin1Encoding : EncodingNLS + internal sealed class Latin1Encoding : EncodingNLS { // Used by Encoding.Latin1 for lazy initialization // The initialization code will not be run until a static member of the class is referenced @@ -42,7 +42,7 @@ internal override unsafe int GetByteCount(char* chars, int charCount, EncoderNLS if (encoder != null) { charLeftOver = encoder._charLeftOver; - Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver), + Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver), "[Latin1Encoding.GetByteCount]leftover character should be high surrogate"); fallback = encoder.Fallback as EncoderReplacementFallback; @@ -164,7 +164,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, { charLeftOver = encoder._charLeftOver; fallback = encoder.Fallback as EncoderReplacementFallback; - Debug.Assert(charLeftOver == 0 || Char.IsHighSurrogate(charLeftOver), + Debug.Assert(charLeftOver == 0 || char.IsHighSurrogate(charLeftOver), "[Latin1Encoding.GetBytes]leftover character should be high surrogate"); // Verify that we have no fallbackbuffer, for ASCII its always empty, so just assert diff --git a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs index bbdfb39f2196..99021e2dda3f 100644 --- a/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/StringBuilder.cs @@ -201,7 +201,7 @@ private StringBuilder(SerializationInfo info, StreamingContext context) int persistedCapacity = 0; string persistedString = null; - int persistedMaxCapacity = Int32.MaxValue; + int persistedMaxCapacity = int.MaxValue; bool capacityPresent = false; // Get the data @@ -1431,7 +1431,7 @@ public StringBuilder Insert(int index, char[] value, int startIndex, int charCou [CLSCompliant(false)] public StringBuilder Insert(int index, ulong value) => Insert(index, value.ToString(), 1); - public StringBuilder Insert(int index, Object value) => (value == null) ? this : Insert(index, value.ToString(), 1); + public StringBuilder Insert(int index, object value) => (value == null) ? this : Insert(index, value.ToString(), 1); public StringBuilder Insert(int index, ReadOnlySpan value) { @@ -1451,13 +1451,13 @@ public StringBuilder Insert(int index, ReadOnlySpan value) return this; } - public StringBuilder AppendFormat(string format, Object arg0) => AppendFormatHelper(null, format, new ParamsArray(arg0)); + public StringBuilder AppendFormat(string format, object arg0) => AppendFormatHelper(null, format, new ParamsArray(arg0)); - public StringBuilder AppendFormat(string format, Object arg0, Object arg1) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1)); + public StringBuilder AppendFormat(string format, object arg0, object arg1) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1)); - public StringBuilder AppendFormat(string format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1, arg2)); + public StringBuilder AppendFormat(string format, object arg0, object arg1, object arg2) => AppendFormatHelper(null, format, new ParamsArray(arg0, arg1, arg2)); - public StringBuilder AppendFormat(string format, params Object[] args) + public StringBuilder AppendFormat(string format, params object[] args) { if (args == null) { @@ -1470,13 +1470,13 @@ public StringBuilder AppendFormat(string format, params Object[] args) return AppendFormatHelper(null, format, new ParamsArray(args)); } - public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0) => AppendFormatHelper(provider, format, new ParamsArray(arg0)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0, Object arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, Object arg0, Object arg1, Object arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); + public StringBuilder AppendFormat(IFormatProvider provider, string format, object arg0, object arg1, object arg2) => AppendFormatHelper(provider, format, new ParamsArray(arg0, arg1, arg2)); - public StringBuilder AppendFormat(IFormatProvider provider, string format, params Object[] args) + public StringBuilder AppendFormat(IFormatProvider provider, string format, params object[] args) { if (args == null) { @@ -1634,7 +1634,7 @@ internal StringBuilder AppendFormatHelper(IFormatProvider provider, string forma // // Start of parsing of optional formatting parameter. // - Object arg = args[index]; + object arg = args[index]; string itemFormat = null; ReadOnlySpan itemFormatSpan = default; // used if itemFormat is null // Is current character a colon? which indicates start of formatting parameter. diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs index 00ac666d5a41..86169e6b16aa 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF32Encoding.cs @@ -103,13 +103,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -125,11 +125,11 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe int GetByteCount(String s) + public override unsafe int GetByteCount(string s) { // Validate input if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); fixed (char* pChars = s) return GetByteCount(pChars, s.Length, null); @@ -144,10 +144,10 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); @@ -158,20 +158,20 @@ public override unsafe int GetByteCount(char* chars, int count) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - public override unsafe int GetBytes(String s, int charIndex, int charCount, + public override unsafe int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? "s" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("s", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -198,16 +198,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0, avoid fixed problem if (charCount == 0) @@ -230,10 +230,10 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } @@ -250,13 +250,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays. if (count == 0) @@ -276,10 +276,10 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } @@ -294,16 +294,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -326,10 +326,10 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } @@ -346,13 +346,13 @@ public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (count == 0) return string.Empty; @@ -417,7 +417,7 @@ internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS enc // // In previous char, we encounter a high surrogate, so we are expecting a low surrogate here. // - if (Char.IsLowSurrogate(ch)) + if (char.IsLowSurrogate(ch)) { // They're all legal highSurrogate = '\0'; @@ -447,7 +447,7 @@ internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS enc } // Do we have another high surrogate? - if (Char.IsHighSurrogate(ch)) + if (char.IsHighSurrogate(ch)) { // // We'll have a high surrogate to check next time. @@ -457,7 +457,7 @@ internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS enc } // Check for illegal characters - if (Char.IsLowSurrogate(ch)) + if (char.IsLowSurrogate(ch)) { // We have a leading low surrogate, do the fallback charsForFallback = chars; @@ -552,7 +552,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, // // In previous char, we encountered a high surrogate, so we are expecting a low surrogate here. // - if (Char.IsLowSurrogate(ch)) + if (char.IsLowSurrogate(ch)) { // Is it a legal one? uint iTemp = GetSurrogate(highSurrogate, ch); @@ -616,7 +616,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, } // Do we have another high surrogate?, if so remember it - if (Char.IsHighSurrogate(ch)) + if (char.IsHighSurrogate(ch)) { // // We'll have a high surrogate to check next time. @@ -626,7 +626,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, } // Check for illegal characters (low surrogate) - if (Char.IsLowSurrogate(ch)) + if (char.IsLowSurrogate(ch)) { // We have a leading low surrogate, do the fallback charsForFallback = chars; @@ -1159,7 +1159,7 @@ public override byte[] GetPreamble() _emitUTF32ByteOrderMark ? (_bigEndian ? s_bigEndianPreamble : s_littleEndianPreamble) : Array.Empty(); - public override bool Equals(Object value) + public override bool Equals(object value) { UTF32Encoding that = value as UTF32Encoding; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs index cfd6c4da0ff1..5c51c81076c5 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF7Encoding.cs @@ -88,7 +88,7 @@ private void MakeTables() } // We go ahead and set this because Encoding expects it, however nothing can fall back in UTF7. - internal override void SetDefaultFallbacks() + internal sealed override void SetDefaultFallbacks() { // UTF7 had an odd decoderFallback behavior, and the Encoder fallback // is irrelevant because we encode surrogates individually and never check for unmatched ones @@ -97,7 +97,7 @@ internal override void SetDefaultFallbacks() this.decoderFallback = new DecoderUTF7Fallback(); } - public override bool Equals(Object value) + public override bool Equals(object value) { UTF7Encoding that = value as UTF7Encoding; if (that != null) @@ -133,13 +133,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -159,7 +159,7 @@ public override unsafe int GetByteCount(string s) { // Validate input if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); fixed (char* pChars = s) return GetByteCount(pChars, s.Length, null); @@ -174,10 +174,10 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); @@ -192,16 +192,16 @@ public override unsafe int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? "s" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("s", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -228,16 +228,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0, avoid fixed problem if (charCount == 0) @@ -260,10 +260,10 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } @@ -280,13 +280,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays. if (count == 0) @@ -306,10 +306,10 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } @@ -324,16 +324,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -356,10 +356,10 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } @@ -376,13 +376,13 @@ public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (count == 0) return string.Empty; @@ -396,7 +396,7 @@ public override unsafe string GetString(byte[] bytes, int index, int count) // End of standard methods copied from EncodingNLS.cs // - internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder) + internal sealed override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder) { Debug.Assert(chars != null, "[UTF7Encoding.GetByteCount]chars!=null"); Debug.Assert(count >= 0, "[UTF7Encoding.GetByteCount]count >=0"); @@ -405,8 +405,8 @@ internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS bas return GetBytes(chars, count, null, 0, baseEncoder); } - internal override unsafe int GetBytes(char* chars, int charCount, - byte* bytes, int byteCount, EncoderNLS baseEncoder) + internal sealed override unsafe int GetBytes( + char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS baseEncoder) { Debug.Assert(byteCount >= 0, "[UTF7Encoding.GetBytes]byteCount >=0"); Debug.Assert(chars != null, "[UTF7Encoding.GetBytes]chars!=null"); @@ -545,7 +545,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, return buffer.Count; } - internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) + internal sealed override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) { Debug.Assert(count >= 0, "[UTF7Encoding.GetCharCount]count >=0"); Debug.Assert(bytes != null, "[UTF7Encoding.GetCharCount]bytes!=null"); @@ -554,8 +554,8 @@ internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS bas return GetChars(bytes, count, null, 0, baseDecoder); } - internal override unsafe int GetChars(byte* bytes, int byteCount, - char* chars, int charCount, DecoderNLS baseDecoder) + internal sealed override unsafe int GetChars( + byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS baseDecoder) { Debug.Assert(byteCount >= 0, "[UTF7Encoding.GetChars]byteCount >=0"); Debug.Assert(bytes != null, "[UTF7Encoding.GetChars]bytes!=null"); @@ -873,7 +873,7 @@ public override int MaxCharCount } } - public override bool Equals(Object value) + public override bool Equals(object value) { DecoderUTF7Fallback that = value as DecoderUTF7Fallback; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs b/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs index 877010afb5db..c9e51f661e0e 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UTF8Encoding.cs @@ -93,7 +93,7 @@ public UTF8Encoding(bool encoderShouldEmitUTF8Identifier, bool throwOnInvalidByt SetDefaultFallbacks(); } - internal override void SetDefaultFallbacks() + internal sealed override void SetDefaultFallbacks() { // For UTF-X encodings, we use a replacement fallback with an empty string if (_isThrowException) @@ -130,13 +130,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -152,7 +152,7 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe int GetByteCount(String chars) + public override unsafe int GetByteCount(string chars) { // Validate input if (chars==null) @@ -171,34 +171,42 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); } + public override unsafe int GetByteCount(ReadOnlySpan chars) + { + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + { + return GetByteCount(charsPtr, chars.Length, baseEncoder: null); + } + } + // Parent method is safe. // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - public override unsafe int GetBytes(String s, int charIndex, int charCount, + public override unsafe int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? "s" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("s", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -225,16 +233,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0, avoid fixed problem if (charCount == 0) @@ -257,14 +265,23 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } + public override unsafe int GetBytes(ReadOnlySpan chars, Span bytes) + { + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + { + return GetBytes(charsPtr, chars.Length, bytesPtr, bytes.Length, baseEncoder: null); + } + } + // Returns the number of characters produced by decoding a range of bytes // in a byte array. // @@ -277,13 +294,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays. if (count == 0) @@ -303,14 +320,22 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } + public override unsafe int GetCharCount(ReadOnlySpan bytes) + { + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + { + return GetCharCount(bytesPtr, bytes.Length, baseDecoder: null); + } + } + // All of our public Encodings that don't use EncodingNLS must have this (including EncodingNLS) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding @@ -321,16 +346,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -353,14 +378,23 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } + public override unsafe int GetChars(ReadOnlySpan bytes, Span chars) + { + fixed (byte* bytesPtr = &MemoryMarshal.GetNonNullPinnableReference(bytes)) + fixed (char* charsPtr = &MemoryMarshal.GetNonNullPinnableReference(chars)) + { + return GetChars(bytesPtr, bytes.Length, charsPtr, chars.Length, baseDecoder: null); + } + } + // Returns a string containing the decoded representation of a range of // bytes in a byte array. // @@ -373,13 +407,13 @@ public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (count == 0) return string.Empty; @@ -395,7 +429,7 @@ public override unsafe string GetString(byte[] bytes, int index, int count) // To simplify maintenance, the structure of GetByteCount and GetBytes should be // kept the same as much as possible - internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder) + internal sealed override unsafe int GetByteCount(char* chars, int count, EncoderNLS baseEncoder) { // For fallback we may need a fallback buffer. // We wait to initialize it though in case we don't have any broken input unicode @@ -804,8 +838,8 @@ private static bool InRange(int ch, int start, int end) // Our workhorse // Note: We ignore mismatched surrogates, unless the exception flag is set in which case we throw - internal override unsafe int GetBytes(char* chars, int charCount, - byte* bytes, int byteCount, EncoderNLS baseEncoder) + internal sealed override unsafe int GetBytes( + char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS baseEncoder) { Debug.Assert(chars != null, "[UTF8Encoding.GetBytes]chars!=null"); Debug.Assert(byteCount >= 0, "[UTF8Encoding.GetBytes]byteCount >=0"); @@ -1293,7 +1327,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, // // To simplify maintenance, the structure of GetCharCount and GetChars should be // kept the same as much as possible - internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) + internal sealed override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) { Debug.Assert(count >= 0, "[UTF8Encoding.GetCharCount]count >=0"); Debug.Assert(bytes != null, "[UTF8Encoding.GetCharCount]bytes!=null"); @@ -1731,8 +1765,8 @@ internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS bas // // To simplify maintenance, the structure of GetCharCount and GetChars should be // kept the same as much as possible - internal override unsafe int GetChars(byte* bytes, int byteCount, - char* chars, int charCount, DecoderNLS baseDecoder) + internal sealed override unsafe int GetChars( + byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS baseDecoder) { Debug.Assert(chars != null, "[UTF8Encoding.GetChars]chars!=null"); Debug.Assert(byteCount >= 0, "[UTF8Encoding.GetChars]count >=0"); @@ -2205,7 +2239,7 @@ internal override unsafe int GetChars(byte* bytes, int byteCount, // extra byte, we're already planning 2 chars for 2 of these bytes, // but the big loop is testing the target against pStop, so we need - // to subtract 2 more or we risk overrunning the input. Subtract + // to subtract 2 more or we risk overrunning the input. Subtract // one here and one below. pStop--; } @@ -2355,11 +2389,17 @@ private unsafe bool FallbackInvalidByteSequence( private unsafe int FallbackInvalidByteSequence( byte* pSrc, int ch, DecoderFallbackBuffer fallback) { + // Calling GetBytesUnknown can adjust the pSrc pointer but we need to pass the pointer before the adjustment + // to fallback.InternalFallback. The input pSrc to fallback.InternalFallback will only be used to calculate the + // index inside bytesUnknown and if we pass the adjusted pointer we can end up with negative index values. + // We store the original pSrc in pOriginalSrc and then pass pOriginalSrc to fallback.InternalFallback. + byte* pOriginalSrc = pSrc; + // Get our byte[] byte[] bytesUnknown = GetBytesUnknown(ref pSrc, ch); // Do the actual fallback - int count = fallback.InternalFallback(bytesUnknown, pSrc); + int count = fallback.InternalFallback(bytesUnknown, pOriginalSrc); // # of fallback chars expected. // Note that we only get here for "long" sequences, and have already unreserved @@ -2368,7 +2408,7 @@ private unsafe int FallbackInvalidByteSequence( } // Note that some of these bytes may have come from a previous fallback, so we cannot - // just decrement the pointer and use the values we read. In those cases we have + // just decrement the pointer and use the values we read. In those cases we have // to regenerate the original values. private unsafe byte[] GetBytesUnknown(ref byte* pSrc, int ch) { @@ -2513,7 +2553,7 @@ public override byte[] GetPreamble() _emitUTF8Identifier ? s_preamble : Array.Empty(); - public override bool Equals(Object value) + public override bool Equals(object value) { UTF8Encoding that = value as UTF8Encoding; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs b/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs index 8386c49c5f86..6a27d2c85561 100644 --- a/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs +++ b/src/System.Private.CoreLib/shared/System/Text/UnicodeEncoding.cs @@ -61,7 +61,7 @@ public UnicodeEncoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidBy SetDefaultFallbacks(); } - internal override void SetDefaultFallbacks() + internal sealed override void SetDefaultFallbacks() { // For UTF-X encodings, we use a replacement fallback with an empty string if (this.isThrowException) @@ -94,13 +94,13 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) { // Validate input parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - index < count) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input, return 0, avoid fixed empty array problem if (count == 0) @@ -116,11 +116,11 @@ public override unsafe int GetByteCount(char[] chars, int index, int count) // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding // parent method is safe - public override unsafe int GetByteCount(String s) + public override unsafe int GetByteCount(string s) { // Validate input if (s==null) - throw new ArgumentNullException("s"); + throw new ArgumentNullException(nameof(s)); fixed (char* pChars = s) return GetByteCount(pChars, s.Length, null); @@ -135,10 +135,10 @@ public override unsafe int GetByteCount(char* chars, int count) { // Validate Parameters if (chars == null) - throw new ArgumentNullException("chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(chars), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); // Call it with empty encoder return GetByteCount(chars, count, null); @@ -149,20 +149,20 @@ public override unsafe int GetByteCount(char* chars, int count) // So if you fix this, fix the others. Currently those include: // EncodingNLS, UTF7Encoding, UTF8Encoding, UTF32Encoding, ASCIIEncoding, UnicodeEncoding - public override unsafe int GetBytes(String s, int charIndex, int charCount, + public override unsafe int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex) { if (s == null || bytes == null) - throw new ArgumentNullException((s == null ? "s" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((s == null ? nameof(s) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (s.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("s", SR.ArgumentOutOfRange_IndexCount); + throw new ArgumentOutOfRangeException(nameof(s), SR.ArgumentOutOfRange_IndexCount); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); int byteCount = bytes.Length - byteIndex; @@ -189,16 +189,16 @@ public override unsafe int GetBytes(char[] chars, int charIndex, int charCount, { // Validate parameters if (chars == null || bytes == null) - throw new ArgumentNullException((chars == null ? "chars" : "bytes"), SR.ArgumentNull_Array); + throw new ArgumentNullException((chars == null ? nameof(chars) : nameof(bytes)), SR.ArgumentNull_Array); if (charIndex < 0 || charCount < 0) - throw new ArgumentOutOfRangeException((charIndex < 0 ? "charIndex" : "charCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charIndex < 0 ? nameof(charIndex) : nameof(charCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if (chars.Length - charIndex < charCount) - throw new ArgumentOutOfRangeException("chars", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(chars), SR.ArgumentOutOfRange_IndexCountBuffer); if (byteIndex < 0 || byteIndex > bytes.Length) - throw new ArgumentOutOfRangeException("byteIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ArgumentOutOfRange_Index); // If nothing to encode return 0, avoid fixed problem if (charCount == 0) @@ -221,10 +221,10 @@ public override unsafe int GetBytes(char* chars, int charCount, byte* bytes, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetBytes(chars, charCount, bytes, byteCount, null); } @@ -241,13 +241,13 @@ public override unsafe int GetCharCount(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // If no input just return 0, fixed doesn't like 0 length arrays if (count == 0) @@ -267,10 +267,10 @@ public override unsafe int GetCharCount(byte* bytes, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (count < 0) - throw new ArgumentOutOfRangeException("count", SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException(nameof(count), SR.ArgumentOutOfRange_NeedNonNegNum); return GetCharCount(bytes, count, null); } @@ -285,16 +285,16 @@ public override unsafe int GetChars(byte[] bytes, int byteIndex, int byteCount, { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (byteIndex < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((byteIndex < 0 ? "byteIndex" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((byteIndex < 0 ? nameof(byteIndex) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); if ( bytes.Length - byteIndex < byteCount) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); if (charIndex < 0 || charIndex > chars.Length) - throw new ArgumentOutOfRangeException("charIndex", SR.ArgumentOutOfRange_Index); + throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ArgumentOutOfRange_Index); // If no input, return 0 & avoid fixed problem if (byteCount == 0) @@ -317,10 +317,10 @@ public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int { // Validate Parameters if (bytes == null || chars == null) - throw new ArgumentNullException(bytes == null ? "bytes" : "chars", SR.ArgumentNull_Array); + throw new ArgumentNullException(bytes == null ? nameof(bytes) : nameof(chars), SR.ArgumentNull_Array); if (charCount < 0 || byteCount < 0) - throw new ArgumentOutOfRangeException((charCount < 0 ? "charCount" : "byteCount"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((charCount < 0 ? nameof(charCount) : nameof(byteCount)), SR.ArgumentOutOfRange_NeedNonNegNum); return GetChars(bytes, byteCount, chars, charCount, null); } @@ -337,13 +337,13 @@ public override unsafe string GetString(byte[] bytes, int index, int count) { // Validate Parameters if (bytes == null) - throw new ArgumentNullException("bytes", SR.ArgumentNull_Array); + throw new ArgumentNullException(nameof(bytes), SR.ArgumentNull_Array); if (index < 0 || count < 0) - throw new ArgumentOutOfRangeException((index < 0 ? "index" : "count"), SR.ArgumentOutOfRange_NeedNonNegNum); + throw new ArgumentOutOfRangeException((index < 0 ? nameof(index) : nameof(count)), SR.ArgumentOutOfRange_NeedNonNegNum); if (bytes.Length - index < count) - throw new ArgumentOutOfRangeException("bytes", SR.ArgumentOutOfRange_IndexCountBuffer); + throw new ArgumentOutOfRangeException(nameof(bytes), SR.ArgumentOutOfRange_IndexCountBuffer); // Avoid problems with empty input buffer if (count == 0) return string.Empty; @@ -357,7 +357,7 @@ public override unsafe string GetString(byte[] bytes, int index, int count) // End of standard methods copied from EncodingNLS.cs // - internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS encoder) + internal sealed override unsafe int GetByteCount(char* chars, int count, EncoderNLS encoder) { Debug.Assert(chars != null, "[UnicodeEncoding.GetByteCount]chars!=null"); Debug.Assert(count >= 0, "[UnicodeEncoding.GetByteCount]count >=0"); @@ -650,8 +650,8 @@ internal override unsafe int GetByteCount(char* chars, int count, EncoderNLS enc return byteCount; } - internal override unsafe int GetBytes(char* chars, int charCount, - byte* bytes, int byteCount, EncoderNLS encoder) + internal sealed override unsafe int GetBytes( + char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS encoder) { Debug.Assert(chars != null, "[UnicodeEncoding.GetBytes]chars!=null"); Debug.Assert(byteCount >= 0, "[UnicodeEncoding.GetBytes]byteCount >=0"); @@ -1007,7 +1007,7 @@ internal override unsafe int GetBytes(char* chars, int charCount, return (int)(bytes - byteStart); } - internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) + internal sealed override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder) { Debug.Assert(bytes != null, "[UnicodeEncoding.GetCharCount]bytes!=null"); Debug.Assert(count >= 0, "[UnicodeEncoding.GetCharCount]count >=0"); @@ -1334,8 +1334,8 @@ internal override unsafe int GetCharCount(byte* bytes, int count, DecoderNLS bas return charCount; } - internal override unsafe int GetChars(byte* bytes, int byteCount, - char* chars, int charCount, DecoderNLS baseDecoder) + internal sealed override unsafe int GetChars( + byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS baseDecoder) { Debug.Assert(chars != null, "[UnicodeEncoding.GetChars]chars!=null"); Debug.Assert(byteCount >= 0, "[UnicodeEncoding.GetChars]byteCount >=0"); @@ -1789,7 +1789,7 @@ public override byte[] GetPreamble() else return new byte[2] { 0xff, 0xfe }; } - return Array.Empty(); + return Array.Empty(); } public override ReadOnlySpan Preamble => @@ -1842,7 +1842,7 @@ public override int GetMaxCharCount(int byteCount) } - public override bool Equals(Object value) + public override bool Equals(object value) { UnicodeEncoding that = value as UnicodeEncoding; if (that != null) diff --git a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs index 1e33bdb49b4d..045a40b65272 100644 --- a/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs +++ b/src/System.Private.CoreLib/shared/System/Text/ValueStringBuilder.cs @@ -9,7 +9,7 @@ namespace System.Text { - internal ref struct ValueStringBuilder + internal ref partial struct ValueStringBuilder { private char[] _arrayToReturnToPool; private Span _chars; @@ -132,7 +132,7 @@ public void Insert(int index, char value, int count) public void Append(char c) { int pos = _pos; - if (pos < _chars.Length) + if ((uint)pos < (uint)_chars.Length) { _chars[pos] = c; _pos = pos + 1; @@ -147,7 +147,7 @@ public void Append(char c) public void Append(string s) { int pos = _pos; - if (s.Length == 1 && pos < _chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. + if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc. { _chars[pos] = s[0]; _pos = pos + 1; diff --git a/src/System.Private.CoreLib/shared/System/Threading/AbandonedMutexException.cs b/src/System.Private.CoreLib/shared/System/Threading/AbandonedMutexException.cs index c7e604f33dde..bd504dd27a72 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/AbandonedMutexException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/AbandonedMutexException.cs @@ -27,13 +27,13 @@ public AbandonedMutexException() HResult = HResults.COR_E_ABANDONEDMUTEX; } - public AbandonedMutexException(String message) + public AbandonedMutexException(string message) : base(message) { HResult = HResults.COR_E_ABANDONEDMUTEX; } - public AbandonedMutexException(String message, Exception inner) + public AbandonedMutexException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_ABANDONEDMUTEX; @@ -46,14 +46,14 @@ public AbandonedMutexException(int location, WaitHandle handle) SetupException(location, handle); } - public AbandonedMutexException(String message, int location, WaitHandle handle) + public AbandonedMutexException(string message, int location, WaitHandle handle) : base(message) { HResult = HResults.COR_E_ABANDONEDMUTEX; SetupException(location, handle); } - public AbandonedMutexException(String message, Exception inner, int location, WaitHandle handle) + public AbandonedMutexException(string message, Exception inner, int location, WaitHandle handle) : base(message, inner) { HResult = HResults.COR_E_ABANDONEDMUTEX; diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs b/src/System.Private.CoreLib/shared/System/Threading/CancellationToken.cs similarity index 89% rename from src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs rename to src/System.Private.CoreLib/shared/System/Threading/CancellationToken.cs index cffaf22cd48d..68e6971a5426 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationToken.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/CancellationToken.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Diagnostics; +using System.Runtime.CompilerServices; namespace System.Threading { @@ -29,14 +30,14 @@ namespace System.Threading [DebuggerDisplay("IsCancellationRequested = {IsCancellationRequested}")] public readonly struct CancellationToken { - private readonly static Action s_actionToActionObjShunt = obj => ((Action)obj)(); - // The backing TokenSource. // if null, it implicitly represents the same thing as new CancellationToken(false). // When required, it will be instantiated to reflect this. private readonly CancellationTokenSource _source; //!! warning. If more fields are added, the assumptions in CreateLinkedToken may no longer be valid + private readonly static Action s_actionToActionObjShunt = obj => ((Action)obj)(); + /// /// Returns an empty CancellationToken value. /// @@ -136,7 +137,7 @@ public CancellationTokenRegistration Register(Action callback) => Register( s_actionToActionObjShunt, callback ?? throw new ArgumentNullException(nameof(callback)), - useSyncContext: false, + useSynchronizationContext: false, useExecutionContext: true); /// @@ -189,7 +190,7 @@ public CancellationTokenRegistration Register(Action callback, bool useSynchroni /// be used to unregister the callback. /// is null. public CancellationTokenRegistration Register(Action callback, object state) => - Register(callback, state, useSyncContext: false, useExecutionContext: true); + Register(callback, state, useSynchronizationContext: false, useExecutionContext: true); /// /// Registers a delegate that will be called when this @@ -222,19 +223,43 @@ public CancellationTokenRegistration Register(Action callback, object st // helper for internal registration needs that don't require an EC capture (e.g. creating linked token sources, or registering unstarted TPL tasks) // has a handy signature, and skips capturing execution context. internal CancellationTokenRegistration InternalRegisterWithoutEC(Action callback, object state) => - Register(callback, state, useSyncContext: false, useExecutionContext: false); + Register(callback, state, useSynchronizationContext: false, useExecutionContext: false); - // the real work.. - private CancellationTokenRegistration Register(Action callback, object state, bool useSyncContext, bool useExecutionContext) + /// + /// Registers a delegate that will be called when this + /// CancellationToken is canceled. + /// + /// + /// + /// If this token is already in the canceled state, the + /// delegate will be run immediately and synchronously. Any exception the delegate generates will be + /// propagated out of this method call. + /// + /// + /// The delegate to be executed when the CancellationToken is canceled. + /// The state to pass to the when the delegate is invoked. This may be null. + /// A Boolean value that indicates whether to capture + /// the current SynchronizationContext and use it + /// when invoking the . + /// The instance that can + /// be used to unregister the callback. + /// is null. + /// The associated CancellationTokenSource has been disposed. +#if CORECLR + private +#else + [MethodImpl(MethodImplOptions.NoInlining)] + public +#endif + CancellationTokenRegistration Register(Action callback, object state, bool useSynchronizationContext, bool useExecutionContext) { if (callback == null) - { throw new ArgumentNullException(nameof(callback)); - } CancellationTokenSource source = _source; return source != null ? - source.InternalRegister(callback, state, useSyncContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) : + source.InternalRegister(callback, state, useSynchronizationContext ? SynchronizationContext.Current : null, useExecutionContext ? ExecutionContext.Capture() : null) : default; // Nothing to do for tokens than can never reach the canceled state. Give back a dummy registration. } @@ -305,9 +330,7 @@ private CancellationTokenRegistration Register(Action callback, object s public void ThrowIfCancellationRequested() { if (IsCancellationRequested) - { ThrowOperationCanceledException(); - } } // Throws an OCE; separated out to enable better inlining of ThrowIfCancellationRequested diff --git a/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.Windows.cs b/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.Windows.cs new file mode 100644 index 000000000000..2da53b2b80b5 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.Windows.cs @@ -0,0 +1,93 @@ +// 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.IO; +using System.Runtime.InteropServices; +using Microsoft.Win32.SafeHandles; + +namespace System.Threading +{ + public partial class EventWaitHandle + { + private const uint AccessRights = (uint)Interop.Kernel32.MAXIMUM_ALLOWED | Interop.Kernel32.SYNCHRONIZE | Interop.Kernel32.EVENT_MODIFY_STATE; + + private EventWaitHandle(SafeWaitHandle handle) + { + SafeWaitHandle = handle; + } + + private void CreateEventCore(bool initialState, EventResetMode mode, string name, out bool createdNew) + { +#if !PLATFORM_WINDOWS + if (name != null) + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); +#endif + uint eventFlags = initialState ? Interop.Kernel32.CREATE_EVENT_INITIAL_SET : 0; + if (mode == EventResetMode.ManualReset) + eventFlags |= (uint)Interop.Kernel32.CREATE_EVENT_MANUAL_RESET; + + SafeWaitHandle handle = Interop.Kernel32.CreateEventEx(IntPtr.Zero, name, eventFlags, AccessRights); + + int errorCode = Marshal.GetLastWin32Error(); + if (handle.IsInvalid) + { + handle.SetHandleAsInvalid(); + if (name != null && name.Length != 0 && errorCode == Interop.Errors.ERROR_INVALID_HANDLE) + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + + throw Win32Marshal.GetExceptionForWin32Error(errorCode, name); + } + createdNew = errorCode != Interop.Errors.ERROR_ALREADY_EXISTS; + SafeWaitHandle = handle; + } + + private static OpenExistingResult OpenExistingWorker(string name, out EventWaitHandle result) + { +#if PLATFORM_WINDOWS + if (name == null) + throw new ArgumentNullException(nameof(name)); + if (name.Length == 0) + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); + + result = null; + SafeWaitHandle myHandle = Interop.Kernel32.OpenEvent(AccessRights, false, name); + + if (myHandle.IsInvalid) + { + int errorCode = Marshal.GetLastWin32Error(); + + if (errorCode == Interop.Errors.ERROR_FILE_NOT_FOUND || errorCode == Interop.Errors.ERROR_INVALID_NAME) + return OpenExistingResult.NameNotFound; + if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND) + return OpenExistingResult.PathNotFound; + if (name != null && name.Length != 0 && errorCode == Interop.Errors.ERROR_INVALID_HANDLE) + return OpenExistingResult.NameInvalid; + + throw Win32Marshal.GetExceptionForWin32Error(errorCode, name); + } + result = new EventWaitHandle(myHandle); + return OpenExistingResult.Success; +#else + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); +#endif + } + + public bool Reset() + { + bool res = Interop.Kernel32.ResetEvent(_waitHandle); + if (!res) + throw Win32Marshal.GetExceptionForLastWin32Error(); + return res; + } + + public bool Set() + { + bool res = Interop.Kernel32.SetEvent(_waitHandle); + if (!res) + throw Win32Marshal.GetExceptionForLastWin32Error(); + return res; + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.cs b/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.cs new file mode 100644 index 000000000000..4cd733b9bd55 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/EventWaitHandle.cs @@ -0,0 +1,51 @@ +// 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.IO; + +namespace System.Threading +{ + public partial class EventWaitHandle : WaitHandle + { + public EventWaitHandle(bool initialState, EventResetMode mode) : + this(initialState, mode, null, out _) + { + } + + public EventWaitHandle(bool initialState, EventResetMode mode, string name) : + this(initialState, mode, name, out _) + { + } + + public EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew) + { + if (mode != EventResetMode.AutoReset && mode != EventResetMode.ManualReset) + throw new ArgumentException(SR.Argument_InvalidFlag, nameof(mode)); + + CreateEventCore(initialState, mode, name, out createdNew); + } + + public static EventWaitHandle OpenExisting(string name) + { + EventWaitHandle result; + switch (OpenExistingWorker(name, out result)) + { + case OpenExistingResult.NameNotFound: + throw new WaitHandleCannotBeOpenedException(); + case OpenExistingResult.NameInvalid: + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + case OpenExistingResult.PathNotFound: + throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, name)); + default: + return result; + } + } + + public static bool TryOpenExisting(string name, out EventWaitHandle result) + { + return OpenExistingWorker(name, out result) == OpenExistingResult.Success; + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs b/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs index 975ed02d4279..694514ef07e8 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @@ -19,7 +19,7 @@ namespace System.Threading { - public delegate void ContextCallback(Object state); + public delegate void ContextCallback(object state); public sealed class ExecutionContext : IDisposable, ISerializable { @@ -112,7 +112,7 @@ public static bool IsFlowSuppressed() internal bool IsDefault => m_isDefault; - public static void Run(ExecutionContext executionContext, ContextCallback callback, Object state) + public static void Run(ExecutionContext executionContext, ContextCallback callback, object state) { // Note: ExecutionContext.Run is an extremely hot function and used by every await, ThreadPool execution, etc. if (executionContext == null) @@ -123,7 +123,7 @@ public static void Run(ExecutionContext executionContext, ContextCallback callba RunInternal(executionContext, callback, state); } - internal static void RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) + internal static void RunInternal(ExecutionContext executionContext, ContextCallback callback, object state) { // Note: ExecutionContext.RunInternal is an extremely hot function and used by every await, ThreadPool execution, etc. // Note: Manual enregistering may be addressed by "Exception Handling Write Through Optimization" diff --git a/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs b/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs similarity index 98% rename from src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs rename to src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs index 297afa1f9c9e..2f57aa750364 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ManualResetEventSlim.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ManualResetEventSlim.cs @@ -1,16 +1,6 @@ // 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. -#pragma warning disable 0420 - -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ -// -// SlimManualResetEvent.cs -// -// -// An manual-reset event that mixes a little spinning with a true Win32 event. -// -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- using System.Diagnostics; @@ -52,7 +42,7 @@ public class ManualResetEventSlim : IDisposable // -- State -- // //For a packed word a uint would seem better, but Interlocked.* doesn't support them as uint isn't CLS-compliant. - private volatile int m_combinedState; //ie a UInt32. Used for the state items listed below. + private volatile int m_combinedState; //ie a uint. Used for the state items listed below. //1-bit for signalled state private const int SignalledState_BitMask = unchecked((int)0x80000000);//1000 0000 0000 0000 0000 0000 0000 0000 @@ -265,7 +255,7 @@ private bool LazyInitializeEvent() if (Interlocked.CompareExchange(ref m_eventObj, newEventObj, null) != null) { // Someone else set the value due to a race condition. Destroy the garbage event. - newEventObj.Close(); + newEventObj.Dispose(); return false; } @@ -342,7 +332,7 @@ private void Set(bool duringCancellation) // necessary. However, the coding pattern { event.Wait(); event.Dispose() } is // quite common, and we must support it. If the waiter woke up and disposed of // the event object before the setter has finished, however, we would try to set a - // now-disposed Win32 event. Crash! To deal with this race condition, we use a lock to + // now-disposed Win32 event. Crash! To deal with this race condition, we use a lock to // protect access to the event object when setting and disposing of it. We also // double-check that the event has not become null in the meantime when in the lock. @@ -561,7 +551,7 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) var spinner = new SpinWait(); while (spinner.Count < spinCount) { - spinner.SpinOnce(SpinWait.Sleep1ThresholdForSpinBeforeWait); + spinner.SpinOnce(SpinWait.Sleep1ThresholdForLongSpinBeforeWait); if (IsSet) { @@ -622,7 +612,6 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) // Clean up: we're done waiting. Waiters = Waiters - 1; } - // Now just loop back around, and the right thing will happen. Either: // 1. We had a spurious wake-up due to some other wait being canceled via a different cancellationToken (rewait) // or 2. the wait was successful. (the loop will break) @@ -654,7 +643,7 @@ public void Dispose() /// true to release both managed and unmanaged resources; /// false to release only unmanaged resources. /// - /// Unlike most of the members of , is not + /// Unlike most of the members of , is not /// thread-safe and may not be used concurrently with other members of this instance. /// protected virtual void Dispose(bool disposing) @@ -672,7 +661,7 @@ protected virtual void Dispose(bool disposing) { lock (eventObj) { - eventObj.Close(); + eventObj.Dispose(); m_eventObj = null; } } diff --git a/src/System.Private.CoreLib/src/System/Threading/Mutex.cs b/src/System.Private.CoreLib/shared/System/Threading/Mutex.Windows.cs similarity index 50% rename from src/System.Private.CoreLib/src/System/Threading/Mutex.cs rename to src/System.Private.CoreLib/shared/System/Threading/Mutex.Windows.cs index 86981b564224..212eb9dc31fa 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Mutex.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Mutex.Windows.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.IO; using Microsoft.Win32; using Microsoft.Win32.SafeHandles; @@ -14,110 +13,28 @@ namespace System.Threading /// /// Synchronization primitive that can also be used for interprocess synchronization /// - public sealed class Mutex : WaitHandle + public sealed partial class Mutex : WaitHandle { private const uint AccessRights = - (uint)Win32Native.MAXIMUM_ALLOWED | Win32Native.SYNCHRONIZE | Win32Native.MUTEX_MODIFY_STATE; - -#if PLATFORM_UNIX - // Maximum file name length on tmpfs file system. - private const int WaitHandleNameMax = 255; -#endif - - public Mutex(bool initiallyOwned, string name, out bool createdNew) - { -#if !PLATFORM_UNIX - VerifyNameForCreate(name); -#endif - CreateMutexCore(initiallyOwned, name, out createdNew); - } - - public Mutex(bool initiallyOwned, string name) - { -#if !PLATFORM_UNIX - VerifyNameForCreate(name); -#endif - CreateMutexCore(initiallyOwned, name, out _); - } - - public Mutex(bool initiallyOwned) - { - CreateMutexCore(initiallyOwned, null, out _); - } - - public Mutex() - { - CreateMutexCore(false, null, out _); - } - - private Mutex(SafeWaitHandle handle) - { - SafeWaitHandle = handle; - } - - public static Mutex OpenExisting(string name) - { - switch (OpenExistingWorker(name, out Mutex result)) - { - case OpenExistingResult.NameNotFound: - throw new WaitHandleCannotBeOpenedException(); - - case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - case OpenExistingResult.PathNotFound: - throw Win32Marshal.GetExceptionForWin32Error(Interop.Errors.ERROR_PATH_NOT_FOUND, name); - - default: - return result; - } - } - - public static bool TryOpenExisting(string name, out Mutex result) => - OpenExistingWorker(name, out result) == OpenExistingResult.Success; - - // Note: To call ReleaseMutex, you must have an ACL granting you - // MUTEX_MODIFY_STATE rights (0x0001). The other interesting value - // in a Mutex's ACL is MUTEX_ALL_ACCESS (0x1F0001). - public void ReleaseMutex() - { - if (!Win32Native.ReleaseMutex(safeWaitHandle)) - { - throw new ApplicationException(SR.Arg_SynchronizationLockException); - } - } - -#if !PLATFORM_UNIX - private static void VerifyNameForCreate(string name) - { - if (name != null && (Interop.Kernel32.MAX_PATH < name.Length)) - { - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); - } - } -#endif + (uint)Interop.Kernel32.MAXIMUM_ALLOWED | Interop.Kernel32.SYNCHRONIZE | Interop.Kernel32.MUTEX_MODIFY_STATE; private void CreateMutexCore(bool initiallyOwned, string name, out bool createdNew) { -#if !PLATFORM_UNIX - Debug.Assert(name == null || name.Length <= Interop.Kernel32.MAX_PATH); -#endif - - uint mutexFlags = initiallyOwned ? Win32Native.CREATE_MUTEX_INITIAL_OWNER : 0; - - SafeWaitHandle mutexHandle = Win32Native.CreateMutexEx(null, name, mutexFlags, AccessRights); + uint mutexFlags = initiallyOwned ? Interop.Kernel32.CREATE_MUTEX_INITIAL_OWNER : 0; + SafeWaitHandle mutexHandle = Interop.Kernel32.CreateMutexEx(IntPtr.Zero, name, mutexFlags, AccessRights); int errorCode = Marshal.GetLastWin32Error(); if (mutexHandle.IsInvalid) { mutexHandle.SetHandleAsInvalid(); -#if PLATFORM_UNIX +#if !PLATFORM_WINDOWS if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, WaitHandleNameMax), nameof(name)); + throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name)); #endif if (errorCode == Interop.Errors.ERROR_INVALID_HANDLE) throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + throw Win32Marshal.GetExceptionForWin32Error(errorCode, name); } @@ -137,33 +54,28 @@ private static OpenExistingResult OpenExistingWorker(string name, out Mutex resu throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); } -#if !PLATFORM_UNIX - VerifyNameForCreate(name); -#endif - result = null; // To allow users to view & edit the ACL's, call OpenMutex // with parameters to allow us to view & edit the ACL. This will - // fail if we don't have permission to view or edit the ACL's. + // fail if we don't have permission to view or edit the ACL's. // If that happens, ask for less permissions. - SafeWaitHandle myHandle = Win32Native.OpenMutex(AccessRights, false, name); + SafeWaitHandle myHandle = Interop.Kernel32.OpenMutex(AccessRights, false, name); if (myHandle.IsInvalid) { int errorCode = Marshal.GetLastWin32Error(); - -#if PLATFORM_UNIX - if (name != null && errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) +#if !PLATFORM_WINDOWS + if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE) { // On Unix, length validation is done by CoreCLR's PAL after converting to utf-8 - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, WaitHandleNameMax), nameof(name)); + throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name)); } #endif if (Interop.Errors.ERROR_FILE_NOT_FOUND == errorCode || Interop.Errors.ERROR_INVALID_NAME == errorCode) return OpenExistingResult.NameNotFound; if (Interop.Errors.ERROR_PATH_NOT_FOUND == errorCode) return OpenExistingResult.PathNotFound; - if (null != name && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) + if (Interop.Errors.ERROR_INVALID_HANDLE == errorCode) return OpenExistingResult.NameInvalid; // this is for passed through Win32Native Errors @@ -171,8 +83,18 @@ private static OpenExistingResult OpenExistingWorker(string name, out Mutex resu } result = new Mutex(myHandle); - return OpenExistingResult.Success; } + + // Note: To call ReleaseMutex, you must have an ACL granting you + // MUTEX_MODIFY_STATE rights (0x0001). The other interesting value + // in a Mutex's ACL is MUTEX_ALL_ACCESS (0x1F0001). + public void ReleaseMutex() + { + if (!Interop.Kernel32.ReleaseMutex(_waitHandle)) + { + throw new ApplicationException(SR.Arg_SynchronizationLockException); + } + } } } diff --git a/src/System.Private.CoreLib/shared/System/Threading/Mutex.cs b/src/System.Private.CoreLib/shared/System/Threading/Mutex.cs new file mode 100644 index 000000000000..d85242892dfb --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/Mutex.cs @@ -0,0 +1,62 @@ +// 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.IO; +using Microsoft.Win32; +using Microsoft.Win32.SafeHandles; +using System.Runtime.InteropServices; +using System.Diagnostics; + +namespace System.Threading +{ + /// + /// Synchronization primitive that can also be used for interprocess synchronization + /// + public sealed partial class Mutex : WaitHandle + { + public Mutex(bool initiallyOwned, string name, out bool createdNew) + { + CreateMutexCore(initiallyOwned, name, out createdNew); + } + + public Mutex(bool initiallyOwned, string name) + { + CreateMutexCore(initiallyOwned, name, out _); + } + + public Mutex(bool initiallyOwned) + { + CreateMutexCore(initiallyOwned, null, out _); + } + + public Mutex() + { + CreateMutexCore(false, null, out _); + } + + private Mutex(SafeWaitHandle handle) + { + SafeWaitHandle = handle; + } + + public static Mutex OpenExisting(string name) + { + switch (OpenExistingWorker(name, out Mutex result)) + { + case OpenExistingResult.NameNotFound: + throw new WaitHandleCannotBeOpenedException(); + case OpenExistingResult.NameInvalid: + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + case OpenExistingResult.PathNotFound: + throw new DirectoryNotFoundException(SR.Format(SR.IO_PathNotFound_Path, name)); + + default: + return result; + } + } + + public static bool TryOpenExisting(string name, out Mutex result) => + OpenExistingWorker(name, out result) == OpenExistingResult.Success; + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/NativeOverlapped.cs b/src/System.Private.CoreLib/shared/System/Threading/NativeOverlapped.cs new file mode 100644 index 000000000000..933cb81ecc69 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/NativeOverlapped.cs @@ -0,0 +1,18 @@ +// 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.Runtime.InteropServices; + +namespace System.Threading +{ + [StructLayout(LayoutKind.Sequential)] + public struct NativeOverlapped + { + public IntPtr InternalLow; + public IntPtr InternalHigh; + public int OffsetLow; + public int OffsetHigh; + public IntPtr EventHandle; + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/ReaderWriterLockSlim.cs b/src/System.Private.CoreLib/shared/System/Threading/ReaderWriterLockSlim.cs index 45175488e7e3..9424fbd5b492 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ReaderWriterLockSlim.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ReaderWriterLockSlim.cs @@ -241,7 +241,7 @@ private struct TimeoutTracker public TimeoutTracker(TimeSpan timeout) { long ltm = (long)timeout.TotalMilliseconds; - if (ltm < -1 || ltm > (long)Int32.MaxValue) + if (ltm < -1 || ltm > (long)int.MaxValue) throw new ArgumentOutOfRangeException(nameof(timeout)); _total = (int)ltm; if (_total != -1 && _total != 0) diff --git a/src/System.Private.CoreLib/shared/System/Threading/Semaphore.Windows.cs b/src/System.Private.CoreLib/shared/System/Threading/Semaphore.Windows.cs new file mode 100644 index 000000000000..8a14f5ef3890 --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/Semaphore.Windows.cs @@ -0,0 +1,88 @@ +// 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.Win32.SafeHandles; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +namespace System.Threading +{ + public sealed partial class Semaphore + { + private const uint AccessRights = (uint)Interop.Kernel32.MAXIMUM_ALLOWED | Interop.Kernel32.SYNCHRONIZE | Interop.Kernel32.SEMAPHORE_MODIFY_STATE; + + private Semaphore(SafeWaitHandle handle) + { + SafeWaitHandle = handle; + } + + private void CreateSemaphoreCore(int initialCount, int maximumCount, string name, out bool createdNew) + { + Debug.Assert(initialCount >= 0); + Debug.Assert(maximumCount >= 1); + Debug.Assert(initialCount <= maximumCount); + +#if !PLATFORM_WINDOWS + if (name != null) + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); +#endif + SafeWaitHandle myHandle = Interop.Kernel32.CreateSemaphoreEx(IntPtr.Zero, initialCount, maximumCount, name, 0, AccessRights); + + int errorCode = Marshal.GetLastWin32Error(); + if (myHandle.IsInvalid) + { + if (name != null && name.Length != 0 && errorCode == Interop.Errors.ERROR_INVALID_HANDLE) + throw new WaitHandleCannotBeOpenedException( + SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + + throw Win32Marshal.GetExceptionForLastWin32Error(); + } + createdNew = errorCode != Interop.Errors.ERROR_ALREADY_EXISTS; + this.SafeWaitHandle = myHandle; + } + + private static OpenExistingResult OpenExistingWorker(string name, out Semaphore result) + { +#if PLATFORM_WINDOWS + if (name == null) + throw new ArgumentNullException(nameof(name)); + if (name.Length == 0) + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); + + // Pass false to OpenSemaphore to prevent inheritedHandles + SafeWaitHandle myHandle = Interop.Kernel32.OpenSemaphore(AccessRights, false, name); + + if (myHandle.IsInvalid) + { + result = null; + int errorCode = Marshal.GetLastWin32Error(); + + if (errorCode == Interop.Errors.ERROR_FILE_NOT_FOUND || errorCode == Interop.Errors.ERROR_INVALID_NAME) + return OpenExistingResult.NameNotFound; + if (errorCode == Interop.Errors.ERROR_PATH_NOT_FOUND) + return OpenExistingResult.PathNotFound; + if (name != null && name.Length != 0 && errorCode == Interop.Errors.ERROR_INVALID_HANDLE) + return OpenExistingResult.NameInvalid; + // this is for passed through NativeMethods Errors + throw Win32Marshal.GetExceptionForLastWin32Error(); + } + + result = new Semaphore(myHandle); + return OpenExistingResult.Success; +#else + throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); +#endif + } + + private int ReleaseCore(int releaseCount) + { + int previousCount; + if (!Interop.Kernel32.ReleaseSemaphore(SafeWaitHandle, releaseCount, out previousCount)) + throw new SemaphoreFullException(); + + return previousCount; + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/Semaphore.cs b/src/System.Private.CoreLib/shared/System/Threading/Semaphore.cs new file mode 100644 index 000000000000..6014fcd1c84c --- /dev/null +++ b/src/System.Private.CoreLib/shared/System/Threading/Semaphore.cs @@ -0,0 +1,67 @@ +// 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.Win32; +using Microsoft.Win32.SafeHandles; +using System.IO; +using System.Runtime.InteropServices; + +namespace System.Threading +{ + public sealed partial class Semaphore : WaitHandle + { + // creates a nameless semaphore object + // Win32 only takes maximum count of int.MaxValue + public Semaphore(int initialCount, int maximumCount) : this(initialCount, maximumCount, null) { } + + public Semaphore(int initialCount, int maximumCount, string name) : + this(initialCount, maximumCount, name, out _) + { + } + + public Semaphore(int initialCount, int maximumCount, string name, out bool createdNew) + { + if (initialCount < 0) + throw new ArgumentOutOfRangeException(nameof(initialCount), SR.ArgumentOutOfRange_NeedNonNegNum); + + if (maximumCount < 1) + throw new ArgumentOutOfRangeException(nameof(maximumCount), SR.ArgumentOutOfRange_NeedPosNum); + + if (initialCount > maximumCount) + throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum); + + CreateSemaphoreCore(initialCount, maximumCount, name, out createdNew); + } + + public static Semaphore OpenExisting(string name) + { + Semaphore result; + switch (OpenExistingWorker(name, out result)) + { + case OpenExistingResult.NameNotFound: + throw new WaitHandleCannotBeOpenedException(); + case OpenExistingResult.NameInvalid: + throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); + case OpenExistingResult.PathNotFound: + throw new IOException(SR.Format(SR.IO_PathNotFound_Path, name)); + default: + return result; + } + } + + public static bool TryOpenExisting(string name, out Semaphore result) => + OpenExistingWorker(name, out result) == OpenExistingResult.Success; + + public int Release() => ReleaseCore(1); + + // increase the count on a semaphore, returns previous count + public int Release(int releaseCount) + { + if (releaseCount < 1) + throw new ArgumentOutOfRangeException(nameof(releaseCount), SR.ArgumentOutOfRange_NeedNonNegNum); + + return ReleaseCore(releaseCount); + } + } +} diff --git a/src/System.Private.CoreLib/shared/System/Threading/SemaphoreFullException.cs b/src/System.Private.CoreLib/shared/System/Threading/SemaphoreFullException.cs index 18558b19e014..a6cff781df61 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/SemaphoreFullException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SemaphoreFullException.cs @@ -15,11 +15,11 @@ public SemaphoreFullException() : base(SR.Threading_SemaphoreFullException) { } - public SemaphoreFullException(String message) : base(message) + public SemaphoreFullException(string message) : base(message) { } - public SemaphoreFullException(String message, Exception innerException) : base(message, innerException) + public SemaphoreFullException(string message, Exception innerException) : base(message, innerException) { } diff --git a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs b/src/System.Private.CoreLib/shared/System/Threading/SemaphoreSlim.cs similarity index 96% rename from src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs rename to src/System.Private.CoreLib/shared/System/Threading/SemaphoreSlim.cs index ac57e9e49989..83f5f1d2826b 100644 --- a/src/System.Private.CoreLib/src/System/Threading/SemaphoreSlim.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SemaphoreSlim.cs @@ -2,25 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ -// -// -// -// A lightweight semahore class that contains the basic semaphore functions plus some useful functions like interrupt -// and wait handle exposing to allow waiting on multiple semaphores. -// -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - using System; using System.Collections.Generic; using System.Diagnostics; -using System.Security; using System.Runtime.InteropServices; using System.Threading.Tasks; -// The class will be part of the current System.Threading namespace - namespace System.Threading { /// @@ -77,14 +65,14 @@ public class SemaphoreSlim : IDisposable private TaskNode m_asyncTail; // A pre-completed task with Result==true - private readonly static Task s_trueTask = + private static readonly Task s_trueTask = new Task(false, true, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); // A pre-completed task with Result==false private readonly static Task s_falseTask = new Task(false, false, (TaskCreationOptions)InternalTaskOptions.DoNotDispose, default); // No maximum constant - private const int NO_MAXIMUM = Int32.MaxValue; + private const int NO_MAXIMUM = int.MaxValue; // Task in a linked list of asynchronous waiters private sealed class TaskNode : Task, IThreadPoolWorkItem @@ -97,8 +85,9 @@ void IThreadPoolWorkItem.ExecuteWorkItem() bool setSuccessfully = TrySetResult(true); Debug.Assert(setSuccessfully, "Should have been able to complete task"); } - - void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae) { /* nop */ } +#if CORECLR + void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae) { /* nop */ } +#endif } #endregion @@ -242,8 +231,8 @@ public void Wait(CancellationToken cancellationToken) public bool Wait(TimeSpan timeout) { // Validate the timeout - Int64 totalMilliseconds = (Int64)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + long totalMilliseconds = (long)timeout.TotalMilliseconds; + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { throw new System.ArgumentOutOfRangeException( nameof(timeout), timeout, SR.SemaphoreSlim_Wait_TimeoutWrong); @@ -272,8 +261,8 @@ public bool Wait(TimeSpan timeout) public bool Wait(TimeSpan timeout, CancellationToken cancellationToken) { // Validate the timeout - Int64 totalMilliseconds = (Int64)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + long totalMilliseconds = (long)timeout.TotalMilliseconds; + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { throw new System.ArgumentOutOfRangeException( nameof(timeout), timeout, SR.SemaphoreSlim_Wait_TimeoutWrong); @@ -348,20 +337,19 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) try { // Perf: first spin wait for the count to be positive. - // This additional amount of spinwaiting in addition - // to Monitor.Enter()’s spinwaiting has shown measurable perf gains in test scenarios. + // This additional amount of spinwaiting in addition + // to Monitor.Enter()’s spinwaiting has shown measurable perf gains in test scenarios. if (m_currentCount == 0) { // Monitor.Enter followed by Monitor.Wait is much more expensive than waiting on an event as it involves another // spin, contention, etc. The usual number of spin iterations that would otherwise be used here is increased to // lessen that extra expense of doing a proper wait. int spinCount = SpinWait.SpinCountforSpinBeforeWait * 4; - const int Sleep1Threshold = SpinWait.Sleep1ThresholdForSpinBeforeWait * 4; var spinner = new SpinWait(); while (spinner.Count < spinCount) { - spinner.SpinOnce(Sleep1Threshold); + spinner.SpinOnce(sleep1Threshold: -1); if (m_currentCount != 0) { @@ -369,7 +357,6 @@ public bool Wait(int millisecondsTimeout, CancellationToken cancellationToken) } } } - // entering the lock and incrementing waiters must not suffer a thread-abort, else we cannot // clean up m_waitCount correctly, which may lead to deadlock due to non-woken waiters. try { } @@ -487,7 +474,6 @@ private bool WaitUntilCountOrTimeout(int millisecondsTimeout, uint startTime, Ca return false; } } - // ** the actual wait ** bool waitSuccessful = Monitor.Wait(m_lockObj, remainingWaitMilliseconds); @@ -604,8 +590,8 @@ public Task WaitAsync(TimeSpan timeout) public Task WaitAsync(TimeSpan timeout, CancellationToken cancellationToken) { // Validate the timeout - Int64 totalMilliseconds = (Int64)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + long totalMilliseconds = (long)timeout.TotalMilliseconds; + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { throw new System.ArgumentOutOfRangeException( nameof(timeout), timeout, SR.SemaphoreSlim_Wait_TimeoutWrong); @@ -911,7 +897,7 @@ public void Dispose() /// true to release both managed and unmanaged resources; /// false to release only unmanaged resources. /// - /// Unlike most of the members of , is not + /// Unlike most of the members of , is not /// thread-safe and may not be used concurrently with other members of this instance. /// protected virtual void Dispose(bool disposing) @@ -920,7 +906,7 @@ protected virtual void Dispose(bool disposing) { if (m_waitHandle != null) { - m_waitHandle.Close(); + m_waitHandle.Dispose(); m_waitHandle = null; } m_lockObj = null; @@ -929,8 +915,6 @@ protected virtual void Dispose(bool disposing) } } - - /// /// Private helper method to wake up waiters when a cancellationToken gets canceled. /// @@ -956,7 +940,6 @@ private void CheckDispose() throw new ObjectDisposedException(null, SR.SemaphoreSlim_Disposed); } } - #endregion } } diff --git a/src/System.Private.CoreLib/shared/System/Threading/SendOrPostCallback.cs b/src/System.Private.CoreLib/shared/System/Threading/SendOrPostCallback.cs index 6692d35ab2e9..b96914ab2c6f 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/SendOrPostCallback.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SendOrPostCallback.cs @@ -4,5 +4,5 @@ namespace System.Threading { - public delegate void SendOrPostCallback(Object state); + public delegate void SendOrPostCallback(object state); } diff --git a/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs b/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs index 414ad1852f87..54857c322c8e 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SpinWait.cs @@ -88,7 +88,16 @@ public struct SpinWait /// for here. /// internal static readonly int SpinCountforSpinBeforeWait = PlatformHelper.IsSingleProcessor ? 1 : 35; - internal const int Sleep1ThresholdForSpinBeforeWait = 40; // should be greater than SpinCountforSpinBeforeWait + + /// + /// Typically, Sleep(1) should not be issued for a spin-wait before a proper wait because it is usually more beneficial + /// to just issue the proper wait. For longer spin-waits (when the spin count is configurable), this value may be used as + /// a threshold for issuing Sleep(1). + /// + /// + /// Should be greater than so that Sleep(1) would not be used by default. + /// + internal const int Sleep1ThresholdForLongSpinBeforeWait = 40; // The number of times we've spun already. private int _count; @@ -127,12 +136,42 @@ internal set /// public void SpinOnce() { - SpinOnce(DefaultSleep1Threshold); + SpinOnceCore(DefaultSleep1Threshold); + } + + /// + /// Performs a single spin. + /// + /// + /// A minimum spin count after which Thread.Sleep(1) may be used. A value of -1 may be used to + /// disable the use of Thread.Sleep(1). + /// + /// + /// is less than -1. + /// + /// + /// This is typically called in a loop, and may change in behavior based on the number of times a + /// has been called thus far on this instance. + /// + public void SpinOnce(int sleep1Threshold) + { + if (sleep1Threshold < -1) + { + throw new ArgumentOutOfRangeException(nameof(sleep1Threshold), sleep1Threshold, SR.ArgumentOutOfRange_NeedNonNegOrNegative1); + } + + if (sleep1Threshold >= 0 && sleep1Threshold < YieldThreshold) + { + sleep1Threshold = YieldThreshold; + } + + SpinOnceCore(sleep1Threshold); } - internal void SpinOnce(int sleep1Threshold) + private void SpinOnceCore(int sleep1Threshold) { - Debug.Assert(sleep1Threshold >= YieldThreshold || PlatformHelper.IsSingleProcessor); // so that NextSpinWillYield behaves as requested + Debug.Assert(sleep1Threshold >= -1); + Debug.Assert(sleep1Threshold < 0 || sleep1Threshold >= YieldThreshold); // (_count - YieldThreshold) % 2 == 0: The purpose of this check is to interleave Thread.Yield/Sleep(0) with // Thread.SpinWait. Otherwise, the following issues occur: @@ -145,7 +184,7 @@ internal void SpinOnce(int sleep1Threshold) // contention), they may switch between one another, delaying work that can make progress. if (( _count >= YieldThreshold && - (_count >= sleep1Threshold || (_count - YieldThreshold) % 2 == 0) + ((_count >= sleep1Threshold && sleep1Threshold >= 0) || (_count - YieldThreshold) % 2 == 0) ) || PlatformHelper.IsSingleProcessor) { @@ -164,7 +203,7 @@ internal void SpinOnce(int sleep1Threshold) // configured to use the (default) coarse-grained system timer. // - if (_count >= sleep1Threshold) + if (_count >= sleep1Threshold && sleep1Threshold >= 0) { RuntimeThread.Sleep(1); } diff --git a/src/System.Private.CoreLib/shared/System/Threading/SynchronizationLockException.cs b/src/System.Private.CoreLib/shared/System/Threading/SynchronizationLockException.cs index e050e1539d00..3b5d31f3c03c 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/SynchronizationLockException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/SynchronizationLockException.cs @@ -26,13 +26,13 @@ public SynchronizationLockException() HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; } - public SynchronizationLockException(String message) + public SynchronizationLockException(string message) : base(message) { HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; } - public SynchronizationLockException(String message, Exception innerException) + public SynchronizationLockException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_SYNCHRONIZATIONLOCK; diff --git a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs index 146e477e2caa..9e3b0bc28b3a 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/Tasks/ConcurrentExclusiveSchedulerPair.cs @@ -62,7 +62,7 @@ public class ConcurrentExclusiveSchedulerPair /// Default MaxItemsPerTask to use for processing if none is specified. private const int DEFAULT_MAXITEMSPERTASK = UNLIMITED_PROCESSING; /// Default MaxConcurrencyLevel is the processor count if not otherwise specified. - private static Int32 DefaultMaxConcurrencyLevel { get { return Environment.ProcessorCount; } } + private static int DefaultMaxConcurrencyLevel { get { return Environment.ProcessorCount; } } /// Gets the sync obj used to protect all state on this instance. private object ValueLock { get { return m_threadProcessingMode; } } @@ -116,8 +116,8 @@ public ConcurrentExclusiveSchedulerPair(TaskScheduler taskScheduler, int maxConc // Treat UNLIMITED_PROCESSING/-1 for both MCL and MIPT as the biggest possible value so that we don't // have to special case UNLIMITED_PROCESSING later on in processing. - if (m_maxConcurrencyLevel == UNLIMITED_PROCESSING) m_maxConcurrencyLevel = Int32.MaxValue; - if (m_maxItemsPerTask == UNLIMITED_PROCESSING) m_maxItemsPerTask = Int32.MaxValue; + if (m_maxConcurrencyLevel == UNLIMITED_PROCESSING) m_maxConcurrencyLevel = int.MaxValue; + if (m_maxItemsPerTask == UNLIMITED_PROCESSING) m_maxItemsPerTask = int.MaxValue; // Create the concurrent/exclusive schedulers for this pair m_exclusiveTaskScheduler = new ConcurrentExclusiveTaskScheduler(this, 1, ProcessingMode.ProcessingExclusiveTask); diff --git a/src/System.Private.CoreLib/shared/System/Threading/ThreadInterruptedException.cs b/src/System.Private.CoreLib/shared/System/Threading/ThreadInterruptedException.cs index 33c1a431047a..0d0288da248a 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ThreadInterruptedException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ThreadInterruptedException.cs @@ -24,13 +24,13 @@ public ThreadInterruptedException() : base( HResult = HResults.COR_E_THREADINTERRUPTED; } - public ThreadInterruptedException(String message) + public ThreadInterruptedException(string message) : base(message) { HResult = HResults.COR_E_THREADINTERRUPTED; } - public ThreadInterruptedException(String message, Exception innerException) + public ThreadInterruptedException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_THREADINTERRUPTED; diff --git a/src/System.Private.CoreLib/shared/System/Threading/ThreadStateException.cs b/src/System.Private.CoreLib/shared/System/Threading/ThreadStateException.cs index 6fc06a8516b8..d9ba48dfc844 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ThreadStateException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ThreadStateException.cs @@ -26,13 +26,13 @@ public ThreadStateException() HResult = HResults.COR_E_THREADSTATE; } - public ThreadStateException(String message) + public ThreadStateException(string message) : base(message) { HResult = HResults.COR_E_THREADSTATE; } - public ThreadStateException(String message, Exception innerException) + public ThreadStateException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_THREADSTATE; diff --git a/src/System.Private.CoreLib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs b/src/System.Private.CoreLib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs index e60e46d2be5b..60821542b5f4 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/WaitHandleCannotBeOpenedException.cs @@ -15,12 +15,12 @@ public WaitHandleCannotBeOpenedException() : base(SR.Threading_WaitHandleCannotB HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } - public WaitHandleCannotBeOpenedException(String message) : base(message) + public WaitHandleCannotBeOpenedException(string message) : base(message) { HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } - public WaitHandleCannotBeOpenedException(String message, Exception innerException) : base(message, innerException) + public WaitHandleCannotBeOpenedException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_WAITHANDLECANNOTBEOPENED; } diff --git a/src/System.Private.CoreLib/shared/System/TimeSpan.cs b/src/System.Private.CoreLib/shared/System/TimeSpan.cs index f9b9c17f01ae..1b94c9f154d5 100644 --- a/src/System.Private.CoreLib/shared/System/TimeSpan.cs +++ b/src/System.Private.CoreLib/shared/System/TimeSpan.cs @@ -50,18 +50,18 @@ public struct TimeSpan : IComparable, IComparable, IEquatable MaxMilliSeconds || totalMilliSeconds < MinMilliSeconds) throw new ArgumentOutOfRangeException(null, SR.Overflow_TimeSpanTooLong); _ticks = (long)totalMilliSeconds * TicksPerMillisecond; @@ -178,7 +178,7 @@ public static int Compare(TimeSpan t1, TimeSpan t2) } // Returns a value less than zero if this object - public int CompareTo(Object value) + public int CompareTo(object value) { if (value == null) return 1; if (!(value is TimeSpan)) @@ -209,7 +209,7 @@ public TimeSpan Duration() return new TimeSpan(_ticks >= 0 ? _ticks : -_ticks); } - public override bool Equals(Object value) + public override bool Equals(object value) { if (value is TimeSpan) { @@ -240,11 +240,11 @@ public static TimeSpan FromHours(double value) private static TimeSpan Interval(double value, int scale) { - if (Double.IsNaN(value)) + if (double.IsNaN(value)) throw new ArgumentException(SR.Arg_CannotBeNaN); double tmp = value * scale; double millis = tmp + (value >= 0 ? 0.5 : -0.5); - if ((millis > Int64.MaxValue / TicksPerMillisecond) || (millis < Int64.MinValue / TicksPerMillisecond)) + if ((millis > long.MaxValue / TicksPerMillisecond) || (millis < long.MinValue / TicksPerMillisecond)) throw new OverflowException(SR.Overflow_TimeSpanTooLong); return new TimeSpan((long)millis * TicksPerMillisecond); } @@ -305,18 +305,18 @@ internal static long TimeToTicks(int hour, int minute, int second) // See System.Globalization.TimeSpanParse and System.Globalization.TimeSpanFormat #region ParseAndFormat - private static void ValidateStyles(TimeSpanStyles style, String parameterName) + private static void ValidateStyles(TimeSpanStyles style, string parameterName) { if (style != TimeSpanStyles.None && style != TimeSpanStyles.AssumeNegative) throw new ArgumentException(SR.Argument_InvalidTimeSpanStyles, parameterName); } - public static TimeSpan Parse(String s) + public static TimeSpan Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); /* Constructs a TimeSpan from a string. Leading and trailing white space characters are allowed. */ return TimeSpanParse.Parse(s, null); } - public static TimeSpan Parse(String input, IFormatProvider formatProvider) + public static TimeSpan Parse(string input, IFormatProvider formatProvider) { if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); return TimeSpanParse.Parse(input, formatProvider); @@ -325,18 +325,18 @@ public static TimeSpan Parse(ReadOnlySpan input, IFormatProvider formatPro { return TimeSpanParse.Parse(input, formatProvider); } - public static TimeSpan ParseExact(String input, String format, IFormatProvider formatProvider) + public static TimeSpan ParseExact(string input, string format, IFormatProvider formatProvider) { if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); if (format == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.format); return TimeSpanParse.ParseExact(input, format, formatProvider, TimeSpanStyles.None); } - public static TimeSpan ParseExact(String input, String[] formats, IFormatProvider formatProvider) + public static TimeSpan ParseExact(string input, string[] formats, IFormatProvider formatProvider) { if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); return TimeSpanParse.ParseExactMultiple(input, formats, formatProvider, TimeSpanStyles.None); } - public static TimeSpan ParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles) + public static TimeSpan ParseExact(string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles) { ValidateStyles(styles, nameof(styles)); if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); @@ -349,7 +349,7 @@ public static TimeSpan ParseExact(ReadOnlySpan input, ReadOnlySpan f ValidateStyles(styles, nameof(styles)); return TimeSpanParse.ParseExact(input, format, formatProvider, styles); } - public static TimeSpan ParseExact(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles) + public static TimeSpan ParseExact(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles) { ValidateStyles(styles, nameof(styles)); if (input == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.input); @@ -360,7 +360,7 @@ public static TimeSpan ParseExact(ReadOnlySpan input, string[] formats, IF ValidateStyles(styles, nameof(styles)); return TimeSpanParse.ParseExactMultiple(input, formats, formatProvider, styles); } - public static Boolean TryParse(String s, out TimeSpan result) + public static bool TryParse(string s, out TimeSpan result) { if (s == null) { @@ -374,7 +374,7 @@ public static bool TryParse(ReadOnlySpan s, out TimeSpan result) return TimeSpanParse.TryParse(s, null, out result); } - public static Boolean TryParse(String input, IFormatProvider formatProvider, out TimeSpan result) + public static bool TryParse(string input, IFormatProvider formatProvider, out TimeSpan result) { if (input == null) { @@ -387,7 +387,7 @@ public static bool TryParse(ReadOnlySpan input, IFormatProvider formatProv { return TimeSpanParse.TryParse(input, formatProvider, out result); } - public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, out TimeSpan result) + public static bool TryParseExact(string input, string format, IFormatProvider formatProvider, out TimeSpan result) { if (input == null || format == null) { @@ -401,7 +401,7 @@ public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan fo { return TimeSpanParse.TryParseExact(input, format, formatProvider, TimeSpanStyles.None, out result); } - public static Boolean TryParseExact(String input, String[] formats, IFormatProvider formatProvider, out TimeSpan result) + public static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, out TimeSpan result) { if (input == null) { @@ -415,7 +415,7 @@ public static bool TryParseExact(ReadOnlySpan input, string[] formats, IFo return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, TimeSpanStyles.None, out result); } - public static Boolean TryParseExact(String input, String format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result) + public static bool TryParseExact(string input, string format, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result) { ValidateStyles(styles, nameof(styles)); if (input == null || format == null) @@ -432,7 +432,7 @@ public static bool TryParseExact(ReadOnlySpan input, ReadOnlySpan fo ValidateStyles(styles, nameof(styles)); return TimeSpanParse.TryParseExact(input, format, formatProvider, styles, out result); } - public static Boolean TryParseExact(String input, String[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result) + public static bool TryParseExact(string input, string[] formats, IFormatProvider formatProvider, TimeSpanStyles styles, out TimeSpan result) { ValidateStyles(styles, nameof(styles)); if (input == null) @@ -448,15 +448,15 @@ public static bool TryParseExact(ReadOnlySpan input, string[] formats, IFo ValidateStyles(styles, nameof(styles)); return TimeSpanParse.TryParseExactMultiple(input, formats, formatProvider, styles, out result); } - public override String ToString() + public override string ToString() { - return TimeSpanFormat.Format(this, null, null); + return TimeSpanFormat.FormatC(this); } - public String ToString(String format) + public string ToString(string format) { return TimeSpanFormat.Format(this, format, null); } - public String ToString(String format, IFormatProvider formatProvider) + public string ToString(string format, IFormatProvider formatProvider) { return TimeSpanFormat.Format(this, format, formatProvider); } diff --git a/src/System.Private.CoreLib/shared/System/TimeZone.cs b/src/System.Private.CoreLib/shared/System/TimeZone.cs index d4059babfc30..010db8090f4d 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZone.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZone.cs @@ -32,15 +32,15 @@ public abstract class TimeZone private static volatile TimeZone currentTimeZone = null; // Private object for locking instead of locking on a public type for SQL reliability work. - private static Object s_InternalSyncObject; - private static Object InternalSyncObject + private static object s_InternalSyncObject; + private static object InternalSyncObject { get { if (s_InternalSyncObject == null) { - Object o = new Object(); - Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); + object o = new object(); + Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); } return s_InternalSyncObject; } @@ -87,12 +87,12 @@ internal static void ResetTimeZone() } } - public abstract String StandardName + public abstract string StandardName { get; } - public abstract String DaylightName + public abstract string DaylightName { get; } @@ -129,8 +129,8 @@ public virtual DateTime ToLocalTime(DateTime time) { return time; } - Boolean isAmbiguousLocalDst = false; - Int64 offset = ((CurrentSystemTimeZone)(TimeZone.CurrentTimeZone)).GetUtcOffsetFromUniversalTime(time, ref isAmbiguousLocalDst); + bool isAmbiguousLocalDst = false; + long offset = ((CurrentSystemTimeZone)(TimeZone.CurrentTimeZone)).GetUtcOffsetFromUniversalTime(time, ref isAmbiguousLocalDst); return new DateTime(time.Ticks + offset, DateTimeKind.Local, isAmbiguousLocalDst); } @@ -247,7 +247,7 @@ internal static TimeSpan CalculateUtcOffset(DateTime time, DaylightTime daylight ambiguousEnd = startTime - daylightTimes.Delta; } - Boolean isDst = false; + bool isDst = false; if (startTime > endTime) { // In southern hemisphere, the daylight saving time starts later in the year, and ends in the beginning of next year. diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs index 54b5d46dbecd..aceb7b90fb46 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.AdjustmentRule.cs @@ -11,6 +11,8 @@ public sealed partial class TimeZoneInfo [Serializable] public sealed class AdjustmentRule : IEquatable, ISerializable, IDeserializationCallback { + private static readonly TimeSpan DaylightDeltaAdjustment = TimeSpan.FromHours(24.0); + private static readonly TimeSpan MaxDaylightDelta = TimeSpan.FromHours(12.0); private readonly DateTime _dateStart; private readonly DateTime _dateEnd; private readonly TimeSpan _daylightDelta; @@ -100,6 +102,7 @@ internal static AdjustmentRule CreateAdjustmentRule( TimeSpan baseUtcOffsetDelta, bool noDaylightTransitions) { + AdjustDaylightDeltaToExpectedRange(ref daylightDelta, ref baseUtcOffsetDelta); return new AdjustmentRule( dateStart, dateEnd, @@ -186,6 +189,26 @@ private static void ValidateAdjustmentRule( } } + /// + /// Ensures the daylight delta is within [-12, 12] hours + /// > + private static void AdjustDaylightDeltaToExpectedRange(ref TimeSpan daylightDelta, ref TimeSpan baseUtcOffsetDelta) + { + if (daylightDelta > MaxDaylightDelta) + { + daylightDelta -= DaylightDeltaAdjustment; + baseUtcOffsetDelta += DaylightDeltaAdjustment; + } + else if (daylightDelta < -MaxDaylightDelta) + { + daylightDelta += DaylightDeltaAdjustment; + baseUtcOffsetDelta -= DaylightDeltaAdjustment; + } + + System.Diagnostics.Debug.Assert(daylightDelta <= MaxDaylightDelta && daylightDelta >= -MaxDaylightDelta, + "DaylightDelta should not ever be more than 24h"); + } + void IDeserializationCallback.OnDeserialization(object sender) { // OnDeserialization is called after each instance of this class is deserialized. diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs index 3e403fb93dd9..5645c2a389d1 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneInfo.Unix.cs @@ -1036,17 +1036,15 @@ private static TZifType TZif_GetEarlyDateTransitionType(TZifType[] transitionTyp /// private static AdjustmentRule TZif_CreateAdjustmentRuleForPosixFormat(string posixFormat, DateTime startTransitionDate, TimeSpan timeZoneBaseUtcOffset) { - string standardName; - string standardOffset; - string daylightSavingsName; - string daylightSavingsOffset; - string start; - string startTime; - string end; - string endTime; - - if (TZif_ParsePosixFormat(posixFormat, out standardName, out standardOffset, out daylightSavingsName, - out daylightSavingsOffset, out start, out startTime, out end, out endTime)) + if (TZif_ParsePosixFormat(posixFormat, + out ReadOnlySpan standardName, + out ReadOnlySpan standardOffset, + out ReadOnlySpan daylightSavingsName, + out ReadOnlySpan daylightSavingsOffset, + out ReadOnlySpan start, + out ReadOnlySpan startTime, + out ReadOnlySpan end, + out ReadOnlySpan endTime)) { // a valid posixFormat has at least standardName and standardOffset @@ -1057,7 +1055,7 @@ private static AdjustmentRule TZif_CreateAdjustmentRuleForPosixFormat(string pos baseOffset = TZif_CalculateTransitionOffsetFromBase(baseOffset, timeZoneBaseUtcOffset); // having a daylightSavingsName means there is a DST rule - if (!string.IsNullOrEmpty(daylightSavingsName)) + if (!daylightSavingsName.IsEmpty) { TimeSpan? parsedDaylightSavings = TZif_ParseOffsetString(daylightSavingsOffset); TimeSpan daylightSavingsTimeSpan; @@ -1141,7 +1139,7 @@ private static AdjustmentRule TZif_CreateAdjustmentRuleForPosixFormat(string pos return result; } - private static DateTime ParseTimeOfDay(string time) + private static DateTime ParseTimeOfDay(ReadOnlySpan time) { DateTime timeOfDay; TimeSpan? timeOffset = TZif_ParseOffsetString(time); @@ -1172,9 +1170,9 @@ private static DateTime ParseTimeOfDay(string time) return timeOfDay; } - private static TransitionTime TZif_CreateTransitionTimeFromPosixRule(string date, string time) + private static TransitionTime TZif_CreateTransitionTimeFromPosixRule(ReadOnlySpan date, ReadOnlySpan time) { - if (string.IsNullOrEmpty(date)) + if (date.IsEmpty) { return default(TransitionTime); } @@ -1190,7 +1188,7 @@ private static TransitionTime TZif_CreateTransitionTimeFromPosixRule(string date DayOfWeek day; if (!TZif_ParseMDateRule(date, out month, out week, out day)) { - throw new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_UnparseablePosixMDateString, date)); + throw new InvalidTimeZoneException(SR.Format(SR.InvalidTimeZone_UnparseablePosixMDateString, date.ToString())); } return TransitionTime.CreateFloatingDateRule(ParseTimeOfDay(time), month, week, day); @@ -1221,10 +1219,10 @@ private static TransitionTime TZif_CreateTransitionTimeFromPosixRule(string date // while in non leap year the rule will start at Mar 2. // // If we need to support n format, we'll have to have a floating adjustment rule support this case. - + throw new InvalidTimeZoneException(SR.InvalidTimeZone_NJulianDayNotSupported); } - + // Julian day TZif_ParseJulianDay(date, out int month, out int day); return TransitionTime.CreateFixedDateRule(ParseTimeOfDay(time), month, day); @@ -1237,12 +1235,12 @@ private static TransitionTime TZif_CreateTransitionTimeFromPosixRule(string date /// /// true if the parsing succeeded; otherwise, false. /// - private static void TZif_ParseJulianDay(string date, out int month, out int day) + private static void TZif_ParseJulianDay(ReadOnlySpan date, out int month, out int day) { // Jn // This specifies the Julian day, with n between 1 and 365.February 29 is never counted, even in leap years. + Debug.Assert(!date.IsEmpty); Debug.Assert(date[0] == 'J'); - Debug.Assert(!String.IsNullOrEmpty(date)); month = day = 0; int index = 1; @@ -1272,7 +1270,7 @@ private static void TZif_ParseJulianDay(string date, out int month, out int day) { i++; } - + Debug.Assert(i > 0 && i < days.Length); month = i; @@ -1285,19 +1283,20 @@ private static void TZif_ParseJulianDay(string date, out int month, out int day) /// /// true if the parsing succeeded; otherwise, false. /// - private static bool TZif_ParseMDateRule(string dateRule, out int month, out int week, out DayOfWeek dayOfWeek) + private static bool TZif_ParseMDateRule(ReadOnlySpan dateRule, out int month, out int week, out DayOfWeek dayOfWeek) { if (dateRule[0] == 'M') { - int firstDotIndex = dateRule.IndexOf('.'); - if (firstDotIndex > 0) + int monthWeekDotIndex = dateRule.IndexOf('.'); + if (monthWeekDotIndex > 0) { - int secondDotIndex = dateRule.IndexOf('.', firstDotIndex + 1); - if (secondDotIndex > 0) + ReadOnlySpan weekDaySpan = dateRule.Slice(monthWeekDotIndex + 1); + int weekDayDotIndex = weekDaySpan.IndexOf('.'); + if (weekDayDotIndex > 0) { - if (int.TryParse(dateRule.AsSpan(1, firstDotIndex - 1), out month) && - int.TryParse(dateRule.AsSpan(firstDotIndex + 1, secondDotIndex - firstDotIndex - 1), out week) && - int.TryParse(dateRule.AsSpan(secondDotIndex + 1), out int day)) + if (int.TryParse(dateRule.Slice(1, monthWeekDotIndex - 1), out month) && + int.TryParse(weekDaySpan.Slice(0, weekDayDotIndex), out week) && + int.TryParse(weekDaySpan.Slice(weekDayDotIndex + 1), out int day)) { dayOfWeek = (DayOfWeek)day; return true; @@ -1313,15 +1312,15 @@ private static bool TZif_ParseMDateRule(string dateRule, out int month, out int } private static bool TZif_ParsePosixFormat( - string posixFormat, - out string standardName, - out string standardOffset, - out string daylightSavingsName, - out string daylightSavingsOffset, - out string start, - out string startTime, - out string end, - out string endTime) + ReadOnlySpan posixFormat, + out ReadOnlySpan standardName, + out ReadOnlySpan standardOffset, + out ReadOnlySpan daylightSavingsName, + out ReadOnlySpan daylightSavingsOffset, + out ReadOnlySpan start, + out ReadOnlySpan startTime, + out ReadOnlySpan end, + out ReadOnlySpan endTime) { standardName = null; standardOffset = null; @@ -1337,7 +1336,7 @@ private static bool TZif_ParsePosixFormat( standardOffset = TZif_ParsePosixOffset(posixFormat, ref index); daylightSavingsName = TZif_ParsePosixName(posixFormat, ref index); - if (!string.IsNullOrEmpty(daylightSavingsName)) + if (!daylightSavingsName.IsEmpty) { daylightSavingsOffset = TZif_ParsePosixOffset(posixFormat, ref index); @@ -1354,10 +1353,10 @@ private static bool TZif_ParsePosixFormat( } } - return !string.IsNullOrEmpty(standardName) && !string.IsNullOrEmpty(standardOffset); + return !standardName.IsEmpty && !standardOffset.IsEmpty; } - private static string TZif_ParsePosixName(string posixFormat, ref int index) + private static ReadOnlySpan TZif_ParsePosixName(ReadOnlySpan posixFormat, ref int index) { bool isBracketEnclosed = index < posixFormat.Length && posixFormat[index] == '<'; if (isBracketEnclosed) @@ -1365,7 +1364,7 @@ private static string TZif_ParsePosixName(string posixFormat, ref int index) // move past the opening bracket index++; - string result = TZif_ParsePosixString(posixFormat, ref index, c => c == '>'); + ReadOnlySpan result = TZif_ParsePosixString(posixFormat, ref index, c => c == '>'); // move past the closing bracket if (index < posixFormat.Length && posixFormat[index] == '>') @@ -1384,10 +1383,10 @@ private static string TZif_ParsePosixName(string posixFormat, ref int index) } } - private static string TZif_ParsePosixOffset(string posixFormat, ref int index) => + private static ReadOnlySpan TZif_ParsePosixOffset(ReadOnlySpan posixFormat, ref int index) => TZif_ParsePosixString(posixFormat, ref index, c => !char.IsDigit(c) && c != '+' && c != '-' && c != ':'); - private static void TZif_ParsePosixDateTime(string posixFormat, ref int index, out string date, out string time) + private static void TZif_ParsePosixDateTime(ReadOnlySpan posixFormat, ref int index, out ReadOnlySpan date, out ReadOnlySpan time) { time = null; @@ -1399,13 +1398,13 @@ private static void TZif_ParsePosixDateTime(string posixFormat, ref int index, o } } - private static string TZif_ParsePosixDate(string posixFormat, ref int index) => + private static ReadOnlySpan TZif_ParsePosixDate(ReadOnlySpan posixFormat, ref int index) => TZif_ParsePosixString(posixFormat, ref index, c => c == '/' || c == ','); - private static string TZif_ParsePosixTime(string posixFormat, ref int index) => + private static ReadOnlySpan TZif_ParsePosixTime(ReadOnlySpan posixFormat, ref int index) => TZif_ParsePosixString(posixFormat, ref index, c => c == ','); - private static string TZif_ParsePosixString(string posixFormat, ref int index, Func breakCondition) + private static ReadOnlySpan TZif_ParsePosixString(ReadOnlySpan posixFormat, ref int index, Func breakCondition) { int startIndex = index; for (; index < posixFormat.Length; index++) @@ -1417,7 +1416,7 @@ private static string TZif_ParsePosixString(string posixFormat, ref int index, F } } - return posixFormat.Substring(startIndex, index - startIndex); + return posixFormat.Slice(startIndex, index - startIndex); } // Returns the Substring from zoneAbbreviations starting at index and ending at '\0' diff --git a/src/System.Private.CoreLib/shared/System/TimeZoneNotFoundException.cs b/src/System.Private.CoreLib/shared/System/TimeZoneNotFoundException.cs index f83c6443c340..3dc1bb1d4cd6 100644 --- a/src/System.Private.CoreLib/shared/System/TimeZoneNotFoundException.cs +++ b/src/System.Private.CoreLib/shared/System/TimeZoneNotFoundException.cs @@ -14,12 +14,12 @@ public TimeZoneNotFoundException() { } - public TimeZoneNotFoundException(String message) + public TimeZoneNotFoundException(string message) : base(message) { } - public TimeZoneNotFoundException(String message, Exception innerException) + public TimeZoneNotFoundException(string message, Exception innerException) : base(message, innerException) { } diff --git a/src/System.Private.CoreLib/shared/System/TimeoutException.cs b/src/System.Private.CoreLib/shared/System/TimeoutException.cs index ddaa47747d2f..2480f4bc28a2 100644 --- a/src/System.Private.CoreLib/shared/System/TimeoutException.cs +++ b/src/System.Private.CoreLib/shared/System/TimeoutException.cs @@ -25,13 +25,13 @@ public TimeoutException() HResult = HResults.COR_E_TIMEOUT; } - public TimeoutException(String message) + public TimeoutException(string message) : base(message) { HResult = HResults.COR_E_TIMEOUT; } - public TimeoutException(String message, Exception innerException) + public TimeoutException(string message, Exception innerException) : base(message, innerException) { HResult = HResults.COR_E_TIMEOUT; diff --git a/src/System.Private.CoreLib/shared/System/Tuple.cs b/src/System.Private.CoreLib/shared/System/Tuple.cs index 2d027cd40ca0..ebbd156dda41 100644 --- a/src/System.Private.CoreLib/shared/System/Tuple.cs +++ b/src/System.Private.CoreLib/shared/System/Tuple.cs @@ -115,12 +115,12 @@ public Tuple(T1 item1) m_Item1 = item1; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -134,12 +134,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -155,15 +155,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return comparer.GetHashCode(m_Item1); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -218,12 +218,12 @@ public Tuple(T1 item1, T2 item2) m_Item2 = item2; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -237,12 +237,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -264,15 +264,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -336,12 +336,12 @@ public Tuple(T1 item1, T2 item2, T3 item3) m_Item3 = item3; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -355,12 +355,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -386,15 +386,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -465,12 +465,12 @@ public Tuple(T1 item1, T2 item2, T3 item3, T4 item4) m_Item4 = item4; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -484,12 +484,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3) && comparer.Equals(m_Item4, objTuple.m_Item4); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -519,15 +519,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -605,12 +605,12 @@ public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) m_Item5 = item5; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -624,12 +624,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3) && comparer.Equals(m_Item4, objTuple.m_Item4) && comparer.Equals(m_Item5, objTuple.m_Item5); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -663,15 +663,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -756,12 +756,12 @@ public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) m_Item6 = item6; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -775,12 +775,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3) && comparer.Equals(m_Item4, objTuple.m_Item4) && comparer.Equals(m_Item5, objTuple.m_Item5) && comparer.Equals(m_Item6, objTuple.m_Item6); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -818,15 +818,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -918,12 +918,12 @@ public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item m_Item7 = item7; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -937,12 +937,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3) && comparer.Equals(m_Item4, objTuple.m_Item4) && comparer.Equals(m_Item5, objTuple.m_Item5) && comparer.Equals(m_Item6, objTuple.m_Item6) && comparer.Equals(m_Item7, objTuple.m_Item7); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -984,15 +984,15 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return Tuple.CombineHashCodes(comparer.GetHashCode(m_Item1), comparer.GetHashCode(m_Item2), comparer.GetHashCode(m_Item3), comparer.GetHashCode(m_Item4), comparer.GetHashCode(m_Item5), comparer.GetHashCode(m_Item6), comparer.GetHashCode(m_Item7)); } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } @@ -1096,12 +1096,12 @@ public Tuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item m_Rest = rest; } - public override Boolean Equals(Object obj) + public override bool Equals(object obj) { - return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; + return ((IStructuralEquatable)this).Equals(obj, EqualityComparer.Default); ; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) return false; @@ -1115,12 +1115,12 @@ Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) return comparer.Equals(m_Item1, objTuple.m_Item1) && comparer.Equals(m_Item2, objTuple.m_Item2) && comparer.Equals(m_Item3, objTuple.m_Item3) && comparer.Equals(m_Item4, objTuple.m_Item4) && comparer.Equals(m_Item5, objTuple.m_Item5) && comparer.Equals(m_Item6, objTuple.m_Item6) && comparer.Equals(m_Item7, objTuple.m_Item7) && comparer.Equals(m_Rest, objTuple.m_Rest); } - Int32 IComparable.CompareTo(Object obj) + int IComparable.CompareTo(object obj) { - return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); + return ((IStructuralComparable)this).CompareTo(obj, Comparer.Default); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) return 1; @@ -1166,10 +1166,10 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) public override int GetHashCode() { - return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); + return ((IStructuralEquatable)this).GetHashCode(EqualityComparer.Default); } - Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { // We want to have a limited hash in this case. We'll use the last 8 elements of the tuple ITupleInternal t = (ITupleInternal)m_Rest; @@ -1198,7 +1198,7 @@ Int32 IStructuralEquatable.GetHashCode(IEqualityComparer comparer) return -1; } - Int32 ITupleInternal.GetHashCode(IEqualityComparer comparer) + int ITupleInternal.GetHashCode(IEqualityComparer comparer) { return ((IStructuralEquatable)this).GetHashCode(comparer); } diff --git a/src/System.Private.CoreLib/shared/System/UInt16.cs b/src/System.Private.CoreLib/shared/System/UInt16.cs index 3047d18198ef..f9ef1f6a624c 100644 --- a/src/System.Private.CoreLib/shared/System/UInt16.cs +++ b/src/System.Private.CoreLib/shared/System/UInt16.cs @@ -13,9 +13,9 @@ namespace System [CLSCompliant(false)] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct UInt16 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct UInt16 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private ushort m_value; // Do not rename (binary serialization) + private readonly ushort m_value; // Do not rename (binary serialization) public const ushort MaxValue = (ushort)0xFFFF; public const ushort MinValue = 0; @@ -27,35 +27,35 @@ public struct UInt16 : IComparable, IConvertible, IFormattable, IComparable destination, out int charsWritten, ReadOnlySpan } [CLSCompliant(false)] - public static ushort Parse(String s) + public static ushort Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } [CLSCompliant(false)] - public static ushort Parse(String s, NumberStyles style) + public static ushort Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -110,14 +110,14 @@ public static ushort Parse(String s, NumberStyles style) [CLSCompliant(false)] - public static ushort Parse(String s, IFormatProvider provider) + public static ushort Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Parse((ReadOnlySpan)s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); } [CLSCompliant(false)] - public static ushort Parse(String s, NumberStyles style, IFormatProvider provider) + public static ushort Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -148,7 +148,7 @@ private static ushort Parse(ReadOnlySpan s, NumberStyles style, NumberForm } [CLSCompliant(false)] - public static bool TryParse(String s, out UInt16 result) + public static bool TryParse(string s, out ushort result) { if (s == null) { @@ -166,7 +166,7 @@ public static bool TryParse(ReadOnlySpan s, out ushort result) } [CLSCompliant(false)] - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt16 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out ushort result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -186,10 +186,10 @@ public static bool TryParse(ReadOnlySpan s, NumberStyles style, IFormatPro return TryParse(s, style, NumberFormatInfo.GetInstance(provider), out result); } - private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out UInt16 result) + private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFormatInfo info, out ushort result) { result = 0; - UInt32 i; + uint i; if (!Number.TryParseUInt32(s, style, info, out i)) { return false; @@ -198,7 +198,7 @@ private static bool TryParse(ReadOnlySpan s, NumberStyles style, NumberFor { return false; } - result = (UInt16)i; + result = (ushort)i; return true; } @@ -271,7 +271,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -281,7 +281,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt16", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/UInt32.cs b/src/System.Private.CoreLib/shared/System/UInt32.cs index 1e33dcf17ba0..5ed193e95626 100644 --- a/src/System.Private.CoreLib/shared/System/UInt32.cs +++ b/src/System.Private.CoreLib/shared/System/UInt32.cs @@ -13,9 +13,9 @@ namespace System [CLSCompliant(false)] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct UInt32 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct UInt32 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private uint m_value; // Do not rename (binary serialization) + private readonly uint m_value; // Do not rename (binary serialization) public const uint MaxValue = (uint)0xffffffff; public const uint MinValue = 0U; @@ -27,13 +27,13 @@ public struct UInt32 : IComparable, IConvertible, IFormattable, IComparable destination, out int charsWritten, ReadOnlySpan } [CLSCompliant(false)] - public static uint Parse(String s) + public static uint Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseUInt32(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } [CLSCompliant(false)] - public static uint Parse(String s, NumberStyles style) + public static uint Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -118,14 +118,14 @@ public static uint Parse(String s, NumberStyles style) [CLSCompliant(false)] - public static uint Parse(String s, IFormatProvider provider) + public static uint Parse(string s, IFormatProvider provider) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseUInt32(s, NumberStyles.Integer, NumberFormatInfo.GetInstance(provider)); } [CLSCompliant(false)] - public static uint Parse(String s, NumberStyles style, IFormatProvider provider) + public static uint Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -140,7 +140,7 @@ public static uint Parse(ReadOnlySpan s, NumberStyles style = NumberStyles } [CLSCompliant(false)] - public static bool TryParse(String s, out UInt32 result) + public static bool TryParse(string s, out uint result) { if (s == null) { @@ -158,7 +158,7 @@ public static bool TryParse(ReadOnlySpan s, out uint result) } [CLSCompliant(false)] - public static bool TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt32 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out uint result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -247,7 +247,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -257,7 +257,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt32", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/UInt64.cs b/src/System.Private.CoreLib/shared/System/UInt64.cs index d30fbe1e42b7..6abd76da21f2 100644 --- a/src/System.Private.CoreLib/shared/System/UInt64.cs +++ b/src/System.Private.CoreLib/shared/System/UInt64.cs @@ -13,9 +13,9 @@ namespace System [CLSCompliant(false)] [StructLayout(LayoutKind.Sequential)] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct UInt64 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable + public readonly struct UInt64 : IComparable, IConvertible, IFormattable, IComparable, IEquatable, ISpanFormattable { - private ulong m_value; // Do not rename (binary serialization) + private readonly ulong m_value; // Do not rename (binary serialization) public const ulong MaxValue = (ulong)0xffffffffffffffffL; public const ulong MinValue = 0x0; @@ -26,13 +26,13 @@ public struct UInt64 : IComparable, IConvertible, IFormattable, IComparable> 32); } - public override String ToString() + public override string ToString() { return Number.FormatUInt64(m_value, null, null); } - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return Number.FormatUInt64(m_value, null, provider); } - public String ToString(String format) + public string ToString(string format) { return Number.FormatUInt64(m_value, format, null); } - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return Number.FormatUInt64(m_value, format, provider); } @@ -100,14 +100,14 @@ public bool TryFormat(Span destination, out int charsWritten, ReadOnlySpan } [CLSCompliant(false)] - public static ulong Parse(String s) + public static ulong Parse(string s) { if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); return Number.ParseUInt64(s, NumberStyles.Integer, NumberFormatInfo.CurrentInfo); } [CLSCompliant(false)] - public static ulong Parse(String s, NumberStyles style) + public static ulong Parse(string s, NumberStyles style) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -122,7 +122,7 @@ public static ulong Parse(string s, IFormatProvider provider) } [CLSCompliant(false)] - public static ulong Parse(String s, NumberStyles style, IFormatProvider provider) + public static ulong Parse(string s, NumberStyles style, IFormatProvider provider) { NumberFormatInfo.ValidateParseStyleInteger(style); if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); @@ -137,7 +137,7 @@ public static ulong Parse(ReadOnlySpan s, NumberStyles style = NumberStyle } [CLSCompliant(false)] - public static Boolean TryParse(String s, out UInt64 result) + public static bool TryParse(string s, out ulong result) { if (s == null) { @@ -155,7 +155,7 @@ public static bool TryParse(ReadOnlySpan s, out ulong result) } [CLSCompliant(false)] - public static Boolean TryParse(String s, NumberStyles style, IFormatProvider provider, out UInt64 result) + public static bool TryParse(string s, NumberStyles style, IFormatProvider provider, out ulong result) { NumberFormatInfo.ValidateParseStyleInteger(style); @@ -244,7 +244,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(m_value); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(m_value); } @@ -254,7 +254,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "UInt64", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } diff --git a/src/System.Private.CoreLib/shared/System/UIntPtr.cs b/src/System.Private.CoreLib/shared/System/UIntPtr.cs index 8b2568fde1e5..9534f4f87280 100644 --- a/src/System.Private.CoreLib/shared/System/UIntPtr.cs +++ b/src/System.Private.CoreLib/shared/System/UIntPtr.cs @@ -18,9 +18,9 @@ namespace System [Serializable] [CLSCompliant(false)] [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct UIntPtr : IEquatable, ISerializable + public readonly struct UIntPtr : IEquatable, ISerializable { - private unsafe void* _value; // Do not rename (binary serialization) + private readonly unsafe void* _value; // Do not rename (binary serialization) [Intrinsic] public static readonly UIntPtr Zero; @@ -68,7 +68,7 @@ unsafe void ISerializable.GetObjectData(SerializationInfo info, StreamingContext info.AddValue("value", ToUInt64()); } - public unsafe override bool Equals(Object obj) + public unsafe override bool Equals(object obj) { if (obj is UIntPtr) { diff --git a/src/System.Private.CoreLib/shared/System/UnauthorizedAccessException.cs b/src/System.Private.CoreLib/shared/System/UnauthorizedAccessException.cs index a28f6dd73ce8..e384dfeb3151 100644 --- a/src/System.Private.CoreLib/shared/System/UnauthorizedAccessException.cs +++ b/src/System.Private.CoreLib/shared/System/UnauthorizedAccessException.cs @@ -29,13 +29,13 @@ public UnauthorizedAccessException() HResult = HResults.COR_E_UNAUTHORIZEDACCESS; } - public UnauthorizedAccessException(String message) + public UnauthorizedAccessException(string message) : base(message) { HResult = HResults.COR_E_UNAUTHORIZEDACCESS; } - public UnauthorizedAccessException(String message, Exception inner) + public UnauthorizedAccessException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_UNAUTHORIZEDACCESS; diff --git a/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventArgs.cs b/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventArgs.cs index 5cde57216164..c214afdc7113 100644 --- a/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventArgs.cs +++ b/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventArgs.cs @@ -6,16 +6,16 @@ namespace System { public class UnhandledExceptionEventArgs : EventArgs { - private Object _exception; + private object _exception; private bool _isTerminating; - public UnhandledExceptionEventArgs(Object exception, bool isTerminating) + public UnhandledExceptionEventArgs(object exception, bool isTerminating) { _exception = exception; _isTerminating = isTerminating; } - public Object ExceptionObject + public object ExceptionObject { get { return _exception; } } diff --git a/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventHandler.cs b/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventHandler.cs index 14e31c7bbdeb..58f1eb5145d2 100644 --- a/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventHandler.cs +++ b/src/System.Private.CoreLib/shared/System/UnhandledExceptionEventHandler.cs @@ -4,5 +4,5 @@ namespace System { - public delegate void UnhandledExceptionEventHandler(Object sender, UnhandledExceptionEventArgs e); + public delegate void UnhandledExceptionEventHandler(object sender, UnhandledExceptionEventArgs e); } diff --git a/src/System.Private.CoreLib/shared/System/Version.cs b/src/System.Private.CoreLib/shared/System/Version.cs index 6bdf969f1730..9d24270eb3ab 100644 --- a/src/System.Private.CoreLib/shared/System/Version.cs +++ b/src/System.Private.CoreLib/shared/System/Version.cs @@ -73,7 +73,7 @@ public Version(int major, int minor) _Minor = minor; } - public Version(String version) + public Version(string version) { Version v = Version.Parse(version); _Major = v.Major; @@ -134,7 +134,7 @@ public short MinorRevision get { return (short)(_Revision & 0xFFFF); } } - public int CompareTo(Object version) + public int CompareTo(object version) { if (version == null) { @@ -162,7 +162,7 @@ public int CompareTo(Version value) 0; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { return Equals(obj as Version); } @@ -422,14 +422,14 @@ private static bool TryParseComponent(ReadOnlySpan component, string compo public static bool operator <(Version v1, Version v2) { - if ((Object)v1 == null) + if ((object)v1 == null) throw new ArgumentNullException(nameof(v1)); return (v1.CompareTo(v2) < 0); } public static bool operator <=(Version v1, Version v2) { - if ((Object)v1 == null) + if ((object)v1 == null) throw new ArgumentNullException(nameof(v1)); return (v1.CompareTo(v2) <= 0); } diff --git a/src/System.Private.CoreLib/src/Internal/Resources/PRIExceptionInfo.cs b/src/System.Private.CoreLib/src/Internal/Resources/PRIExceptionInfo.cs new file mode 100644 index 000000000000..6593c27b1ad0 --- /dev/null +++ b/src/System.Private.CoreLib/src/Internal/Resources/PRIExceptionInfo.cs @@ -0,0 +1,14 @@ +// 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 Internal.Resources +{ + public class PRIExceptionInfo + { + public string PackageSimpleName; + public string ResWFile; + } +} diff --git a/src/System.Private.CoreLib/src/Internal/Resources/WindowsRuntimeResourceManagerBase.cs b/src/System.Private.CoreLib/src/Internal/Resources/WindowsRuntimeResourceManagerBase.cs new file mode 100644 index 000000000000..6594ae6f055e --- /dev/null +++ b/src/System.Private.CoreLib/src/Internal/Resources/WindowsRuntimeResourceManagerBase.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; +using System.Globalization; + +namespace Internal.Resources +{ + // This is implemented in System.Runtime.WindowsRuntime as System.Resources.WindowsRuntimeResourceManager, + // allowing us to ask for a WinRT-specific ResourceManager. + public abstract class WindowsRuntimeResourceManagerBase + { + public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo); + + public abstract string GetString(string stringName, string startingCulture, string neutralResourcesCulture); + + public abstract CultureInfo GlobalResourceContextBestFitCultureInfo + { + get; + } + + public abstract bool SetGlobalResourceContextDefaultCulture(CultureInfo ci); + + /// + /// Check whether CultureData exists for specified cultureName + /// This API is used for WindowsRuntimeResourceManager in System.Runtime.WindowsRuntime + /// + public static bool IsValidCulture(string cultureName) + { + return CultureData.GetCultureData(cultureName, /* useUserOverride */ true) != null; + } + } +} diff --git a/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeThread.cs b/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeThread.cs index 80c11594b1ef..9a2204bf24d0 100644 --- a/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeThread.cs +++ b/src/System.Private.CoreLib/src/Internal/Runtime/Augments/RuntimeThread.cs @@ -242,8 +242,8 @@ private static int RefreshCurrentProcessorId() Debug.Assert(ProcessorIdRefreshRate <= ProcessorIdCacheCountDownMask); - // Mask with Int32.MaxValue to ensure the execution Id is not negative - t_currentProcessorIdCache = ((currentProcessorId << ProcessorIdCacheShift) & Int32.MaxValue) | ProcessorIdRefreshRate; + // Mask with int.MaxValue to ensure the execution Id is not negative + t_currentProcessorIdCache = ((currentProcessorId << ProcessorIdCacheShift) & int.MaxValue) | ProcessorIdRefreshRate; return currentProcessorId; } diff --git a/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/WindowsRuntime/ExceptionSupport.cs b/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/WindowsRuntime/ExceptionSupport.cs new file mode 100644 index 000000000000..1772105d1e13 --- /dev/null +++ b/src/System.Private.CoreLib/src/Internal/Runtime/InteropServices/WindowsRuntime/ExceptionSupport.cs @@ -0,0 +1,79 @@ +// 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.Runtime.InteropServices.WindowsRuntime; + +namespace Internal.Runtime.InteropServices.WindowsRuntime +{ + public static class ExceptionSupport + { + /// + /// Attach restricted error information to the exception if it may apply to that exception, returning + /// back the input value + /// + public static Exception AttachRestrictedErrorInfo(Exception e) + { + // If there is no exception, then the restricted error info doesn't apply to it + if (e != null) + { + try + { + // Get the restricted error info for this thread and see if it may correlate to the current + // exception object. Note that in general the thread's IRestrictedErrorInfo is not meant for + // exceptions that are marshaled Windows.Foundation.HResults and instead are intended for + // HRESULT ABI return values. However, in many cases async APIs will set the thread's restricted + // error info as a convention in order to provide extended debugging information for the ErrorCode + // property. + IRestrictedErrorInfo restrictedErrorInfo = UnsafeNativeMethods.GetRestrictedErrorInfo(); + if (restrictedErrorInfo != null) + { + string description; + string restrictedDescription; + string capabilitySid; + int restrictedErrorInfoHResult; + restrictedErrorInfo.GetErrorDetails(out description, + out restrictedErrorInfoHResult, + out restrictedDescription, + out capabilitySid); + + // Since this is a special case where by convention there may be a correlation, there is not a + // guarantee that the restricted error info does belong to the async error code. In order to + // reduce the risk that we associate incorrect information with the exception object, we need + // to apply a heuristic where we attempt to match the current exception's HRESULT with the + // HRESULT the IRestrictedErrorInfo belongs to. If it is a match we will assume association + // for the IAsyncInfo case. + if (e.HResult == restrictedErrorInfoHResult) + { + string errorReference; + restrictedErrorInfo.GetReference(out errorReference); + + e.AddExceptionDataForRestrictedErrorInfo(restrictedDescription, + errorReference, + capabilitySid, + restrictedErrorInfo); + } + } + } + catch + { + // If we can't get the restricted error info, then proceed as if it isn't associated with this + // error. + } + } + + return e; + } + + /// + /// Report that an exception has occurred which went user unhandled. This allows the global error handler + /// for the application to be invoked to process the error. + /// + /// true if the error was reported, false if not (ie running on Win8) + public static bool ReportUnhandledError(Exception ex) + { + return WindowsRuntimeMarshal.ReportUnhandledError(ex); + } + } +} diff --git a/src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs b/src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs new file mode 100644 index 000000000000..b16157f8be08 --- /dev/null +++ b/src/System.Private.CoreLib/src/Internal/Threading/Tasks/AsyncCausalitySupport.cs @@ -0,0 +1,62 @@ +// 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.Diagnostics; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Runtime.CompilerServices; +using AsyncCausalityStatus = System.Threading.Tasks.AsyncCausalityStatus; +using CausalityTraceLevel = System.Threading.Tasks.CausalityTraceLevel; + +namespace Internal.Threading.Tasks +{ + // + // An internal contract that exposes just enough async debugger support needed by the AsTask() extension methods in the WindowsRuntimeSystemExtensions class. + // + public static class AsyncCausalitySupport + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void AddToActiveTasks(Task task) + { + if (Task.s_asyncDebuggingEnabled) + Task.AddToActiveTasks(task); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void RemoveFromActiveTasks(Task task) + { + if (Task.s_asyncDebuggingEnabled) + Task.RemoveFromActiveTasks(task.Id); + } + + public static bool LoggingOn + { + [MethodImpl(MethodImplOptions.AggressiveInlining)] + get + { + return AsyncCausalityTracer.LoggingOn; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCreation(Task task, string operationName) + { + AsyncCausalityTracer.TraceOperationCreation(CausalityTraceLevel.Required, task.Id, operationName, 0); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCompletedSuccess(Task task) + { + AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Completed); + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void TraceOperationCompletedError(Task task) + { + AsyncCausalityTracer.TraceOperationCompletion(CausalityTraceLevel.Required, task.Id, AsyncCausalityStatus.Error); + } + } +} + diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs index 053507b2d4bc..99ac9ba6a38b 100644 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs +++ b/src/System.Private.CoreLib/src/Microsoft/Win32/OAVariantLib.cs @@ -36,24 +36,24 @@ internal static class OAVariantLib internal static readonly Type[] ClassTypes = { typeof(Empty), typeof(void), - typeof(Boolean), - typeof(Char), - typeof(SByte), - typeof(Byte), - typeof(Int16), - typeof(UInt16), - typeof(Int32), - typeof(UInt32), - typeof(Int64), - typeof(UInt64), - typeof(Single), - typeof(Double), - typeof(String), + typeof(bool), + typeof(char), + typeof(sbyte), + typeof(byte), + typeof(short), + typeof(ushort), + typeof(int), + typeof(uint), + typeof(long), + typeof(ulong), + typeof(float), + typeof(double), + typeof(string), typeof(void), typeof(DateTime), typeof(TimeSpan), - typeof(Object), - typeof(Decimal), + typeof(object), + typeof(decimal), null, // Enums - what do we do here? typeof(Missing), typeof(DBNull), @@ -100,7 +100,7 @@ internal static Variant ChangeType(Variant source, Type targetClass, short optio private static int GetCVTypeFromClass(Type ctype) { Debug.Assert(ctype != null); - Debug.Assert(ClassTypes[CV_OBJECT] == typeof(Object), "OAVariantLib::ClassTypes[CV_OBJECT] == Object.class"); + Debug.Assert(ClassTypes[CV_OBJECT] == typeof(object), "OAVariantLib::ClassTypes[CV_OBJECT] == Object.class"); int cvtype = -1; for (int i = 0; i < ClassTypes.Length; i++) diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs index f861e5f9b817..28f86f35ddb1 100644 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs +++ b/src/System.Private.CoreLib/src/Microsoft/Win32/RegistryKey.cs @@ -523,12 +523,12 @@ public object GetValue(string name) * * @return the data associated with the value. */ - public Object GetValue(string name, Object defaultValue) + public object GetValue(string name, object defaultValue) { return InternalGetValue(name, defaultValue, false, true); } - public Object GetValue(string name, Object defaultValue, RegistryValueOptions options) + public object GetValue(string name, object defaultValue, RegistryValueOptions options) { if (options < RegistryValueOptions.None || options > RegistryValueOptions.DoNotExpandEnvironmentNames) { @@ -538,7 +538,7 @@ public Object GetValue(string name, Object defaultValue, RegistryValueOptions op return InternalGetValue(name, defaultValue, doNotExpand, true); } - internal Object InternalGetValue(string name, Object defaultValue, bool doNotExpand, bool checkSecurity) + internal object InternalGetValue(string name, object defaultValue, bool doNotExpand, bool checkSecurity) { if (checkSecurity) { @@ -546,7 +546,7 @@ internal Object InternalGetValue(string name, Object defaultValue, bool doNotExp EnsureNotDisposed(); } - Object data = defaultValue; + object data = defaultValue; int type = 0; int datasize = 0; @@ -563,15 +563,15 @@ internal Object InternalGetValue(string name, Object defaultValue, bool doNotExp byte[] blob = new byte[size]; while (Interop.Errors.ERROR_MORE_DATA == (r = Win32Native.RegQueryValueEx(_hkey, name, null, ref type, blob, ref sizeInput))) { - if (size == Int32.MaxValue) + if (size == int.MaxValue) { - // ERROR_MORE_DATA was returned however we cannot increase the buffer size beyond Int32.MaxValue + // ERROR_MORE_DATA was returned however we cannot increase the buffer size beyond int.MaxValue Win32Error(r, name); } - else if (size > (Int32.MaxValue / 2)) + else if (size > (int.MaxValue / 2)) { // at this point in the loop "size * 2" would cause an overflow - size = Int32.MaxValue; + size = int.MaxValue; } else { @@ -798,12 +798,12 @@ internal Object InternalGetValue(string name, Object defaultValue, bool doNotExp * @param name Name of value to store data in. * @param value Data to store. */ - public void SetValue(string name, Object value) + public void SetValue(string name, object value) { SetValue(name, value, RegistryValueKind.Unknown); } - public unsafe void SetValue(string name, Object value, RegistryValueKind valueKind) + public unsafe void SetValue(string name, object value, RegistryValueKind valueKind) { if (value == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.value); @@ -956,12 +956,12 @@ public unsafe void SetValue(string name, Object value, RegistryValueKind valueKi Win32Error(ret, null); } - private RegistryValueKind CalculateValueKind(Object value) + private RegistryValueKind CalculateValueKind(object value) { // This logic matches what used to be in SetValue(string name, object value) in the v1.0 and v1.1 days. // Even though we could add detection for an int64 in here, we want to maintain compatibility with the // old behavior. - if (value is Int32) + if (value is int) return RegistryValueKind.DWord; else if (value is Array) { diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs deleted file mode 100644 index 1141e6d027ff..000000000000 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/SafeHandles/SafeWaitHandle.cs +++ /dev/null @@ -1,43 +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. - -/*============================================================ -** -** -** -** A wrapper for Win32 events (mutexes, auto reset events, and -** manual reset events). Used by WaitHandle. -** -** -===========================================================*/ - -using System; -using System.Security; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Runtime.ConstrainedExecution; -using System.Runtime.Versioning; -using Microsoft.Win32; -using System.Threading; - -namespace Microsoft.Win32.SafeHandles -{ - public sealed class SafeWaitHandle : SafeHandleZeroOrMinusOneIsInvalid - { - // Called by P/Invoke marshaler - private SafeWaitHandle() : base(true) - { - } - - public SafeWaitHandle(IntPtr existingHandle, bool ownsHandle) : base(ownsHandle) - { - SetHandle(existingHandle); - } - - override protected bool ReleaseHandle() - { - return Win32Native.CloseHandle(handle); - } - } -} diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/UnsafeNativeMethods.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/UnsafeNativeMethods.cs index cc8887aed660..2f904e2e20bc 100644 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/UnsafeNativeMethods.cs +++ b/src/System.Private.CoreLib/src/Microsoft/Win32/UnsafeNativeMethods.cs @@ -189,11 +189,11 @@ internal static extern int EnumerateTraceGuidsEx( } #if FEATURE_COMINTEROP - [DllImport("combase.dll", PreserveSig = true)] + [DllImport("api-ms-win-core-winrt-l1-1-0.dll", PreserveSig = true)] internal static extern int RoGetActivationFactory( [MarshalAs(UnmanagedType.HString)] string activatableClassId, [In] ref Guid iid, - [Out, MarshalAs(UnmanagedType.IInspectable)] out Object factory); + [Out, MarshalAs(UnmanagedType.IInspectable)] out object factory); #endif } } diff --git a/src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs b/src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs index 9a2678fabdef..d1a92a3e0f79 100644 --- a/src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs +++ b/src/System.Private.CoreLib/src/Microsoft/Win32/Win32Native.cs @@ -152,30 +152,10 @@ internal static class Win32Native // Win32 ACL-related constants: internal const int READ_CONTROL = 0x00020000; internal const int SYNCHRONIZE = 0x00100000; - internal const int MAXIMUM_ALLOWED = 0x02000000; internal const int STANDARD_RIGHTS_READ = READ_CONTROL; internal const int STANDARD_RIGHTS_WRITE = READ_CONTROL; - // STANDARD_RIGHTS_REQUIRED (0x000F0000L) - // SEMAPHORE_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3) - - // SEMAPHORE and Event both use 0x0002 - // MUTEX uses 0x001 (MUTANT_QUERY_STATE) - - // Note that you may need to specify the SYNCHRONIZE bit as well - // to be able to open a synchronization primitive. - internal const int SEMAPHORE_MODIFY_STATE = 0x00000002; - internal const int EVENT_MODIFY_STATE = 0x00000002; - internal const int MUTEX_MODIFY_STATE = 0x00000001; - - // CreateEventEx: flags - internal const uint CREATE_EVENT_MANUAL_RESET = 0x1; - internal const uint CREATE_EVENT_INITIAL_SET = 0x2; - - // CreateMutexEx: flags - internal const uint CREATE_MUTEX_INITIAL_OWNER = 0x1; - internal const int LMEM_FIXED = 0x0000; internal const int LMEM_ZEROINIT = 0x0040; internal const int LPTR = (LMEM_FIXED | LMEM_ZEROINIT); @@ -239,12 +219,12 @@ internal unsafe struct MEMORY_BASIC_INFORMATION internal uint Type; } - internal const String ADVAPI32 = "advapi32.dll"; - internal const String SHELL32 = "shell32.dll"; - internal const String SHIM = "mscoree.dll"; - internal const String CRYPT32 = "crypt32.dll"; - internal const String SECUR32 = "secur32.dll"; - internal const String MSCORWKS = "coreclr.dll"; + internal const string ADVAPI32 = "advapi32.dll"; + internal const string SHELL32 = "shell32.dll"; + internal const string SHIM = "mscoree.dll"; + internal const string CRYPT32 = "crypt32.dll"; + internal const string SECUR32 = "secur32.dll"; + internal const string MSCORWKS = "coreclr.dll"; [DllImport(Interop.Libraries.Kernel32, EntryPoint = "LocalAlloc")] internal static extern IntPtr LocalAlloc_NoSafeHandle(int uFlags, UIntPtr sizetdwBytes); @@ -280,7 +260,7 @@ internal static bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX buffer) internal static extern int lstrlenW(IntPtr ptr); [DllImport(Interop.Libraries.OleAut32, CharSet = CharSet.Unicode)] - internal static extern IntPtr SysAllocStringLen(String src, int len); // BSTR + internal static extern IntPtr SysAllocStringLen(string src, int len); // BSTR [DllImport(Interop.Libraries.OleAut32)] internal static extern uint SysStringLen(IntPtr bstr); @@ -297,43 +277,9 @@ internal static bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX buffer) #endif - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] - internal static extern bool SetEvent(SafeWaitHandle handle); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] - internal static extern bool ResetEvent(SafeWaitHandle handle); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle CreateEventEx(SECURITY_ATTRIBUTES lpSecurityAttributes, string name, uint flags, uint desiredAccess); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle OpenEvent(uint desiredAccess, bool inheritHandle, string name); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle CreateMutexEx(SECURITY_ATTRIBUTES lpSecurityAttributes, string name, uint flags, uint desiredAccess); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] - internal static extern bool ReleaseMutex(SafeWaitHandle handle); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] - internal static extern bool CloseHandle(IntPtr handle); - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] internal static extern unsafe int WriteFile(SafeFileHandle handle, byte* bytes, int numBytesToWrite, out int numBytesWritten, IntPtr mustBeZero); - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle CreateSemaphoreEx(SECURITY_ATTRIBUTES lpSecurityAttributes, int initialCount, int maximumCount, string name, uint flags, uint desiredAccess); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount); - - [DllImport(Interop.Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern SafeWaitHandle OpenSemaphore(uint desiredAccess, bool inheritHandle, string name); - internal static readonly IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); // WinBase.h // Note, these are #defines used to extract handles, and are NOT handles. @@ -389,7 +335,7 @@ internal static unsafe int GetEnvironmentVariable(string lpName, Span lpVa #if FEATURE_WIN32_REGISTRY [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegDeleteValue(SafeRegistryHandle hKey, String lpValueName); + internal static extern int RegDeleteValue(SafeRegistryHandle hKey, string lpValueName); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] internal static extern unsafe int RegEnumKeyEx(SafeRegistryHandle hKey, int dwIndex, @@ -404,48 +350,48 @@ internal static extern unsafe int RegEnumValue(SafeRegistryHandle hKey, int dwIn int[] lpcbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegOpenKeyEx(SafeRegistryHandle hKey, String lpSubKey, + internal static extern int RegOpenKeyEx(SafeRegistryHandle hKey, string lpSubKey, int ulOptions, int samDesired, out SafeRegistryHandle hkResult); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, [Out] byte[] lpData, ref int lpcbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, ref int lpData, ref int lpcbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, ref long lpData, ref int lpcbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegQueryValueEx(SafeRegistryHandle hKey, string lpValueName, int[] lpReserved, ref int lpType, [Out] char[] lpData, ref int lpcbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegSetValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, byte[] lpData, int cbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegSetValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, ref int lpData, int cbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegSetValueEx(SafeRegistryHandle hKey, String lpValueName, + internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, int Reserved, RegistryValueKind dwType, ref long lpData, int cbData); [DllImport(ADVAPI32, CharSet = CharSet.Auto, BestFitMapping = false)] - internal static extern int RegSetValueEx(SafeRegistryHandle hKey, String lpValueName, - int Reserved, RegistryValueKind dwType, String lpData, int cbData); + internal static extern int RegSetValueEx(SafeRegistryHandle hKey, string lpValueName, + int Reserved, RegistryValueKind dwType, string lpData, int cbData); #endif // FEATURE_WIN32_REGISTRY [DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Auto, SetLastError = true, BestFitMapping = false)] - internal static extern int ExpandEnvironmentStrings(String lpSrc, [Out]StringBuilder lpDst, int nSize); + internal static extern int ExpandEnvironmentStrings(string lpSrc, [Out]StringBuilder lpDst, int nSize); [DllImport(Interop.Libraries.Kernel32)] internal static extern IntPtr LocalReAlloc(IntPtr handle, IntPtr sizetcbBytes, int uFlags); diff --git a/src/System.Private.CoreLib/src/System/Activator.cs b/src/System.Private.CoreLib/src/System/Activator.cs index 05b8f3766e5d..c2197d4c3b80 100644 --- a/src/System.Private.CoreLib/src/System/Activator.cs +++ b/src/System.Private.CoreLib/src/System/Activator.cs @@ -4,6 +4,8 @@ using System.Reflection; using System.Globalization; +using System.Runtime.Remoting; +using System.Threading; namespace System { @@ -62,6 +64,156 @@ internal static object CreateInstance(Type type, bool nonPublic, bool wrapExcept throw new ArgumentException(SR.Arg_MustBeType, nameof(type)); } + [System.Security.DynamicSecurityMethod] + public static ObjectHandle CreateInstance(string assemblyName, string typeName) + { + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return CreateInstanceInternal(assemblyName, + typeName, + false, + Activator.ConstructorDefault, + null, + null, + null, + null, + ref stackMark); + } + + [System.Security.DynamicSecurityMethod] + public static ObjectHandle CreateInstance(string assemblyName, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) + { + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return CreateInstanceInternal(assemblyName, + typeName, + ignoreCase, + bindingAttr, + binder, + args, + culture, + activationAttributes, + ref stackMark); + } + + [System.Security.DynamicSecurityMethod] + public static ObjectHandle CreateInstance(string assemblyName, string typeName, object[] activationAttributes) + { + StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; + return CreateInstanceInternal(assemblyName, + typeName, + false, + Activator.ConstructorDefault, + null, + null, + null, + activationAttributes, + ref stackMark); + } + + private static ObjectHandle CreateInstanceInternal(string assemblyString, + string typeName, + bool ignoreCase, + BindingFlags bindingAttr, + Binder binder, + object[] args, + CultureInfo culture, + object[] activationAttributes, + ref StackCrawlMark stackMark) + { + Type type = null; + Assembly assembly = null; + if (assemblyString == null) + { + assembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark); + } + else + { + RuntimeAssembly assemblyFromResolveEvent; + AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(assemblyString, out assemblyFromResolveEvent); + if (assemblyFromResolveEvent != null) + { + // Assembly was resolved via AssemblyResolve event + assembly = assemblyFromResolveEvent; + } + else if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime) + { + // WinRT type - we have to use Type.GetType + type = Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, ignoreCase); + } + else + { + // Classic managed type + assembly = RuntimeAssembly.InternalLoadAssemblyName( + assemblyName, null, ref stackMark, + true /*thrownOnFileNotFound*/); + } + } + + if (type == null) + { + type = assembly.GetType(typeName, true /*throwOnError*/, ignoreCase); + } + + object o = Activator.CreateInstance(type, + bindingAttr, + binder, + args, + culture, + activationAttributes); + + return (o != null) ? new ObjectHandle(o) : null; + } + + public static ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName) + { + return CreateInstanceFrom(assemblyFile, typeName, null); + } + + public static ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, bool ignoreCase, BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) + { + return CreateInstanceFromInternal(assemblyFile, + typeName, + ignoreCase, + bindingAttr, + binder, + args, + culture, + activationAttributes); + } + + public static ObjectHandle CreateInstanceFrom(string assemblyFile, string typeName, object[] activationAttributes) + { + return CreateInstanceFrom(assemblyFile, + typeName, + false, + Activator.ConstructorDefault, + null, + null, + null, + activationAttributes); + } + + private static ObjectHandle CreateInstanceFromInternal(string assemblyFile, + string typeName, + bool ignoreCase, + BindingFlags bindingAttr, + Binder binder, + object[] args, + CultureInfo culture, + object[] activationAttributes) + { + Assembly assembly = Assembly.LoadFrom(assemblyFile); + Type t = assembly.GetType(typeName, true, ignoreCase); + + object o = Activator.CreateInstance(t, + bindingAttr, + binder, + args, + culture, + activationAttributes); + + return (o != null) ? new ObjectHandle(o) : null; + } + public static T CreateInstance() { var rt = (RuntimeType)typeof(T); diff --git a/src/System.Private.CoreLib/src/System/AppDomain.cs b/src/System.Private.CoreLib/src/System/AppDomain.cs index 292fa926cba7..d96710b8e97c 100644 --- a/src/System.Private.CoreLib/src/System/AppDomain.cs +++ b/src/System.Private.CoreLib/src/System/AppDomain.cs @@ -267,11 +267,6 @@ internal Assembly[] GetAssemblies(bool forIntrospection) return nGetAssemblies(forIntrospection); } - // this is true when we've just started going through the finalizers and are forcing objects to finalize - // so must be aware that certain infrastructure may have gone away - [MethodImpl(MethodImplOptions.InternalCall)] - public extern bool IsFinalizingForUnload(); - [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void PublishAnonymouslyHostedDynamicMethodsAssembly(RuntimeAssembly assemblyHandle); diff --git a/src/System.Private.CoreLib/src/System/AppDomainSetup.cs b/src/System.Private.CoreLib/src/System/AppDomainSetup.cs index f3b3d8c8236d..b89995446d6e 100644 --- a/src/System.Private.CoreLib/src/System/AppDomainSetup.cs +++ b/src/System.Private.CoreLib/src/System/AppDomainSetup.cs @@ -2,23 +2,13 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** Purpose: Defines the settings that the loader uses to find assemblies in an -** AppDomain -** -** -=============================================================================*/ +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.Versioning; +using System.IO; + namespace System { - using System.Text; - using System.Runtime.InteropServices; - using System.Security; - using Path = System.IO.Path; - using System.Diagnostics; - using System.Collections.Generic; - internal sealed class AppDomainSetup { internal enum LoaderInformation @@ -55,7 +45,7 @@ internal enum LoaderInformation private string[] _Entries; #pragma warning disable 169 - private String _AppBase; // for compat with v1.1 + private string _AppBase; // for compat with v1.1 #pragma warning restore 169 // A collection of strings used to indicate which breaking changes shouldn't be applied @@ -120,12 +110,12 @@ internal string[] Value get { if (_Entries == null) - _Entries = new String[(int)LoaderInformation.LoaderMaximum]; + _Entries = new string[(int)LoaderInformation.LoaderMaximum]; return _Entries; } } - public String ApplicationBase + public string ApplicationBase { get { @@ -144,12 +134,12 @@ internal Dictionary GetCompatibilityFlags() return _CompatFlags; } - public void SetCompatibilitySwitches(IEnumerable switches) + public void SetCompatibilitySwitches(IEnumerable switches) { if (switches != null) { _CompatFlags = new Dictionary(); - foreach (String str in switches) + foreach (string str in switches) { _CompatFlags.Add(str, null); } @@ -160,16 +150,11 @@ public void SetCompatibilitySwitches(IEnumerable switches) } } - // A target Framework moniker, in a format parsible by the FrameworkName class. - public String TargetFrameworkName - { - get - { - return null; - } - } + // The Target framework is not the framework that the process is actually running on. + // It is the value read from the TargetFrameworkAttribute on the .exe that started the process. + public string TargetFrameworkName => Assembly.GetEntryAssembly()?.GetCustomAttribute()?.FrameworkName; - public String ApplicationName + public string ApplicationName { get { diff --git a/src/System.Private.CoreLib/src/System/ArgIterator.cs b/src/System.Private.CoreLib/src/System/ArgIterator.cs index 67e549c9dc67..72ea2548e21b 100644 --- a/src/System.Private.CoreLib/src/System/ArgIterator.cs +++ b/src/System.Private.CoreLib/src/System/ArgIterator.cs @@ -27,7 +27,7 @@ public ref struct ArgIterator private IntPtr ArgPtr; // Pointer to remaining args. private int RemainingArgs; // # of remaining args. -#if VARARGS_ENABLED //The JIT doesn't support Varargs calling convention. +#if PLATFORM_WINDOWS // Native Varargs are not supported on Unix [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern ArgIterator(IntPtr arglist); @@ -128,11 +128,11 @@ public override int GetHashCode() } // Inherited from object - public override bool Equals(Object o) + public override bool Equals(object o) { throw new NotSupportedException(SR.NotSupported_NYI); } -#else +#else public ArgIterator(RuntimeArgumentHandle arglist) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ArgIterator); // https://github.com/dotnet/coreclr/issues/9204 @@ -180,6 +180,6 @@ public int GetRemainingCount() { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ArgIterator); // https://github.com/dotnet/coreclr/issues/9204 } -#endif //VARARGS_ENABLED +#endif // PLATFORM_WINDOWS } } diff --git a/src/System.Private.CoreLib/src/System/Array.cs b/src/System.Private.CoreLib/src/System/Array.cs index dc4c8060fe1f..630ccfc09cac 100644 --- a/src/System.Private.CoreLib/src/System/Array.cs +++ b/src/System.Private.CoreLib/src/System/Array.cs @@ -162,7 +162,7 @@ public static Array CreateInstance(Type elementType, params long[] lengths) for (int i = 0; i < lengths.Length; ++i) { long len = lengths[i]; - if (len > Int32.MaxValue || len < Int32.MinValue) + if (len > int.MaxValue || len < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.len, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intLengths[i] = (int)len; } @@ -249,7 +249,7 @@ public static void ConstrainedCopy(Array sourceArray, int sourceIndex, Array des public static void Copy(Array sourceArray, Array destinationArray, long length) { - if (length > Int32.MaxValue || length < Int32.MinValue) + if (length > int.MaxValue || length < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Array.Copy(sourceArray, destinationArray, (int)length); @@ -257,11 +257,11 @@ public static void Copy(Array sourceArray, Array destinationArray, long length) public static void Copy(Array sourceArray, long sourceIndex, Array destinationArray, long destinationIndex, long length) { - if (sourceIndex > Int32.MaxValue || sourceIndex < Int32.MinValue) + if (sourceIndex > int.MaxValue || sourceIndex < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.sourceIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (destinationIndex > Int32.MaxValue || destinationIndex < Int32.MinValue) + if (destinationIndex > int.MaxValue || destinationIndex < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.destinationIndex, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (length > Int32.MaxValue || length < Int32.MinValue) + if (length > int.MaxValue || length < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.length, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); Array.Copy(sourceArray, (int)sourceIndex, destinationArray, (int)destinationIndex, (int)length); @@ -296,7 +296,7 @@ public static unsafe void Clear(Array array, int index, int length) private static extern ref byte GetRawArrayGeometry(Array array, out uint numComponents, out uint elementSize, out int lowerBound, out bool containsGCPointers); // The various Get values... - public unsafe Object GetValue(params int[] indices) + public unsafe object GetValue(params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); @@ -309,7 +309,7 @@ public unsafe Object GetValue(params int[] indices) return TypedReference.InternalToObject(&elemref); } - public unsafe Object GetValue(int index) + public unsafe object GetValue(int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); @@ -319,7 +319,7 @@ public unsafe Object GetValue(int index) return TypedReference.InternalToObject(&elemref); } - public unsafe Object GetValue(int index1, int index2) + public unsafe object GetValue(int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); @@ -333,7 +333,7 @@ public unsafe Object GetValue(int index1, int index2) return TypedReference.InternalToObject(&elemref); } - public unsafe Object GetValue(int index1, int index2, int index3) + public unsafe object GetValue(int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); @@ -348,37 +348,37 @@ public unsafe Object GetValue(int index1, int index2, int index3) return TypedReference.InternalToObject(&elemref); } - public Object GetValue(long index) + public object GetValue(long index) { - if (index > Int32.MaxValue || index < Int32.MinValue) + if (index > int.MaxValue || index < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue((int)index); } - public Object GetValue(long index1, long index2) + public object GetValue(long index1, long index2) { - if (index1 > Int32.MaxValue || index1 < Int32.MinValue) + if (index1 > int.MaxValue || index1 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index2 > Int32.MaxValue || index2 < Int32.MinValue) + if (index2 > int.MaxValue || index2 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue((int)index1, (int)index2); } - public Object GetValue(long index1, long index2, long index3) + public object GetValue(long index1, long index2, long index3) { - if (index1 > Int32.MaxValue || index1 < Int32.MinValue) + if (index1 > int.MaxValue || index1 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index2 > Int32.MaxValue || index2 < Int32.MinValue) + if (index2 > int.MaxValue || index2 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index3 > Int32.MaxValue || index3 < Int32.MinValue) + if (index3 > int.MaxValue || index3 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); return this.GetValue((int)index1, (int)index2, (int)index3); } - public Object GetValue(params long[] indices) + public object GetValue(params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); @@ -390,7 +390,7 @@ public Object GetValue(params long[] indices) for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; - if (index > Int32.MaxValue || index < Int32.MinValue) + if (index > int.MaxValue || index < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = (int)index; } @@ -399,7 +399,7 @@ public Object GetValue(params long[] indices) } - public unsafe void SetValue(Object value, int index) + public unsafe void SetValue(object value, int index) { if (Rank != 1) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need1DArray); @@ -409,7 +409,7 @@ public unsafe void SetValue(Object value, int index) InternalSetValue(&elemref, value); } - public unsafe void SetValue(Object value, int index1, int index2) + public unsafe void SetValue(object value, int index1, int index2) { if (Rank != 2) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need2DArray); @@ -423,7 +423,7 @@ public unsafe void SetValue(Object value, int index1, int index2) InternalSetValue(&elemref, value); } - public unsafe void SetValue(Object value, int index1, int index2, int index3) + public unsafe void SetValue(object value, int index1, int index2, int index3) { if (Rank != 3) ThrowHelper.ThrowArgumentException(ExceptionResource.Arg_Need3DArray); @@ -438,7 +438,7 @@ public unsafe void SetValue(Object value, int index1, int index2, int index3) InternalSetValue(&elemref, value); } - public unsafe void SetValue(Object value, params int[] indices) + public unsafe void SetValue(object value, params int[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); @@ -451,37 +451,37 @@ public unsafe void SetValue(Object value, params int[] indices) InternalSetValue(&elemref, value); } - public void SetValue(Object value, long index) + public void SetValue(object value, long index) { - if (index > Int32.MaxValue || index < Int32.MinValue) + if (index > int.MaxValue || index < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, (int)index); } - public void SetValue(Object value, long index1, long index2) + public void SetValue(object value, long index1, long index2) { - if (index1 > Int32.MaxValue || index1 < Int32.MinValue) + if (index1 > int.MaxValue || index1 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index2 > Int32.MaxValue || index2 < Int32.MinValue) + if (index2 > int.MaxValue || index2 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, (int)index1, (int)index2); } - public void SetValue(Object value, long index1, long index2, long index3) + public void SetValue(object value, long index1, long index2, long index3) { - if (index1 > Int32.MaxValue || index1 < Int32.MinValue) + if (index1 > int.MaxValue || index1 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index1, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index2 > Int32.MaxValue || index2 < Int32.MinValue) + if (index2 > int.MaxValue || index2 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index2, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); - if (index3 > Int32.MaxValue || index3 < Int32.MinValue) + if (index3 > int.MaxValue || index3 < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index3, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.SetValue(value, (int)index1, (int)index2, (int)index3); } - public void SetValue(Object value, params long[] indices) + public void SetValue(object value, params long[] indices) { if (indices == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.indices); @@ -493,7 +493,7 @@ public void SetValue(Object value, params long[] indices) for (int i = 0; i < indices.Length; ++i) { long index = indices[i]; - if (index > Int32.MaxValue || index < Int32.MinValue) + if (index > int.MaxValue || index < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); intIndices[i] = (int)index; } @@ -508,7 +508,7 @@ public void SetValue(Object value, params long[] indices) // Ideally, we would like to use TypedReference.SetValue instead. Unfortunately, TypedReference.SetValue // always throws not-supported exception [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern unsafe void InternalSetValue(void* target, Object value); + private static extern unsafe void InternalSetValue(void* target, object value); public extern int Length { @@ -569,7 +569,7 @@ int ICollection.Count // Returns an object appropriate for synchronizing access to this // Array. - public Object SyncRoot + public object SyncRoot { get { return this; } } // Is this Array read-only? @@ -589,19 +589,19 @@ public bool IsSynchronized { get { return false; } } - Object IList.this[int index] + object IList.this[int index] { get { return GetValue(index); } set { SetValue(value, index); } } - int IList.Add(Object value) + int IList.Add(object value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); return default; } - bool IList.Contains(Object value) + bool IList.Contains(object value) { return Array.IndexOf(this, value) >= this.GetLowerBound(0); } @@ -611,17 +611,17 @@ void IList.Clear() Array.Clear(this, this.GetLowerBound(0), this.Length); } - int IList.IndexOf(Object value) + int IList.IndexOf(object value) { return Array.IndexOf(this, value); } - void IList.Insert(int index, Object value) + void IList.Insert(int index, object value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } - void IList.Remove(Object value) + void IList.Remove(object value) { ThrowHelper.ThrowNotSupportedException(ExceptionResource.NotSupported_FixedSizeCollection); } @@ -633,12 +633,12 @@ void IList.RemoveAt(int index) // Make a new array which is a shallow copy of the original array. // - public Object Clone() + public object Clone() { return MemberwiseClone(); } - Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) + int IStructuralComparable.CompareTo(object other, IComparer comparer) { if (other == null) { @@ -667,14 +667,14 @@ Int32 IStructuralComparable.CompareTo(Object other, IComparer comparer) return c; } - Boolean IStructuralEquatable.Equals(Object other, IEqualityComparer comparer) + bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer) { if (other == null) { return false; } - if (Object.ReferenceEquals(this, other)) + if (object.ReferenceEquals(this, other)) { return true; } @@ -736,7 +736,7 @@ int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) // negative result to produce the index of the first element (if any) that // is larger than the given search value. // - public static int BinarySearch(Array array, Object value) + public static int BinarySearch(Array array, object value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -757,7 +757,7 @@ public static int BinarySearch(Array array, Object value) // negative result to produce the index of the first element (if any) that // is larger than the given search value. // - public static int BinarySearch(Array array, int index, int length, Object value) + public static int BinarySearch(Array array, int index, int length, object value) { return BinarySearch(array, index, length, value, null); } @@ -776,7 +776,7 @@ public static int BinarySearch(Array array, int index, int length, Object value) // negative result to produce the index of the first element (if any) that // is larger than the given search value. // - public static int BinarySearch(Array array, Object value, IComparer comparer) + public static int BinarySearch(Array array, object value, IComparer comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -799,7 +799,7 @@ public static int BinarySearch(Array array, Object value, IComparer comparer) // negative result to produce the index of the first element (if any) that // is larger than the given search value. // - public static int BinarySearch(Array array, int index, int length, Object value, IComparer comparer) + public static int BinarySearch(Array array, int index, int length, object value, IComparer comparer) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -824,7 +824,7 @@ public static int BinarySearch(Array array, int index, int length, Object value, int lo = index; int hi = index + length - 1; - Object[] objArray = array as Object[]; + object[] objArray = array as object[]; if (objArray != null) { while (lo <= hi) @@ -882,7 +882,7 @@ public static int BinarySearch(Array array, int index, int length, Object value, } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool TrySZBinarySearch(Array sourceArray, int sourceIndex, int count, Object value, out int retVal); + private static extern bool TrySZBinarySearch(Array sourceArray, int sourceIndex, int count, object value, out int retVal); public static int BinarySearch(T[] array, T value) { @@ -955,7 +955,7 @@ public void CopyTo(Array array, int index) public void CopyTo(Array array, long index) { - if (index > Int32.MaxValue || index < Int32.MinValue) + if (index > int.MaxValue || index < int.MinValue) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ArgumentOutOfRange_HugeArrayNotSupported); this.CopyTo(array, (int)index); @@ -1230,7 +1230,7 @@ public IEnumerator GetEnumerator() // The array is searched forwards, and the elements of the array are // compared to the given value using the Object.Equals method. // - public static int IndexOf(Array array, Object value) + public static int IndexOf(Array array, object value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1244,7 +1244,7 @@ public static int IndexOf(Array array, Object value) // elements of the array are compared to the given value using the // Object.Equals method. // - public static int IndexOf(Array array, Object value, int startIndex) + public static int IndexOf(Array array, object value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1258,7 +1258,7 @@ public static int IndexOf(Array array, Object value, int startIndex) // elements of the array are compared to the given value using the // Object.Equals method. // - public static int IndexOf(Array array, Object value, int startIndex, int count) + public static int IndexOf(Array array, object value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1277,7 +1277,7 @@ public static int IndexOf(Array array, Object value, int startIndex, int count) if (r) return retVal; - Object[] objArray = array as Object[]; + object[] objArray = array as object[]; int endIndex = startIndex + count; if (objArray != null) { @@ -1292,7 +1292,7 @@ public static int IndexOf(Array array, Object value, int startIndex, int count) { for (int i = startIndex; i < endIndex; i++) { - Object obj = objArray[i]; + object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } @@ -1301,7 +1301,7 @@ public static int IndexOf(Array array, Object value, int startIndex, int count) { for (int i = startIndex; i < endIndex; i++) { - Object obj = array.GetValue(i); + object obj = array.GetValue(i); if (obj == null) { if (value == null) return i; @@ -1360,14 +1360,14 @@ public static int IndexOf(T[] array, T value, int startIndex, int count) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool TrySZIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal); + private static extern bool TrySZIndexOf(Array sourceArray, int sourceIndex, int count, object value, out int retVal); // Returns the index of the last occurrence of a given value in an array. // The array is searched backwards, and the elements of the array are // compared to the given value using the Object.Equals method. // - public static int LastIndexOf(Array array, Object value) + public static int LastIndexOf(Array array, object value) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1380,7 +1380,7 @@ public static int LastIndexOf(Array array, Object value) // startIndex and ending at index 0. The elements of the array are // compared to the given value using the Object.Equals method. // - public static int LastIndexOf(Array array, Object value, int startIndex) + public static int LastIndexOf(Array array, object value, int startIndex) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1394,7 +1394,7 @@ public static int LastIndexOf(Array array, Object value, int startIndex) // the array are compared to the given value using the Object.Equals // method. // - public static int LastIndexOf(Array array, Object value, int startIndex, int count) + public static int LastIndexOf(Array array, object value, int startIndex, int count) { if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); @@ -1419,7 +1419,7 @@ public static int LastIndexOf(Array array, Object value, int startIndex, int cou if (r) return retVal; - Object[] objArray = array as Object[]; + object[] objArray = array as object[]; int endIndex = startIndex - count + 1; if (objArray != null) { @@ -1434,7 +1434,7 @@ public static int LastIndexOf(Array array, Object value, int startIndex, int cou { for (int i = startIndex; i >= endIndex; i--) { - Object obj = objArray[i]; + object obj = objArray[i]; if (obj != null && obj.Equals(value)) return i; } } @@ -1443,7 +1443,7 @@ public static int LastIndexOf(Array array, Object value, int startIndex, int cou { for (int i = startIndex; i >= endIndex; i--) { - Object obj = array.GetValue(i); + object obj = array.GetValue(i); if (obj == null) { if (value == null) return i; @@ -1519,7 +1519,7 @@ public static int LastIndexOf(T[] array, T value, int startIndex, int count) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool TrySZLastIndexOf(Array sourceArray, int sourceIndex, int count, Object value, out int retVal); + private static extern bool TrySZLastIndexOf(Array sourceArray, int sourceIndex, int count, object value, out int retVal); // Reverses all elements of the given array. Following a call to this @@ -1562,7 +1562,7 @@ public static void Reverse(Array array, int index, int length) if (r) return; - Object[] objArray = array as Object[]; + object[] objArray = array as object[]; if (objArray != null) { Array.Reverse(objArray, index, length); @@ -1573,7 +1573,7 @@ public static void Reverse(Array array, int index, int length) int j = index + length - 1; while (i < j) { - Object temp = array.GetValue(i); + object temp = array.GetValue(i); array.SetValue(array.GetValue(j), i); array.SetValue(temp, j); i++; @@ -1736,10 +1736,10 @@ public static void Sort(Array keys, Array items, int index, int length, ICompare return; } - Object[] objKeys = keys as Object[]; - Object[] objItems = null; + object[] objKeys = keys as object[]; + object[] objItems = null; if (objKeys != null) - objItems = items as Object[]; + objItems = items as object[]; if (objKeys != null && (items == null || objItems != null)) { SorterObjectArray sorter = new SorterObjectArray(objKeys, objItems, comparer); @@ -1891,11 +1891,11 @@ public static bool TrueForAll(T[] array, Predicate match) // Private value type used by the Sort methods. private struct SorterObjectArray { - private Object[] keys; - private Object[] items; + private object[] keys; + private object[] items; private IComparer comparer; - internal SorterObjectArray(Object[] keys, Object[] items, IComparer comparer) + internal SorterObjectArray(object[] keys, object[] items, IComparer comparer) { if (comparer == null) comparer = Comparer.Default; this.keys = keys; @@ -1909,12 +1909,12 @@ internal void SwapIfGreaterWithItems(int a, int b) { if (comparer.Compare(keys[a], keys[b]) > 0) { - Object temp = keys[a]; + object temp = keys[a]; keys[a] = keys[b]; keys[b] = temp; if (items != null) { - Object item = items[a]; + object item = items[a]; items[a] = items[b]; items[b] = item; } @@ -1924,13 +1924,13 @@ internal void SwapIfGreaterWithItems(int a, int b) private void Swap(int i, int j) { - Object t = keys[i]; + object t = keys[i]; keys[i] = keys[j]; keys[j] = t; if (items != null) { - Object item = items[i]; + object item = items[i]; items[i] = items[j]; items[j] = item; } @@ -2010,7 +2010,7 @@ private int PickPivotAndPartition(int lo, int hi) SwapIfGreaterWithItems(lo, hi); SwapIfGreaterWithItems(mid, hi); - Object pivot = keys[mid]; + object pivot = keys[mid]; Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. @@ -2047,8 +2047,8 @@ private void Heapsort(int lo, int hi) private void DownHeap(int i, int n, int lo) { - Object d = keys[lo + i - 1]; - Object dt = (items != null) ? items[lo + i - 1] : null; + object d = keys[lo + i - 1]; + object dt = (items != null) ? items[lo + i - 1] : null; int child; while (i <= n / 2) { @@ -2072,7 +2072,7 @@ private void DownHeap(int i, int n, int lo) private void InsertionSort(int lo, int hi) { int i, j; - Object t, ti; + object t, ti; for (i = lo; i < hi; i++) { j = i; @@ -2115,12 +2115,12 @@ internal void SwapIfGreaterWithItems(int a, int b) { if (comparer.Compare(keys.GetValue(a), keys.GetValue(b)) > 0) { - Object key = keys.GetValue(a); + object key = keys.GetValue(a); keys.SetValue(keys.GetValue(b), a); keys.SetValue(key, b); if (items != null) { - Object item = items.GetValue(a); + object item = items.GetValue(a); items.SetValue(items.GetValue(b), a); items.SetValue(item, b); } @@ -2130,13 +2130,13 @@ internal void SwapIfGreaterWithItems(int a, int b) private void Swap(int i, int j) { - Object t1 = keys.GetValue(i); + object t1 = keys.GetValue(i); keys.SetValue(keys.GetValue(j), i); keys.SetValue(t1, j); if (items != null) { - Object t2 = items.GetValue(i); + object t2 = items.GetValue(i); items.SetValue(items.GetValue(j), i); items.SetValue(t2, j); } @@ -2216,7 +2216,7 @@ private int PickPivotAndPartition(int lo, int hi) SwapIfGreaterWithItems(lo, hi); SwapIfGreaterWithItems(mid, hi); - Object pivot = keys.GetValue(mid); + object pivot = keys.GetValue(mid); Swap(mid, hi - 1); int left = lo, right = hi - 1; // We already partitioned lo and hi and put the pivot in hi - 1. And we pre-increment & decrement below. @@ -2253,8 +2253,8 @@ private void Heapsort(int lo, int hi) private void DownHeap(int i, int n, int lo) { - Object d = keys.GetValue(lo + i - 1); - Object dt = (items != null) ? items.GetValue(lo + i - 1) : null; + object d = keys.GetValue(lo + i - 1); + object dt = (items != null) ? items.GetValue(lo + i - 1) : null; int child; while (i <= n / 2) { @@ -2280,7 +2280,7 @@ private void DownHeap(int i, int n, int lo) private void InsertionSort(int lo, int hi) { int i, j; - Object t, dt; + object t, dt; for (i = lo; i < hi; i++) { j = i; @@ -2317,7 +2317,7 @@ internal SZArrayEnumerator(Array array) _endIndex = array.Length; } - public Object Clone() + public object Clone() { return MemberwiseClone(); } @@ -2332,7 +2332,7 @@ public bool MoveNext() return false; } - public Object Current + public object Current { get { @@ -2404,7 +2404,7 @@ private void IncArray() } } - public Object Clone() + public object Clone() { return MemberwiseClone(); } @@ -2421,7 +2421,7 @@ public bool MoveNext() return !_complete; } - public Object Current + public object Current { get { diff --git a/src/System.Private.CoreLib/src/System/Attribute.cs b/src/System.Private.CoreLib/src/System/Attribute.cs index 5934284c0fb0..fd84dd33b08c 100644 --- a/src/System.Private.CoreLib/src/System/Attribute.cs +++ b/src/System.Private.CoreLib/src/System/Attribute.cs @@ -245,7 +245,7 @@ private static Attribute[] InternalParamGetCustomAttributes(ParameterInfo param, // class inherits from and return the respective ParameterInfo attributes List disAllowMultiple = new List(); - Object[] objAttr; + object[] objAttr; if (type == null) type = typeof(Attribute); @@ -344,7 +344,7 @@ private static bool InternalParamIsDefined(ParameterInfo param, Type type, bool while (baseParam != null) { - Object[] objAttr = baseParam.GetCustomAttributes(type, false); + object[] objAttr = baseParam.GetCustomAttributes(type, false); for (int i = 0; i < objAttr.Length; i++) { @@ -422,7 +422,7 @@ private static void AddAttributesToList(List attributeList, Attribute private static AttributeUsageAttribute InternalGetAttributeUsage(Type type) { // Check if the custom attributes is Inheritable - Object[] obj = type.GetCustomAttributes(typeof(AttributeUsageAttribute), false); + object[] obj = type.GetCustomAttributes(typeof(AttributeUsageAttribute), false); if (obj.Length == 1) return (AttributeUsageAttribute)obj[0]; @@ -814,7 +814,7 @@ protected Attribute() { } #endregion #region Object Overrides - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj == null) return false; @@ -825,8 +825,8 @@ public override bool Equals(Object obj) if (thatType != thisType) return false; - Object thisObj = this; - Object thisResult, thatResult; + object thisObj = this; + object thisResult, thatResult; while (thisType != typeof(Attribute)) { @@ -850,7 +850,7 @@ public override bool Equals(Object obj) } // Compares values of custom-attribute fields. - private static bool AreFieldValuesEqual(Object thisValue, Object thatValue) + private static bool AreFieldValuesEqual(object thisValue, object thatValue) { if (thisValue == null && thatValue == null) return true; @@ -903,12 +903,12 @@ public override int GetHashCode() while (type != typeof(Attribute)) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly); - Object vThis = null; + object vThis = null; for (int i = 0; i < fields.Length; i++) { // Visibility check and consistency check are not necessary. - Object fieldValue = ((RtFieldInfo)fields[i]).UnsafeGetValue(this); + object fieldValue = ((RtFieldInfo)fields[i]).UnsafeGetValue(this); // The hashcode of an array ignores the contents of the array, so it can produce // different hashcodes for arrays with the same contents. @@ -932,9 +932,9 @@ public override int GetHashCode() #endregion #region Public Virtual Members - public virtual Object TypeId { get { return GetType(); } } + public virtual object TypeId { get { return GetType(); } } - public virtual bool Match(Object obj) { return Equals(obj); } + public virtual bool Match(object obj) { return Equals(obj); } #endregion #region Public Members diff --git a/src/System.Private.CoreLib/src/System/Buffer.cs b/src/System.Private.CoreLib/src/System/Buffer.cs index 43372ca67350..d9cd453107fb 100644 --- a/src/System.Private.CoreLib/src/System/Buffer.cs +++ b/src/System.Private.CoreLib/src/System/Buffer.cs @@ -6,28 +6,26 @@ #define HAS_CUSTOM_BLOCKS #endif -namespace System -{ - //Only contains static methods. Does not require serialization - - using System; - using System.Runtime.CompilerServices; - using System.Runtime.ConstrainedExecution; - using System.Runtime.InteropServices; - using System.Runtime.Versioning; - using System.Diagnostics; - using System.Security; - using System.Runtime; - using Internal.Runtime.CompilerServices; +using System; +using System.Runtime.CompilerServices; +using System.Runtime.ConstrainedExecution; +using System.Runtime.InteropServices; +using System.Runtime.Versioning; +using System.Diagnostics; +using System.Security; +using System.Runtime; +using Internal.Runtime.CompilerServices; #if BIT64 - using nint = System.Int64; - using nuint = System.UInt64; +using nint = System.Int64; +using nuint = System.UInt64; #else // BIT64 - using nint = System.Int32; - using nuint = System.UInt32; +using nint = System.Int32; +using nuint = System.UInt32; #endif // BIT64 +namespace System +{ public static class Buffer { // Copies from one primitive array to another primitive array without @@ -183,12 +181,12 @@ internal static unsafe void Memmove(byte* dest, byte* src, nuint len) #if PLATFORM_WINDOWS // Determined optimal value for Windows. // https://github.com/dotnet/coreclr/issues/13843 - const nuint CopyThreshold = UInt64.MaxValue; + const nuint CopyThreshold = ulong.MaxValue; #else // PLATFORM_WINDOWS // Managed code is currently faster than glibc unoptimized memmove // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros // https://github.com/dotnet/coreclr/issues/13844 - const nuint CopyThreshold = UInt64.MaxValue; + const nuint CopyThreshold = ulong.MaxValue; #endif // PLATFORM_WINDOWS #else const nuint CopyThreshold = 512; @@ -394,12 +392,12 @@ private static void Memmove(ref byte dest, ref byte src, nuint len) #if PLATFORM_WINDOWS // Determined optimal value for Windows. // https://github.com/dotnet/coreclr/issues/13843 - const nuint CopyThreshold = UInt64.MaxValue; + const nuint CopyThreshold = ulong.MaxValue; #else // PLATFORM_WINDOWS // Managed code is currently faster than glibc unoptimized memmove // TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros // https://github.com/dotnet/coreclr/issues/13844 - const nuint CopyThreshold = UInt64.MaxValue; + const nuint CopyThreshold = ulong.MaxValue; #endif // PLATFORM_WINDOWS #else const nuint CopyThreshold = 512; diff --git a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs deleted file mode 100644 index cc6033fdc0bf..000000000000 --- a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentDictionary.cs +++ /dev/null @@ -1,1590 +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. - -/*============================================================ -** -** Class: ConcurrentDictionary -** -** -** Purpose: A scalable dictionary for concurrent access -** -** -===========================================================*/ - -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Threading; - -namespace System.Collections.Concurrent -{ - /// - /// Represents a thread-safe collection of keys and values. - /// - /// The type of the keys in the dictionary. - /// The type of the values in the dictionary. - /// - /// All public and protected members of are thread-safe and may be used - /// concurrently from multiple threads. - /// - [DebuggerTypeProxy(typeof(IDictionaryDebugView<,>))] - [DebuggerDisplay("Count = {Count}")] - internal class ConcurrentDictionary : IDictionary, IDictionary, IReadOnlyDictionary - { - /// - /// Tables that hold the internal state of the ConcurrentDictionary - /// - /// Wrapping the three tables in a single object allows us to atomically - /// replace all tables at once. - /// - private sealed class Tables - { - internal readonly Node[] _buckets; // A singly-linked list for each bucket. - internal readonly object[] _locks; // A set of locks, each guarding a section of the table. - internal volatile int[] _countPerLock; // The number of elements guarded by each lock. - - internal Tables(Node[] buckets, object[] locks, int[] countPerLock) - { - _buckets = buckets; - _locks = locks; - _countPerLock = countPerLock; - } - } - - private volatile Tables _tables; // Internal tables of the dictionary - private IEqualityComparer _comparer; // Key equality comparer - private readonly bool _growLockArray; // Whether to dynamically increase the size of the striped lock - private int _budget; // The maximum number of elements per lock before a resize operation is triggered - - // The default capacity, i.e. the initial # of buckets. When choosing this value, we are making - // a trade-off between the size of a very small dictionary, and the number of resizes when - // constructing a large dictionary. Also, the capacity should not be divisible by a small prime. - private const int DefaultCapacity = 31; - - // The maximum size of the striped lock that will not be exceeded when locks are automatically - // added as the dictionary grows. However, the user is allowed to exceed this limit by passing - // a concurrency level larger than MaxLockNumber into the constructor. - private const int MaxLockNumber = 1024; - - // Whether TValue is a type that can be written atomically (i.e., with no danger of torn reads) - private static readonly bool s_isValueWriteAtomic = IsValueWriteAtomic(); - - /// - /// Determines whether type TValue can be written atomically - /// - private static bool IsValueWriteAtomic() - { - // - // Section 12.6.6 of ECMA CLI explains which types can be read and written atomically without - // the risk of tearing. - // - // See http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-335.pdf - // - Type valueType = typeof(TValue); - if (!valueType.IsValueType) - { - return true; - } - if (valueType.IsEnum) - { - valueType = Enum.GetUnderlyingType(valueType); - } - - switch (Type.GetTypeCode(valueType)) - { - case TypeCode.Boolean: - case TypeCode.Byte: - case TypeCode.Char: - case TypeCode.Int16: - case TypeCode.Int32: - case TypeCode.SByte: - case TypeCode.Single: - case TypeCode.UInt16: - case TypeCode.UInt32: - return true; - case TypeCode.Int64: - case TypeCode.Double: - case TypeCode.UInt64: - return IntPtr.Size == 8; - default: - return false; - } - } - - /// - /// Initializes a new instance of the - /// class that is empty, has the default concurrency level, has the default initial capacity, and - /// uses the default comparer for the key type. - /// - public ConcurrentDictionary() : this(DefaultConcurrencyLevel, DefaultCapacity, true, null) { } - - internal ConcurrentDictionary(int concurrencyLevel, int capacity, bool growLockArray, IEqualityComparer comparer) - { - if (concurrencyLevel < 1) - { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.concurrencyLevel, ExceptionResource.ConcurrentDictionary_ConcurrencyLevelMustBePositive); - } - if (capacity < 0) - { - ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity, ExceptionResource.ConcurrentDictionary_CapacityMustNotBeNegative); - } - - // The capacity should be at least as large as the concurrency level. Otherwise, we would have locks that don't guard - // any buckets. - if (capacity < concurrencyLevel) - { - capacity = concurrencyLevel; - } - - object[] locks = new object[concurrencyLevel]; - for (int i = 0; i < locks.Length; i++) - { - locks[i] = new object(); - } - - int[] countPerLock = new int[locks.Length]; - Node[] buckets = new Node[capacity]; - _tables = new Tables(buckets, locks, countPerLock); - - _comparer = comparer ?? EqualityComparer.Default; - _growLockArray = growLockArray; - _budget = buckets.Length / locks.Length; - } - - /// - /// Attempts to add the specified key and value to the . - /// - /// The key of the element to add. - /// The value of the element to add. The value can be a null reference (Nothing - /// in Visual Basic) for reference types. - /// true if the key/value pair was added to the - /// successfully; otherwise, false. - /// is null reference - /// (Nothing in Visual Basic). - /// The - /// contains too many elements. - public bool TryAdd(TKey key, TValue value) - { - if (key == null) ThrowKeyNullException(); - TValue dummy; - return TryAddInternal(key, _comparer.GetHashCode(key), value, false, true, out dummy); - } - - /// - /// Determines whether the contains the specified - /// key. - /// - /// The key to locate in the . - /// true if the contains an element with - /// the specified key; otherwise, false. - /// is a null reference - /// (Nothing in Visual Basic). - public bool ContainsKey(TKey key) - { - if (key == null) ThrowKeyNullException(); - - TValue throwAwayValue; - return TryGetValue(key, out throwAwayValue); - } - - /// - /// Attempts to remove and return the value with the specified key from the - /// . - /// - /// The key of the element to remove and return. - /// When this method returns, contains the object removed from the - /// or the default value of - /// if the operation failed. - /// true if an object was removed successfully; otherwise, false. - /// is a null reference - /// (Nothing in Visual Basic). - public bool TryRemove(TKey key, out TValue value) - { - if (key == null) ThrowKeyNullException(); - - return TryRemoveInternal(key, out value, false, default); - } - - /// - /// Removes the specified key from the dictionary if it exists and returns its associated value. - /// If matchValue flag is set, the key will be removed only if is associated with a particular - /// value. - /// - /// The key to search for and remove if it exists. - /// The variable into which the removed value, if found, is stored. - /// Whether removal of the key is conditional on its value. - /// The conditional value to compare against if is true - /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] - private bool TryRemoveInternal(TKey key, out TValue value, bool matchValue, TValue oldValue) - { - int hashcode = _comparer.GetHashCode(key); - while (true) - { - Tables tables = _tables; - - int bucketNo, lockNo; - GetBucketAndLockNo(hashcode, out bucketNo, out lockNo, tables._buckets.Length, tables._locks.Length); - - lock (tables._locks[lockNo]) - { - // If the table just got resized, we may not be holding the right lock, and must retry. - // This should be a rare occurrence. - if (tables != _tables) - { - continue; - } - - Node prev = null; - for (Node curr = tables._buckets[bucketNo]; curr != null; curr = curr._next) - { - Debug.Assert((prev == null && curr == tables._buckets[bucketNo]) || prev._next == curr); - - if (hashcode == curr._hashcode && _comparer.Equals(curr._key, key)) - { - if (matchValue) - { - bool valuesMatch = EqualityComparer.Default.Equals(oldValue, curr._value); - if (!valuesMatch) - { - value = default; - return false; - } - } - - if (prev == null) - { - Volatile.Write(ref tables._buckets[bucketNo], curr._next); - } - else - { - prev._next = curr._next; - } - - value = curr._value; - tables._countPerLock[lockNo]--; - return true; - } - prev = curr; - } - } - - value = default; - return false; - } - } - - /// - /// Attempts to get the value associated with the specified key from the . - /// - /// The key of the value to get. - /// When this method returns, contains the object from - /// the - /// with the specified key or the default value of - /// , if the operation failed. - /// true if the key was found in the ; - /// otherwise, false. - /// is a null reference - /// (Nothing in Visual Basic). - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] - public bool TryGetValue(TKey key, out TValue value) - { - if (key == null) ThrowKeyNullException(); - return TryGetValueInternal(key, _comparer.GetHashCode(key), out value); - } - - private bool TryGetValueInternal(TKey key, int hashcode, out TValue value) - { - Debug.Assert(_comparer.GetHashCode(key) == hashcode); - - // We must capture the _buckets field in a local variable. It is set to a new table on each table resize. - Tables tables = _tables; - - int bucketNo = GetBucket(hashcode, tables._buckets.Length); - - // We can get away w/out a lock here. - // The Volatile.Read ensures that we have a copy of the reference to tables._buckets[bucketNo]. - // This protects us from reading fields ('_hashcode', '_key', '_value' and '_next') of different instances. - Node n = Volatile.Read(ref tables._buckets[bucketNo]); - - while (n != null) - { - if (hashcode == n._hashcode && _comparer.Equals(n._key, key)) - { - value = n._value; - return true; - } - n = n._next; - } - - value = default; - return false; - } - - /// - /// Removes all keys and values from the . - /// - public void Clear() - { - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - - Tables newTables = new Tables(new Node[DefaultCapacity], _tables._locks, new int[_tables._countPerLock.Length]); - _tables = newTables; - _budget = Math.Max(1, newTables._buckets.Length / newTables._locks.Length); - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Copies the elements of the to an array of - /// type , starting at the - /// specified array index. - /// - /// The one-dimensional array of type - /// that is the destination of the elements copied from the . The array must have zero-based indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference - /// (Nothing in Visual Basic). - /// is less than - /// 0. - /// is equal to or greater than - /// the length of the . -or- The number of elements in the source - /// is greater than the available space from to the end of the destination - /// . - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - void ICollection>.CopyTo(KeyValuePair[] array, int index) - { - if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); - if (index < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ConcurrentDictionary_IndexIsNegative); - - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - - int count = 0; - - for (int i = 0; i < _tables._locks.Length && count >= 0; i++) - { - count += _tables._countPerLock[i]; - } - - if (array.Length - count < index || count < 0) //"count" itself or "count + index" can overflow - { - ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayNotLargeEnough); - } - - CopyToPairs(array, index); - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Copies the key and value pairs stored in the to a - /// new array. - /// - /// A new array containing a snapshot of key and value pairs copied from the . - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - public KeyValuePair[] ToArray() - { - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - int count = 0; - checked - { - for (int i = 0; i < _tables._locks.Length; i++) - { - count += _tables._countPerLock[i]; - } - } - - if (count == 0) - { - return Array.Empty>(); - } - - KeyValuePair[] array = new KeyValuePair[count]; - CopyToPairs(array, 0); - return array; - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Copy dictionary contents to an array - shared implementation between ToArray and CopyTo. - /// - /// Important: the caller must hold all locks in _locks before calling CopyToPairs. - /// - private void CopyToPairs(KeyValuePair[] array, int index) - { - Node[] buckets = _tables._buckets; - for (int i = 0; i < buckets.Length; i++) - { - for (Node current = buckets[i]; current != null; current = current._next) - { - array[index] = new KeyValuePair(current._key, current._value); - index++; //this should never flow, CopyToPairs is only called when there's no overflow risk - } - } - } - - /// - /// Copy dictionary contents to an array - shared implementation between ToArray and CopyTo. - /// - /// Important: the caller must hold all locks in _locks before calling CopyToEntries. - /// - private void CopyToEntries(DictionaryEntry[] array, int index) - { - Node[] buckets = _tables._buckets; - for (int i = 0; i < buckets.Length; i++) - { - for (Node current = buckets[i]; current != null; current = current._next) - { - array[index] = new DictionaryEntry(current._key, current._value); - index++; //this should never flow, CopyToEntries is only called when there's no overflow risk - } - } - } - - /// - /// Copy dictionary contents to an array - shared implementation between ToArray and CopyTo. - /// - /// Important: the caller must hold all locks in _locks before calling CopyToObjects. - /// - private void CopyToObjects(object[] array, int index) - { - Node[] buckets = _tables._buckets; - for (int i = 0; i < buckets.Length; i++) - { - for (Node current = buckets[i]; current != null; current = current._next) - { - array[index] = new KeyValuePair(current._key, current._value); - index++; //this should never flow, CopyToObjects is only called when there's no overflow risk - } - } - } - - /// Returns an enumerator that iterates through the . - /// An enumerator for the . - /// - /// The enumerator returned from the dictionary is safe to use concurrently with - /// reads and writes to the dictionary, however it does not represent a moment-in-time snapshot - /// of the dictionary. The contents exposed through the enumerator may contain modifications - /// made to the dictionary after was called. - /// - public IEnumerator> GetEnumerator() - { - Node[] buckets = _tables._buckets; - - for (int i = 0; i < buckets.Length; i++) - { - // The Volatile.Read ensures that we have a copy of the reference to buckets[i]. - // This protects us from reading fields ('_key', '_value' and '_next') of different instances. - Node current = Volatile.Read(ref buckets[i]); - - while (current != null) - { - yield return new KeyValuePair(current._key, current._value); - current = current._next; - } - } - } - - /// - /// Shared internal implementation for inserts and updates. - /// If key exists, we always return false; and if updateIfExists == true we force update with value; - /// If key doesn't exist, we always add value and return true; - /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] - private bool TryAddInternal(TKey key, int hashcode, TValue value, bool updateIfExists, bool acquireLock, out TValue resultingValue) - { - Debug.Assert(_comparer.GetHashCode(key) == hashcode); - - while (true) - { - int bucketNo, lockNo; - - Tables tables = _tables; - GetBucketAndLockNo(hashcode, out bucketNo, out lockNo, tables._buckets.Length, tables._locks.Length); - - bool resizeDesired = false; - bool lockTaken = false; - try - { - if (acquireLock) - Monitor.Enter(tables._locks[lockNo], ref lockTaken); - - // If the table just got resized, we may not be holding the right lock, and must retry. - // This should be a rare occurrence. - if (tables != _tables) - { - continue; - } - - // Try to find this key in the bucket - Node prev = null; - for (Node node = tables._buckets[bucketNo]; node != null; node = node._next) - { - Debug.Assert((prev == null && node == tables._buckets[bucketNo]) || prev._next == node); - if (hashcode == node._hashcode && _comparer.Equals(node._key, key)) - { - // The key was found in the dictionary. If updates are allowed, update the value for that key. - // We need to create a new node for the update, in order to support TValue types that cannot - // be written atomically, since lock-free reads may be happening concurrently. - if (updateIfExists) - { - if (s_isValueWriteAtomic) - { - node._value = value; - } - else - { - Node newNode = new Node(node._key, value, hashcode, node._next); - if (prev == null) - { - Volatile.Write(ref tables._buckets[bucketNo], newNode); - } - else - { - prev._next = newNode; - } - } - resultingValue = value; - } - else - { - resultingValue = node._value; - } - return false; - } - prev = node; - } - - // The key was not found in the bucket. Insert the key-value pair. - Volatile.Write(ref tables._buckets[bucketNo], new Node(key, value, hashcode, tables._buckets[bucketNo])); - checked - { - tables._countPerLock[lockNo]++; - } - - // - // If the number of elements guarded by this lock has exceeded the budget, resize the bucket table. - // It is also possible that GrowTable will increase the budget but won't resize the bucket table. - // That happens if the bucket table is found to be poorly utilized due to a bad hash function. - // - if (tables._countPerLock[lockNo] > _budget) - { - resizeDesired = true; - } - } - finally - { - if (lockTaken) - Monitor.Exit(tables._locks[lockNo]); - } - - // - // The fact that we got here means that we just performed an insertion. If necessary, we will grow the table. - // - // Concurrency notes: - // - Notice that we are not holding any locks at when calling GrowTable. This is necessary to prevent deadlocks. - // - As a result, it is possible that GrowTable will be called unnecessarily. But, GrowTable will obtain lock 0 - // and then verify that the table we passed to it as the argument is still the current table. - // - if (resizeDesired) - { - GrowTable(tables); - } - - resultingValue = value; - return true; - } - } - - /// - /// Gets or sets the value associated with the specified key. - /// - /// The key of the value to get or set. - /// The value associated with the specified key. If the specified key is not found, a get - /// operation throws a - /// , and a set operation creates a new - /// element with the specified key. - /// is a null reference - /// (Nothing in Visual Basic). - /// The property is retrieved and - /// - /// does not exist in the collection. - public TValue this[TKey key] - { - get - { - TValue value; - if (!TryGetValue(key, out value)) - { - ThrowKeyNotFoundException(key); - } - return value; - } - set - { - if (key == null) ThrowKeyNullException(); - TValue dummy; - TryAddInternal(key, _comparer.GetHashCode(key), value, true, true, out dummy); - } - } - - // These exception throwing sites have been extracted into their own methods as these are - // uncommonly needed and when inlined are observed to prevent the inlining of important - // methods like TryGetValue and ContainsKey. - - private static void ThrowKeyNotFoundException(object key) - { - throw new KeyNotFoundException(SR.Format(SR.Arg_KeyNotFoundWithKey, key.ToString())); - } - - private static void ThrowKeyNullException() - { - throw new ArgumentNullException("key"); - } - - /// - /// Gets the number of key/value pairs contained in the . - /// - /// The dictionary contains too many - /// elements. - /// The number of key/value pairs contained in the . - /// Count has snapshot semantics and represents the number of items in the - /// at the moment when Count was accessed. - public int Count - { - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - get - { - int acquiredLocks = 0; - try - { - // Acquire all locks - AcquireAllLocks(ref acquiredLocks); - - return GetCountInternal(); - } - finally - { - // Release locks that have been acquired earlier - ReleaseLocks(0, acquiredLocks); - } - } - } - - /// - /// Gets the number of key/value pairs contained in the . Should only be used after all locks - /// have been acquired. - /// - /// The dictionary contains too many - /// elements. - /// The number of key/value pairs contained in the . - /// Count has snapshot semantics and represents the number of items in the - /// at the moment when Count was accessed. - private int GetCountInternal() - { - int count = 0; - - // Compute the count, we allow overflow - for (int i = 0; i < _tables._countPerLock.Length; i++) - { - count += _tables._countPerLock[i]; - } - - return count; - } - - /// - /// Gets a value that indicates whether the is empty. - /// - /// true if the is empty; otherwise, - /// false. - public bool IsEmpty - { - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - get - { - int acquiredLocks = 0; - try - { - // Acquire all locks - AcquireAllLocks(ref acquiredLocks); - - for (int i = 0; i < _tables._countPerLock.Length; i++) - { - if (_tables._countPerLock[i] != 0) - { - return false; - } - } - } - finally - { - // Release locks that have been acquired earlier - ReleaseLocks(0, acquiredLocks); - } - - return true; - } - } - - #region IDictionary members - - /// - /// Adds the specified key and value to the . - /// - /// The object to use as the key of the element to add. - /// The object to use as the value of the element to add. - /// is a null reference - /// (Nothing in Visual Basic). - /// The dictionary contains too many - /// elements. - /// - /// An element with the same key already exists in the . - void IDictionary.Add(TKey key, TValue value) - { - if (!TryAdd(key, value)) - { - ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_KeyAlreadyExisted, ExceptionArgument.key); - } - } - - /// - /// Removes the element with the specified key from the . - /// - /// The key of the element to remove. - /// true if the element is successfully remove; otherwise false. This method also returns - /// false if - /// was not found in the original . - /// - /// is a null reference - /// (Nothing in Visual Basic). - bool IDictionary.Remove(TKey key) - { - TValue throwAwayValue; - return TryRemove(key, out throwAwayValue); - } - - /// - /// Gets a collection containing the keys in the . - /// - /// An containing the keys in the - /// . - public ICollection Keys - { - get { return GetKeys(); } - } - - /// - /// Gets an containing the keys of - /// the . - /// - /// An containing the keys of - /// the . - IEnumerable IReadOnlyDictionary.Keys - { - get { return GetKeys(); } - } - - /// - /// Gets a collection containing the values in the . - /// - /// An containing the values in - /// the - /// . - public ICollection Values - { - get { return GetValues(); } - } - - /// - /// Gets an containing the values - /// in the . - /// - /// An containing the - /// values in the . - IEnumerable IReadOnlyDictionary.Values - { - get { return GetValues(); } - } - #endregion - - #region ICollection> Members - - /// - /// Adds the specified value to the - /// with the specified key. - /// - /// The - /// structure representing the key and value to add to the . - /// The of is null. - /// The - /// contains too many elements. - /// An element with the same key already exists in the - /// - void ICollection>.Add(KeyValuePair keyValuePair) - { - ((IDictionary)this).Add(keyValuePair.Key, keyValuePair.Value); - } - - /// - /// Determines whether the - /// contains a specific key and value. - /// - /// The - /// structure to locate in the . - /// true if the is found in the ; otherwise, false. - bool ICollection>.Contains(KeyValuePair keyValuePair) - { - TValue value; - if (!TryGetValue(keyValuePair.Key, out value)) - { - return false; - } - return EqualityComparer.Default.Equals(value, keyValuePair.Value); - } - - /// - /// Gets a value indicating whether the dictionary is read-only. - /// - /// true if the is - /// read-only; otherwise, false. For , this property always returns - /// false. - bool ICollection>.IsReadOnly - { - get { return false; } - } - - /// - /// Removes a key and value from the dictionary. - /// - /// The - /// structure representing the key and value to remove from the . - /// true if the key and value represented by is successfully - /// found and removed; otherwise, false. - /// The Key property of is a null reference (Nothing in Visual Basic). - bool ICollection>.Remove(KeyValuePair keyValuePair) - { - if (keyValuePair.Key == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.keyValuePair, ExceptionResource.ConcurrentDictionary_ItemKeyIsNull); - - TValue throwAwayValue; - return TryRemoveInternal(keyValuePair.Key, out throwAwayValue, true, keyValuePair.Value); - } - - #endregion - - #region IEnumerable Members - - /// Returns an enumerator that iterates through the . - /// An enumerator for the . - /// - /// The enumerator returned from the dictionary is safe to use concurrently with - /// reads and writes to the dictionary, however it does not represent a moment-in-time snapshot - /// of the dictionary. The contents exposed through the enumerator may contain modifications - /// made to the dictionary after was called. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return ((ConcurrentDictionary)this).GetEnumerator(); - } - - #endregion - - #region IDictionary Members - - /// - /// Adds the specified key and value to the dictionary. - /// - /// The object to use as the key. - /// The object to use as the value. - /// is a null reference - /// (Nothing in Visual Basic). - /// The dictionary contains too many - /// elements. - /// - /// is of a type that is not assignable to the key type of the . -or- - /// is of a type that is not assignable to , - /// the type of values in the . - /// -or- A value with the same key already exists in the . - /// - void IDictionary.Add(object key, object value) - { - if (key == null) ThrowKeyNullException(); - if (!(key is TKey)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfKeyIncorrect, ExceptionArgument.key); - - TValue typedValue; - try - { - typedValue = (TValue)value; - } - catch (InvalidCastException) - { - ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfValueIncorrect, ExceptionArgument.value); - return; - } - - ((IDictionary)this).Add((TKey)key, typedValue); - } - - /// - /// Gets whether the contains an - /// element with the specified key. - /// - /// The key to locate in the . - /// true if the contains - /// an element with the specified key; otherwise, false. - /// is a null reference - /// (Nothing in Visual Basic). - bool IDictionary.Contains(object key) - { - if (key == null) ThrowKeyNullException(); - - return (key is TKey) && this.ContainsKey((TKey)key); - } - - /// Provides an for the - /// . - /// An for the . - IDictionaryEnumerator IDictionary.GetEnumerator() - { - return new DictionaryEnumerator(this); - } - - /// - /// Gets a value indicating whether the has a fixed size. - /// - /// true if the has a - /// fixed size; otherwise, false. For , this property always - /// returns false. - bool IDictionary.IsFixedSize - { - get { return false; } - } - - /// - /// Gets a value indicating whether the is read-only. - /// - /// true if the is - /// read-only; otherwise, false. For , this property always - /// returns false. - bool IDictionary.IsReadOnly - { - get { return false; } - } - - /// - /// Gets an containing the keys of the . - /// - /// An containing the keys of the . - ICollection IDictionary.Keys - { - get { return GetKeys(); } - } - - /// - /// Removes the element with the specified key from the . - /// - /// The key of the element to remove. - /// is a null reference - /// (Nothing in Visual Basic). - void IDictionary.Remove(object key) - { - if (key == null) ThrowKeyNullException(); - - TValue throwAwayValue; - if (key is TKey) - { - TryRemove((TKey)key, out throwAwayValue); - } - } - - /// - /// Gets an containing the values in the . - /// - /// An containing the values in the . - ICollection IDictionary.Values - { - get { return GetValues(); } - } - - /// - /// Gets or sets the value associated with the specified key. - /// - /// The key of the value to get or set. - /// The value associated with the specified key, or a null reference (Nothing in Visual Basic) - /// if is not in the dictionary or is of a type that is - /// not assignable to the key type of the . - /// is a null reference - /// (Nothing in Visual Basic). - /// - /// A value is being assigned, and is of a type that is not assignable to the - /// key type of the . -or- A value is being - /// assigned, and is of a type that is not assignable to the value type - /// of the - /// - object IDictionary.this[object key] - { - get - { - if (key == null) ThrowKeyNullException(); - - TValue value; - if (key is TKey && TryGetValue((TKey)key, out value)) - { - return value; - } - - return null; - } - set - { - if (key == null) ThrowKeyNullException(); - - if (!(key is TKey)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfKeyIncorrect, ExceptionArgument.key); - if (!(value is TValue)) ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_TypeOfValueIncorrect, ExceptionArgument.value); - - ((ConcurrentDictionary)this)[(TKey)key] = (TValue)value; - } - } - - #endregion - - #region ICollection Members - - /// - /// Copies the elements of the to an array, starting - /// at the specified array index. - /// - /// The one-dimensional array that is the destination of the elements copied from - /// the . The array must have zero-based - /// indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference - /// (Nothing in Visual Basic). - /// is less than - /// 0. - /// is equal to or greater than - /// the length of the . -or- The number of elements in the source - /// is greater than the available space from to the end of the destination - /// . - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - void ICollection.CopyTo(Array array, int index) - { - if (array == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); - if (index < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index, ExceptionResource.ConcurrentDictionary_IndexIsNegative); - - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - Tables tables = _tables; - - int count = 0; - - for (int i = 0; i < tables._locks.Length && count >= 0; i++) - { - count += tables._countPerLock[i]; - } - - if (array.Length - count < index || count < 0) //"count" itself or "count + index" can overflow - { - ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayNotLargeEnough); - } - - // To be consistent with the behavior of ICollection.CopyTo() in Dictionary, - // we recognize three types of target arrays: - // - an array of KeyValuePair structs - // - an array of DictionaryEntry structs - // - an array of objects - - KeyValuePair[] pairs = array as KeyValuePair[]; - if (pairs != null) - { - CopyToPairs(pairs, index); - return; - } - - DictionaryEntry[] entries = array as DictionaryEntry[]; - if (entries != null) - { - CopyToEntries(entries, index); - return; - } - - object[] objects = array as object[]; - if (objects != null) - { - CopyToObjects(objects, index); - return; - } - - ThrowHelper.ThrowArgumentException(ExceptionResource.ConcurrentDictionary_ArrayIncorrectType, ExceptionArgument.array); - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Gets a value indicating whether access to the is - /// synchronized with the SyncRoot. - /// - /// true if access to the is synchronized - /// (thread safe); otherwise, false. For , this property always - /// returns false. - bool ICollection.IsSynchronized - { - get { return false; } - } - - /// - /// Gets an object that can be used to synchronize access to the . This property is not supported. - /// - /// The SyncRoot property is not supported. - object ICollection.SyncRoot - { - get - { - ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); - return default; - } - } - - #endregion - - /// - /// Replaces the bucket table with a larger one. To prevent multiple threads from resizing the - /// table as a result of races, the Tables instance that holds the table of buckets deemed too - /// small is passed in as an argument to GrowTable(). GrowTable() obtains a lock, and then checks - /// the Tables instance has been replaced in the meantime or not. - /// - private void GrowTable(Tables tables) - { - const int MaxArrayLength = 0X7FEFFFFF; - int locksAcquired = 0; - try - { - // The thread that first obtains _locks[0] will be the one doing the resize operation - AcquireLocks(0, 1, ref locksAcquired); - - // Make sure nobody resized the table while we were waiting for lock 0: - if (tables != _tables) - { - // We assume that since the table reference is different, it was already resized (or the budget - // was adjusted). If we ever decide to do table shrinking, or replace the table for other reasons, - // we will have to revisit this logic. - return; - } - - // Compute the (approx.) total size. Use an Int64 accumulation variable to avoid an overflow. - long approxCount = 0; - for (int i = 0; i < tables._countPerLock.Length; i++) - { - approxCount += tables._countPerLock[i]; - } - - // - // If the bucket array is too empty, double the budget instead of resizing the table - // - if (approxCount < tables._buckets.Length / 4) - { - _budget = 2 * _budget; - if (_budget < 0) - { - _budget = int.MaxValue; - } - return; - } - - - // Compute the new table size. We find the smallest integer larger than twice the previous table size, and not divisible by - // 2,3,5 or 7. We can consider a different table-sizing policy in the future. - int newLength = 0; - bool maximizeTableSize = false; - try - { - checked - { - // Double the size of the buckets table and add one, so that we have an odd integer. - newLength = tables._buckets.Length * 2 + 1; - - // Now, we only need to check odd integers, and find the first that is not divisible - // by 3, 5 or 7. - while (newLength % 3 == 0 || newLength % 5 == 0 || newLength % 7 == 0) - { - newLength += 2; - } - - Debug.Assert(newLength % 2 != 0); - - if (newLength > MaxArrayLength) - { - maximizeTableSize = true; - } - } - } - catch (OverflowException) - { - maximizeTableSize = true; - } - - if (maximizeTableSize) - { - newLength = MaxArrayLength; - - // We want to make sure that GrowTable will not be called again, since table is at the maximum size. - // To achieve that, we set the budget to int.MaxValue. - // - // (There is one special case that would allow GrowTable() to be called in the future: - // calling Clear() on the ConcurrentDictionary will shrink the table and lower the budget.) - _budget = int.MaxValue; - } - - // Now acquire all other locks for the table - AcquireLocks(1, tables._locks.Length, ref locksAcquired); - - object[] newLocks = tables._locks; - - // Add more locks - if (_growLockArray && tables._locks.Length < MaxLockNumber) - { - newLocks = new object[tables._locks.Length * 2]; - Array.Copy(tables._locks, 0, newLocks, 0, tables._locks.Length); - for (int i = tables._locks.Length; i < newLocks.Length; i++) - { - newLocks[i] = new object(); - } - } - - Node[] newBuckets = new Node[newLength]; - int[] newCountPerLock = new int[newLocks.Length]; - - // Copy all data into a new table, creating new nodes for all elements - for (int i = 0; i < tables._buckets.Length; i++) - { - Node current = tables._buckets[i]; - while (current != null) - { - Node next = current._next; - int newBucketNo, newLockNo; - GetBucketAndLockNo(current._hashcode, out newBucketNo, out newLockNo, newBuckets.Length, newLocks.Length); - - newBuckets[newBucketNo] = new Node(current._key, current._value, current._hashcode, newBuckets[newBucketNo]); - - checked - { - newCountPerLock[newLockNo]++; - } - - current = next; - } - } - - // Adjust the budget - _budget = Math.Max(1, newBuckets.Length / newLocks.Length); - - // Replace tables with the new versions - _tables = new Tables(newBuckets, newLocks, newCountPerLock); - } - finally - { - // Release all locks that we took earlier - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Computes the bucket for a particular key. - /// - private static int GetBucket(int hashcode, int bucketCount) - { - int bucketNo = (hashcode & 0x7fffffff) % bucketCount; - Debug.Assert(bucketNo >= 0 && bucketNo < bucketCount); - return bucketNo; - } - - /// - /// Computes the bucket and lock number for a particular key. - /// - private static void GetBucketAndLockNo(int hashcode, out int bucketNo, out int lockNo, int bucketCount, int lockCount) - { - bucketNo = (hashcode & 0x7fffffff) % bucketCount; - lockNo = bucketNo % lockCount; - - Debug.Assert(bucketNo >= 0 && bucketNo < bucketCount); - Debug.Assert(lockNo >= 0 && lockNo < lockCount); - } - - /// - /// The number of concurrent writes for which to optimize by default. - /// - private static int DefaultConcurrencyLevel - { - get { return PlatformHelper.ProcessorCount; } - } - - /// - /// Acquires all locks for this hash table, and increments locksAcquired by the number - /// of locks that were successfully acquired. The locks are acquired in an increasing - /// order. - /// - private void AcquireAllLocks(ref int locksAcquired) - { - // First, acquire lock 0 - AcquireLocks(0, 1, ref locksAcquired); - - // Now that we have lock 0, the _locks array will not change (i.e., grow), - // and so we can safely read _locks.Length. - AcquireLocks(1, _tables._locks.Length, ref locksAcquired); - Debug.Assert(locksAcquired == _tables._locks.Length); - } - - /// - /// Acquires a contiguous range of locks for this hash table, and increments locksAcquired - /// by the number of locks that were successfully acquired. The locks are acquired in an - /// increasing order. - /// - private void AcquireLocks(int fromInclusive, int toExclusive, ref int locksAcquired) - { - Debug.Assert(fromInclusive <= toExclusive); - object[] locks = _tables._locks; - - for (int i = fromInclusive; i < toExclusive; i++) - { - bool lockTaken = false; - try - { - Monitor.Enter(locks[i], ref lockTaken); - } - finally - { - if (lockTaken) - { - locksAcquired++; - } - } - } - } - - /// - /// Releases a contiguous range of locks. - /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread safety")] - private void ReleaseLocks(int fromInclusive, int toExclusive) - { - Debug.Assert(fromInclusive <= toExclusive); - - for (int i = fromInclusive; i < toExclusive; i++) - { - Monitor.Exit(_tables._locks[i]); - } - } - - /// - /// Gets a collection containing the keys in the dictionary. - /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - private ReadOnlyCollection GetKeys() - { - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - - int count = GetCountInternal(); - if (count < 0) ThrowHelper.ThrowOutOfMemoryException(); - - List keys = new List(count); - for (int i = 0; i < _tables._buckets.Length; i++) - { - Node current = _tables._buckets[i]; - while (current != null) - { - keys.Add(current._key); - current = current._next; - } - } - - return new ReadOnlyCollection(keys); - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// Gets a collection containing the values in the dictionary. - /// - [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "ConcurrencyCop just doesn't know about these locks")] - private ReadOnlyCollection GetValues() - { - int locksAcquired = 0; - try - { - AcquireAllLocks(ref locksAcquired); - - int count = GetCountInternal(); - if (count < 0) ThrowHelper.ThrowOutOfMemoryException(); - - List values = new List(count); - for (int i = 0; i < _tables._buckets.Length; i++) - { - Node current = _tables._buckets[i]; - while (current != null) - { - values.Add(current._value); - current = current._next; - } - } - - return new ReadOnlyCollection(values); - } - finally - { - ReleaseLocks(0, locksAcquired); - } - } - - /// - /// A node in a singly-linked list representing a particular hash table bucket. - /// - private sealed class Node - { - internal readonly TKey _key; - internal TValue _value; - internal volatile Node _next; - internal readonly int _hashcode; - - internal Node(TKey key, TValue value, int hashcode, Node next) - { - _key = key; - _value = value; - _next = next; - _hashcode = hashcode; - } - } - - /// - /// A private class to represent enumeration over the dictionary that implements the - /// IDictionaryEnumerator interface. - /// - private sealed class DictionaryEnumerator : IDictionaryEnumerator - { - IEnumerator> _enumerator; // Enumerator over the dictionary. - - internal DictionaryEnumerator(ConcurrentDictionary dictionary) - { - _enumerator = dictionary.GetEnumerator(); - } - - public DictionaryEntry Entry - { - get { return new DictionaryEntry(_enumerator.Current.Key, _enumerator.Current.Value); } - } - - public object Key - { - get { return _enumerator.Current.Key; } - } - - public object Value - { - get { return _enumerator.Current.Value; } - } - - public object Current - { - get { return Entry; } - } - - public bool MoveNext() - { - return _enumerator.MoveNext(); - } - - public void Reset() - { - _enumerator.Reset(); - } - } - } -} diff --git a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs b/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs deleted file mode 100644 index 019bc4e5459f..000000000000 --- a/src/System.Private.CoreLib/src/System/Collections/Concurrent/ConcurrentStack.cs +++ /dev/null @@ -1,490 +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. - -// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+ -// -// ConcurrentStack.cs -// -// A lock-free, concurrent stack primitive, and its associated debugger view type. -// -// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading; - -namespace System.Collections.Concurrent -{ - // A stack that uses CAS operations internally to maintain thread-safety in a lock-free - // manner. Attempting to push or pop concurrently from the stack will not trigger waiting, - // although some optimistic concurrency and retry is used, possibly leading to lack of - // fairness and/or livelock. The stack uses spinning and backoff to add some randomization, - // in hopes of statistically decreasing the possibility of livelock. - // - // Note that we currently allocate a new node on every push. This avoids having to worry - // about potential ABA issues, since the CLR GC ensures that a memory address cannot be - // reused before all references to it have died. - - /// - /// Represents a thread-safe last-in, first-out collection of objects. - /// - /// Specifies the type of elements in the stack. - /// - /// All public and protected members of are thread-safe and may be used - /// concurrently from multiple threads. - /// - [DebuggerDisplay("Count = {Count}")] - [DebuggerTypeProxy(typeof(IProducerConsumerCollectionDebugView<>))] - internal class ConcurrentStack : IProducerConsumerCollection, IReadOnlyCollection - { - /// - /// A simple (internal) node type used to store elements of concurrent stacks and queues. - /// - private class Node - { - internal readonly T _value; // Value of the node. - internal Node _next; // Next pointer. - - /// - /// Constructs a new node with the specified value and no next node. - /// - /// The value of the node. - internal Node(T value) - { - _value = value; - _next = null; - } - } - - private volatile Node _head; // The stack is a singly linked list, and only remembers the head. - private const int BACKOFF_MAX_YIELDS = 8; // Arbitrary number to cap backoff. - - /// - /// Initializes a new instance of the - /// class. - /// - public ConcurrentStack() - { - } - - /// - /// Gets the number of elements contained in the . - /// - /// The number of elements contained in the . - /// - /// For determining whether the collection contains any items, use of the - /// property is recommended rather than retrieving the number of items from the - /// property and comparing it to 0. - /// - public int Count - { - // Counts the number of entries in the stack. This is an O(n) operation. The answer may be out - // of date before returning, but guarantees to return a count that was once valid. Conceptually, - // the implementation snaps a copy of the list and then counts the entries, though physically - // this is not what actually happens. - get - { - int count = 0; - - // Just whip through the list and tally up the number of nodes. We rely on the fact that - // node next pointers are immutable after being enqueued for the first time, even as - // they are being dequeued. If we ever changed this (e.g. to pool nodes somehow), - // we'd need to revisit this implementation. - - for (Node curr = _head; curr != null; curr = curr._next) - { - count++; //we don't handle overflow, to be consistent with existing generic collection types in CLR - } - - return count; - } - } - - - /// - /// Gets a value indicating whether access to the is - /// synchronized with the SyncRoot. - /// - /// true if access to the is synchronized - /// with the SyncRoot; otherwise, false. For , this property always - /// returns false. - bool ICollection.IsSynchronized - { - // Gets a value indicating whether access to this collection is synchronized. Always returns - // false. The reason is subtle. While access is in face thread safe, it's not the case that - // locking on the SyncRoot would have prevented concurrent pushes and pops, as this property - // would typically indicate; that's because we internally use CAS operations vs. true locks. - get { return false; } - } - - /// - /// Gets an object that can be used to synchronize access to the . This property is not supported. - /// - /// The SyncRoot property is not supported - object ICollection.SyncRoot - { - get - { - ThrowHelper.ThrowNotSupportedException(ExceptionResource.ConcurrentCollection_SyncRoot_NotSupported); - return default; - } - } - - /// - /// Copies the elements of the to an , starting at a particular - /// index. - /// - /// The one-dimensional that is the destination of - /// the elements copied from the - /// . The must - /// have zero-based indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference (Nothing in - /// Visual Basic). - /// is less than - /// zero. - /// - /// is multidimensional. -or- - /// does not have zero-based indexing. -or- - /// is equal to or greater than the length of the - /// -or- The number of elements in the source is - /// greater than the available space from to the end of the destination - /// . -or- The type of the source cannot be cast automatically to the type of the - /// destination . - /// - void ICollection.CopyTo(Array array, int index) - { - // Validate arguments. - if (array == null) - { - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); - } - - // We must be careful not to corrupt the array, so we will first accumulate an - // internal list of elements that we will then copy to the array. This requires - // some extra allocation, but is necessary since we don't know up front whether - // the array is sufficiently large to hold the stack's contents. - ((ICollection)ToList()).CopyTo(array, index); - } - - /// - /// Copies the elements to an existing one-dimensional , starting at the specified array index. - /// - /// The one-dimensional that is the destination of - /// the elements copied from the - /// . The must have zero-based - /// indexing. - /// The zero-based index in at which copying - /// begins. - /// is a null reference (Nothing in - /// Visual Basic). - /// is less than - /// zero. - /// is equal to or greater than the - /// length of the - /// -or- The number of elements in the source is greater than the - /// available space from to the end of the destination . - /// - public void CopyTo(T[] array, int index) - { - if (array == null) - { - ThrowHelper.ThrowArgumentNullException(ExceptionArgument.array); - } - - // We must be careful not to corrupt the array, so we will first accumulate an - // internal list of elements that we will then copy to the array. This requires - // some extra allocation, but is necessary since we don't know up front whether - // the array is sufficiently large to hold the stack's contents. - ToList().CopyTo(array, index); - } - -#pragma warning disable 0420 // No warning for Interlocked.xxx if compiled with new managed compiler (Roslyn) - /// - /// Inserts an object at the top of the . - /// - /// The object to push onto the . The value can be - /// a null reference (Nothing in Visual Basic) for reference types. - /// - public void Push(T item) - { - // Pushes a node onto the front of the stack thread-safely. Internally, this simply - // swaps the current head pointer using a (thread safe) CAS operation to accomplish - // lock freedom. If the CAS fails, we add some back off to statistically decrease - // contention at the head, and then go back around and retry. - - Node newNode = new Node(item); - newNode._next = _head; - if (Interlocked.CompareExchange(ref _head, newNode, newNode._next) == newNode._next) - { - return; - } - - // If we failed, go to the slow path and loop around until we succeed. - PushCore(newNode, newNode); - } - - - /// - /// Push one or many nodes into the stack, if head and tails are equal then push one node to the stack other wise push the list between head - /// and tail to the stack - /// - /// The head pointer to the new list - /// The tail pointer to the new list - private void PushCore(Node head, Node tail) - { - SpinWait spin = new SpinWait(); - - // Keep trying to CAS the existing head with the new node until we succeed. - do - { - spin.SpinOnce(); - // Reread the head and link our new node. - tail._next = _head; - } - while (Interlocked.CompareExchange( - ref _head, head, tail._next) != tail._next); - } - - /// - /// Attempts to pop and return the object at the top of the . - /// - /// - /// When this method returns, if the operation was successful, contains the - /// object removed. If no object was available to be removed, the value is unspecified. - /// - /// true if an element was removed and returned from the top of the - /// successfully; otherwise, false. - public bool TryPop(out T result) - { - Node head = _head; - //stack is empty - if (head == null) - { - result = default; - return false; - } - if (Interlocked.CompareExchange(ref _head, head._next, head) == head) - { - result = head._value; - return true; - } - - // Fall through to the slow path. - return TryPopCore(out result); - } - - /// - /// Local helper function to Pop an item from the stack, slow path - /// - /// The popped item - /// True if succeeded, false otherwise - private bool TryPopCore(out T result) - { - Node poppedNode; - - if (TryPopCore(1, out poppedNode) == 1) - { - result = poppedNode._value; - return true; - } - - result = default; - return false; - } - - /// - /// Slow path helper for TryPop. This method assumes an initial attempt to pop an element - /// has already occurred and failed, so it begins spinning right away. - /// - /// The number of items to pop. - /// - /// When this method returns, if the pop succeeded, contains the removed object. If no object was - /// available to be removed, the value is unspecified. This parameter is passed uninitialized. - /// - /// The number of objects successfully popped from the top of - /// the . - private int TryPopCore(int count, out Node poppedHead) - { - SpinWait spin = new SpinWait(); - - // Try to CAS the head with its current next. We stop when we succeed or - // when we notice that the stack is empty, whichever comes first. - Node head; - Node next; - int backoff = 1; - Random r = null; - while (true) - { - head = _head; - // Is the stack empty? - if (head == null) - { - poppedHead = null; - return 0; - } - next = head; - int nodesCount = 1; - for (; nodesCount < count && next._next != null; nodesCount++) - { - next = next._next; - } - - // Try to swap the new head. If we succeed, break out of the loop. - if (Interlocked.CompareExchange(ref _head, next._next, head) == head) - { - // Return the popped Node. - poppedHead = head; - return nodesCount; - } - - // We failed to CAS the new head. Spin briefly and retry. - for (int i = 0; i < backoff; i++) - { - spin.SpinOnce(); - } - - if (spin.NextSpinWillYield) - { - if (r == null) - { - r = new Random(); - } - backoff = r.Next(1, BACKOFF_MAX_YIELDS); - } - else - { - backoff *= 2; - } - } - } -#pragma warning restore 0420 - - /// - /// Copies the items stored in the to a new array. - /// - /// A new array containing a snapshot of elements copied from the . - public T[] ToArray() - { - Node curr = _head; - return curr == null ? - Array.Empty() : - ToList(curr).ToArray(); - } - - /// - /// Returns an array containing a snapshot of the list's contents, using - /// the target list node as the head of a region in the list. - /// - /// A list of the stack's contents. - private List ToList() - { - return ToList(_head); - } - - /// - /// Returns an array containing a snapshot of the list's contents starting at the specified node. - /// - /// A list of the stack's contents starting at the specified node. - private List ToList(Node curr) - { - List list = new List(); - - while (curr != null) - { - list.Add(curr._value); - curr = curr._next; - } - - return list; - } - - /// - /// Attempts to add an object to the . - /// - /// The object to add to the . The value can be a null - /// reference (Nothing in Visual Basic) for reference types. - /// - /// true if the object was added successfully; otherwise, false. - /// For , this operation will always insert the object onto the - /// top of the - /// and return true. - bool IProducerConsumerCollection.TryAdd(T item) - { - Push(item); - return true; - } - - /// - /// Attempts to remove and return an object from the . - /// - /// - /// When this method returns, if the operation was successful, contains the - /// object removed. If no object was available to be removed, the value is unspecified. - /// - /// true if an element was removed and returned successfully; otherwise, false. - /// For , this operation will attempt to pop the object at - /// the top of the . - /// - bool IProducerConsumerCollection.TryTake(out T item) => TryPop(out item); - - /// - /// Returns an enumerator that iterates through the . - /// - /// An enumerator for the . - /// - /// The enumeration represents a moment-in-time snapshot of the contents - /// of the stack. It does not reflect any updates to the collection after - /// was called. The enumerator is safe to use - /// concurrently with reads from and writes to the stack. - /// - public IEnumerator GetEnumerator() - { - // Returns an enumerator for the stack. This effectively takes a snapshot - // of the stack's contents at the time of the call, i.e. subsequent modifications - // (pushes or pops) will not be reflected in the enumerator's contents. - - //If we put yield-return here, the iterator will be lazily evaluated. As a result a snapshot of - //the stack is not taken when GetEnumerator is initialized but when MoveNext() is first called. - //This is inconsistent with existing generic collections. In order to prevent it, we capture the - //value of _head in a buffer and call out to a helper method - return GetEnumerator(_head); - } - - private IEnumerator GetEnumerator(Node head) - { - Node current = head; - while (current != null) - { - yield return current._value; - current = current._next; - } - } - - /// - /// Returns an enumerator that iterates through a collection. - /// - /// An that can be used to iterate through - /// the collection. - /// - /// The enumeration represents a moment-in-time snapshot of the contents of the stack. It does not - /// reflect any updates to the collection after - /// was called. The enumerator is safe to use concurrently with reads - /// from and writes to the stack. - /// - IEnumerator IEnumerable.GetEnumerator() - { - return ((IEnumerable)this).GetEnumerator(); - } - } -} diff --git a/src/System.Private.CoreLib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs b/src/System.Private.CoreLib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs index a6a04b4964cd..72e40c7ce16a 100644 --- a/src/System.Private.CoreLib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs +++ b/src/System.Private.CoreLib/src/System/Collections/EmptyReadOnlyDictionaryInternal.cs @@ -60,7 +60,7 @@ public int Count } } - public Object SyncRoot + public object SyncRoot { get { @@ -78,7 +78,7 @@ public bool IsSynchronized // IDictionary members - public Object this[Object key] + public object this[object key] { get { @@ -109,7 +109,7 @@ public ICollection Keys { get { - return Array.Empty(); + return Array.Empty(); } } @@ -117,16 +117,16 @@ public ICollection Values { get { - return Array.Empty(); + return Array.Empty(); } } - public bool Contains(Object key) + public bool Contains(object key) { return false; } - public void Add(Object key, Object value) + public void Add(object key, object value) { if (key == null) { @@ -168,7 +168,7 @@ public IDictionaryEnumerator GetEnumerator() return new NodeEnumerator(); } - public void Remove(Object key) + public void Remove(object key) { throw new InvalidOperationException(SR.InvalidOperation_ReadOnly); } @@ -186,7 +186,7 @@ public bool MoveNext() return false; } - public Object Current + public object Current { get { @@ -200,7 +200,7 @@ public void Reset() // IDictionaryEnumerator members - public Object Key + public object Key { get { @@ -208,7 +208,7 @@ public Object Key } } - public Object Value + public object Value { get { diff --git a/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs index 25d03355e4a9..29446b29c58b 100644 --- a/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs +++ b/src/System.Private.CoreLib/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs @@ -23,7 +23,7 @@ namespace System.Collections.ObjectModel internal class ReadOnlyDictionary : IDictionary, IDictionary, IReadOnlyDictionary { private readonly IDictionary m_dictionary; - private Object m_syncRoot; + private object m_syncRoot; private KeyCollection m_keys; private ValueCollection m_values; @@ -350,7 +350,7 @@ object ICollection.SyncRoot } else { - System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new object(), null); } } return m_syncRoot; @@ -426,7 +426,7 @@ IEnumerable IReadOnlyDictionary.Values public sealed class KeyCollection : ICollection, ICollection, IReadOnlyCollection { private readonly ICollection m_collection; - private Object m_syncRoot; + private object m_syncRoot; internal KeyCollection(ICollection collection) { @@ -520,7 +520,7 @@ object ICollection.SyncRoot } else { - System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new object(), null); } } return m_syncRoot; @@ -535,7 +535,7 @@ object ICollection.SyncRoot public sealed class ValueCollection : ICollection, ICollection, IReadOnlyCollection { private readonly ICollection m_collection; - private Object m_syncRoot; + private object m_syncRoot; internal ValueCollection(ICollection collection) { @@ -629,7 +629,7 @@ object ICollection.SyncRoot } else { - System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new Object(), null); + System.Threading.Interlocked.CompareExchange(ref m_syncRoot, new object(), null); } } return m_syncRoot; diff --git a/src/System.Private.CoreLib/src/System/Currency.cs b/src/System.Private.CoreLib/src/System/Currency.cs index 4b735bbfe340..c9e8dc030eb8 100644 --- a/src/System.Private.CoreLib/src/System/Currency.cs +++ b/src/System.Private.CoreLib/src/System/Currency.cs @@ -2,12 +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; -using System.Globalization; -using System.Runtime.CompilerServices; -using System.Runtime.Versioning; - namespace System { internal struct Currency @@ -16,48 +10,19 @@ internal struct Currency // Constructs a Currency from a Decimal value. // - public Currency(Decimal value) - { - m_value = Decimal.ToCurrency(value).m_value; - } - - // Constructs a Currency from a long value without scaling. The - // ignored parameter exists only to distinguish this constructor - // from the constructor that takes a long. Used only in the System - // package, especially in Variant. - internal Currency(long value, int ignored) - { - m_value = value; - } - - // Creates a Currency from an OLE Automation Currency. This method - // applies no scaling to the Currency value, essentially doing a bitwise - // copy. - // - public static Currency FromOACurrency(long cy) - { - return new Currency(cy, 0); - } - - //Creates an OLE Automation Currency from a Currency instance. This - // method applies no scaling to the Currency value, essentially doing - // a bitwise copy. - // - public long ToOACurrency() + public Currency(decimal value) { - return m_value; + m_value = decimal.ToOACurrency(value); } + } - // Converts a Currency to a Decimal. + partial struct Decimal + { + // Constructs a Decimal from a Currency value. // - public static Decimal ToDecimal(Currency c) + internal Decimal(Currency value) { - Decimal result = new Decimal(); - FCallToDecimal(ref result, c); - return result; + this = FromOACurrency(value.m_value); } - - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void FCallToDecimal(ref Decimal result, Currency c); } } diff --git a/src/System.Private.CoreLib/src/System/DateTime.CoreCLR.cs b/src/System.Private.CoreLib/src/System/DateTime.CoreCLR.cs index 84cda1d81311..c9a0f23c8305 100644 --- a/src/System.Private.CoreLib/src/System/DateTime.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/DateTime.CoreCLR.cs @@ -16,7 +16,7 @@ public static DateTime UtcNow long ticks = 0; ticks = GetSystemTimeAsFileTime(); - return new DateTime(((UInt64)(ticks + FileTimeOffset)) | KindUtc); + return new DateTime(((ulong)(ticks + FileTimeOffset)) | KindUtc); } } diff --git a/src/System.Private.CoreLib/src/System/Decimal.DecCalc.cs b/src/System.Private.CoreLib/src/System/Decimal.DecCalc.cs deleted file mode 100644 index d18a52e348e1..000000000000 --- a/src/System.Private.CoreLib/src/System/Decimal.DecCalc.cs +++ /dev/null @@ -1,96 +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. - -using System.Runtime.CompilerServices; -using Internal.Runtime.CompilerServices; - -namespace System -{ - public partial struct Decimal - { - internal static uint DecDivMod1E9(ref decimal value) - { - return D32DivMod1E9(D32DivMod1E9(D32DivMod1E9(0, - ref Unsafe.As(ref value.hi)), - ref Unsafe.As(ref value.mid)), - ref Unsafe.As(ref value.lo)); - - uint D32DivMod1E9(uint hi32, ref uint lo32) - { - ulong n = (ulong)hi32 << 32 | lo32; - lo32 = (uint)(n / 1000000000); - return (uint)(n % 1000000000); - } - } - - private static int GetHashCode(ref decimal d) - { - if ((d.Low | d.Mid | d.High) == 0) - return 0; - - uint flags = (uint)d.flags; - if ((flags & ScaleMask) == 0 || (d.Low & 1) != 0) - return (int)(flags ^ d.High ^ d.Mid ^ d.Low); - - int scale = (byte)(flags >> ScaleShift); - uint low = d.Low; - ulong high64 = ((ulong)d.High << 32) | d.Mid; - - Unscale(ref low, ref high64, ref scale); - - flags = ((flags) & ~(uint)ScaleMask) | (uint)scale << ScaleShift; - return (int)(flags ^ (uint)(high64 >> 32) ^ (uint)high64 ^ low); - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool Div96ByConst(ref ulong high64, ref uint low, uint pow) - { - ulong div64; -#if !BIT64 - if (high64 <= uint.MaxValue) - { - div64 = ((high64 << 32) | low) / pow; - if (low == (uint)div64 * pow) - { - low = (uint)div64; - high64 = div64 >> 32; - return true; - } - return false; - } -#endif - div64 = high64 / pow; - uint div = (uint)((((high64 - (uint)div64 * pow) << 32) | low) / pow); - if (low == div * pow) - { - high64 = div64; - low = div; - return true; - } - return false; - } - - // Normalize (unscale) the number by trying to divide out 10^8, 10^4, 10^2, and 10^1. - // If a division by one of these powers returns a zero remainder, then we keep the quotient. - // - // Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 we can extract. - // We use this as a quick test on whether to try a given power. - // - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static void Unscale(ref uint low, ref ulong high64, ref int scale) - { - while ((byte)low == 0 && scale >= 8 && Div96ByConst(ref high64, ref low, 100000000)) - scale -= 8; - - if ((low & 0xF) == 0 && scale >= 4 && Div96ByConst(ref high64, ref low, 10000)) - scale -= 4; - - if ((low & 3) == 0 && scale >= 2 && Div96ByConst(ref high64, ref low, 100)) - scale -= 2; - - if ((low & 1) == 0 && scale >= 1 && Div96ByConst(ref high64, ref low, 10)) - scale--; - } - } -} diff --git a/src/System.Private.CoreLib/src/System/Delegate.cs b/src/System.Private.CoreLib/src/System/Delegate.cs index 690fafb819c3..0d6c1e15231b 100644 --- a/src/System.Private.CoreLib/src/System/Delegate.cs +++ b/src/System.Private.CoreLib/src/System/Delegate.cs @@ -19,11 +19,11 @@ namespace System public abstract class Delegate : ICloneable, ISerializable { // _target is the object we will invoke on - internal Object _target; + internal object _target; // MethodBase, either cached after first request or assigned from a DynamicMethod // For open delegates to collectible types, this may be a LoaderAllocator object - internal Object _methodBase; + internal object _methodBase; // _methodPtr is a pointer to the method we will invoke // It could be a small thunk if this is a static or UM call @@ -37,7 +37,7 @@ public abstract class Delegate : ICloneable, ISerializable // This constructor is called from the class generated by the // compiler generated code - protected Delegate(Object target, String method) + protected Delegate(object target, string method) { if (target == null) throw new ArgumentNullException(nameof(target)); @@ -60,7 +60,7 @@ protected Delegate(Object target, String method) // This constructor is called from a class to generate a // delegate based upon a static method name and the Type object // for the class defining the method. - protected unsafe Delegate(Type target, String method) + protected unsafe Delegate(Type target, string method) { if (target == null) throw new ArgumentNullException(nameof(target)); @@ -93,7 +93,7 @@ private Delegate() { } - public Object DynamicInvoke(params Object[] args) + public object DynamicInvoke(params object[] args) { // Theoretically we should set up a LookForMyCaller stack mark here and pass that along. // But to maintain backward compatibility we can't switch to calling an @@ -113,7 +113,7 @@ protected virtual object DynamicInvokeImpl(object[] args) } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj == null || !InternalEqualTypes(this, obj)) return false; @@ -183,7 +183,7 @@ public override int GetHashCode() public static Delegate Combine(Delegate a, Delegate b) { - if ((Object)a == null) // cast to object for a more efficient test + if ((object)a == null) // cast to object for a more efficient test return b; return a.CombineImpl(b); @@ -272,7 +272,7 @@ protected virtual MethodInfo GetMethodImpl() return (MethodInfo)_methodBase; } - public Object Target + public object Target { get { @@ -320,25 +320,25 @@ protected virtual Delegate RemoveImpl(Delegate d) } - public virtual Object Clone() + public virtual object Clone() { return MemberwiseClone(); } // V1 API. - public static Delegate CreateDelegate(Type type, Object target, String method) + public static Delegate CreateDelegate(Type type, object target, string method) { return CreateDelegate(type, target, method, false, true); } // V1 API. - public static Delegate CreateDelegate(Type type, Object target, String method, bool ignoreCase) + public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase) { return CreateDelegate(type, target, method, ignoreCase, true); } // V1 API. - public static Delegate CreateDelegate(Type type, Object target, String method, bool ignoreCase, bool throwOnBindFailure) + public static Delegate CreateDelegate(Type type, object target, string method, bool ignoreCase, bool throwOnBindFailure) { if (type == null) throw new ArgumentNullException(nameof(type)); @@ -376,19 +376,19 @@ public static Delegate CreateDelegate(Type type, Object target, String method, b } // V1 API. - public static Delegate CreateDelegate(Type type, Type target, String method) + public static Delegate CreateDelegate(Type type, Type target, string method) { return CreateDelegate(type, target, method, false, true); } // V1 API. - public static Delegate CreateDelegate(Type type, Type target, String method, bool ignoreCase) + public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase) { return CreateDelegate(type, target, method, ignoreCase, true); } // V1 API. - public static Delegate CreateDelegate(Type type, Type target, String method, bool ignoreCase, bool throwOnBindFailure) + public static Delegate CreateDelegate(Type type, Type target, string method, bool ignoreCase, bool throwOnBindFailure) { if (type == null) throw new ArgumentNullException(nameof(type)); @@ -467,13 +467,13 @@ public static Delegate CreateDelegate(Type type, MethodInfo method, bool throwOn } // V2 API. - public static Delegate CreateDelegate(Type type, Object firstArgument, MethodInfo method) + public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method) { return CreateDelegate(type, firstArgument, method, true); } // V2 API. - public static Delegate CreateDelegate(Type type, Object firstArgument, MethodInfo method, bool throwOnBindFailure) + public static Delegate CreateDelegate(Type type, object firstArgument, MethodInfo method, bool throwOnBindFailure) { // Validate the parameters. if (type == null) @@ -511,16 +511,16 @@ public static Delegate CreateDelegate(Type type, Object firstArgument, MethodInf public static bool operator ==(Delegate d1, Delegate d2) { - if ((Object)d1 == null) - return (Object)d2 == null; + if ((object)d1 == null) + return (object)d2 == null; return d1.Equals(d2); } public static bool operator !=(Delegate d1, Delegate d2) { - if ((Object)d1 == null) - return (Object)d2 != null; + if ((object)d1 == null) + return (object)d2 != null; return !d1.Equals(d2); } @@ -540,7 +540,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte // V2 internal API. // This is Critical because it skips the security check when creating the delegate. - internal static unsafe Delegate CreateDelegateNoSecurityCheck(Type type, Object target, RuntimeMethodHandle method) + internal static unsafe Delegate CreateDelegateNoSecurityCheck(Type type, object target, RuntimeMethodHandle method) { // Validate the parameters. if (type == null) @@ -572,7 +572,7 @@ internal static unsafe Delegate CreateDelegateNoSecurityCheck(Type type, Object } // Caution: this method is intended for deserialization only, no security checks are performed. - internal static Delegate CreateDelegateNoSecurityCheck(RuntimeType type, Object firstArgument, MethodInfo method) + internal static Delegate CreateDelegateNoSecurityCheck(RuntimeType type, object firstArgument, MethodInfo method) { // Validate the parameters. if (type == null) @@ -612,7 +612,7 @@ public static Delegate CreateDelegate(Type type, MethodInfo method) return CreateDelegate(type, method, true); } - internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags) + internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, object firstArgument, DelegateBindingFlags flags) { Delegate d = InternalAlloc(rtType); @@ -627,10 +627,10 @@ internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMetho // [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern bool BindToMethodName(Object target, RuntimeType methodType, String method, DelegateBindingFlags flags); + private extern bool BindToMethodName(object target, RuntimeType methodType, string method, DelegateBindingFlags flags); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern bool BindToMethodInfo(Object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags); + private extern bool BindToMethodInfo(object target, IRuntimeMethodInfo method, RuntimeType methodType, DelegateBindingFlags flags); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern MulticastDelegate InternalAlloc(RuntimeType type); @@ -644,7 +644,7 @@ internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMetho // Used by the ctor. Do not call directly. // The name of this function will appear in managed stacktraces as delegate constructor. [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern void DelegateConstruct(Object target, IntPtr slot); + private extern void DelegateConstruct(object target, IntPtr slot); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern IntPtr GetMulticastInvoke(); @@ -659,12 +659,12 @@ internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMetho internal static extern bool InternalEqualMethodHandles(Delegate left, Delegate right); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal extern IntPtr AdjustTarget(Object target, IntPtr methodPtr); + internal extern IntPtr AdjustTarget(object target, IntPtr methodPtr); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern IntPtr GetCallStub(IntPtr methodPtr); - internal virtual Object GetTarget() + internal virtual object GetTarget() { return (_methodPtrAux == IntPtr.Zero) ? _target : null; } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs index e94ef46f2462..44bb846277d0 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/Contracts.cs @@ -141,14 +141,14 @@ public bool Value [AttributeUsage(AttributeTargets.Field)] public sealed class ContractPublicPropertyNameAttribute : Attribute { - private String _publicName; + private string _publicName; - public ContractPublicPropertyNameAttribute(String name) + public ContractPublicPropertyNameAttribute(string name) { _publicName = name; } - public String Name + public string Name { get { return _publicName; } } @@ -180,31 +180,31 @@ public sealed class ContractAbbreviatorAttribute : Attribute [Conditional("CONTRACTS_FULL")] public sealed class ContractOptionAttribute : Attribute { - private String _category; - private String _setting; + private string _category; + private string _setting; private bool _enabled; - private String _value; + private string _value; - public ContractOptionAttribute(String category, String setting, bool enabled) + public ContractOptionAttribute(string category, string setting, bool enabled) { _category = category; _setting = setting; _enabled = enabled; } - public ContractOptionAttribute(String category, String setting, String value) + public ContractOptionAttribute(string category, string setting, string value) { _category = category; _setting = setting; _value = value; } - public String Category + public string Category { get { return _category; } } - public String Setting + public string Setting { get { return _setting; } } @@ -214,7 +214,7 @@ public bool Enabled get { return _enabled; } } - public String Value + public string Value { get { return _value; } } @@ -267,7 +267,7 @@ public static void Assume(bool condition) [Pure] [Conditional("DEBUG")] [Conditional("CONTRACTS_FULL")] - public static void Assume(bool condition, String userMessage) + public static void Assume(bool condition, string userMessage) { if (!condition) { @@ -300,7 +300,7 @@ public static void Assert(bool condition) [Pure] [Conditional("DEBUG")] [Conditional("CONTRACTS_FULL")] - public static void Assert(bool condition, String userMessage) + public static void Assert(bool condition, string userMessage) { if (!condition) ReportFailure(ContractFailureKind.Assert, userMessage, null, null); @@ -338,7 +338,7 @@ public static void Requires(bool condition) /// [Pure] [Conditional("CONTRACTS_FULL")] - public static void Requires(bool condition, String userMessage) + public static void Requires(bool condition, string userMessage) { AssertMustUseRewriter(ContractFailureKind.Precondition, "Requires"); } @@ -369,7 +369,7 @@ public static void Requires(bool condition) where TException : Excep /// Use this form when you want to throw a particular exception. /// [Pure] - public static void Requires(bool condition, String userMessage) where TException : Exception + public static void Requires(bool condition, string userMessage) where TException : Exception { AssertMustUseRewriter(ContractFailureKind.Precondition, "Requires"); } @@ -406,7 +406,7 @@ public static void Ensures(bool condition) /// [Pure] [Conditional("CONTRACTS_FULL")] - public static void Ensures(bool condition, String userMessage) + public static void Ensures(bool condition, string userMessage) { AssertMustUseRewriter(ContractFailureKind.Postcondition, "Ensures"); } @@ -441,7 +441,7 @@ public static void EnsuresOnThrow(bool condition) where TException : /// [Pure] [Conditional("CONTRACTS_FULL")] - public static void EnsuresOnThrow(bool condition, String userMessage) where TException : Exception + public static void EnsuresOnThrow(bool condition, string userMessage) where TException : Exception { AssertMustUseRewriter(ContractFailureKind.PostconditionOnException, "EnsuresOnThrow"); } @@ -517,7 +517,7 @@ public static void Invariant(bool condition) /// [Pure] [Conditional("CONTRACTS_FULL")] - public static void Invariant(bool condition, String userMessage) + public static void Invariant(bool condition, string userMessage) { AssertMustUseRewriter(ContractFailureKind.Invariant, "Invariant"); } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs index f1cb53c3936f..f0c2f0764e5d 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Contracts/ContractsBCL.cs @@ -201,7 +201,7 @@ public static partial class ContractHelper #region Private fields private static volatile EventHandler contractFailedEvent; - private static readonly Object lockObject = new Object(); + private static readonly object lockObject = new object(); internal const int COR_E_CODECONTRACTFAILED = unchecked((int)0x80131542); diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs index 1f5a54584998..71f38f1a131e 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Debug.Windows.cs @@ -34,7 +34,7 @@ private static void ShowDialog(string stackTrace, string message, string detailM } } - private static readonly object s_ForLock = new Object(); + private static readonly object s_ForLock = new object(); private static void WriteCore(string message) { diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/EditAndContinueHelper.cs b/src/System.Private.CoreLib/src/System/Diagnostics/EditAndContinueHelper.cs index 6b8c150ab827..89aec101648c 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/EditAndContinueHelper.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/EditAndContinueHelper.cs @@ -20,7 +20,7 @@ internal sealed class EditAndContinueHelper { #pragma warning disable 169 #pragma warning disable 414 // Field is not used from managed. - private Object _objectReference; + private object _objectReference; #pragma warning restore 414 #pragma warning restore 169 } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/DotNETRuntimeEventSource.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/DotNETRuntimeEventSource.cs new file mode 100644 index 000000000000..8bfac2b04b67 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/DotNETRuntimeEventSource.cs @@ -0,0 +1,33 @@ +// 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. +namespace System.Diagnostics.Tracing +{ +#if FEATURE_PERFTRACING + /// + /// RuntimeEventSource is an EventSource that represents the ETW/EventPipe events emitted by the native runtime. + /// Most of RuntimeEventSource is auto-generated by scripts/genRuntimeEventSources.py based on the contents of the Microsoft-Windows-DotNETRuntime provider. + /// + internal sealed partial class RuntimeEventSource : EventSource + { + /// + /// Dispatch a single event with the specified event ID and payload. + /// + /// The eventID corresponding to the event as defined in the auto-generated portion of the RuntimeEventSource class. + /// A span pointing to the data payload for the event. + [NonEvent] + internal unsafe void ProcessEvent(uint eventID, ReadOnlySpan payload) + { + // Make sure the eventID is valid. + if (eventID >= m_eventData.Length) + { + return; + } + + // Decode the payload. + object[] decodedPayloadFields = EventPipePayloadDecoder.DecodePayload(ref m_eventData[eventID], payload); + WriteToAllListeners((int)eventID, null, null, decodedPayloadFields); + } + } +#endif // FEATURE_PERFTRACING +} diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.cs index 58091be27ff9..89528cfd30c1 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipe.cs @@ -7,8 +7,19 @@ using System.Security; using Microsoft.Win32; +#if FEATURE_PERFTRACING + namespace System.Diagnostics.Tracing { + [StructLayout(LayoutKind.Sequential)] + internal struct EventPipeEventInstanceData + { + internal IntPtr ProviderID; + internal uint EventID; + internal IntPtr Payload; + internal uint PayloadLength; + } + [StructLayout(LayoutKind.Sequential)] internal struct EventPipeProviderConfiguration { @@ -165,6 +176,9 @@ internal static class EventPipeInternal [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern unsafe IntPtr DefineEvent(IntPtr provHandle, uint eventID, long keywords, uint eventVersion, uint level, void *pMetadata, uint metadataLength); + [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] + internal static extern IntPtr GetProvider(string providerName); + [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern void DeleteProvider(IntPtr provHandle); @@ -176,5 +190,10 @@ internal static class EventPipeInternal [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] internal static extern unsafe void WriteEventData(IntPtr eventHandle, uint eventID, EventProvider.EventData* pEventData, uint dataCount, Guid* activityId, Guid* relatedActivityId); + + [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] + internal static extern unsafe bool GetNextEvent(EventPipeEventInstanceData* pInstance); } } + +#endif // FEATURE_PERFTRACING diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventDispatcher.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventDispatcher.cs new file mode 100644 index 000000000000..7d08d0db8415 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventDispatcher.cs @@ -0,0 +1,162 @@ +// 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.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Diagnostics.Tracing +{ +#if FEATURE_PERFTRACING + internal sealed class EventPipeEventDispatcher + { + internal sealed class EventListenerSubscription + { + internal EventKeywords MatchAnyKeywords { get; private set; } + internal EventLevel Level { get; private set; } + + internal EventListenerSubscription(EventKeywords matchAnyKeywords, EventLevel level) + { + MatchAnyKeywords = matchAnyKeywords; + Level = level; + } + } + + internal static readonly EventPipeEventDispatcher Instance = new EventPipeEventDispatcher(); + + private IntPtr m_RuntimeProviderID; + + private bool m_stopDispatchTask; + private Task m_dispatchTask = null; + private object m_dispatchControlLock = new object(); + private Dictionary m_subscriptions = new Dictionary(); + + private EventPipeEventDispatcher() + { + // Get the ID of the runtime provider so that it can be used as a filter when processing events. + m_RuntimeProviderID = EventPipeInternal.GetProvider(RuntimeEventSource.EventSourceName); + } + + internal void SendCommand(EventListener eventListener, EventCommand command, bool enable, EventLevel level, EventKeywords matchAnyKeywords) + { + if (command == EventCommand.Update && enable) + { + lock (m_dispatchControlLock) + { + // Add the new subscription. This will overwrite an existing subscription for the listener if one exists. + m_subscriptions[eventListener] = new EventListenerSubscription(matchAnyKeywords, level); + + // Commit the configuration change. + CommitDispatchConfiguration(); + } + } + else if (command == EventCommand.Update && !enable) + { + RemoveEventListener(eventListener); + } + } + + internal void RemoveEventListener(EventListener listener) + { + lock (m_dispatchControlLock) + { + // Remove the event listener from the list of subscribers. + if (m_subscriptions.ContainsKey(listener)) + { + m_subscriptions.Remove(listener); + } + + // Commit the configuration change. + CommitDispatchConfiguration(); + } + } + + private void CommitDispatchConfiguration() + { + // Ensure that the dispatch task is stopped. + // This is a no-op if the task is already stopped. + StopDispatchTask(); + + // Stop tracing. + // This is a no-op if it's already disabled. + EventPipeInternal.Disable(); + + // Check to see if tracing should be enabled. + if (m_subscriptions.Count <= 0) + { + return; + } + + // Start collecting events. + EventKeywords aggregatedKeywords = EventKeywords.None; + EventLevel highestLevel = EventLevel.LogAlways; + + foreach (EventListenerSubscription subscription in m_subscriptions.Values) + { + aggregatedKeywords |= subscription.MatchAnyKeywords; + highestLevel = (subscription.Level > highestLevel) ? subscription.Level : highestLevel; + } + + EventPipeProviderConfiguration[] providerConfiguration = new EventPipeProviderConfiguration[] + { + new EventPipeProviderConfiguration(RuntimeEventSource.EventSourceName, (ulong) aggregatedKeywords, (uint) highestLevel) + }; + + EventPipeInternal.Enable(null, 1024, 1, providerConfiguration, 1); + + // Start the dispatch task. + StartDispatchTask(); + } + + private void StartDispatchTask() + { + Debug.Assert(Monitor.IsEntered(m_dispatchControlLock)); + + if (m_dispatchTask == null) + { + m_stopDispatchTask = false; + m_dispatchTask = Task.Factory.StartNew(DispatchEventsToEventListeners, TaskCreationOptions.LongRunning); + } + } + + private void StopDispatchTask() + { + Debug.Assert(Monitor.IsEntered(m_dispatchControlLock)); + + if(m_dispatchTask != null) + { + m_stopDispatchTask = true; + m_dispatchTask.Wait(); + m_dispatchTask = null; + } + } + + private unsafe void DispatchEventsToEventListeners() + { + // Struct to fill with the call to GetNextEvent. + EventPipeEventInstanceData instanceData; + + while (!m_stopDispatchTask) + { + // Get the next event. + while (!m_stopDispatchTask && EventPipeInternal.GetNextEvent(&instanceData)) + { + // Filter based on provider. + if (instanceData.ProviderID == m_RuntimeProviderID) + { + // Dispatch the event. + ReadOnlySpan payload = new ReadOnlySpan((void*)instanceData.Payload, (int)instanceData.PayloadLength); + RuntimeEventSource.Log.ProcessEvent(instanceData.EventID, payload); + } + } + + // Wait for more events. + if (!m_stopDispatchTask) + { + Thread.Sleep(10); + } + } + } + } +#endif // FEATURE_PERFTRACING +} diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs index 42061df04364..214788ebc3dd 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeEventProvider.cs @@ -87,7 +87,7 @@ int IEventProvider.EventActivityIdControl(UnsafeNativeMethods.ManifestEtw.Activi } // Define an EventPipeEvent handle. - unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, Int64 keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) + unsafe IntPtr IEventProvider.DefineEventHandle(uint eventID, string eventName, long keywords, uint eventVersion, uint level, byte *pMetadata, uint metadataLength) { IntPtr eventHandlePtr = EventPipeInternal.DefineEvent(m_provHandle, eventID, keywords, eventVersion, level, pMetadata, metadataLength); return eventHandlePtr; diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs index d18610d922ca..a5cc756ae6e2 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipeMetadataGenerator.cs @@ -384,6 +384,13 @@ private static TypeCode GetTypeCodeExtended(Type parameterType) if (parameterType == typeof(Guid)) // Guid is not a part of TypeCode enum return GuidTypeCode; + // IntPtr and UIntPtr are converted to their non-pointer types. + if (parameterType == typeof(IntPtr)) + return IntPtr.Size == 4 ? TypeCode.Int32 : TypeCode.Int64; + + if (parameterType == typeof(UIntPtr)) + return UIntPtr.Size == 4 ? TypeCode.UInt32 : TypeCode.UInt64; + return Type.GetTypeCode(parameterType); } } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipePayloadDecoder.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipePayloadDecoder.cs new file mode 100644 index 000000000000..48aa5802dd16 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/EventPipePayloadDecoder.cs @@ -0,0 +1,183 @@ +// 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.Reflection; +using System.Runtime.InteropServices; + +namespace System.Diagnostics.Tracing +{ +#if FEATURE_PERFTRACING + internal static class EventPipePayloadDecoder + { + /// + /// Given the metadata for an event and an event payload, decode and deserialize the event payload. + /// + internal static object[] DecodePayload(ref EventSource.EventMetadata metadata, ReadOnlySpan payload) + { + ParameterInfo[] parameters = metadata.Parameters; + object[] decodedFields = new object[parameters.Length]; + for (int i = 0; i < parameters.Length; i++) + { + // It is possible that an older version of the event was emitted. + // If this happens, the payload might be missing arguments at the end. + // We can just leave these unset. + if (payload.Length <= 0) + { + break; + } + + Type parameterType = parameters[i].ParameterType; + if (parameterType == typeof(IntPtr)) + { + if (IntPtr.Size == 8) + { + // Payload is automatically updated to point to the next piece of data. + decodedFields[i] = (IntPtr)ReadUnalignedUInt64(ref payload); + } + else if (IntPtr.Size == 4) + { + decodedFields[i] = (IntPtr)MemoryMarshal.Read(payload); + payload = payload.Slice(IntPtr.Size); + } + else + { + Debug.Assert(false, "Unsupported pointer size."); + } + } + else if (parameterType == typeof(int)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(int)); + } + else if (parameterType == typeof(uint)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(uint)); + } + else if (parameterType == typeof(long)) + { + // Payload is automatically updated to point to the next piece of data. + decodedFields[i] = (long)ReadUnalignedUInt64(ref payload); + } + else if (parameterType == typeof(ulong)) + { + // Payload is automatically updated to point to the next piece of data. + decodedFields[i] = ReadUnalignedUInt64(ref payload); + } + else if (parameterType == typeof(byte)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(byte)); + } + else if (parameterType == typeof(sbyte)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(sbyte)); + } + else if (parameterType == typeof(short)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(short)); + } + else if (parameterType == typeof(ushort)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(ushort)); + } + else if (parameterType == typeof(float)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(float)); + } + else if (parameterType == typeof(double)) + { + // Payload is automatically updated to point to the next piece of data. + Int64 doubleBytes = (Int64)ReadUnalignedUInt64(ref payload); + decodedFields[i] = BitConverter.Int64BitsToDouble(doubleBytes); + } + else if (parameterType == typeof(bool)) + { + // The manifest defines a bool as a 32bit type (WIN32 BOOL), not 1 bit as CLR Does. + decodedFields[i] = (MemoryMarshal.Read(payload) == 1); + payload = payload.Slice(sizeof(int)); + } + else if (parameterType == typeof(Guid)) + { + // Payload is automatically updated to point to the next piece of data. + decodedFields[i] = ReadUnalignedGuid(ref payload); + } + else if (parameterType == typeof(char)) + { + decodedFields[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(char)); + } + else if (parameterType == typeof(string)) + { + ReadOnlySpan charPayload = MemoryMarshal.Cast(payload); + int charCount = 0; + foreach(char c in charPayload) + { + if (c == '\0') + break; + charCount++; + } + string val = new string(charPayload.ToArray(), 0, charCount); + payload = payload.Slice((val.Length + 1) * sizeof(char)); + decodedFields[i] = val; + } + else + { + Debug.Assert(false, "Unsupported type encountered."); + } + } + + return decodedFields; + } + + private static UInt64 ReadUnalignedUInt64(ref ReadOnlySpan payload) + { + UInt64 val = 0; + if (BitConverter.IsLittleEndian) + { + val |= MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(UInt32)); + val |= (MemoryMarshal.Read(payload) << sizeof(UInt32)); + payload = payload.Slice(sizeof(UInt32)); + } + else + { + val |= (MemoryMarshal.Read(payload) << sizeof(UInt32)); + payload = payload.Slice(sizeof(UInt32)); + val |= MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(UInt32)); + } + + return val; + } + + private static Guid ReadUnalignedGuid(ref ReadOnlySpan payload) + { + const int sizeOfGuid = 16; + byte[] guidBytes = new byte[sizeOfGuid]; + if (BitConverter.IsLittleEndian) + { + for (int i = sizeOfGuid - 1; i >= 0; i--) + { + guidBytes[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(byte)); + } + } + else + { + for (int i = 0; i < sizeOfGuid; i++) + { + guidBytes[i] = MemoryMarshal.Read(payload); + payload = payload.Slice(sizeof(byte)); + } + } + + return new Guid(guidBytes); + } + } +#endif // FEATURE_PERFTRACING +} diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs index a1fbc1a6b99d..740fff432d50 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/FrameworkEventSource.cs @@ -230,20 +230,20 @@ private unsafe void WriteEvent(int eventId, long arg1, bool arg2, bool arg3, int // ResourceManager Event Definitions [Event(1, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerLookupStarted(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerLookupStarted(string baseName, string mainAssemblyName, string cultureName) { WriteEvent(1, baseName, mainAssemblyName, cultureName); } [Event(2, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerLookingForResourceSet(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerLookingForResourceSet(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(2, baseName, mainAssemblyName, cultureName); } [Event(3, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerFoundResourceSetInCache(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerFoundResourceSetInCache(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(3, baseName, mainAssemblyName, cultureName); @@ -253,7 +253,7 @@ public void ResourceManagerFoundResourceSetInCache(String baseName, String mainA // the cache. This can happen if you have an assembly load callback that called into this // instance of the ResourceManager. [Event(4, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerFoundResourceSetInCacheUnexpected(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(4, baseName, mainAssemblyName, cultureName); @@ -261,7 +261,7 @@ public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, St // manifest resource stream lookup succeeded [Event(5, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerStreamFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) + public void ResourceManagerStreamFound(string baseName, string mainAssemblyName, string cultureName, string loadedAssemblyName, string resourceFileName) { if (IsEnabled()) WriteEvent(5, baseName, mainAssemblyName, cultureName, loadedAssemblyName, resourceFileName); @@ -269,35 +269,35 @@ public void ResourceManagerStreamFound(String baseName, String mainAssemblyName, // manifest resource stream lookup failed [Event(6, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerStreamNotFound(String baseName, String mainAssemblyName, String cultureName, String loadedAssemblyName, String resourceFileName) + public void ResourceManagerStreamNotFound(string baseName, string mainAssemblyName, string cultureName, string loadedAssemblyName, string resourceFileName) { if (IsEnabled()) WriteEvent(6, baseName, mainAssemblyName, cultureName, loadedAssemblyName, resourceFileName); } [Event(7, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, String mainAssemblyName, String cultureName, String assemblyName) + public void ResourceManagerGetSatelliteAssemblySucceeded(string baseName, string mainAssemblyName, string cultureName, string assemblyName) { if (IsEnabled()) WriteEvent(7, baseName, mainAssemblyName, cultureName, assemblyName); } [Event(8, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, String mainAssemblyName, String cultureName, String assemblyName) + public void ResourceManagerGetSatelliteAssemblyFailed(string baseName, string mainAssemblyName, string cultureName, string assemblyName) { if (IsEnabled()) WriteEvent(8, baseName, mainAssemblyName, cultureName, assemblyName); } [Event(9, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) + public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(string baseName, string mainAssemblyName, string assemblyName, string resourceFileName) { if (IsEnabled()) WriteEvent(9, baseName, mainAssemblyName, assemblyName, resourceFileName); } [Event(10, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, String mainAssemblyName, String assemblyName, String resourceFileName) + public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(string baseName, string mainAssemblyName, string assemblyName, string resourceFileName) { if (IsEnabled()) WriteEvent(10, baseName, mainAssemblyName, assemblyName, resourceFileName); @@ -305,7 +305,7 @@ public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String base // Could not access the manifest resource the assembly [Event(11, Level = EventLevel.Error, Keywords = Keywords.Loader)] - public void ResourceManagerManifestResourceAccessDenied(String baseName, String mainAssemblyName, String assemblyName, String canonicalName) + public void ResourceManagerManifestResourceAccessDenied(string baseName, string mainAssemblyName, string assemblyName, string canonicalName) { if (IsEnabled()) WriteEvent(11, baseName, mainAssemblyName, assemblyName, canonicalName); @@ -313,77 +313,77 @@ public void ResourceManagerManifestResourceAccessDenied(String baseName, String // Neutral resources are sufficient for this culture. Skipping satellites [Event(12, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesSufficient(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerNeutralResourcesSufficient(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(12, baseName, mainAssemblyName, cultureName); } [Event(13, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourceAttributeMissing(String mainAssemblyName) + public void ResourceManagerNeutralResourceAttributeMissing(string mainAssemblyName) { if (IsEnabled()) WriteEvent(13, mainAssemblyName); } [Event(14, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName, String fileName) + public void ResourceManagerCreatingResourceSet(string baseName, string mainAssemblyName, string cultureName, string fileName) { if (IsEnabled()) WriteEvent(14, baseName, mainAssemblyName, cultureName, fileName); } [Event(15, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNotCreatingResourceSet(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerNotCreatingResourceSet(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(15, baseName, mainAssemblyName, cultureName); } [Event(16, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerLookupFailed(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerLookupFailed(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(16, baseName, mainAssemblyName, cultureName); } [Event(17, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerReleasingResources(String baseName, String mainAssemblyName) + public void ResourceManagerReleasingResources(string baseName, string mainAssemblyName) { if (IsEnabled()) WriteEvent(17, baseName, mainAssemblyName); } [Event(18, Level = EventLevel.Warning, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesNotFound(String baseName, String mainAssemblyName, String resName) + public void ResourceManagerNeutralResourcesNotFound(string baseName, string mainAssemblyName, string resName) { if (IsEnabled()) WriteEvent(18, baseName, mainAssemblyName, resName); } [Event(19, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerNeutralResourcesFound(String baseName, String mainAssemblyName, String resName) + public void ResourceManagerNeutralResourcesFound(string baseName, string mainAssemblyName, string resName) { if (IsEnabled()) WriteEvent(19, baseName, mainAssemblyName, resName); } [Event(20, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerAddingCultureFromConfigFile(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerAddingCultureFromConfigFile(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(20, baseName, mainAssemblyName, cultureName); } [Event(21, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCultureNotFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerCultureNotFoundInConfigFile(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(21, baseName, mainAssemblyName, cultureName); } [Event(22, Level = EventLevel.Informational, Keywords = Keywords.Loader)] - public void ResourceManagerCultureFoundInConfigFile(String baseName, String mainAssemblyName, String cultureName) + public void ResourceManagerCultureFoundInConfigFile(string baseName, string mainAssemblyName, string cultureName) { if (IsEnabled()) WriteEvent(22, baseName, mainAssemblyName, cultureName); @@ -393,84 +393,84 @@ public void ResourceManagerCultureFoundInConfigFile(String baseName, String main // ResourceManager Event Wrappers [NonEvent] - public void ResourceManagerLookupStarted(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerLookupStarted(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerLookupStarted(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerLookingForResourceSet(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerLookingForResourceSet(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerLookingForResourceSet(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerFoundResourceSetInCache(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerFoundResourceSetInCache(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerFoundResourceSetInCache(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerFoundResourceSetInCacheUnexpected(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerFoundResourceSetInCacheUnexpected(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerFoundResourceSetInCacheUnexpected(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerStreamFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) + public void ResourceManagerStreamFound(string baseName, Assembly mainAssembly, string cultureName, Assembly loadedAssembly, string resourceFileName) { if (IsEnabled()) ResourceManagerStreamFound(baseName, GetName(mainAssembly), cultureName, GetName(loadedAssembly), resourceFileName); } [NonEvent] - public void ResourceManagerStreamNotFound(String baseName, Assembly mainAssembly, String cultureName, Assembly loadedAssembly, String resourceFileName) + public void ResourceManagerStreamNotFound(string baseName, Assembly mainAssembly, string cultureName, Assembly loadedAssembly, string resourceFileName) { if (IsEnabled()) ResourceManagerStreamNotFound(baseName, GetName(mainAssembly), cultureName, GetName(loadedAssembly), resourceFileName); } [NonEvent] - public void ResourceManagerGetSatelliteAssemblySucceeded(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) + public void ResourceManagerGetSatelliteAssemblySucceeded(string baseName, Assembly mainAssembly, string cultureName, string assemblyName) { if (IsEnabled()) ResourceManagerGetSatelliteAssemblySucceeded(baseName, GetName(mainAssembly), cultureName, assemblyName); } [NonEvent] - public void ResourceManagerGetSatelliteAssemblyFailed(String baseName, Assembly mainAssembly, String cultureName, String assemblyName) + public void ResourceManagerGetSatelliteAssemblyFailed(string baseName, Assembly mainAssembly, string cultureName, string assemblyName) { if (IsEnabled()) ResourceManagerGetSatelliteAssemblyFailed(baseName, GetName(mainAssembly), cultureName, assemblyName); } [NonEvent] - public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) + public void ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(string baseName, Assembly mainAssembly, string assemblyName, string resourceFileName) { if (IsEnabled()) ResourceManagerCaseInsensitiveResourceStreamLookupSucceeded(baseName, GetName(mainAssembly), assemblyName, resourceFileName); } [NonEvent] - public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(String baseName, Assembly mainAssembly, String assemblyName, String resourceFileName) + public void ResourceManagerCaseInsensitiveResourceStreamLookupFailed(string baseName, Assembly mainAssembly, string assemblyName, string resourceFileName) { if (IsEnabled()) ResourceManagerCaseInsensitiveResourceStreamLookupFailed(baseName, GetName(mainAssembly), assemblyName, resourceFileName); } [NonEvent] - public void ResourceManagerManifestResourceAccessDenied(String baseName, Assembly mainAssembly, String assemblyName, String canonicalName) + public void ResourceManagerManifestResourceAccessDenied(string baseName, Assembly mainAssembly, string assemblyName, string canonicalName) { if (IsEnabled()) ResourceManagerManifestResourceAccessDenied(baseName, GetName(mainAssembly), assemblyName, canonicalName); } [NonEvent] - public void ResourceManagerNeutralResourcesSufficient(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerNeutralResourcesSufficient(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerNeutralResourcesSufficient(baseName, GetName(mainAssembly), cultureName); @@ -484,63 +484,63 @@ public void ResourceManagerNeutralResourceAttributeMissing(Assembly mainAssembly } [NonEvent] - public void ResourceManagerCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName, String fileName) + public void ResourceManagerCreatingResourceSet(string baseName, Assembly mainAssembly, string cultureName, string fileName) { if (IsEnabled()) ResourceManagerCreatingResourceSet(baseName, GetName(mainAssembly), cultureName, fileName); } [NonEvent] - public void ResourceManagerNotCreatingResourceSet(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerNotCreatingResourceSet(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerNotCreatingResourceSet(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerLookupFailed(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerLookupFailed(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerLookupFailed(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerReleasingResources(String baseName, Assembly mainAssembly) + public void ResourceManagerReleasingResources(string baseName, Assembly mainAssembly) { if (IsEnabled()) ResourceManagerReleasingResources(baseName, GetName(mainAssembly)); } [NonEvent] - public void ResourceManagerNeutralResourcesNotFound(String baseName, Assembly mainAssembly, String resName) + public void ResourceManagerNeutralResourcesNotFound(string baseName, Assembly mainAssembly, string resName) { if (IsEnabled()) ResourceManagerNeutralResourcesNotFound(baseName, GetName(mainAssembly), resName); } [NonEvent] - public void ResourceManagerNeutralResourcesFound(String baseName, Assembly mainAssembly, String resName) + public void ResourceManagerNeutralResourcesFound(string baseName, Assembly mainAssembly, string resName) { if (IsEnabled()) ResourceManagerNeutralResourcesFound(baseName, GetName(mainAssembly), resName); } [NonEvent] - public void ResourceManagerAddingCultureFromConfigFile(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerAddingCultureFromConfigFile(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerAddingCultureFromConfigFile(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerCultureNotFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerCultureNotFoundInConfigFile(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerCultureNotFoundInConfigFile(baseName, GetName(mainAssembly), cultureName); } [NonEvent] - public void ResourceManagerCultureFoundInConfigFile(String baseName, Assembly mainAssembly, String cultureName) + public void ResourceManagerCultureFoundInConfigFile(string baseName, Assembly mainAssembly, string cultureName) { if (IsEnabled()) ResourceManagerCultureFoundInConfigFile(baseName, GetName(mainAssembly), cultureName); diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventHandleTable.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventHandleTable.cs new file mode 100644 index 000000000000..9afc1cf0d676 --- /dev/null +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/TraceLogging/TraceLoggingEventHandleTable.cs @@ -0,0 +1,61 @@ +// 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.Threading; + +namespace System.Diagnostics.Tracing +{ +#if FEATURE_PERFTRACING + /// + /// Per-EventSource data structure for caching EventPipe EventHandles associated with TraceLogging events. + /// + internal sealed class TraceLoggingEventHandleTable + { + private const int DefaultLength = 10; + private IntPtr[] m_innerTable; + + internal TraceLoggingEventHandleTable() + { + m_innerTable = new IntPtr[DefaultLength]; + } + + internal IntPtr this[int eventID] + { + get + { + IntPtr ret = IntPtr.Zero; + IntPtr[] innerTable = Volatile.Read(ref m_innerTable); + + if (eventID >= 0 && eventID < innerTable.Length) + { + ret = innerTable[eventID]; + } + + return ret; + } + } + + internal void SetEventHandle(int eventID, IntPtr eventHandle) + { + // Set operations must be serialized to ensure that re-size operations don't lose concurrent writes. + Debug.Assert(Monitor.IsEntered(this)); + + if (eventID >= m_innerTable.Length) + { + int newSize = m_innerTable.Length * 2; + if (newSize <= eventID) + { + newSize = eventID + 1; + } + + IntPtr[] newTable = new IntPtr[newSize]; + Array.Copy(m_innerTable, 0, newTable, 0, m_innerTable.Length); + Volatile.Write(ref m_innerTable, newTable); + } + + m_innerTable[eventID] = eventHandle; + } + } +#endif +} diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/XplatEventLogger.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/XplatEventLogger.cs index 31f79f5218e2..54238aff51f3 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/XplatEventLogger.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Eventing/XplatEventLogger.cs @@ -71,10 +71,10 @@ private static void minimalJsonserializer(string payload, StringBuilder sb) private static string Serialize(ReadOnlyCollection payloadName, ReadOnlyCollection payload, string eventMessage) { if (payloadName == null || payload == null ) - return String.Empty; + return string.Empty; if (payloadName.Count == 0 || payload.Count == 0) - return String.Empty; + return string.Empty; int eventDataCount = payloadName.Count; @@ -156,8 +156,14 @@ private static void AppendByteArrayAsHexString(StringBuilder builder, byte[] byt internal protected override void OnEventSourceCreated(EventSource eventSource) { + // Don't enable forwarding of RuntimeEventSource events.` + if (eventSource.GetType() == typeof(RuntimeEventSource)) + { + return; + } + string eventSourceFilter = eventSourceNameFilter.Value; - if (String.IsNullOrEmpty(eventSourceFilter) || (eventSource.Name.IndexOf(eventSourceFilter, StringComparison.OrdinalIgnoreCase) >= 0)) + if (string.IsNullOrEmpty(eventSourceFilter) || (eventSource.Name.IndexOf(eventSourceFilter, StringComparison.OrdinalIgnoreCase) >= 0)) { EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All, null); } @@ -166,7 +172,7 @@ internal protected override void OnEventSourceCreated(EventSource eventSource) internal protected override void OnEventWritten(EventWrittenEventArgs eventData) { string eventFilter = eventSourceEventFilter.Value; - if (String.IsNullOrEmpty(eventFilter) || (eventData.EventName.IndexOf(eventFilter, StringComparison.OrdinalIgnoreCase) >= 0)) + if (string.IsNullOrEmpty(eventFilter) || (eventData.EventName.IndexOf(eventFilter, StringComparison.OrdinalIgnoreCase) >= 0)) { LogOnEventWritten(eventData); } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs b/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs index c5a07a2c5389..e8d7ef540064 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs @@ -30,7 +30,7 @@ internal class StackFrameHelper #pragma warning disable 414 // dynamicMethods is an array of System.Resolver objects, used to keep // DynamicMethodDescs alive for the lifetime of StackFrameHelper. - private Object dynamicMethods; // Field is not used from managed. + private object dynamicMethods; // Field is not used from managed. private IntPtr[] rgMethodHandle; private string[] rgAssemblyPath; diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs b/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs index 3e4da5c98418..e6351a361246 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/Stacktrace.cs @@ -181,7 +181,7 @@ internal static int CalculateFramesToSkip(StackFrameHelper StackF, int iNumFrame string ns = t.Namespace; if (ns == null) break; - if (string.Compare(ns, PackageName, StringComparison.Ordinal) != 0) + if (!string.Equals(ns, PackageName, StringComparison.Ordinal)) break; } iRetVal++; diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/ISymWriter.cs b/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/ISymWriter.cs index fa2a59797a23..31f81e1bed07 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/ISymWriter.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/ISymWriter.cs @@ -26,7 +26,7 @@ internal interface ISymbolWriter // Define a source document. Guid's will be provided for the // languages, vendors, and document types that we currently know // about. - ISymbolDocumentWriter DefineDocument(String url, + ISymbolDocumentWriter DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType); @@ -86,7 +86,7 @@ void DefineSequencePoints(ISymbolDocumentWriter document, // variable of the same name that has multiple homes throughout a // scope. (Note: start/end offsets must not overlap in such a // case.) - void DefineLocalVariable(String name, + void DefineLocalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, @@ -99,13 +99,13 @@ void DefineLocalVariable(String name, // Defines a custom attribute based upon its name. Not to be // confused with Metadata custom attributes, these attributes are // held in the symbol store. - void SetSymAttribute(SymbolToken parent, String name, byte[] data); + void SetSymAttribute(SymbolToken parent, string name, byte[] data); // Specifies that the given, fully qualified namespace name is // being used within the currently open lexical scope. Closing the // current scope will also stop using the namespace, and the // namespace will be in use in all scopes that inherit from the // currently open scope. - void UsingNamespace(String fullName); + void UsingNamespace(string fullName); } } diff --git a/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/Token.cs b/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/Token.cs index a6e6fdc0ef78..238e3a524df1 100644 --- a/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/Token.cs +++ b/src/System.Private.CoreLib/src/System/Diagnostics/SymbolStore/Token.cs @@ -25,7 +25,7 @@ internal struct SymbolToken public override int GetHashCode() { return m_token; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is SymbolToken) return Equals((SymbolToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Enum.cs b/src/System.Private.CoreLib/src/System/Enum.cs index c837437a103c..505c5acdfb0e 100644 --- a/src/System.Private.CoreLib/src/System/Enum.cs +++ b/src/System.Private.CoreLib/src/System/Enum.cs @@ -31,7 +31,7 @@ public abstract class Enum : ValueType, IComparable, IFormattable, IConvertible { #region Private Constants private const char enumSeparatorChar = ','; - private const String enumSeparatorString = ", "; + private const string enumSeparatorString = ", "; #endregion #region Private Static Methods @@ -42,7 +42,7 @@ private static TypeValuesAndNames GetCachedValuesAndNames(RuntimeType enumType, if (entry == null || (getNames && entry.Names == null)) { ulong[] values = null; - String[] names = null; + string[] names = null; bool isFlags = enumType.IsDefined(typeof(System.FlagsAttribute), false); GetEnumValuesAndNames( @@ -58,7 +58,7 @@ private static TypeValuesAndNames GetCachedValuesAndNames(RuntimeType enumType, return entry; } - private unsafe String InternalFormattedHexString() + private unsafe string InternalFormattedHexString() { fixed (void* pValue = &JitHelpers.GetPinningHelper(this).m_data) { @@ -86,7 +86,7 @@ private unsafe String InternalFormattedHexString() } } - private static String InternalFormattedHexString(object value) + private static string InternalFormattedHexString(object value) { TypeCode typeCode = Convert.GetTypeCode(value); @@ -100,26 +100,26 @@ private static String InternalFormattedHexString(object value) // direct cast from bool to byte is not allowed return Convert.ToByte((bool)value).ToString("X2", null); case TypeCode.Int16: - return ((UInt16)(Int16)value).ToString("X4", null); + return ((ushort)(short)value).ToString("X4", null); case TypeCode.UInt16: - return ((UInt16)value).ToString("X4", null); + return ((ushort)value).ToString("X4", null); case TypeCode.Char: - return ((UInt16)(Char)value).ToString("X4", null); + return ((ushort)(char)value).ToString("X4", null); case TypeCode.UInt32: - return ((UInt32)value).ToString("X8", null); + return ((uint)value).ToString("X8", null); case TypeCode.Int32: - return ((UInt32)(Int32)value).ToString("X8", null); + return ((uint)(int)value).ToString("X8", null); case TypeCode.UInt64: - return ((UInt64)value).ToString("X16", null); + return ((ulong)value).ToString("X16", null); case TypeCode.Int64: - return ((UInt64)(Int64)value).ToString("X16", null); + return ((ulong)(long)value).ToString("X16", null); // All unsigned types will be directly cast default: throw new InvalidOperationException(SR.InvalidOperation_UnknownEnumType); } } - internal static String GetEnumName(RuntimeType eT, ulong ulValue) + internal static string GetEnumName(RuntimeType eT, ulong ulValue) { Debug.Assert(eT != null); ulong[] ulValues = Enum.InternalGetValues(eT); @@ -134,7 +134,7 @@ internal static String GetEnumName(RuntimeType eT, ulong ulValue) return null; // return null so the caller knows to .ToString() the input } - private static String InternalFormat(RuntimeType eT, ulong value) + private static string InternalFormat(RuntimeType eT, ulong value) { Debug.Assert(eT != null); @@ -151,7 +151,7 @@ private static String InternalFormat(RuntimeType eT, ulong value) } } - private static String InternalFlagsFormat(RuntimeType eT, ulong result) + private static string InternalFlagsFormat(RuntimeType eT, ulong result) { // These values are sorted by value. Don't change this TypeValuesAndNames entry = GetCachedValuesAndNames(eT, true); @@ -159,11 +159,11 @@ private static String InternalFlagsFormat(RuntimeType eT, ulong result) return InternalFlagsFormat(eT, entry, result); } - private static String InternalFlagsFormat(RuntimeType eT, TypeValuesAndNames entry, ulong result) + private static string InternalFlagsFormat(RuntimeType eT, TypeValuesAndNames entry, ulong result) { Debug.Assert(eT != null); - String[] names = entry.Names; + string[] names = entry.Names; ulong[] values = entry.Values; Debug.Assert(names.Length == values.Length); @@ -220,7 +220,7 @@ private static String InternalFlagsFormat(RuntimeType eT, TypeValuesAndNames ent return returnString; } - internal static ulong ToUInt64(Object value) + internal static ulong ToUInt64(object value) { // Helper function to silently convert the value to UInt64 from the other base types for enum without throwing an exception. // This is need since the Convert functions do overflow checks. @@ -240,16 +240,16 @@ internal static ulong ToUInt64(Object value) result = Convert.ToByte((bool)value); break; case TypeCode.Int16: - result = (ulong)(Int16)value; + result = (ulong)(short)value; break; case TypeCode.UInt16: - result = (UInt16)value; + result = (ushort)value; break; case TypeCode.Char: - result = (UInt16)(Char)value; + result = (ushort)(char)value; break; case TypeCode.UInt32: - result = (UInt32)value; + result = (uint)value; break; case TypeCode.Int32: result = (ulong)(int)value; @@ -258,7 +258,7 @@ internal static ulong ToUInt64(Object value) result = (ulong)value; break; case TypeCode.Int64: - result = (ulong)(Int64)value; + result = (ulong)(long)value; break; // All unsigned types will be directly cast default: @@ -269,7 +269,7 @@ internal static ulong ToUInt64(Object value) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern int InternalCompareTo(Object o1, Object o2); + private static extern int InternalCompareTo(object o1, object o2); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern RuntimeType InternalGetUnderlyingType(RuntimeType enumType); @@ -278,7 +278,7 @@ internal static ulong ToUInt64(Object value) private static extern void GetEnumValuesAndNames(RuntimeTypeHandle enumType, ObjectHandleOnStack values, ObjectHandleOnStack names, bool getNames); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern Object InternalBoxEnum(RuntimeType enumType, long value); + private static extern object InternalBoxEnum(RuntimeType enumType, long value); #endregion #region Public Static Methods @@ -345,12 +345,12 @@ internal Exception GetEnumParseException() } } - public static bool TryParse(Type enumType, String value, out Object result) + public static bool TryParse(Type enumType, string value, out object result) { return TryParse(enumType, value, false, out result); } - public static bool TryParse(Type enumType, String value, bool ignoreCase, out Object result) + public static bool TryParse(Type enumType, string value, bool ignoreCase, out object result) { result = null; EnumResult parseResult = new EnumResult(); @@ -361,12 +361,12 @@ public static bool TryParse(Type enumType, String value, bool ignoreCase, out Ob return retValue; } - public static bool TryParse(String value, out TEnum result) where TEnum : struct + public static bool TryParse(string value, out TEnum result) where TEnum : struct { return TryParse(value, false, out result); } - public static bool TryParse(String value, bool ignoreCase, out TEnum result) where TEnum : struct + public static bool TryParse(string value, bool ignoreCase, out TEnum result) where TEnum : struct { result = default; EnumResult parseResult = new EnumResult(); @@ -377,12 +377,12 @@ public static bool TryParse(String value, bool ignoreCase, out TEnum resu return retValue; } - public static Object Parse(Type enumType, String value) + public static object Parse(Type enumType, string value) { return Parse(enumType, value, false); } - public static Object Parse(Type enumType, String value, bool ignoreCase) + public static object Parse(Type enumType, string value, bool ignoreCase) { EnumResult parseResult = new EnumResult() { canThrow = true }; if (TryParseEnum(enumType, value, ignoreCase, ref parseResult)) @@ -391,12 +391,12 @@ public static Object Parse(Type enumType, String value, bool ignoreCase) throw parseResult.GetEnumParseException(); } - public static TEnum Parse(String value) where TEnum : struct + public static TEnum Parse(string value) where TEnum : struct { return Parse(value, false); } - public static TEnum Parse(String value, bool ignoreCase) where TEnum : struct + public static TEnum Parse(string value, bool ignoreCase) where TEnum : struct { EnumResult parseResult = new EnumResult() { canThrow = true }; if (TryParseEnum(typeof(TEnum), value, ignoreCase, ref parseResult)) @@ -405,7 +405,7 @@ public static TEnum Parse(String value, bool ignoreCase) where TEnum : st throw parseResult.GetEnumParseException(); } - private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, ref EnumResult parseResult) + private static bool TryParseEnum(Type enumType, string value, bool ignoreCase, ref EnumResult parseResult) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -426,7 +426,7 @@ private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, r int firstNonWhitespaceIndex = -1; for (int i = 0; i < value.Length; i++) { - if (!Char.IsWhiteSpace(value[i])) + if (!char.IsWhiteSpace(value[i])) { firstNonWhitespaceIndex = i; break; @@ -443,10 +443,10 @@ private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, r ulong result = 0; char firstNonWhitespaceChar = value[firstNonWhitespaceIndex]; - if (Char.IsDigit(firstNonWhitespaceChar) || firstNonWhitespaceChar == '-' || firstNonWhitespaceChar == '+') + if (char.IsDigit(firstNonWhitespaceChar) || firstNonWhitespaceChar == '-' || firstNonWhitespaceChar == '+') { Type underlyingType = GetUnderlyingType(enumType); - Object temp; + object temp; try { @@ -475,7 +475,7 @@ private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, r // Find the field. Let's assume that these are always static classes // because the class is an enum. TypeValuesAndNames entry = GetCachedValuesAndNames(rtType, true); - String[] enumNames = entry.Names; + string[] enumNames = entry.Names; ulong[] enumValues = entry.Values; StringComparison comparison = ignoreCase ? @@ -494,8 +494,8 @@ private static bool TryParseEnum(Type enumType, String value, bool ignoreCase, r // Shift the starting and ending indices to eliminate whitespace int endIndexNoWhitespace = endIndex; - while (valueIndex < endIndex && Char.IsWhiteSpace(value[valueIndex])) valueIndex++; - while (endIndexNoWhitespace > valueIndex && Char.IsWhiteSpace(value[endIndexNoWhitespace - 1])) endIndexNoWhitespace--; + while (valueIndex < endIndex && char.IsWhiteSpace(value[valueIndex])) valueIndex++; + while (endIndexNoWhitespace > valueIndex && char.IsWhiteSpace(value[endIndexNoWhitespace - 1])) endIndexNoWhitespace--; int valueSubstringLength = endIndexNoWhitespace - valueIndex; // Try to match this substring against each enum name @@ -562,7 +562,7 @@ internal static ulong[] InternalGetValues(RuntimeType enumType) return GetCachedValuesAndNames(enumType, false).Values; } - public static String GetName(Type enumType, Object value) + public static string GetName(Type enumType, object value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -570,7 +570,7 @@ public static String GetName(Type enumType, Object value) return enumType.GetEnumName(value); } - public static String[] GetNames(Type enumType) + public static string[] GetNames(Type enumType) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -578,13 +578,13 @@ public static String[] GetNames(Type enumType) return enumType.GetEnumNames(); } - internal static String[] InternalGetNames(RuntimeType enumType) + internal static string[] InternalGetNames(RuntimeType enumType) { // Get all of the names return GetCachedValuesAndNames(enumType, true).Names; } - public static Object ToObject(Type enumType, Object value) + public static object ToObject(Type enumType, object value) { if (value == null) throw new ArgumentNullException(nameof(value)); @@ -630,7 +630,7 @@ public static Object ToObject(Type enumType, Object value) } } - public static bool IsDefined(Type enumType, Object value) + public static bool IsDefined(Type enumType, object value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -638,7 +638,7 @@ public static bool IsDefined(Type enumType, Object value) return enumType.IsEnumDefined(value); } - public static String Format(Type enumType, Object value, String format) + public static string Format(Type enumType, object value, string format) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -707,7 +707,7 @@ public static String Format(Type enumType, Object value, String format) private class TypeValuesAndNames { // Each entry contains a list of sorted pair of enum field names and values, sorted by values - public TypeValuesAndNames(bool isFlag, ulong[] values, String[] names) + public TypeValuesAndNames(bool isFlag, ulong[] values, string[] names) { this.IsFlag = isFlag; this.Values = values; @@ -716,12 +716,12 @@ public TypeValuesAndNames(bool isFlag, ulong[] values, String[] names) public bool IsFlag; public ulong[] Values; - public String[] Names; + public string[] Names; } #endregion #region Private Methods - internal unsafe Object GetValue() + internal unsafe object GetValue() { fixed (void* pValue = &JitHelpers.GetPinningHelper(this).m_data) { @@ -824,7 +824,7 @@ private unsafe ulong ToUInt64() #region Object Overrides [MethodImplAttribute(MethodImplOptions.InternalCall)] - public extern override bool Equals(Object obj); + public extern override bool Equals(object obj); public override unsafe int GetHashCode() { @@ -871,7 +871,7 @@ public override unsafe int GetHashCode() } } - public override String ToString() + public override string ToString() { // Returns the value in a human readable format. For PASCAL style enums who's value maps directly the name of the field is returned. // For PASCAL style enums who's values do not map directly the decimal value of the field is returned. @@ -887,14 +887,14 @@ public override String ToString() #region IFormattable [Obsolete("The provider argument is not used. Please use ToString(String).")] - public String ToString(String format, IFormatProvider provider) + public string ToString(string format, IFormatProvider provider) { return ToString(format); } #endregion #region IComparable - public int CompareTo(Object target) + public int CompareTo(object target) { const int retIncompatibleMethodTables = 2; // indicates that the method tables did not match const int retInvalidEnumType = 3; // indicates that the enum was of an unknown/unsupported underlying type @@ -927,7 +927,7 @@ public int CompareTo(Object target) #endregion #region Public Methods - public String ToString(String format) + public string ToString(string format) { char formatCh; if (format == null || format.Length == 0) @@ -953,13 +953,13 @@ public String ToString(String format) } [Obsolete("The provider argument is not used. Please use ToString().")] - public String ToString(IFormatProvider provider) + public string ToString(IFormatProvider provider) { return ToString(); } [Intrinsic] - public Boolean HasFlag(Enum flag) + public bool HasFlag(Enum flag) { if (flag == null) throw new ArgumentNullException(nameof(flag)); @@ -1064,7 +1064,7 @@ double IConvertible.ToDouble(IFormatProvider provider) return Convert.ToDouble(GetValue(), CultureInfo.CurrentCulture); } - Decimal IConvertible.ToDecimal(IFormatProvider provider) + decimal IConvertible.ToDecimal(IFormatProvider provider) { return Convert.ToDecimal(GetValue(), CultureInfo.CurrentCulture); } @@ -1074,7 +1074,7 @@ DateTime IConvertible.ToDateTime(IFormatProvider provider) throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "Enum", "DateTime")); } - Object IConvertible.ToType(Type type, IFormatProvider provider) + object IConvertible.ToType(Type type, IFormatProvider provider) { return Convert.DefaultToType((IConvertible)this, type, provider); } @@ -1082,7 +1082,7 @@ Object IConvertible.ToType(Type type, IFormatProvider provider) #region ToObject [CLSCompliant(false)] - public static Object ToObject(Type enumType, sbyte value) + public static object ToObject(Type enumType, sbyte value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1094,7 +1094,7 @@ public static Object ToObject(Type enumType, sbyte value) return InternalBoxEnum(rtType, value); } - public static Object ToObject(Type enumType, short value) + public static object ToObject(Type enumType, short value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1106,7 +1106,7 @@ public static Object ToObject(Type enumType, short value) return InternalBoxEnum(rtType, value); } - public static Object ToObject(Type enumType, int value) + public static object ToObject(Type enumType, int value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1118,7 +1118,7 @@ public static Object ToObject(Type enumType, int value) return InternalBoxEnum(rtType, value); } - public static Object ToObject(Type enumType, byte value) + public static object ToObject(Type enumType, byte value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1131,7 +1131,7 @@ public static Object ToObject(Type enumType, byte value) } [CLSCompliant(false)] - public static Object ToObject(Type enumType, ushort value) + public static object ToObject(Type enumType, ushort value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1144,7 +1144,7 @@ public static Object ToObject(Type enumType, ushort value) } [CLSCompliant(false)] - public static Object ToObject(Type enumType, uint value) + public static object ToObject(Type enumType, uint value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1156,7 +1156,7 @@ public static Object ToObject(Type enumType, uint value) return InternalBoxEnum(rtType, value); } - public static Object ToObject(Type enumType, long value) + public static object ToObject(Type enumType, long value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1169,7 +1169,7 @@ public static Object ToObject(Type enumType, long value) } [CLSCompliant(false)] - public static Object ToObject(Type enumType, ulong value) + public static object ToObject(Type enumType, ulong value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1181,7 +1181,7 @@ public static Object ToObject(Type enumType, ulong value) return InternalBoxEnum(rtType, unchecked((long)value)); } - private static Object ToObject(Type enumType, char value) + private static object ToObject(Type enumType, char value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); @@ -1193,7 +1193,7 @@ private static Object ToObject(Type enumType, char value) return InternalBoxEnum(rtType, value); } - private static Object ToObject(Type enumType, bool value) + private static object ToObject(Type enumType, bool value) { if (enumType == null) throw new ArgumentNullException(nameof(enumType)); diff --git a/src/System.Private.CoreLib/src/System/Environment.cs b/src/System.Private.CoreLib/src/System/Environment.cs index 902c6769acd4..bfd9e06e1241 100644 --- a/src/System.Private.CoreLib/src/System/Environment.cs +++ b/src/System.Private.CoreLib/src/System/Environment.cs @@ -57,7 +57,7 @@ internal static partial class Environment // if you change this method's signature then you must change the code that calls it // in excep.cpp and probably you will have to visit mscorlib.h to add the new signature // as well as metasig.h to create the new signature type - internal static String GetResourceStringLocal(String key) + internal static string GetResourceStringLocal(string key) { return SR.GetResourceString(key); } @@ -97,7 +97,7 @@ public static extern int ExitCode // to assign blame for crashes. Don't mess with this, such as by making it call // another managed helper method, unless you consult with some CLR Watson experts. [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void FailFast(String message); + public static extern void FailFast(string message); // This overload of FailFast will allow you to specify the exception object // whose bucket details *could* be used when undergoing the failfast process. @@ -113,14 +113,14 @@ public static extern int ExitCode // IP for bucketing. If the exception object is not preallocated, it will use the bucket // details contained in the object (if any). [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void FailFast(String message, Exception exception); + public static extern void FailFast(string message, Exception exception); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void FailFast(String message, Exception exception, String errorMessage); + public static extern void FailFast(string message, Exception exception, string errorMessage); #if FEATURE_WIN32_REGISTRY // This is only used by RegistryKey on Windows. - public static String ExpandEnvironmentVariables(String name) + public static string ExpandEnvironmentVariables(string name) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -156,7 +156,7 @@ public static String ExpandEnvironmentVariables(String name) #endif // FEATURE_WIN32_REGISTRY [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern Int32 GetProcessorCount(); + private static extern int GetProcessorCount(); public static int ProcessorCount { @@ -173,7 +173,7 @@ public static int ProcessorCount **Arguments: None **Exceptions: None. ==============================================================================*/ - public static String[] GetCommandLineArgs() + public static string[] GetCommandLineArgs() { /* * There are multiple entry points to a hosted app. @@ -195,7 +195,7 @@ public static String[] GetCommandLineArgs() } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern String[] GetCommandLineArgsNative(); + private static extern string[] GetCommandLineArgsNative(); private static string[] s_CommandLineArgs = null; private static void SetCommandLineArgs(string[] cmdLineArgs) @@ -251,7 +251,7 @@ private static unsafe char[] GetEnvironmentCharArray() **Arguments: None. **Exceptions: None. ==============================================================================*/ - public static String NewLine + public static string NewLine { get { @@ -321,7 +321,7 @@ public static Version Version **Arguments: **Exceptions: ==============================================================================*/ - public static String StackTrace + public static string StackTrace { [MethodImpl(MethodImplOptions.NoInlining)] // Prevent inlining from affecting where the stacktrace starts get @@ -330,7 +330,7 @@ public static String StackTrace } } - internal static String GetStackTrace(Exception e, bool needFileInfo) + internal static string GetStackTrace(Exception e, bool needFileInfo) { // Note: Setting needFileInfo to true will start up COM and set our // apartment state. Try to not call this when passing "true" diff --git a/src/System.Private.CoreLib/src/System/Exception.cs b/src/System.Private.CoreLib/src/System/Exception.cs index daa687d59e26..b45100042117 100644 --- a/src/System.Private.CoreLib/src/System/Exception.cs +++ b/src/System.Private.CoreLib/src/System/Exception.cs @@ -51,7 +51,7 @@ public Exception() Init(); } - public Exception(String message) + public Exception(string message) { Init(); _message = message; @@ -62,7 +62,7 @@ public Exception(String message) // Note: the stack trace is not started until the exception // is thrown // - public Exception(String message, Exception innerException) + public Exception(string message, Exception innerException) { Init(); _message = message; @@ -92,7 +92,7 @@ protected Exception(SerializationInfo info, StreamingContext context) // We use the no throw version since we could be deserializing a pre-V4 // exception object that may not have this entry. In such a case, we would // get null. - _watsonBuckets = (Object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization) + _watsonBuckets = (object)info.GetValueNoThrow("WatsonBuckets", typeof(byte[])); // Do not rename (binary serialization) if (_className == null || HResult == 0) @@ -118,7 +118,7 @@ protected Exception(SerializationInfo info, StreamingContext context) } - public virtual String Message + public virtual string Message { get { @@ -183,7 +183,6 @@ public object RealErrorObject } } - // [FriendAccessAllowed] internal void AddExceptionDataForRestrictedErrorInfo( string restrictedError, string restrictedErrorReference, @@ -258,7 +257,7 @@ public Exception InnerException [MethodImplAttribute(MethodImplOptions.InternalCall)] - static private extern IRuntimeMethodInfo GetMethodFromStackTrace(Object stackTrace); + static private extern IRuntimeMethodInfo GetMethodFromStackTrace(object stackTrace); private MethodBase GetExceptionMethodFromStackTrace() { @@ -298,7 +297,7 @@ private MethodBase GetTargetSiteInternal() // Returns the stack trace as a string. If no stack trace is // available, null is returned. - public virtual String StackTrace + public virtual string StackTrace { get { @@ -331,7 +330,7 @@ private string GetStackTrace(bool needFileInfo) // will add the path to the source file if the PDB is present and a demand // for FileIOPermission(PathDiscovery) succeeds, we need to make sure we // don't store the stack trace string in the _stackTraceString member variable. - String tempStackTraceString = Environment.GetStackTrace(this, needFileInfo); + string tempStackTraceString = Environment.GetStackTrace(this, needFileInfo); return remoteStackTraceString + tempStackTraceString; } @@ -339,7 +338,7 @@ private string GetStackTrace(bool needFileInfo) // This should be in a URL/URN form, such as: // "file:///C:/Applications/Bazzal/help.html#ErrorNum42" // Changed to be a read-write String and not return an exception - public virtual String HelpLink + public virtual string HelpLink { get { @@ -351,7 +350,7 @@ public virtual String HelpLink } } - public virtual String Source + public virtual string Source { get { @@ -385,15 +384,15 @@ public virtual String Source set { _source = value; } } - public override String ToString() + public override string ToString() { return ToString(true, true); } - private String ToString(bool needFileLineInfo, bool needMessage) + private string ToString(bool needFileLineInfo, bool needMessage) { - String message = (needMessage ? Message : null); - String s; + string message = (needMessage ? Message : null); + string s; if (message == null || message.Length <= 0) { @@ -432,7 +431,7 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte throw new ArgumentNullException(nameof(info)); } - String tempStackTraceString = _stackTraceString; + string tempStackTraceString = _stackTraceString; if (_stackTrace != null) { @@ -451,17 +450,17 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte _source = Source; // Set the Source information correctly before serialization } - info.AddValue("ClassName", GetClassName(), typeof(String)); // Do not rename (binary serialization) - info.AddValue("Message", _message, typeof(String)); // Do not rename (binary serialization) + info.AddValue("ClassName", GetClassName(), typeof(string)); // Do not rename (binary serialization) + info.AddValue("Message", _message, typeof(string)); // Do not rename (binary serialization) info.AddValue("Data", _data, typeof(IDictionary)); // Do not rename (binary serialization) info.AddValue("InnerException", _innerException, typeof(Exception)); // Do not rename (binary serialization) - info.AddValue("HelpURL", _helpURL, typeof(String)); // Do not rename (binary serialization) - info.AddValue("StackTraceString", tempStackTraceString, typeof(String)); // Do not rename (binary serialization) - info.AddValue("RemoteStackTraceString", _remoteStackTraceString, typeof(String)); // Do not rename (binary serialization) - info.AddValue("RemoteStackIndex", _remoteStackIndex, typeof(Int32)); // Do not rename (binary serialization) - info.AddValue("ExceptionMethod", null, typeof(String)); // Do not rename (binary serialization) + info.AddValue("HelpURL", _helpURL, typeof(string)); // Do not rename (binary serialization) + info.AddValue("StackTraceString", tempStackTraceString, typeof(string)); // Do not rename (binary serialization) + info.AddValue("RemoteStackTraceString", _remoteStackTraceString, typeof(string)); // Do not rename (binary serialization) + info.AddValue("RemoteStackIndex", _remoteStackIndex, typeof(int)); // Do not rename (binary serialization) + info.AddValue("ExceptionMethod", null, typeof(string)); // Do not rename (binary serialization) info.AddValue("HResult", HResult); // Do not rename (binary serialization) - info.AddValue("Source", _source, typeof(String)); // Do not rename (binary serialization) + info.AddValue("Source", _source, typeof(string)); // Do not rename (binary serialization) // Serialize the Watson bucket details as well info.AddValue("WatsonBuckets", _watsonBuckets, typeof(byte[])); // Do not rename (binary serialization) @@ -646,24 +645,24 @@ internal void RestoreExceptionDispatchInfo(System.Runtime.ExceptionServices.Exce } } - private String _className; //Needed for serialization. + private string _className; //Needed for serialization. private MethodBase _exceptionMethod; //Needed for serialization. - internal String _message; + internal string _message; private IDictionary _data; private Exception _innerException; - private String _helpURL; - private Object _stackTrace; + private string _helpURL; + private object _stackTrace; [OptionalField] // This isnt present in pre-V4 exception objects that would be serialized. - private Object _watsonBuckets; - private String _stackTraceString; //Needed for serialization. - private String _remoteStackTraceString; + private object _watsonBuckets; + private string _stackTraceString; //Needed for serialization. + private string _remoteStackTraceString; private int _remoteStackIndex; #pragma warning disable 414 // Field is not used from managed. // _dynamicMethods is an array of System.Resolver objects, used to keep // DynamicMethodDescs alive for the lifetime of the exception. We do this because // the _stackTrace field holds MethodDescs, and a DynamicMethodDesc can be destroyed // unless a System.Resolver object roots it. - private Object _dynamicMethods; + private object _dynamicMethods; #pragma warning restore 414 // @MANAGED: HResult is used from within the EE! Rename with care - check VM directory @@ -681,7 +680,7 @@ public int HResult } } - private String _source; // Mainly used by VB. + private string _source; // Mainly used by VB. // WARNING: Don't delete/rename _xptrs and _xcode - used by functions // on Marshal class. Native functions are in COMUtilNative.cpp & AppDomain private IntPtr _xptrs; // Internal EE stuff @@ -697,7 +696,7 @@ public int HResult // InternalToString is called by the runtime to get the exception text // and create a corresponding CrossAppDomainMarshaledException - internal virtual String InternalToString() + internal virtual string InternalToString() { // Get the current stack trace string. return ToString(true, true); @@ -738,7 +737,7 @@ internal enum ExceptionMessageKind } // See comment on ExceptionMessageKind - internal static String GetMessageFromNativeResources(ExceptionMessageKind kind) + internal static string GetMessageFromNativeResources(ExceptionMessageKind kind) { string retMesg = null; GetMessageFromNativeResources(kind, JitHelpers.GetStringHandleOnStack(ref retMesg)); @@ -758,7 +757,7 @@ internal static String GetMessageFromNativeResources(ExceptionMessageKind kind) internal sealed class CrossAppDomainMarshaledException : SystemException { - public CrossAppDomainMarshaledException(String message, int errorCode) + public CrossAppDomainMarshaledException(string message, int errorCode) : base(message) { HResult = errorCode; @@ -767,7 +766,7 @@ public CrossAppDomainMarshaledException(String message, int errorCode) // Normally, only Telesto's UEF will see these exceptions. // This override prints out the original Exception's ToString() // output and hides the fact that it is wrapped inside another excepton. - internal override String InternalToString() + internal override string InternalToString() { return Message; } diff --git a/src/System.Private.CoreLib/src/System/GC.cs b/src/System.Private.CoreLib/src/System/GC.cs index dd75601a5c78..aac612a63ae8 100644 --- a/src/System.Private.CoreLib/src/System/GC.cs +++ b/src/System.Private.CoreLib/src/System/GC.cs @@ -105,10 +105,10 @@ internal static extern void GetMemoryInfo(out uint highMemLoadThreshold, internal static extern bool IsServerGC(); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void _AddMemoryPressure(UInt64 bytesAllocated); + private static extern void _AddMemoryPressure(ulong bytesAllocated); [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void _RemoveMemoryPressure(UInt64 bytesAllocated); + private static extern void _RemoveMemoryPressure(ulong bytesAllocated); public static void AddMemoryPressure(long bytesAllocated) { @@ -118,7 +118,7 @@ public static void AddMemoryPressure(long bytesAllocated) SR.ArgumentOutOfRange_NeedPosNum); } - if ((4 == IntPtr.Size) && (bytesAllocated > Int32.MaxValue)) + if ((4 == IntPtr.Size) && (bytesAllocated > int.MaxValue)) { throw new ArgumentOutOfRangeException("pressure", SR.ArgumentOutOfRange_MustBeNonNegInt32); @@ -135,7 +135,7 @@ public static void RemoveMemoryPressure(long bytesAllocated) SR.ArgumentOutOfRange_NeedPosNum); } - if ((4 == IntPtr.Size) && (bytesAllocated > Int32.MaxValue)) + if ((4 == IntPtr.Size) && (bytesAllocated > int.MaxValue)) { throw new ArgumentOutOfRangeException(nameof(bytesAllocated), SR.ArgumentOutOfRange_MustBeNonNegInt32); @@ -148,7 +148,7 @@ public static void RemoveMemoryPressure(long bytesAllocated) // Returns the generation that obj is currently in. // [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern int GetGeneration(Object obj); + public static extern int GetGeneration(object obj); // Forces a collection of all generations from 0 through Generation. @@ -256,7 +256,7 @@ public static int CollectionCount(int generation) // If we insert a call to GC.KeepAlive(this) at the end of Problem(), then // Foo doesn't get finalized and the stream stays open. [MethodImplAttribute(MethodImplOptions.NoInlining)] // disable optimizations - public static void KeepAlive(Object obj) + public static void KeepAlive(object obj) { } @@ -288,9 +288,9 @@ public static void WaitForPendingFinalizers() // Indicates that the system should not call the Finalize() method on // an object that would normally require this call. [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void _SuppressFinalize(Object o); + private static extern void _SuppressFinalize(object o); - public static void SuppressFinalize(Object obj) + public static void SuppressFinalize(object obj) { if (obj == null) throw new ArgumentNullException(nameof(obj)); @@ -302,9 +302,9 @@ public static void SuppressFinalize(Object obj) // where calling ReRegisterForFinalize is useful is inside a finalizer that // needs to resurrect itself or an object that it references. [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void _ReRegisterForFinalize(Object o); + private static extern void _ReRegisterForFinalize(object o); - public static void ReRegisterForFinalize(Object obj) + public static void ReRegisterForFinalize(object obj) { if (obj == null) throw new ArgumentNullException(nameof(obj)); diff --git a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs index d9ce874ad40f..107a08cf076a 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Windows.cs @@ -11,6 +11,7 @@ using System.Threading; #if FEATURE_APPX using System.Resources; +using Internal.Resources; #endif namespace System.Globalization @@ -92,7 +93,7 @@ private static CultureInfo GetUserDefaultUICulture() index++; } - CultureInfo temp = GetCultureByName(new String(languages, 0, index), true); + CultureInfo temp = GetCultureByName(new string(languages, 0, index), true); temp._isReadOnly = true; return temp; } diff --git a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs index 7929956393e8..f0da4bf1918c 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.cs @@ -371,7 +371,7 @@ internal static bool VerifyCultureName(string cultureName, bool throwException) { char c = cultureName[i]; // TODO: Names can only be RFC4646 names (ie: a-zA-Z0-9) while this allows any unicode letter/digit - if (Char.IsLetterOrDigit(c) || c == '-' || c == '_') + if (char.IsLetterOrDigit(c) || c == '-' || c == '_') { continue; } @@ -736,15 +736,15 @@ public virtual TextInfo TextInfo // // Equals // - // Implements Object.Equals(). Returns a boolean indicating whether + // Implements object.Equals(). Returns a boolean indicating whether // or not object refers to the same CultureInfo as the current instance. // //////////////////////////////////////////////////////////////////////// - public override bool Equals(Object value) + public override bool Equals(object value) { - if (Object.ReferenceEquals(this, value)) + if (object.ReferenceEquals(this, value)) return true; CultureInfo that = value as CultureInfo; @@ -765,7 +765,7 @@ public override bool Equals(Object value) // // GetHashCode // - // Implements Object.GetHashCode(). Returns the hash code for the + // Implements object.GetHashCode(). Returns the hash code for the // CultureInfo. The hash code is guaranteed to be the same for CultureInfo A // and B where A.Equals(B) is true. // @@ -781,7 +781,7 @@ public override int GetHashCode() // // ToString // - // Implements Object.ToString(). Returns the name of the CultureInfo, + // Implements object.ToString(). Returns the name of the CultureInfo, // eg. "de-DE_phoneb", "en-US", or "fj-FJ". // //////////////////////////////////////////////////////////////////////// diff --git a/src/System.Private.CoreLib/src/System/Internal.cs b/src/System.Private.CoreLib/src/System/Internal.cs index a3aa9d274a14..033ae9aa9971 100644 --- a/src/System.Private.CoreLib/src/System/Internal.cs +++ b/src/System.Private.CoreLib/src/System/Internal.cs @@ -59,91 +59,91 @@ static CommonlyUsedGenericInstantiations() new ArraySegment(new byte[1], 0, 0); - new Dictionary(); - new Dictionary(); - new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); new Dictionary(); // Added for Visual Studio 2010 - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); - new Dictionary(); // Added for Visual Studio 2010 + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); // Added for Visual Studio 2010 new Dictionary(); // NCL team needs this - new Dictionary(); - new Dictionary(); - new Dictionary(); + new Dictionary(); + new Dictionary(); + new Dictionary(); // to genereate mdil for Dictionary instantiation when key is user defined value type - new Dictionary(); + new Dictionary(); // Microsoft.Windows.Design - new Dictionary(); + new Dictionary(); new EnumEqualityComparer(); // Microsoft.Expression.DesignModel - new Dictionary>(); - new Dictionary, Object>(); + new Dictionary>(); + new Dictionary, object>(); - NullableHelper(); - NullableHelper(); - NullableHelper(); + NullableHelper(); + NullableHelper(); + NullableHelper(); NullableHelper(); - NullableHelper(); - NullableHelper(); + NullableHelper(); + NullableHelper(); NullableHelper(); - NullableHelper(); - NullableHelper(); - NullableHelper(); - NullableHelper(); + NullableHelper(); + NullableHelper(); + NullableHelper(); + NullableHelper(); NullableHelper(); NullableHelper(); // For SQL - new List(); - new List(); - new List(); + new List(); + new List(); + new List(); new List(); - new List(); - new List(); + new List(); + new List(); new List(); - new List(); - new List(); - new List(); + new List(); + new List(); + new List(); new List(); - new List(); - new List(); - new List(); - new List(); - new List(); + new List(); + new List(); + new List(); + new List(); + new List(); new List(); - new List>(); + new List>(); new List(); // NCL team needs this new List(); - new KeyValuePair('\0', UInt16.MinValue); - new KeyValuePair(UInt16.MinValue, Double.MinValue); - new KeyValuePair(string.Empty, Int32.MinValue); - new KeyValuePair(Int32.MinValue, Int32.MinValue); - SZArrayHelper(null); - SZArrayHelper(null); + new KeyValuePair('\0', ushort.MinValue); + new KeyValuePair(ushort.MinValue, double.MinValue); + new KeyValuePair(string.Empty, int.MinValue); + new KeyValuePair(int.MinValue, int.MinValue); + SZArrayHelper(null); + SZArrayHelper(null); SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); - SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); + SZArrayHelper(null); SZArrayHelper(null); SZArrayHelper(null); @@ -181,7 +181,7 @@ private static async void AsyncHelper() } // System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[System.__Canon] // System.Runtime.CompilerServices.TaskAwaiter'[System.__Canon] - private static async Task AsyncHelper2() + private static async Task AsyncHelper2() { return await Task.FromResult(""); } diff --git a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs index ef630bc15829..263481946c5e 100644 --- a/src/System.Private.CoreLib/src/System/MulticastDelegate.cs +++ b/src/System.Private.CoreLib/src/System/MulticastDelegate.cs @@ -18,20 +18,20 @@ public abstract class MulticastDelegate : Delegate // 1. Multicast delegate // 2. Secure/Wrapper delegate // 3. Inner delegate of secure delegate where the secure delegate security context is a collectible method - private Object _invocationList; + private object _invocationList; private IntPtr _invocationCount; // This constructor is called from the class generated by the // compiler generated code (This must match the constructor // in Delegate - protected MulticastDelegate(Object target, String method) : base(target, method) + protected MulticastDelegate(object target, string method) : base(target, method) { } // This constructor is called from a class to generate a // delegate based upon a static method name and the Type object // for the class defining the method. - protected MulticastDelegate(Type target, String method) : base(target, method) + protected MulticastDelegate(Type target, string method) : base(target, method) { } @@ -52,7 +52,7 @@ public override void GetObjectData(SerializationInfo info, StreamingContext cont // equals returns true IIF the delegate is not null and has the // same target, method and invocation list as this object - public override sealed bool Equals(Object obj) + public override sealed bool Equals(object obj) { if (obj == null) return false; @@ -101,7 +101,7 @@ public override sealed bool Equals(Object obj) } else { - Debug.Assert((_invocationList as Object[]) != null, "empty invocation list on multicast delegate"); + Debug.Assert((_invocationList as object[]) != null, "empty invocation list on multicast delegate"); return InvocationListEquals(d); } } @@ -132,8 +132,8 @@ public override sealed bool Equals(Object obj) // Recursive function which will check for equality of the invocation list. private bool InvocationListEquals(MulticastDelegate d) { - Debug.Assert(d != null && (_invocationList as Object[]) != null, "bogus delegate in multicast list comparison"); - Object[] invocationList = _invocationList as Object[]; + Debug.Assert(d != null && (_invocationList as object[]) != null, "bogus delegate in multicast list comparison"); + object[] invocationList = _invocationList as object[]; if (d._invocationCount != _invocationCount) return false; @@ -141,16 +141,16 @@ private bool InvocationListEquals(MulticastDelegate d) for (int i = 0; i < invocationCount; i++) { Delegate dd = (Delegate)invocationList[i]; - Object[] dInvocationList = d._invocationList as Object[]; + object[] dInvocationList = d._invocationList as object[]; if (!dd.Equals(dInvocationList[i])) return false; } return true; } - private bool TrySetSlot(Object[] a, int index, Object o) + private bool TrySetSlot(object[] a, int index, object o) { - if (a[index] == null && System.Threading.Interlocked.CompareExchange(ref a[index], o, null) == null) + if (a[index] == null && System.Threading.Interlocked.CompareExchange(ref a[index], o, null) == null) return true; // The slot may be already set because we have added and removed the same method before. @@ -170,7 +170,7 @@ private bool TrySetSlot(Object[] a, int index, Object o) return false; } - private MulticastDelegate NewMulticastDelegate(Object[] invocationList, int invocationCount, bool thisIsMultiCastAlready) + private MulticastDelegate NewMulticastDelegate(object[] invocationList, int invocationCount, bool thisIsMultiCastAlready) { // First, allocate a new multicast delegate just like this one, i.e. same type as the this object MulticastDelegate result = (MulticastDelegate)InternalAllocLike(this); @@ -194,7 +194,7 @@ private MulticastDelegate NewMulticastDelegate(Object[] invocationList, int invo return result; } - internal MulticastDelegate NewMulticastDelegate(Object[] invocationList, int invocationCount) + internal MulticastDelegate NewMulticastDelegate(object[] invocationList, int invocationCount) { return NewMulticastDelegate(invocationList, invocationCount, false); } @@ -216,7 +216,7 @@ internal void StoreDynamicMethod(MethodInfo dynamicMethod) // to form a new delegate. protected override sealed Delegate CombineImpl(Delegate follow) { - if ((Object)follow == null) // cast to object for a more efficient test + if ((object)follow == null) // cast to object for a more efficient test return this; // Verify that the types are the same... @@ -224,18 +224,18 @@ protected override sealed Delegate CombineImpl(Delegate follow) throw new ArgumentException(SR.Arg_DlgtTypeMis); MulticastDelegate dFollow = (MulticastDelegate)follow; - Object[] resultList; + object[] resultList; int followCount = 1; - Object[] followList = dFollow._invocationList as Object[]; + object[] followList = dFollow._invocationList as object[]; if (followList != null) followCount = (int)dFollow._invocationCount; int resultCount; - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList == null) { resultCount = 1 + followCount; - resultList = new Object[resultCount]; + resultList = new object[resultCount]; resultList[0] = this; if (followList == null) { @@ -280,7 +280,7 @@ protected override sealed Delegate CombineImpl(Delegate follow) while (allocCount < resultCount) allocCount *= 2; - resultList = new Object[allocCount]; + resultList = new object[allocCount]; for (int i = 0; i < invocationCount; i++) resultList[i] = invocationList[i]; @@ -299,14 +299,14 @@ protected override sealed Delegate CombineImpl(Delegate follow) } } - private Object[] DeleteFromInvocationList(Object[] invocationList, int invocationCount, int deleteIndex, int deleteCount) + private object[] DeleteFromInvocationList(object[] invocationList, int invocationCount, int deleteIndex, int deleteCount) { - Object[] thisInvocationList = _invocationList as Object[]; + object[] thisInvocationList = _invocationList as object[]; int allocCount = thisInvocationList.Length; while (allocCount / 2 >= invocationCount - deleteCount) allocCount /= 2; - Object[] newInvocationList = new Object[allocCount]; + object[] newInvocationList = new object[allocCount]; for (int i = 0; i < deleteIndex; i++) newInvocationList[i] = invocationList[i]; @@ -317,7 +317,7 @@ private Object[] DeleteFromInvocationList(Object[] invocationList, int invocatio return newInvocationList; } - private bool EqualInvocationLists(Object[] a, Object[] b, int start, int count) + private bool EqualInvocationLists(object[] a, object[] b, int start, int count) { for (int i = 0; i < count; i++) { @@ -341,9 +341,9 @@ protected override sealed Delegate RemoveImpl(Delegate value) if (v == null) return this; - if (v._invocationList as Object[] == null) + if (v._invocationList as object[] == null) { - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList == null) { // they are both not real Multicast @@ -364,7 +364,7 @@ protected override sealed Delegate RemoveImpl(Delegate value) } else { - Object[] list = DeleteFromInvocationList(invocationList, invocationCount, i, 1); + object[] list = DeleteFromInvocationList(invocationList, invocationCount, i, 1); return NewMulticastDelegate(list, invocationCount - 1, true); } } @@ -373,14 +373,14 @@ protected override sealed Delegate RemoveImpl(Delegate value) } else { - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList != null) { int invocationCount = (int)_invocationCount; int vInvocationCount = (int)v._invocationCount; for (int i = invocationCount - vInvocationCount; i >= 0; i--) { - if (EqualInvocationLists(invocationList, v._invocationList as Object[], i, vInvocationCount)) + if (EqualInvocationLists(invocationList, v._invocationList as object[], i, vInvocationCount)) { if (invocationCount - vInvocationCount == 0) { @@ -394,7 +394,7 @@ protected override sealed Delegate RemoveImpl(Delegate value) } else { - Object[] list = DeleteFromInvocationList(invocationList, invocationCount, i, vInvocationCount); + object[] list = DeleteFromInvocationList(invocationList, invocationCount, i, vInvocationCount); return NewMulticastDelegate(list, invocationCount - vInvocationCount, true); } } @@ -409,7 +409,7 @@ protected override sealed Delegate RemoveImpl(Delegate value) public override sealed Delegate[] GetInvocationList() { Delegate[] del; - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList == null) { del = new Delegate[1]; @@ -463,7 +463,7 @@ public override sealed int GetHashCode() } } - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList == null) { return base.GetHashCode(); @@ -480,7 +480,7 @@ public override sealed int GetHashCode() } } - internal override Object GetTarget() + internal override object GetTarget() { if (_invocationCount != (IntPtr)0) { @@ -496,7 +496,7 @@ internal override Object GetTarget() } else { - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList != null) { int invocationCount = (int)_invocationCount; @@ -518,7 +518,7 @@ protected override MethodInfo GetMethodImpl() if (_invocationCount != (IntPtr)0 && _invocationList != null) { // multicast case - Object[] invocationList = _invocationList as Object[]; + object[] invocationList = _invocationList as object[]; if (invocationList != null) { int index = (int)_invocationCount - 1; @@ -564,7 +564,7 @@ private void ThrowNullThisInDelegateToInstance() } [System.Diagnostics.DebuggerNonUserCode] - private void CtorClosed(Object target, IntPtr methodPtr) + private void CtorClosed(object target, IntPtr methodPtr) { if (target == null) ThrowNullThisInDelegateToInstance(); @@ -573,21 +573,21 @@ private void CtorClosed(Object target, IntPtr methodPtr) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorClosedStatic(Object target, IntPtr methodPtr) + private void CtorClosedStatic(object target, IntPtr methodPtr) { this._target = target; this._methodPtr = methodPtr; } [System.Diagnostics.DebuggerNonUserCode] - private void CtorRTClosed(Object target, IntPtr methodPtr) + private void CtorRTClosed(object target, IntPtr methodPtr) { this._target = target; this._methodPtr = AdjustTarget(target, methodPtr); } [System.Diagnostics.DebuggerNonUserCode] - private void CtorOpened(Object target, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -595,7 +595,7 @@ private void CtorOpened(Object target, IntPtr methodPtr, IntPtr shuffleThunk) } [System.Diagnostics.DebuggerNonUserCode] - private void CtorVirtualDispatch(Object target, IntPtr methodPtr, IntPtr shuffleThunk) + private void CtorVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk) { this._target = this; this._methodPtr = shuffleThunk; @@ -603,7 +603,7 @@ private void CtorVirtualDispatch(Object target, IntPtr methodPtr, IntPtr shuffle } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleClosedStatic(Object target, IntPtr methodPtr, IntPtr gchandle) + private void CtorCollectibleClosedStatic(object target, IntPtr methodPtr, IntPtr gchandle) { this._target = target; this._methodPtr = methodPtr; @@ -611,7 +611,7 @@ private void CtorCollectibleClosedStatic(Object target, IntPtr methodPtr, IntPtr } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleOpened(Object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleOpened(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; @@ -620,7 +620,7 @@ private void CtorCollectibleOpened(Object target, IntPtr methodPtr, IntPtr shuff } [System.Diagnostics.DebuggerNonUserCode] - private void CtorCollectibleVirtualDispatch(Object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) + private void CtorCollectibleVirtualDispatch(object target, IntPtr methodPtr, IntPtr shuffleThunk, IntPtr gchandle) { this._target = this; this._methodPtr = shuffleThunk; diff --git a/src/System.Private.CoreLib/src/System/Number.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Number.CoreCLR.cs index e14db0276235..30e70d0bd7cd 100644 --- a/src/System.Private.CoreLib/src/System/Number.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Number.CoreCLR.cs @@ -13,8 +13,5 @@ internal static partial class Number [MethodImpl(MethodImplOptions.InternalCall)] public static extern double NumberToDouble(ref NumberBuffer number); - - [MethodImpl(MethodImplOptions.InternalCall)] - public static extern bool NumberBufferToDecimal(ref NumberBuffer number, ref decimal value); } } diff --git a/src/System.Private.CoreLib/src/System/Numerics/Hashing/HashHelpers.cs b/src/System.Private.CoreLib/src/System/Numerics/Hashing/HashHelpers.cs index f017309a9041..dd405eba78f3 100644 --- a/src/System.Private.CoreLib/src/System/Numerics/Hashing/HashHelpers.cs +++ b/src/System.Private.CoreLib/src/System/Numerics/Hashing/HashHelpers.cs @@ -8,7 +8,7 @@ namespace System.Numerics.Hashing internal static class HashHelpers { - public static readonly int RandomSeed = new Random().Next(Int32.MinValue, Int32.MaxValue); + public static readonly int RandomSeed = new Random().Next(int.MinValue, int.MaxValue); public static int Combine(int h1, int h2) { diff --git a/src/System.Private.CoreLib/src/System/Object.cs b/src/System.Private.CoreLib/src/System/Object.cs index 01e60ce82679..7cb584af4e26 100644 --- a/src/System.Private.CoreLib/src/System/Object.cs +++ b/src/System.Private.CoreLib/src/System/Object.cs @@ -57,12 +57,12 @@ public virtual string ToString() // replace Equals with EqualsValue for value types). // - public virtual bool Equals(Object obj) + public virtual bool Equals(object obj) { return RuntimeHelpers.Equals(this, obj); } - public static bool Equals(Object objA, Object objB) + public static bool Equals(object objA, object objB) { if (objA == objB) { @@ -76,7 +76,7 @@ public static bool Equals(Object objA, Object objB) } [System.Runtime.Versioning.NonVersionable] - public static bool ReferenceEquals(Object objA, Object objB) + public static bool ReferenceEquals(object objA, object objB) { return objA == objB; } @@ -113,12 +113,12 @@ public virtual int GetHashCode() // support the ICloneable interface. // [MethodImplAttribute(MethodImplOptions.InternalCall)] - protected extern Object MemberwiseClone(); + protected extern object MemberwiseClone(); // Sets the value specified in the variant on the field // - private void FieldSetter(string typeName, string fieldName, Object val) + private void FieldSetter(string typeName, string fieldName, object val) { Debug.Assert(typeName != null); Debug.Assert(fieldName != null); @@ -148,7 +148,7 @@ private void FieldSetter(string typeName, string fieldName, Object val) // Gets the value specified in the variant on the field // - private void FieldGetter(string typeName, string fieldName, ref Object val) + private void FieldGetter(string typeName, string fieldName, ref object val) { Debug.Assert(typeName != null); Debug.Assert(fieldName != null); diff --git a/src/System.Private.CoreLib/src/System/OleAutBinder.cs b/src/System.Private.CoreLib/src/System/OleAutBinder.cs index 3a9f03c5f079..b0942232f2c1 100644 --- a/src/System.Private.CoreLib/src/System/OleAutBinder.cs +++ b/src/System.Private.CoreLib/src/System/OleAutBinder.cs @@ -19,7 +19,7 @@ internal class OleAutBinder : DefaultBinder { // ChangeType // This binder uses OLEAUT to change the type of the variant. - public override Object ChangeType(Object value, Type type, CultureInfo cultureInfo) + public override object ChangeType(object value, Type type, CultureInfo cultureInfo) { Variant myValue = new Variant(value); if (cultureInfo == null) @@ -66,7 +66,7 @@ public override Object ChangeType(Object value, Type type, CultureInfo cultureIn #endif // Specify the LocalBool flag to have BOOL values converted to local language rather // than 0 or -1. - Object RetObj = OAVariantLib.ChangeType(myValue, type, OAVariantLib.LocalBool, cultureInfo).ToObject(); + object RetObj = OAVariantLib.ChangeType(myValue, type, OAVariantLib.LocalBool, cultureInfo).ToObject(); #if DISPLAY_DEBUG_INFO Console.WriteLine("Object returned from ChangeType is of type: " + RetObj.GetType().Name); diff --git a/src/System.Private.CoreLib/src/System/PinnableBufferCache.cs b/src/System.Private.CoreLib/src/System/PinnableBufferCache.cs deleted file mode 100644 index 1bfd2cf07b3e..000000000000 --- a/src/System.Private.CoreLib/src/System/PinnableBufferCache.cs +++ /dev/null @@ -1,445 +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. -#define ENABLE -#define MINBUFFERS - -using System; -using System.Runtime.InteropServices; -using System.Runtime.ConstrainedExecution; -using System.Collections.Generic; -using System.Collections.Concurrent; -using System.Threading; -using System.Runtime.CompilerServices; -using System.Diagnostics; - -#if PINNABLEBUFFERCACHE_MSCORLIB -namespace System.Threading -#else -namespace System -#endif -{ - internal sealed class PinnableBufferCache - { - /// - /// Create a PinnableBufferCache that works on any object (it is intended for OverlappedData) - /// This is only used in mscorlib. - /// - internal PinnableBufferCache(string cacheName, Func factory) - { - m_NotGen2 = new List(DefaultNumberOfBuffers); - m_factory = factory; -#if ENABLE - // Check to see if we should disable the cache. - string envVarName = "PinnableBufferCache_" + cacheName + "_Disabled"; - try - { - string envVar = Environment.GetEnvironmentVariable(envVarName); - if (envVar != null) - { - PinnableBufferCacheEventSource.Log.DebugMessage("Creating " + cacheName + " PinnableBufferCacheDisabled=" + envVar); - int index = envVar.IndexOf(cacheName, StringComparison.OrdinalIgnoreCase); - if (0 <= index) - { - // The cache is disabled because we haven't set the cache name. - PinnableBufferCacheEventSource.Log.DebugMessage("Disabling " + cacheName); - return; - } - } - } - catch - { - // Ignore failures when reading the environment variable. - } -#endif -#if MINBUFFERS - // Allow the environment to specify a minimum buffer count. - string minEnvVarName = "PinnableBufferCache_" + cacheName + "_MinCount"; - try - { - string minEnvVar = Environment.GetEnvironmentVariable(minEnvVarName); - if (minEnvVar != null) - { - if (int.TryParse(minEnvVar, out m_minBufferCount)) - CreateNewBuffers(); - } - } - catch - { - // Ignore failures when reading the environment variable. - } -#endif - - PinnableBufferCacheEventSource.Log.Create(cacheName); - m_CacheName = cacheName; - } - - /// - /// Get a object from the buffer manager. If no buffers exist, allocate a new one. - /// - internal object Allocate() - { -#if ENABLE - // Check to see whether or not the cache is disabled. - if (m_CacheName == null) - return m_factory(); -#endif - // Fast path, get it from our Gen2 aged m_FreeList. - object returnBuffer; - if (!m_FreeList.TryPop(out returnBuffer)) - Restock(out returnBuffer); - - // Computing free count is expensive enough that we don't want to compute it unless logging is on. - if (PinnableBufferCacheEventSource.Log.IsEnabled()) - { - int numAllocCalls = Interlocked.Increment(ref m_numAllocCalls); - if (numAllocCalls >= 1024) - { - lock (this) - { - int previousNumAllocCalls = Interlocked.Exchange(ref m_numAllocCalls, 0); - if (previousNumAllocCalls >= 1024) - { - int nonGen2Count = 0; - foreach (object o in m_FreeList) - { - if (GC.GetGeneration(o) < GC.MaxGeneration) - { - nonGen2Count++; - } - } - - PinnableBufferCacheEventSource.Log.WalkFreeListResult(m_CacheName, m_FreeList.Count, nonGen2Count); - } - } - } - - PinnableBufferCacheEventSource.Log.AllocateBuffer(m_CacheName, PinnableBufferCacheEventSource.AddressOf(returnBuffer), returnBuffer.GetHashCode(), GC.GetGeneration(returnBuffer), m_FreeList.Count); - } - return returnBuffer; - } - - /// - /// Return a buffer back to the buffer manager. - /// - internal void Free(object buffer) - { -#if ENABLE - // Check to see whether or not the cache is disabled. - if (m_CacheName == null) - return; -#endif - if (PinnableBufferCacheEventSource.Log.IsEnabled()) - PinnableBufferCacheEventSource.Log.FreeBuffer(m_CacheName, PinnableBufferCacheEventSource.AddressOf(buffer), buffer.GetHashCode(), m_FreeList.Count); - - - // After we've done 3 gen1 GCs, assume that all buffers have aged into gen2 on the free path. - if ((m_gen1CountAtLastRestock + 3) > GC.CollectionCount(GC.MaxGeneration - 1)) - { - lock (this) - { - if (GC.GetGeneration(buffer) < GC.MaxGeneration) - { - // The buffer is not aged, so put it in the non-aged free list. - m_moreThanFreeListNeeded = true; - PinnableBufferCacheEventSource.Log.FreeBufferStillTooYoung(m_CacheName, m_NotGen2.Count); - m_NotGen2.Add(buffer); - m_gen1CountAtLastRestock = GC.CollectionCount(GC.MaxGeneration - 1); - return; - } - } - } - - // If we discovered that it is indeed Gen2, great, put it in the Gen2 list. - m_FreeList.Push(buffer); - } - - #region Private - - /// - /// Called when we don't have any buffers in our free list to give out. - /// - /// - private void Restock(out object returnBuffer) - { - lock (this) - { - // Try again after getting the lock as another thread could have just filled the free list. If we don't check - // then we unnecessarily grab a new set of buffers because we think we are out. - if (m_FreeList.TryPop(out returnBuffer)) - return; - - // Lazy init, Ask that TrimFreeListIfNeeded be called on every Gen 2 GC. - if (m_restockSize == 0) - Gen2GcCallback.Register(Gen2GcCallbackFunc, this); - - // Indicate to the trimming policy that the free list is insufficent. - m_moreThanFreeListNeeded = true; - PinnableBufferCacheEventSource.Log.AllocateBufferFreeListEmpty(m_CacheName, m_NotGen2.Count); - - // Get more buffers if needed. - if (m_NotGen2.Count == 0) - CreateNewBuffers(); - - // We have no buffers in the aged freelist, so get one from the newer list. Try to pick the best one. - // Debug.Assert(m_NotGen2.Count != 0); - int idx = m_NotGen2.Count - 1; - if (GC.GetGeneration(m_NotGen2[idx]) < GC.MaxGeneration && GC.GetGeneration(m_NotGen2[0]) == GC.MaxGeneration) - idx = 0; - returnBuffer = m_NotGen2[idx]; - m_NotGen2.RemoveAt(idx); - - // Remember any sub-optimial buffer so we don't put it on the free list when it gets freed. - if (PinnableBufferCacheEventSource.Log.IsEnabled() && GC.GetGeneration(returnBuffer) < GC.MaxGeneration) - { - PinnableBufferCacheEventSource.Log.AllocateBufferFromNotGen2(m_CacheName, m_NotGen2.Count); - } - - // If we have a Gen1 collection, then everything on m_NotGen2 should have aged. Move them to the m_Free list. - if (!AgePendingBuffers()) - { - // Before we could age at set of buffers, we have handed out half of them. - // This implies we should be proactive about allocating more (since we will trim them if we over-allocate). - if (m_NotGen2.Count == m_restockSize / 2) - { - PinnableBufferCacheEventSource.Log.DebugMessage("Proactively adding more buffers to aging pool"); - CreateNewBuffers(); - } - } - } - } - - /// - /// See if we can promote the buffers to the free list. Returns true if successful. - /// - private bool AgePendingBuffers() - { - if (m_gen1CountAtLastRestock < GC.CollectionCount(GC.MaxGeneration - 1)) - { - // Allocate a temp list of buffers that are not actually in gen2, and swap it in once - // we're done scanning all buffers. - int promotedCount = 0; - List notInGen2 = new List(); - PinnableBufferCacheEventSource.Log.AllocateBufferAged(m_CacheName, m_NotGen2.Count); - for (int i = 0; i < m_NotGen2.Count; i++) - { - // We actually check every object to ensure that we aren't putting non-aged buffers into the free list. - object currentBuffer = m_NotGen2[i]; - if (GC.GetGeneration(currentBuffer) >= GC.MaxGeneration) - { - m_FreeList.Push(currentBuffer); - promotedCount++; - } - else - { - notInGen2.Add(currentBuffer); - } - } - PinnableBufferCacheEventSource.Log.AgePendingBuffersResults(m_CacheName, promotedCount, notInGen2.Count); - m_NotGen2 = notInGen2; - - return true; - } - return false; - } - - /// - /// Generates some buffers to age into Gen2. - /// - private void CreateNewBuffers() - { - // We choose a very modest number of buffers initially because for the client case. This is often enough. - if (m_restockSize == 0) - m_restockSize = 4; - else if (m_restockSize < DefaultNumberOfBuffers) - m_restockSize = DefaultNumberOfBuffers; - else if (m_restockSize < 256) - m_restockSize = m_restockSize * 2; // Grow quickly at small sizes - else if (m_restockSize < 4096) - m_restockSize = m_restockSize * 3 / 2; // Less agressively at large ones - else - m_restockSize = 4096; // Cap how agressive we are - - // Ensure we hit our minimums - if (m_minBufferCount > m_buffersUnderManagement) - m_restockSize = Math.Max(m_restockSize, m_minBufferCount - m_buffersUnderManagement); - - PinnableBufferCacheEventSource.Log.AllocateBufferCreatingNewBuffers(m_CacheName, m_buffersUnderManagement, m_restockSize); - for (int i = 0; i < m_restockSize; i++) - { - // Make a new buffer. - object newBuffer = m_factory(); - - // Create space between the objects. We do this because otherwise it forms a single plug (group of objects) - // and the GC pins the entire plug making them NOT move to Gen1 and Gen2. by putting space between them - // we ensure that object get a chance to move independently (even if some are pinned). - var dummyObject = new object(); - m_NotGen2.Add(newBuffer); - } - m_buffersUnderManagement += m_restockSize; - m_gen1CountAtLastRestock = GC.CollectionCount(GC.MaxGeneration - 1); - } - - /// - /// This is the static function that is called from the gen2 GC callback. - /// The input object is the cache itself. - /// NOTE: The reason that we make this functionstatic and take the cache as a parameter is that - /// otherwise, we root the cache to the Gen2GcCallback object, and leak the cache even when - /// the application no longer needs it. - /// - private static bool Gen2GcCallbackFunc(object targetObj) - { - return ((PinnableBufferCache)(targetObj)).TrimFreeListIfNeeded(); - } - - /// - /// This is called on every gen2 GC to see if we need to trim the free list. - /// NOTE: DO NOT CALL THIS DIRECTLY FROM THE GEN2GCCALLBACK. INSTEAD CALL IT VIA A STATIC FUNCTION (SEE ABOVE). - /// If you register a non-static function as a callback, then this object will be leaked. - /// - private bool TrimFreeListIfNeeded() - { - int curMSec = Environment.TickCount; - int deltaMSec = curMSec - m_msecNoUseBeyondFreeListSinceThisTime; - PinnableBufferCacheEventSource.Log.TrimCheck(m_CacheName, m_buffersUnderManagement, m_moreThanFreeListNeeded, deltaMSec); - - // If we needed more than just the set of aged buffers since the last time we were called, - // we obviously should not be trimming any memory, so do nothing except reset the flag - if (m_moreThanFreeListNeeded) - { - m_moreThanFreeListNeeded = false; - m_trimmingExperimentInProgress = false; - m_msecNoUseBeyondFreeListSinceThisTime = curMSec; - return true; - } - - // We require a minimum amount of clock time to pass (10 seconds) before we trim. Ideally this time - // is larger than the typical buffer hold time. - if (0 <= deltaMSec && deltaMSec < 10000) - return true; - - // If we got here we have spend the last few second without needing to lengthen the free list. Thus - // we have 'enough' buffers, but maybe we have too many. - // See if we can trim - lock (this) - { - // Hit a race, try again later. - if (m_moreThanFreeListNeeded) - { - m_moreThanFreeListNeeded = false; - m_trimmingExperimentInProgress = false; - m_msecNoUseBeyondFreeListSinceThisTime = curMSec; - return true; - } - - var freeCount = m_FreeList.Count; // This is expensive to fetch, do it once. - - // If there is something in m_NotGen2 it was not used for the last few seconds, it is trimable. - if (m_NotGen2.Count > 0) - { - // If we are not performing an experiment and we have stuff that is waiting to go into the - // free list but has not made it there, it could be becasue the 'slow path' of restocking - // has not happened, so force this (which should flush the list) and start over. - if (!m_trimmingExperimentInProgress) - { - PinnableBufferCacheEventSource.Log.TrimFlush(m_CacheName, m_buffersUnderManagement, freeCount, m_NotGen2.Count); - AgePendingBuffers(); - m_trimmingExperimentInProgress = true; - return true; - } - - PinnableBufferCacheEventSource.Log.TrimFree(m_CacheName, m_buffersUnderManagement, freeCount, m_NotGen2.Count); - m_buffersUnderManagement -= m_NotGen2.Count; - - // Possibly revise the restocking down. We don't want to grow agressively if we are trimming. - var newRestockSize = m_buffersUnderManagement / 4; - if (newRestockSize < m_restockSize) - m_restockSize = Math.Max(newRestockSize, DefaultNumberOfBuffers); - - m_NotGen2.Clear(); - m_trimmingExperimentInProgress = false; - return true; - } - - // Set up an experiment where we use 25% less buffers in our free list. We put them in - // m_NotGen2, and if they are needed they will be put back in the free list again. - var trimSize = freeCount / 4 + 1; - - // We are OK with a 15% overhead, do nothing in that case. - if (freeCount * 15 <= m_buffersUnderManagement || m_buffersUnderManagement - trimSize <= m_minBufferCount) - { - PinnableBufferCacheEventSource.Log.TrimFreeSizeOK(m_CacheName, m_buffersUnderManagement, freeCount); - return true; - } - - // Move buffers from the free list back to the non-aged list. If we don't use them by next time, then we'll consider trimming them. - PinnableBufferCacheEventSource.Log.TrimExperiment(m_CacheName, m_buffersUnderManagement, freeCount, trimSize); - object buffer; - for (int i = 0; i < trimSize; i++) - { - if (m_FreeList.TryPop(out buffer)) - m_NotGen2.Add(buffer); - } - m_msecNoUseBeyondFreeListSinceThisTime = curMSec; - m_trimmingExperimentInProgress = true; - } - - // Indicate that we want to be called back on the next Gen 2 GC. - return true; - } - - private const int DefaultNumberOfBuffers = 16; - private string m_CacheName; - private Func m_factory; - - /// - /// Contains 'good' buffers to reuse. They are guaranteed to be Gen 2 ENFORCED! - /// - private ConcurrentStack m_FreeList = new ConcurrentStack(); - /// - /// Contains buffers that are not gen 2 and thus we do not wish to give out unless we have to. - /// To implement trimming we sometimes put aged buffers in here as a place to 'park' them - /// before true deletion. - /// - private List m_NotGen2; - /// - /// What was the gen 1 count the last time re restocked? If it is now greater, then - /// we know that all objects are in Gen 2 so we don't have to check. Should be updated - /// every time something gets added to the m_NotGen2 list. - /// - private int m_gen1CountAtLastRestock; - - /// - /// Used to ensure we have a minimum time between trimmings. - /// - private int m_msecNoUseBeyondFreeListSinceThisTime; - /// - /// To trim, we remove things from the free list (which is Gen 2) and see if we 'hit bottom' - /// This flag indicates that we hit bottom (we really needed a bigger free list). - /// - private bool m_moreThanFreeListNeeded; - /// - /// The total number of buffers that this cache has ever allocated. - /// Used in trimming heuristics. - /// - private int m_buffersUnderManagement; - /// - /// The number of buffers we added the last time we restocked. - /// - private int m_restockSize; - /// - /// Did we put some buffers into m_NotGen2 to see if we can trim? - /// - private bool m_trimmingExperimentInProgress; - /// - /// A forced minimum number of buffers. - /// - private int m_minBufferCount; - /// - /// The number of calls to Allocate. - /// - private int m_numAllocCalls; - - #endregion - } -} diff --git a/src/System.Private.CoreLib/src/System/PinnableBufferCacheEventSource.cs b/src/System.Private.CoreLib/src/System/PinnableBufferCacheEventSource.cs deleted file mode 100644 index 7d382f3c1227..000000000000 --- a/src/System.Private.CoreLib/src/System/PinnableBufferCacheEventSource.cs +++ /dev/null @@ -1,36 +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. - -using System.Diagnostics.Tracing; - -namespace System -{ - internal sealed class PinnableBufferCacheEventSource - { - public static readonly PinnableBufferCacheEventSource Log = new PinnableBufferCacheEventSource(); - - public bool IsEnabled() { return false; } - public void DebugMessage(string message) { } - public void Create(string cacheName) { } - public void AllocateBuffer(string cacheName, ulong objectId, int objectHash, int objectGen, int freeCountAfter) { } - public void AllocateBufferFromNotGen2(string cacheName, int notGen2CountAfter) { } - public void AllocateBufferCreatingNewBuffers(string cacheName, int totalBuffsBefore, int objectCount) { } - public void AllocateBufferAged(string cacheName, int agedCount) { } - public void AllocateBufferFreeListEmpty(string cacheName, int notGen2CountBefore) { } - public void FreeBuffer(string cacheName, ulong objectId, int objectHash, int freeCountBefore) { } - public void FreeBufferStillTooYoung(string cacheName, int notGen2CountBefore) { } - public void TrimCheck(string cacheName, int totalBuffs, bool neededMoreThanFreeList, int deltaMSec) { } - public void TrimFree(string cacheName, int totalBuffs, int freeListCount, int toBeFreed) { } - public void TrimExperiment(string cacheName, int totalBuffs, int freeListCount, int numTrimTrial) { } - public void TrimFreeSizeOK(string cacheName, int totalBuffs, int freeListCount) { } - public void TrimFlush(string cacheName, int totalBuffs, int freeListCount, int notGen2CountBefore) { } - public void AgePendingBuffersResults(string cacheName, int promotedToFreeListCount, int heldBackCount) { } - public void WalkFreeListResult(string cacheName, int freeListCount, int gen0BuffersInFreeList) { } - - internal static ulong AddressOf(object obj) - { - return 0; - } - } -} diff --git a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs index 0931e3ccdc51..6de94d4e8ace 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Assembly.CoreCLR.cs @@ -69,7 +69,7 @@ private static Assembly LoadFromResolveHandler(object sender, ResolveEventArgs a return resolvedAssembly; } - public static Assembly LoadFrom(String assemblyFile) + public static Assembly LoadFrom(string assemblyFile) { if (assemblyFile == null) throw new ArgumentNullException(nameof(assemblyFile)); @@ -101,7 +101,7 @@ public static Assembly LoadFrom(String assemblyFile) return AssemblyLoadContext.Default.LoadFromAssemblyPath(fullPath); } - public static Assembly LoadFrom(String assemblyFile, + public static Assembly LoadFrom(string assemblyFile, byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm) { @@ -111,7 +111,7 @@ public static Assembly LoadFrom(String assemblyFile, // Locate an assembly by the long form of the assembly name. // eg. "Toolbox.dll, version=1.1.10.1220, locale=en, publickey=1234567890123456789012345678901234567890" [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public static Assembly Load(String assemblyString) + public static Assembly Load(string assemblyString) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RuntimeAssembly.InternalLoad(assemblyString, ref stackMark); @@ -177,7 +177,7 @@ public static Assembly Load(byte[] rawAssembly, private static Dictionary s_loadfile = new Dictionary(); - public static Assembly LoadFile(String path) + public static Assembly LoadFile(string path) { AppDomain.CheckLoadFileSupported(); diff --git a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs index d541c4c1d4d2..b8e1573187c7 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/CustomAttribute.cs @@ -1253,13 +1253,13 @@ internal static bool IsDefined(RuntimeModule module, RuntimeType caType) return IsCustomAttributeDefined(module, module.MetadataToken, caType); } - internal static Object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit) + internal static object[] GetCustomAttributes(RuntimeType type, RuntimeType caType, bool inherit) { Debug.Assert(type != null); Debug.Assert(caType != null); if (type.GetElementType() != null) - return (caType.IsValueType) ? Array.Empty() : CreateAttributeArrayHelper(caType, 0); + return (caType.IsValueType) ? Array.Empty() : CreateAttributeArrayHelper(caType, 0); if (type.IsGenericType && !type.IsGenericTypeDefinition) type = type.GetGenericTypeDefinition() as RuntimeType; @@ -1299,7 +1299,7 @@ internal static Object[] GetCustomAttributes(RuntimeType type, RuntimeType caTyp return typedResult; } - internal static Object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) + internal static object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, bool inherit) { Debug.Assert(method != null); Debug.Assert(caType != null); @@ -1342,7 +1342,7 @@ internal static Object[] GetCustomAttributes(RuntimeMethodInfo method, RuntimeTy return typedResult; } - internal static Object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeConstructorInfo ctor, RuntimeType caType) { Debug.Assert(ctor != null); Debug.Assert(caType != null); @@ -1353,7 +1353,7 @@ internal static Object[] GetCustomAttributes(RuntimeConstructorInfo ctor, Runtim return attributes; } - internal static Object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimePropertyInfo property, RuntimeType caType) { Debug.Assert(property != null); Debug.Assert(caType != null); @@ -1365,7 +1365,7 @@ internal static Object[] GetCustomAttributes(RuntimePropertyInfo property, Runti return attributes; } - internal static Object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caType) { Debug.Assert(e != null); Debug.Assert(caType != null); @@ -1376,7 +1376,7 @@ internal static Object[] GetCustomAttributes(RuntimeEventInfo e, RuntimeType caT return attributes; } - internal static Object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType caType) { Debug.Assert(field != null); Debug.Assert(caType != null); @@ -1387,7 +1387,7 @@ internal static Object[] GetCustomAttributes(RuntimeFieldInfo field, RuntimeType return attributes; } - internal static Object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeParameterInfo parameter, RuntimeType caType) { Debug.Assert(parameter != null); Debug.Assert(caType != null); @@ -1398,7 +1398,7 @@ internal static Object[] GetCustomAttributes(RuntimeParameterInfo parameter, Run return attributes; } - internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) { Debug.Assert(assembly != null); Debug.Assert(caType != null); @@ -1410,7 +1410,7 @@ internal static Object[] GetCustomAttributes(RuntimeAssembly assembly, RuntimeTy return attributes; } - internal static Object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType) + internal static object[] GetCustomAttributes(RuntimeModule module, RuntimeType caType) { Debug.Assert(module != null); Debug.Assert(caType != null); @@ -1826,8 +1826,8 @@ private static void ParseAttributeUsageAttribute( } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern unsafe Object _CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, byte** ppBlob, byte* pEndBlob, int* pcNamedArgs); - private static unsafe Object CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs) + private static extern unsafe object _CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, byte** ppBlob, byte* pEndBlob, int* pcNamedArgs); + private static unsafe object CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, ref IntPtr blob, IntPtr blobEnd, out int namedArgs) { byte* pBlob = (byte*)blob; byte* pBlobEnd = (byte*)blobEnd; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs index 2c446f7ecbf8..59d906a34069 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilder.cs @@ -76,12 +76,12 @@ public override bool Equals(object obj) // Assembly methods that are overridden by AssemblyBuilder should be overridden by InternalAssemblyBuilder too #region Methods inherited from Assembly - public override String[] GetManifestResourceNames() + public override string[] GetManifestResourceNames() { throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override FileStream GetFile(String name) + public override FileStream GetFile(string name) { throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } @@ -91,22 +91,22 @@ public override FileStream[] GetFiles(bool getResourceModules) throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override Stream GetManifestResourceStream(Type type, String name) + public override Stream GetManifestResourceStream(Type type, string name) { throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override Stream GetManifestResourceStream(String name) + public override Stream GetManifestResourceStream(string name) { throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) + public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) { throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override String Location + public override string Location { get { @@ -114,7 +114,7 @@ public override String Location } } - public override String CodeBase + public override string CodeBase { get { @@ -127,7 +127,7 @@ public override Type[] GetExportedTypes() throw new NotSupportedException(SR.NotSupported_DynamicAssembly); } - public override String ImageRuntimeVersion + public override string ImageRuntimeVersion { get { @@ -337,7 +337,7 @@ internal static AssemblyBuilder InternalDefineDynamicAssembly( **********************************************/ [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ModuleBuilder DefineDynamicModule( - String name) + string name) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return DefineDynamicModuleInternal(name, false, ref stackMark); @@ -345,7 +345,7 @@ public ModuleBuilder DefineDynamicModule( [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod public ModuleBuilder DefineDynamicModule( - String name, + string name, bool emitSymbolInfo) // specify if emit symbol info or not { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; @@ -353,7 +353,7 @@ public ModuleBuilder DefineDynamicModule( } private ModuleBuilder DefineDynamicModuleInternal( - String name, + string name, bool emitSymbolInfo, // specify if emit symbol info or not ref StackCrawlMark stackMark) { @@ -364,7 +364,7 @@ private ModuleBuilder DefineDynamicModuleInternal( } private ModuleBuilder DefineDynamicModuleInternalNoLock( - String name, + string name, bool emitSymbolInfo, // specify if emit symbol info or not ref StackCrawlMark stackMark) { @@ -393,7 +393,7 @@ private ModuleBuilder DefineDynamicModuleInternalNoLock( { writer = SymWrapperCore.SymWriter.CreateSymWriter(); - String fileName = "Unused"; // this symfile is never written to disk so filename does not matter. + string fileName = "Unused"; // this symfile is never written to disk so filename does not matter. // Pass the "real" module to the VM pInternalSymWriter = ModuleBuilder.nCreateISymWriterForDynamicModule(dynModule.InternalModule, fileName); @@ -460,12 +460,12 @@ public override bool Equals(object obj) #endregion #region ICustomAttributeProvider Members - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return InternalAssembly.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return InternalAssembly.GetCustomAttributes(attributeType, inherit); } @@ -483,12 +483,12 @@ public override IList GetCustomAttributesData() #region Assembly overrides // Returns the names of all the resources - public override String[] GetManifestResourceNames() + public override string[] GetManifestResourceNames() { return InternalAssembly.GetManifestResourceNames(); } - public override FileStream GetFile(String name) + public override FileStream GetFile(string name) { return InternalAssembly.GetFile(name); } @@ -498,22 +498,22 @@ public override FileStream[] GetFiles(bool getResourceModules) return InternalAssembly.GetFiles(getResourceModules); } - public override Stream GetManifestResourceStream(Type type, String name) + public override Stream GetManifestResourceStream(Type type, string name) { return InternalAssembly.GetManifestResourceStream(type, name); } - public override Stream GetManifestResourceStream(String name) + public override Stream GetManifestResourceStream(string name) { return InternalAssembly.GetManifestResourceStream(name); } - public override ManifestResourceInfo GetManifestResourceInfo(String resourceName) + public override ManifestResourceInfo GetManifestResourceInfo(string resourceName) { return InternalAssembly.GetManifestResourceInfo(resourceName); } - public override String Location + public override string Location { get { @@ -521,7 +521,7 @@ public override String Location } } - public override String ImageRuntimeVersion + public override string ImageRuntimeVersion { get { @@ -529,7 +529,7 @@ public override String ImageRuntimeVersion } } - public override String CodeBase + public override string CodeBase { get { @@ -558,7 +558,7 @@ public override AssemblyName GetName(bool copiedName) return InternalAssembly.GetName(copiedName); } - public override String FullName + public override string FullName { get { @@ -566,7 +566,7 @@ public override String FullName } } - public override Type GetType(String name, bool throwOnError, bool ignoreCase) + public override Type GetType(string name, bool throwOnError, bool ignoreCase) { return InternalAssembly.GetType(name, throwOnError, ignoreCase); } @@ -587,7 +587,7 @@ public override bool ReflectionOnly } } - public override Module GetModule(String name) + public override Module GetModule(string name) { return InternalAssembly.GetModule(name); } @@ -605,7 +605,7 @@ public override bool GlobalAssemblyCache } } - public override Int64 HostContext + public override long HostContext { get { @@ -654,7 +654,7 @@ public override bool IsDynamic * **********************************************/ public ModuleBuilder GetDynamicModule( - String name) // the name of module for the look up + string name) // the name of module for the look up { lock (SyncRoot) { @@ -663,7 +663,7 @@ public ModuleBuilder GetDynamicModule( } private ModuleBuilder GetDynamicModuleNoLock( - String name) // the name of module for the look up + string name) // the name of module for the look up { if (name == null) throw new ArgumentNullException(nameof(name)); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs index ea1f6994e977..bbee037f55ad 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/AssemblyBuilderData.cs @@ -26,7 +26,7 @@ internal class AssemblyBuilderData { internal AssemblyBuilderData( InternalAssemblyBuilder assembly, - String strAssemblyName, + string strAssemblyName, AssemblyBuilderAccess access) { m_assembly = assembly; @@ -95,7 +95,7 @@ internal void AddCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) } // Helper to ensure the type name is unique underneath assemblyBuilder - internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingType) + internal void CheckTypeNameConflict(string strTypeName, TypeBuilder enclosingType) { for (int i = 0; i < m_moduleBuilderList.Count; i++) { @@ -116,7 +116,7 @@ internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingTyp internal List m_moduleBuilderList; internal List m_resWriterList; - internal String m_strAssemblyName; + internal string m_strAssemblyName; internal AssemblyBuilderAccess m_access; private InternalAssemblyBuilder m_assembly; @@ -140,7 +140,7 @@ internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingTyp internal Assembly m_ISymWrapperAssembly; // For unmanaged resources - internal String m_strResourceFileName; + internal string m_strResourceFileName; internal byte[] m_resourceBytes; internal NativeVersionInfo m_nativeVersion; internal bool m_hasUnmanagedVersionInfo; @@ -156,9 +156,9 @@ internal void CheckTypeNameConflict(String strTypeName, TypeBuilder enclosingTyp **********************************************/ internal class ResWriterData { - internal String m_strName; - internal String m_strFileName; - internal String m_strFullFileName; + internal string m_strName; + internal string m_strFileName; + internal string m_strFullFileName; internal Stream m_memoryStream; internal ResWriterData m_nextResWriter; internal ResourceAttributes m_attribute; @@ -179,14 +179,14 @@ internal NativeVersionInfo() m_lcid = -1; } - internal String m_strDescription; - internal String m_strCompany; - internal String m_strTitle; - internal String m_strCopyright; - internal String m_strTrademark; - internal String m_strProduct; - internal String m_strProductVersion; - internal String m_strFileVersion; + internal string m_strDescription; + internal string m_strCompany; + internal string m_strTitle; + internal string m_strCopyright; + internal string m_strTrademark; + internal string m_strProduct; + internal string m_strProductVersion; + internal string m_strFileVersion; internal int m_lcid; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs index b333dc392260..91e64e4f6b49 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ConstructorBuilder.cs @@ -21,7 +21,7 @@ public sealed class ConstructorBuilder : ConstructorInfo #region Constructor - internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention, + internal ConstructorBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, Type[][] requiredCustomModifiers, Type[][] optionalCustomModifiers, ModuleBuilder mod, TypeBuilder type) { int sigLength; @@ -38,7 +38,7 @@ internal ConstructorBuilder(String name, MethodAttributes attributes, CallingCon token = m_methodBuilder.GetToken(); } - internal ConstructorBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention, + internal ConstructorBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention, Type[] parameterTypes, ModuleBuilder mod, TypeBuilder type) : this(name, attributes, callingConvention, parameterTypes, null, null, mod, type) { @@ -59,7 +59,7 @@ private TypeBuilder GetTypeBuilder() #endregion #region Object Overrides - public override String ToString() + public override string ToString() { return m_methodBuilder.ToString(); } @@ -87,7 +87,7 @@ public override Type DeclaringType get { return m_methodBuilder.DeclaringType; } } - public override String Name + public override string Name { get { return m_methodBuilder.Name; } } @@ -95,7 +95,7 @@ public override String Name #endregion #region MethodBase Overrides - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -124,7 +124,7 @@ public override RuntimeMethodHandle MethodHandle #endregion #region ConstructorInfo Overrides - public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -132,12 +132,12 @@ public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] p #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return m_methodBuilder.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_methodBuilder.GetCustomAttributes(attributeType, inherit); } @@ -155,7 +155,7 @@ public MethodToken GetToken() return m_methodBuilder.GetToken(); } - public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, String strParamName) + public ParameterBuilder DefineParameter(int iSequence, ParameterAttributes attributes, string strParamName) { // Theoretically we shouldn't allow iSequence to be 0 because in reflection ctors don't have // return parameters. But we'll allow it for backward compatibility with V2. The attributes @@ -204,7 +204,7 @@ internal override Type GetReturnType() return m_methodBuilder.ReturnType; } - public String Signature + public string Signature { get { return m_methodBuilder.Signature; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs index f48a07251a67..1dd3a1ee5a8a 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/CustomAttributeBuilder.cs @@ -28,36 +28,36 @@ public class CustomAttributeBuilder { // public constructor to form the custom attribute with constructor and constructor // parameters. - public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs) + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs) { InitCustomAttributeBuilder(con, constructorArgs, - new PropertyInfo[] { }, new Object[] { }, - new FieldInfo[] { }, new Object[] { }); + new PropertyInfo[] { }, new object[] { }, + new FieldInfo[] { }, new object[] { }); } // public constructor to form the custom attribute with constructor, constructor // parameters and named properties. - public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, - PropertyInfo[] namedProperties, Object[] propertyValues) + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, + PropertyInfo[] namedProperties, object[] propertyValues) { InitCustomAttributeBuilder(con, constructorArgs, namedProperties, - propertyValues, new FieldInfo[] { }, new Object[] { }); + propertyValues, new FieldInfo[] { }, new object[] { }); } // public constructor to form the custom attribute with constructor and constructor // parameters. - public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, - FieldInfo[] namedFields, Object[] fieldValues) + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, + FieldInfo[] namedFields, object[] fieldValues) { InitCustomAttributeBuilder(con, constructorArgs, new PropertyInfo[] { }, - new Object[] { }, namedFields, fieldValues); + new object[] { }, namedFields, fieldValues); } // public constructor to form the custom attribute with constructor and constructor // parameters. - public CustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, - PropertyInfo[] namedProperties, Object[] propertyValues, - FieldInfo[] namedFields, Object[] fieldValues) + public CustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, + PropertyInfo[] namedProperties, object[] propertyValues, + FieldInfo[] namedFields, object[] fieldValues) { InitCustomAttributeBuilder(con, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues); @@ -70,7 +70,7 @@ private bool ValidateType(Type t) { return t != typeof(IntPtr) && t != typeof(UIntPtr); } - if (t == typeof(String) || t == typeof(Type)) + if (t == typeof(string) || t == typeof(Type)) { return true; } @@ -97,12 +97,12 @@ private bool ValidateType(Type t) return false; return ValidateType(t.GetElementType()); } - return t == typeof(Object); + return t == typeof(object); } - internal void InitCustomAttributeBuilder(ConstructorInfo con, Object[] constructorArgs, - PropertyInfo[] namedProperties, Object[] propertyValues, - FieldInfo[] namedFields, Object[] fieldValues) + internal void InitCustomAttributeBuilder(ConstructorInfo con, object[] constructorArgs, + PropertyInfo[] namedProperties, object[] propertyValues, + FieldInfo[] namedFields, object[] fieldValues) { if (con == null) throw new ArgumentNullException(nameof(con)); @@ -130,7 +130,7 @@ internal void InitCustomAttributeBuilder(ConstructorInfo con, Object[] construct // Cache information used elsewhere. m_con = con; - m_constructorArgs = new Object[constructorArgs.Length]; + m_constructorArgs = new object[constructorArgs.Length]; Array.Copy(constructorArgs, 0, m_constructorArgs, 0, constructorArgs.Length); Type[] paramTypes; @@ -357,7 +357,7 @@ private void EmitType(BinaryWriter writer, Type type) writer.Write((byte)CustomAttributeEncoding.Enum); EmitString(writer, type.AssemblyQualifiedName); } - else if (type == typeof(String)) + else if (type == typeof(string)) { writer.Write((byte)CustomAttributeEncoding.String); } @@ -377,7 +377,7 @@ private void EmitType(BinaryWriter writer, Type type) } } - private void EmitString(BinaryWriter writer, String str) + private void EmitString(BinaryWriter writer, string str) { // Strings are emitted with a length prefix in a compressed format (1, 2 or 4 bytes) as used internally by metadata. byte[] utf8Str = Encoding.UTF8.GetBytes(str); @@ -401,7 +401,7 @@ private void EmitString(BinaryWriter writer, String str) writer.Write(utf8Str); } - private void EmitValue(BinaryWriter writer, Type type, Object value) + private void EmitValue(BinaryWriter writer, Type type, object value) { if (type.IsEnum) { @@ -436,12 +436,12 @@ private void EmitValue(BinaryWriter writer, Type type, Object value) break; } } - else if (type == typeof(String)) + else if (type == typeof(string)) { if (value == null) writer.Write((byte)0xff); else - EmitString(writer, (String)value); + EmitString(writer, (string)value); } else if (type == typeof(Type)) { @@ -449,7 +449,7 @@ private void EmitValue(BinaryWriter writer, Type type, Object value) writer.Write((byte)0xff); else { - String typeName = TypeNameBuilder.ToString((Type)value, TypeNameBuilder.Format.AssemblyQualifiedName); + string typeName = TypeNameBuilder.ToString((Type)value, TypeNameBuilder.Format.AssemblyQualifiedName); if (typeName == null) throw new ArgumentException(SR.Format(SR.Argument_InvalidTypeForCA, value.GetType())); EmitString(writer, typeName); @@ -519,7 +519,7 @@ private void EmitValue(BinaryWriter writer, Type type, Object value) // TypeBuilder), so we need to canonicalize this case back to Type. If we have a null value we follow the convention // used by C# and emit a null typed as a string (it doesn't really matter what type we pick as long as it's a // reference type). - Type ot = value == null ? typeof(String) : value is Type ? typeof(Type) : value.GetType(); + Type ot = value == null ? typeof(string) : value is Type ? typeof(Type) : value.GetType(); // value cannot be a "System.Object" object. // If we allow this we will get into an infinite recursion @@ -559,7 +559,7 @@ internal void CreateCustomAttribute(ModuleBuilder mod, int tkOwner, int tkAttrib } internal ConstructorInfo m_con; - internal Object[] m_constructorArgs; + internal object[] m_constructorArgs; internal byte[] m_blob; } } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs index 5f265787f77e..3315daf17319 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicILGenerator.cs @@ -641,8 +641,7 @@ internal DynamicResolver(DynamicILInfo dynamicILInfo) // We go over all DynamicMethodDesc during AppDomain shutdown and make sure // that everything associated with them is released. So it is ok to skip reregistration // for finalization during appdomain shutdown - if (!Environment.HasShutdownStarted && - !AppDomain.CurrentDomain.IsFinalizingForUnload()) + if (!Environment.HasShutdownStarted) { // Try again later. GC.ReRegisterForFinalize(this); @@ -667,8 +666,7 @@ private class DestroyScout // It is not safe to destroy the method if the managed resolver is alive. if (RuntimeMethodHandle.GetResolver(m_methodHandle) != null) { - if (!Environment.HasShutdownStarted && - !AppDomain.CurrentDomain.IsFinalizingForUnload()) + if (!Environment.HasShutdownStarted) { // Somebody might have been holding a reference on us via weak handle. // We will keep trying. It will be hopefully released eventually. @@ -794,7 +792,7 @@ internal override void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle = new IntPtr(); fieldHandle = new IntPtr(); - Object handle = m_scope[token]; + object handle = m_scope[token]; if (handle == null) throw new InvalidProgramException(); @@ -914,13 +912,13 @@ internal byte[] LocalSignature internal class DynamicScope { #region Private Data Members - internal List m_tokens; + internal List m_tokens; #endregion #region Constructor internal unsafe DynamicScope() { - m_tokens = new List(); + m_tokens = new List(); m_tokens.Add(null); } #endregion diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs index 00ee65d9f0c3..ce329b56d75a 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.cs @@ -241,7 +241,7 @@ private static RuntimeModule GetDynamicMethodsModule() return s_anonymouslyHostedDynamicMethodsModule; ConstructorInfo transparencyCtor = typeof(SecurityTransparentAttribute).GetConstructor(Type.EmptyTypes); - CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty()); + CustomAttributeBuilder transparencyAttribute = new CustomAttributeBuilder(transparencyCtor, Array.Empty()); List assemblyAttributes = new List(); assemblyAttributes.Add(transparencyAttribute); @@ -263,7 +263,7 @@ private static RuntimeModule GetDynamicMethodsModule() return s_anonymouslyHostedDynamicMethodsModule; } - private unsafe void Init(String name, + private unsafe void Init(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, @@ -365,7 +365,7 @@ public sealed override Delegate CreateDelegate(Type delegateType) return d; } - public sealed override Delegate CreateDelegate(Type delegateType, Object target) + public sealed override Delegate CreateDelegate(Type delegateType, object target) { if (m_restrictedSkipVisibility) { @@ -408,9 +408,9 @@ internal unsafe RuntimeMethodHandle GetMethodDescriptor() // MethodInfo api. They mostly forward to RTDynamicMethod // - public override String ToString() { return m_dynMethod.ToString(); } + public override string ToString() { return m_dynMethod.ToString(); } - public override String Name { get { return m_dynMethod.Name; } } + public override string Name { get { return m_dynMethod.Name; } } public override Type DeclaringType { get { return m_dynMethod.DeclaringType; } } @@ -431,15 +431,6 @@ internal unsafe RuntimeMethodHandle GetMethodDescriptor() public override MethodImplAttributes GetMethodImplementationFlags() { return m_dynMethod.GetMethodImplementationFlags(); } - // - // Security transparency accessors - // - // Since the dynamic method may not be JITed yet, we don't always have the runtime method handle - // which is needed to determine the official runtime transparency status of the dynamic method. We - // fall back to saying that the dynamic method matches the transparency of its containing module - // until we get a JITed version, since dynamic methods cannot have attributes of their own. - // - public override bool IsSecurityCritical { get { return true; } @@ -455,7 +446,7 @@ public override bool IsSecurityTransparent get { return false; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { if ((CallingConvention & CallingConventions.VarArgs) == CallingConventions.VarArgs) throw new NotSupportedException(SR.NotSupported_CallToVarArg); @@ -482,10 +473,10 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder // if we are here we passed all the previous checks. Time to look at the arguments bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0; - Object retValue = null; + object retValue = null; if (actualCount > 0) { - Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); + object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, false, wrapExceptions); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) @@ -500,12 +491,12 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder return retValue; } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_dynMethod.GetCustomAttributes(attributeType, inherit); } - public override Object[] GetCustomAttributes(bool inherit) { return m_dynMethod.GetCustomAttributes(inherit); } + public override object[] GetCustomAttributes(bool inherit) { return m_dynMethod.GetCustomAttributes(inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_dynMethod.IsDefined(attributeType, inherit); } @@ -519,7 +510,7 @@ public override Object[] GetCustomAttributes(Type attributeType, bool inherit) // DynamicMethod specific methods // - public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String parameterName) + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string parameterName) { if (position < 0 || position > m_parameterTypes.Length) throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); @@ -577,11 +568,11 @@ internal sealed class RTDynamicMethod : MethodInfo { internal DynamicMethod m_owner; private RuntimeParameterInfo[] m_parameters; - private String m_name; + private string m_name; private MethodAttributes m_attributes; private CallingConventions m_callingConvention; - internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attributes, CallingConventions callingConvention) + internal RTDynamicMethod(DynamicMethod owner, string name, MethodAttributes attributes, CallingConventions callingConvention) { m_owner = owner; m_name = name; @@ -592,12 +583,12 @@ internal RTDynamicMethod(DynamicMethod owner, String name, MethodAttributes attr // // MethodInfo api // - public override String ToString() + public override string ToString() { return ReturnType.FormatTypeName() + " " + FormatNameAndSig(); } - public override String Name + public override string Name { get { return m_name; } } @@ -650,7 +641,7 @@ public override MethodImplAttributes GetMethodImplementationFlags() return MethodImplAttributes.IL | MethodImplAttributes.NoInlining; } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { // We want the creator of the DynamicMethod to control who has access to the // DynamicMethod (just like we do for delegates). However, a user can get to @@ -661,21 +652,21 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, "this"); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); if (attributeType.IsAssignableFrom(typeof(MethodImplAttribute))) - return new Object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) }; + return new object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) }; else - return Array.Empty(); + return Array.Empty(); } - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { // support for MethodImplAttribute PCA - return new Object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) }; + return new object[] { new MethodImplAttribute((MethodImplOptions)GetMethodImplementationFlags()) }; } public override bool IsDefined(Type attributeType, bool inherit) @@ -753,14 +744,14 @@ private class EmptyCAHolder : ICustomAttributeProvider { internal EmptyCAHolder() { } - Object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) + object[] ICustomAttributeProvider.GetCustomAttributes(Type attributeType, bool inherit) { - return Array.Empty(); + return Array.Empty(); } - Object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) + object[] ICustomAttributeProvider.GetCustomAttributes(bool inherit) { - return Array.Empty(); + return Array.Empty(); } bool ICustomAttributeProvider.IsDefined(Type attributeType, bool inherit) diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs index 1e4d30849c11..a77d5b058e6f 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/EnumBuilder.cs @@ -31,7 +31,7 @@ public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo) // Define literal for enum - public FieldBuilder DefineLiteral(string literalName, Object literalValue) + public FieldBuilder DefineLiteral(string literalName, object literalValue) { // Define the underlying field for the enum. It will be a non-static, private field with special name bit set. FieldBuilder fieldBuilder = m_typeBuilder.DefineField( @@ -84,12 +84,12 @@ public override Guid GUID } } - public override Object InvokeMember( + public override object InvokeMember( string name, BindingFlags invokeAttr, Binder binder, - Object target, - Object[] args, + object target, + object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) @@ -303,13 +303,13 @@ public override Type UnderlyingSystemType } //ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return m_typeBuilder.GetCustomAttributes(inherit); } // Return a custom attribute identified by Type - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_typeBuilder.GetCustomAttributes(attributeType, inherit); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.cs index c67d5559fdc6..eee969914b82 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/EventBuilder.cs @@ -29,7 +29,7 @@ public sealed class EventBuilder // internal EventBuilder( ModuleBuilder mod, // the module containing this EventBuilder - String name, // Event name + string name, // Event name EventAttributes attr, // event attribute such as Public, Private, and Protected defined above //int eventType, // event type TypeBuilder type, // containing type @@ -114,7 +114,7 @@ public void SetCustomAttribute(CustomAttributeBuilder customBuilder) } // These are package private so that TypeBuilder can access them. - private String m_name; // The name of the event + private string m_name; // The name of the event private EventToken m_evToken; // The token of this event private ModuleBuilder m_module; private EventAttributes m_attributes; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs index e44dc3d0ce72..53dfa9a60380 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/EventToken.cs @@ -39,7 +39,7 @@ public override int GetHashCode() return m_event; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is EventToken) return Equals((EventToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.cs index 78a1ed5bb5c9..56d49d0ebef5 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldBuilder.cs @@ -17,13 +17,13 @@ public sealed class FieldBuilder : FieldInfo private int m_fieldTok; private FieldToken m_tkField; private TypeBuilder m_typeBuilder; - private String m_fieldName; + private string m_fieldName; private FieldAttributes m_Attributes; private Type m_fieldType; #endregion #region Constructor - internal FieldBuilder(TypeBuilder typeBuilder, String fieldName, Type type, + internal FieldBuilder(TypeBuilder typeBuilder, string fieldName, Type type, Type[] requiredCustomModifiers, Type[] optionalCustomModifiers, FieldAttributes attributes) { if (fieldName == null) @@ -78,7 +78,7 @@ public override Module Module get { return m_typeBuilder.Module; } } - public override String Name + public override string Name { get { return m_fieldName; } } @@ -113,7 +113,7 @@ public override Type FieldType get { return m_fieldType; } } - public override Object GetValue(Object obj) + public override object GetValue(object obj) { // NOTE!! If this is implemented, make sure that this throws // a NotSupportedException for Save-only dynamic assemblies. @@ -122,7 +122,7 @@ public override Object GetValue(Object obj) throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj, Object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) + public override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { // NOTE!! If this is implemented, make sure that this throws // a NotSupportedException for Save-only dynamic assemblies. @@ -144,12 +144,12 @@ public override FieldAttributes Attributes #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -174,7 +174,7 @@ public void SetOffset(int iOffset) TypeBuilder.SetFieldLayoutOffset(m_typeBuilder.GetModuleBuilder().GetNativeHandle(), GetToken().Token, iOffset); } - public void SetConstant(Object defaultValue) + public void SetConstant(object defaultValue) { m_typeBuilder.ThrowIfCreated(); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs index c7450ca301b7..b6441bf4f23a 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/FieldToken.cs @@ -27,7 +27,7 @@ public struct FieldToken public static readonly FieldToken Empty = new FieldToken(); internal int m_fieldTok; - internal Object m_class; + internal object m_class; // Creates an empty FieldToken. A publicly visible constructor so that // it can be created on the stack. @@ -59,7 +59,7 @@ public override int GetHashCode() // Returns true if obj is an instance of FieldToken and is // equal to this instance. - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is FieldToken) return Equals((FieldToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs index a79e8841ad1c..7232600485e6 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/GenericTypeParameterBuilder.cs @@ -100,7 +100,7 @@ public override Type MakeArrayType(int rank) public override Guid GUID { get { throw new NotSupportedException(); } } - public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } + public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } public override Assembly Assembly { get { return m_type.Assembly; } } @@ -202,9 +202,9 @@ public override Type MakeArrayType(int rank) #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } public override bool IsDefined(Type attributeType, bool inherit) { throw new NotSupportedException(); } #endregion diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs index a1cee10ba3cd..d01c9cb6d29d 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ILGenerator.cs @@ -2,7 +2,7 @@ // 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.Diagnostics.SymbolStore; @@ -255,7 +255,7 @@ internal byte[] BakeByteArray() if (m_fixupData[i].m_fixupInstSize == 1) { //Verify that our one-byte arg will fit into a Signed Byte. - if (updateAddr < SByte.MinValue || updateAddr > SByte.MaxValue) + if (updateAddr < sbyte.MinValue || updateAddr > sbyte.MaxValue) { throw new NotSupportedException(SR.Format(SR.NotSupported_IllegalOneByteBranch, m_fixupData[i].m_fixupPos, updateAddr)); } @@ -815,7 +815,7 @@ public virtual void Emit(OpCode opcode, FieldInfo field) PutInteger4(tempVal); } - public virtual void Emit(OpCode opcode, String str) + public virtual void Emit(OpCode opcode, string str) { // Puts the opcode onto the IL stream followed by the metadata token // represented by str. The location of str is recorded for future @@ -905,7 +905,7 @@ public virtual void Emit(OpCode opcode, LocalBuilder local) else { //Handle stloc_1, ldloc_1 - if (tempVal > Byte.MaxValue) + if (tempVal > byte.MaxValue) { throw new InvalidOperationException(SR.InvalidOperation_BadInstructionOrIndexOutOfBound); } @@ -991,7 +991,7 @@ public virtual void EndExceptionBlock() this.Emit(OpCodes.Endfinally); } - //Check if we've alredy set this label. + //Check if we've already set this label. //The only reason why we might have set this is if we have a finally block. if (m_labelList[endLabel.GetLabelValue()] == -1) { @@ -1092,7 +1092,7 @@ public virtual void BeginFinallyBlock() Label finallyEndLabel = this.DefineLabel(); current.SetFinallyEndLabel(finallyEndLabel); - // generate leave for try clause + // generate leave for try clause this.Emit(OpCodes.Leave, finallyEndLabel); if (catchEndAddr == 0) catchEndAddr = m_length; @@ -1173,13 +1173,13 @@ private static Type GetConsoleType() return Type.GetType("System.Console, System.Console", throwOnError: true); } - public virtual void EmitWriteLine(String value) + public virtual void EmitWriteLine(string value) { // Emits the IL to call Console.WriteLine with a string. Emit(OpCodes.Ldstr, value); Type[] parameterTypes = new Type[1]; - parameterTypes[0] = typeof(String); + parameterTypes[0] = typeof(string); MethodInfo mi = GetConsoleType().GetMethod("WriteLine", parameterTypes); Emit(OpCodes.Call, mi); } @@ -1191,7 +1191,7 @@ public virtual void EmitWriteLine(LocalBuilder localBuilder) // one of the types for which Console.WriteLine implements overloads. (e.g. // we do *not* call ToString on the locals. - Object cls; + object cls; if (m_methodBuilder == null) { throw new ArgumentException(SR.InvalidOperation_BadILGeneratorUsage); @@ -1223,7 +1223,7 @@ public virtual void EmitWriteLine(FieldInfo fld) // one of the types for which Console.WriteLine implements overloads. (e.g. // we do *not* call ToString on the fields. - Object cls; + object cls; if (fld == null) { @@ -1300,7 +1300,7 @@ public virtual LocalBuilder DeclareLocal(Type localType, bool pinned) return localBuilder; } - public virtual void UsingNamespace(String usingNamespace) + public virtual void UsingNamespace(string usingNamespace) { // Specifying the namespace to be used in evaluating locals and watches // for the current active lexical scope. @@ -1576,7 +1576,7 @@ internal Label GetFinallyEndLabel() // WARNING: This is not a generic function to determine the innerness // of an exception. This is somewhat of a mis-nomer. This gives a // random result for cases where the two exceptions being compared do - // not having a nesting relation. + // not having a nesting relation. internal bool IsInner(__ExceptionInfo exc) { Debug.Assert(exc != null); @@ -1663,7 +1663,7 @@ internal int GetCurrentActiveScopeIndex() } internal void AddLocalSymInfoToCurrentScope( - String strName, + string strName, byte[] signature, int slot, int startOffset, @@ -1678,7 +1678,7 @@ internal void AddLocalSymInfoToCurrentScope( } internal void AddUsingNamespaceToCurrentScope( - String strNamespace) + string strNamespace) { int i = GetCurrentActiveScopeIndex(); if (m_localSymInfos[i] == null) @@ -1824,7 +1824,7 @@ private int FindDocument(ISymbolDocumentWriter document) } } - // cannot find an existing document so add one to the array + // cannot find an existing document so add one to the array EnsureCapacity(); m_iLastFound = m_DocumentCount; m_Documents[m_iLastFound] = new REDocument(document); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ISymWrapperCore.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ISymWrapperCore.cs index cda651c9cebe..030132918569 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ISymWrapperCore.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ISymWrapperCore.cs @@ -165,7 +165,7 @@ private SymWriter() //------------------------------------------------------------------------------ // DefineDocument() wrapper //------------------------------------------------------------------------------ - ISymbolDocumentWriter ISymbolWriter.DefineDocument(String url, + ISymbolDocumentWriter ISymbolWriter.DefineDocument(string url, Guid language, Guid languageVendor, Guid documentType) @@ -295,7 +295,7 @@ void ISymbolWriter.CloseScope(int endOffset) //------------------------------------------------------------------------------ // DefineLocalVariable() wrapper //------------------------------------------------------------------------------ - void ISymbolWriter.DefineLocalVariable(String name, + void ISymbolWriter.DefineLocalVariable(string name, FieldAttributes attributes, byte[] signature, SymAddressKind addrKind, @@ -325,7 +325,7 @@ void ISymbolWriter.DefineLocalVariable(String name, //------------------------------------------------------------------------------ // SetSymAttribute() wrapper //------------------------------------------------------------------------------ - void ISymbolWriter.SetSymAttribute(SymbolToken parent, String name, byte[] data) + void ISymbolWriter.SetSymAttribute(SymbolToken parent, string name, byte[] data) { int hr = m_vtable.SetSymAttribute(m_pWriter, parent.GetToken(), name, data.Length, data); if (hr < 0) @@ -337,7 +337,7 @@ void ISymbolWriter.SetSymAttribute(SymbolToken parent, String name, byte[] data) //------------------------------------------------------------------------------ // UsingNamespace() wrapper //------------------------------------------------------------------------------ - void ISymbolWriter.UsingNamespace(String name) + void ISymbolWriter.UsingNamespace(string name) { int hr = m_vtable.UsingNamespace(m_pWriter, name); if (hr < 0) @@ -366,13 +366,13 @@ internal void InternalSetUnderlyingWriter(IntPtr ppUnderlyingWriter) //------------------------------------------------------------------------------ private delegate int DInitialize(ISymUnmanagedWriter* pthis, IntPtr emitter, //IUnknown* - [MarshalAs(UnmanagedType.LPWStr)] String filename, //WCHAR* + [MarshalAs(UnmanagedType.LPWStr)] string filename, //WCHAR* IntPtr pIStream, //IStream* [MarshalAs(UnmanagedType.Bool)] bool fFullBuild ); private delegate int DDefineDocument(ISymUnmanagedWriter* pthis, - [MarshalAs(UnmanagedType.LPWStr)] String url, + [MarshalAs(UnmanagedType.LPWStr)] string url, [In] ref Guid language, [In] ref Guid languageVender, [In] ref Guid documentType, @@ -398,7 +398,7 @@ private delegate int DDefineSequencePoints(ISymUnmanagedWriter* pthis, private delegate int DSetScopeRange(ISymUnmanagedWriter* pthis, int scopeID, int startOffset, int endOffset); private delegate int DDefineLocalVariable(ISymUnmanagedWriter* pthis, - [MarshalAs(UnmanagedType.LPWStr)] String name, + [MarshalAs(UnmanagedType.LPWStr)] string name, int attributes, int cSig, [In] byte[] signature, @@ -414,15 +414,15 @@ int endOffset private delegate int DSetSymAttribute(ISymUnmanagedWriter* pthis, int parent, - [MarshalAs(UnmanagedType.LPWStr)] String name, + [MarshalAs(UnmanagedType.LPWStr)] string name, int cData, [In] byte[] data ); - private delegate int DOpenNamespace(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] String name); + private delegate int DOpenNamespace(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] string name); private delegate int DCloseNamespace(ISymUnmanagedWriter* pthis); - private delegate int DUsingNamespace(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] String name); + private delegate int DUsingNamespace(ISymUnmanagedWriter* pthis, [MarshalAs(UnmanagedType.LPWStr)] string name); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs index 1e07f3a4e038..0e0db23b687c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/LocalBuilder.cs @@ -53,12 +53,12 @@ public override Type LocalType #endregion #region Public Members - public void SetLocalSymInfo(String name) + public void SetLocalSymInfo(string name) { SetLocalSymInfo(name, 0, 0); } - public void SetLocalSymInfo(String name, int startOffset, int endOffset) + public void SetLocalSymInfo(string name, int startOffset, int endOffset) { ModuleBuilder dynMod; SignatureHelper sigHelp; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs index 70b5b66d657e..9c91c2f5f85e 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilder.cs @@ -21,7 +21,7 @@ public sealed class MethodBuilder : MethodInfo { #region Private Data Members // Identity - internal String m_strName; // The name of the method + internal string m_strName; // The name of the method private MethodToken m_tkMethod; // The token of this method private ModuleBuilder m_module; internal TypeBuilder m_containingType; @@ -62,7 +62,7 @@ public sealed class MethodBuilder : MethodInfo #region Constructor - internal MethodBuilder(String name, MethodAttributes attributes, CallingConventions callingConvention, + internal MethodBuilder(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod) @@ -73,7 +73,7 @@ internal MethodBuilder(String name, MethodAttributes attributes, CallingConventi mod, type, bIsGlobalMethod); } - private void Init(String name, MethodAttributes attributes, CallingConventions callingConvention, + private void Init(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, ModuleBuilder mod, TypeBuilder type, bool bIsGlobalMethod) @@ -358,6 +358,11 @@ internal static Type GetMethodBaseReturnType(MethodBase method) } } + internal void SetToken(MethodToken token) + { + m_tkMethod = token; + } + internal byte[] GetBody() { // Returns the il bytes of this method. @@ -460,7 +465,7 @@ internal ModuleBuilder GetModuleBuilder() #endregion #region Object Overrides - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (!(obj is MethodBuilder)) { @@ -489,7 +494,7 @@ public override int GetHashCode() return this.m_strName.GetHashCode(); } - public override String ToString() + public override string ToString() { StringBuilder sb = new StringBuilder(1000); sb.Append("Name: " + m_strName + " " + Environment.NewLine); @@ -502,7 +507,7 @@ public override String ToString() #endregion #region MemberInfo Overrides - public override String Name + public override string Name { get { @@ -555,7 +560,7 @@ public override Type ReflectedType #endregion #region MethodBase Overrides - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -635,12 +640,12 @@ public override ParameterInfo ReturnParameter #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -817,7 +822,7 @@ public void SetSignature( } - public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, String strParamName) + public ParameterBuilder DefineParameter(int position, ParameterAttributes attributes, string strParamName) { if (position < 0) throw new ArgumentOutOfRangeException(SR.ArgumentOutOfRange_ParamSequence); @@ -835,7 +840,7 @@ public ParameterBuilder DefineParameter(int position, ParameterAttributes attrib private List m_symCustomAttrs; private struct SymCustomAttr { - public String m_name; + public string m_name; public byte[] m_data; } @@ -898,7 +903,7 @@ public Module GetModule() return GetModuleBuilder(); } - public String Signature + public string Signature { get { @@ -979,13 +984,13 @@ internal class LocalSymInfo // and namespace information with a given active lexical scope. #region Internal Data Members - internal String[] m_strName; + internal string[] m_strName; internal byte[][] m_ubSignature; internal int[] m_iLocalSlot; internal int[] m_iStartOffset; internal int[] m_iEndOffset; internal int m_iLocalSymCount; // how many entries in the arrays are occupied - internal String[] m_namespace; + internal string[] m_namespace; internal int m_iNameSpaceCount; internal const int InitialSize = 16; #endregion @@ -1004,11 +1009,11 @@ private void EnsureCapacityNamespace() { if (m_iNameSpaceCount == 0) { - m_namespace = new String[InitialSize]; + m_namespace = new string[InitialSize]; } else if (m_iNameSpaceCount == m_namespace.Length) { - String[] strTemp = new String[checked(m_iNameSpaceCount * 2)]; + string[] strTemp = new string[checked(m_iNameSpaceCount * 2)]; Array.Copy(m_namespace, 0, strTemp, 0, m_iNameSpaceCount); m_namespace = strTemp; } @@ -1019,7 +1024,7 @@ private void EnsureCapacity() if (m_iLocalSymCount == 0) { // First time. Allocate the arrays. - m_strName = new String[InitialSize]; + m_strName = new string[InitialSize]; m_ubSignature = new byte[InitialSize][]; m_iLocalSlot = new int[InitialSize]; m_iStartOffset = new int[InitialSize]; @@ -1042,7 +1047,7 @@ private void EnsureCapacity() Array.Copy(m_iEndOffset, 0, temp, 0, m_iLocalSymCount); m_iEndOffset = temp; - String[] strTemp = new String[newSize]; + string[] strTemp = new string[newSize]; Array.Copy(m_strName, 0, strTemp, 0, m_iLocalSymCount); m_strName = strTemp; @@ -1055,7 +1060,7 @@ private void EnsureCapacity() #endregion #region Internal Members - internal void AddLocalSymInfo(String strName, byte[] signature, int slot, int startOffset, int endOffset) + internal void AddLocalSymInfo(string strName, byte[] signature, int slot, int startOffset, int endOffset) { // make sure that arrays are large enough to hold addition info EnsureCapacity(); @@ -1067,7 +1072,7 @@ internal void AddLocalSymInfo(String strName, byte[] signature, int slot, int st checked { m_iLocalSymCount++; } } - internal void AddUsingNamespace(String strNamespace) + internal void AddUsingNamespace(string strNamespace) { EnsureCapacityNamespace(); m_namespace[m_iNameSpaceCount] = strNamespace; @@ -1161,7 +1166,7 @@ public override int GetHashCode() return m_exceptionClass ^ m_tryStartOffset ^ m_tryEndOffset ^ m_filterOffset ^ m_handlerStartOffset ^ m_handlerEndOffset ^ (int)m_kind; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { return obj is ExceptionHandler && Equals((ExceptionHandler)obj); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs index 63f299a511ba..bbb7c1156320 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodBuilderInstantiation.cs @@ -44,11 +44,11 @@ internal override Type[] GetParameterTypes() #region MemberBase public override MemberTypes MemberType { get { return m_method.MemberType; } } - public override String Name { get { return m_method.Name; } } + public override string Name { get { return m_method.Name; } } public override Type DeclaringType { get { return m_method.DeclaringType; } } public override Type ReflectedType { get { return m_method.ReflectedType; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); } + public override object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_method.IsDefined(attributeType, inherit); } public override Module Module { get { return m_method.Module; } } #endregion @@ -58,7 +58,7 @@ internal override Type[] GetParameterTypes() public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); } public override RuntimeMethodHandle MethodHandle { get { throw new NotSupportedException(SR.NotSupported_DynamicModule); } } public override MethodAttributes Attributes { get { return m_method.Attributes; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs index 9698b0733398..2c0a91872e9d 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/MethodToken.cs @@ -38,7 +38,7 @@ public override int GetHashCode() return m_method; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is MethodToken) return Equals((MethodToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs index 62c6f26b3c16..d0b8c87ab0f9 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ModuleBuilder.cs @@ -219,7 +219,7 @@ internal virtual Type FindTypeBuilderWithName(string strTypeName, bool ignoreCas { foreach (string name in m_TypeBuilderDict.Keys) { - if (string.Compare(name, strTypeName, (StringComparison.OrdinalIgnoreCase)) == 0) + if (string.Equals(name, strTypeName, StringComparison.OrdinalIgnoreCase)) return m_TypeBuilderDict[name]; } } @@ -527,12 +527,12 @@ public override bool Equals(object obj) #endregion #region ICustomAttributeProvider Members - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return InternalModule.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return InternalModule.GetCustomAttributes(attributeType, inherit); } @@ -933,8 +933,35 @@ private EnumBuilder DefineEnumNoLock(string name, TypeAttributes visibility, Typ #region Define Resource #endregion - #region Define Global Method + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, + CallingConventions callingConvention, Type returnType, Type[] parameterTypes, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + return DefinePInvokeMethod(name, dllName, name, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet); + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, + CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, + CharSet nativeCharSet) + { + lock (SyncRoot) + { + //Global methods must be static. + if ((attributes & MethodAttributes.Static) == 0) + { + throw new ArgumentException(SR.Argument_GlobalFunctionHasToBeStatic); + } + + CheckContext(returnType); + CheckContext(parameterTypes); + + m_moduleData.m_fHasGlobal = true; + return m_moduleData.m_globalTypeBuilder.DefinePInvokeMethod(name, dllName, entryName, attributes, callingConvention, returnType, parameterTypes, nativeCallConv, nativeCharSet); + } + } + public MethodBuilder DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) { return DefineGlobalMethod(name, attributes, CallingConventions.Standard, returnType, parameterTypes); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs index a875e3b943fb..2b0e18f4f8d7 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterBuilder.cs @@ -22,7 +22,7 @@ namespace System.Reflection.Emit public class ParameterBuilder { // Set the default value of the parameter - public virtual void SetConstant(Object defaultValue) + public virtual void SetConstant(object defaultValue) { TypeBuilder.SetConstantValue( m_methodBuilder.GetModuleBuilder(), @@ -62,7 +62,7 @@ internal ParameterBuilder( MethodBuilder methodBuilder, int sequence, ParameterAttributes attributes, - String strParamName) // can be NULL string + string strParamName) // can be NULL string { m_iPosition = sequence; m_strParamName = strParamName; @@ -82,7 +82,7 @@ public virtual ParameterToken GetToken() return m_pdToken; } - public virtual String Name + public virtual string Name { get { return m_strParamName; } } @@ -110,7 +110,7 @@ public bool IsOptional get { return ((m_attributes & ParameterAttributes.Optional) != 0); } } - private String m_strParamName; + private string m_strParamName; private int m_iPosition; private ParameterAttributes m_attributes; private MethodBuilder m_methodBuilder; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs index 067bc2d01009..edb351460916 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/ParameterToken.cs @@ -41,7 +41,7 @@ public override int GetHashCode() return m_tkParameter; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is ParameterToken) return Equals((ParameterToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs index 0fbdd8371b87..3ebfbe9d099e 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyBuilder.cs @@ -30,7 +30,7 @@ public sealed class PropertyBuilder : PropertyInfo // internal PropertyBuilder( ModuleBuilder mod, // the module containing this PropertyBuilder - String name, // property name + string name, // property name SignatureHelper sig, // property signature descriptor info PropertyAttributes attr, // property attribute such as DefaultProperty, Bindable, DisplayBind, etc Type returnType, // return type of the property. @@ -57,7 +57,7 @@ internal PropertyBuilder( //************************************************ // Set the default value of the Property //************************************************ - public void SetConstant(Object defaultValue) + public void SetConstant(object defaultValue) { m_containingType.ThrowIfCreated(); @@ -146,22 +146,22 @@ public void SetCustomAttribute(CustomAttributeBuilder customBuilder) } // Not supported functions in dynamic module. - public override Object GetValue(Object obj, Object[] index) + public override object GetValue(object obj, object[] index) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) + public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj, Object value, Object[] index) + public override void SetValue(object obj, object value, object[] index) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -216,12 +216,12 @@ public override bool CanWrite get { if (m_setMethod != null) return true; else return false; } } - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(SR.NotSupported_DynamicModule); } @@ -231,7 +231,7 @@ public override bool IsDefined(Type attributeType, bool inherit) throw new NotSupportedException(SR.NotSupported_DynamicModule); } - public override String Name + public override string Name { get { return m_name; } } @@ -247,7 +247,7 @@ public override Type ReflectedType } // These are package private so that TypeBuilder can access them. - private String m_name; // The name of the property + private string m_name; // The name of the property private PropertyToken m_prToken; // The token of this property private int m_tkProperty; private ModuleBuilder m_moduleBuilder; diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs index 02f34881f404..25b92244cc5f 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/PropertyToken.cs @@ -41,7 +41,7 @@ public override int GetHashCode() } // Satisfy value class requirements - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is PropertyToken) return Equals((PropertyToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs index d9490838aa58..cad49cb1bc25 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureHelper.cs @@ -820,7 +820,7 @@ public void AddSentinel() AddElementType(CorElementType.Sentinel); } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (!(obj is SignatureHelper)) { @@ -888,7 +888,7 @@ internal byte[] GetSignature(bool appendEndOfSig) return m_signature; } - public override String ToString() + public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("Length: " + m_currSig + Environment.NewLine); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs index e17e0c955ed4..780c61e3142d 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SignatureToken.cs @@ -42,7 +42,7 @@ public override int GetHashCode() return m_signature; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is SignatureToken) return Equals((SignatureToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/StringToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/StringToken.cs index cc5b734ae879..936d56953cff 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/StringToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/StringToken.cs @@ -44,7 +44,7 @@ public override int GetHashCode() return m_string; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is StringToken) return Equals((StringToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs index 5e5668ac7b59..5c644b648eca 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolMethod.cs @@ -16,7 +16,7 @@ internal sealed class SymbolMethod : MethodInfo #region Private Data Members private ModuleBuilder m_module; private Type m_containingType; - private String m_name; + private string m_name; private CallingConventions m_callingConvention; private Type m_returnType; private MethodToken m_mdMethod; @@ -25,7 +25,7 @@ internal sealed class SymbolMethod : MethodInfo #endregion #region Constructor - internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, String methodName, + internal SymbolMethod(ModuleBuilder mod, MethodToken token, Type arrayClass, string methodName, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) { // This is a kind of MethodInfo to represent methods for array type of unbaked type @@ -83,7 +83,7 @@ public override Type ReflectedType get { return m_containingType as Type; } } - public override String Name + public override string Name { get { return m_name; } } @@ -136,7 +136,7 @@ public override ICustomAttributeProvider ReturnTypeCustomAttributes get { return null; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } @@ -148,12 +148,12 @@ public override MethodInfo GetBaseDefinition() #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(SR.NotSupported_SymbolMethod); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs index 07fd6d922dc8..d550dbbd4e6c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/SymbolType.cs @@ -322,8 +322,8 @@ public override Guid GUID get { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } } - public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, - Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) + public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, + object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } @@ -555,12 +555,12 @@ public override Type UnderlyingSystemType get { return this; } } - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(SR.NotSupported_NonReflectedType); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs index 3f4a83801f1f..30978730ffed 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilder.cs @@ -3,7 +3,7 @@ // See the LICENSE file in the project root for more information. -// +// namespace System.Reflection.Emit { @@ -18,20 +18,6 @@ namespace System.Reflection.Emit using System.Runtime.Versioning; using System.Diagnostics; - - public enum PackingSize - { - Unspecified = 0, - Size1 = 1, - Size2 = 2, - Size4 = 4, - Size8 = 8, - Size16 = 16, - Size32 = 32, - Size64 = 64, - Size128 = 128, - } - public sealed class TypeBuilder : TypeInfo { public override bool IsAssignableFrom(System.Reflection.TypeInfo typeInfo) @@ -88,11 +74,11 @@ public static MethodInfo GetMethod(Type type, MethodInfo method) if (!(type is TypeBuilder) && !(type is TypeBuilderInstantiation)) throw new ArgumentException(SR.Argument_MustBeTypeBuilder); - // The following checks establishes invariants that more simply put require type to be generic and + // The following checks establishes invariants that more simply put require type to be generic and // method to be a generic method definition declared on the generic type definition of type. - // To create generic method G.M these invariants require that G.M be created by calling + // To create generic method G.M these invariants require that G.M be created by calling // this function followed by MakeGenericMethod on the resulting MethodInfo to finally get G.M. - // We could also allow G.M to be created before G.M (BindGenParm followed by this method) + // We could also allow G.M to be created before G.M (BindGenParm followed by this method) // if we wanted to but that just complicates things so these checks are designed to prevent that scenario. if (method.IsGenericMethod && !method.IsGenericMethodDefinition) @@ -105,7 +91,7 @@ public static MethodInfo GetMethod(Type type, MethodInfo method) throw new ArgumentException(SR.Argument_InvalidMethodDeclaringType, nameof(type)); // The following converts from Type or TypeBuilder of G to TypeBuilderInstantiation G. These types - // both logically represent the same thing. The runtime displays a similar convention by having + // both logically represent the same thing. The runtime displays a similar convention by having // G.M() be encoded by a typeSpec whose parent is the typeDef for G and whose instantiation is also G. if (type.IsGenericTypeDefinition) type = type.MakeGenericType(type.GetGenericArguments()); @@ -241,6 +227,9 @@ internal static extern int SetParamInfo(RuntimeModule module, int tkMethod, int [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] private static extern unsafe void SetConstantValue(RuntimeModule module, int tk, int corType, void* pValue); + [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] + private static extern void SetPInvokeData(RuntimeModule module, string DllName, string name, int token, int linkFlags); + #endregion #region Internal\Private Static Members @@ -277,18 +266,18 @@ internal static bool IsTypeEqual(Type t1, Type t2) runtimeType2 = t2; } - // If the type builder view is eqaul then it is equal - if (tb1 != null && tb2 != null && Object.ReferenceEquals(tb1, tb2)) + // If the type builder view is eqaul then it is equal + if (tb1 != null && tb2 != null && object.ReferenceEquals(tb1, tb2)) return true; - // if the runtimetype view is eqaul than it is equal + // if the runtimetype view is eqaul than it is equal if (runtimeType1 != null && runtimeType2 != null && runtimeType1 == runtimeType2) return true; return false; } - internal static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, Object value) + internal static unsafe void SetConstantValue(ModuleBuilder module, int tk, Type destType, object value) { // This is a helper function that is used by ParameterBuilder, PropertyBuilder, // and FieldBuilder to validate a default value and save it in the meta-data. @@ -594,7 +583,6 @@ private void Init(string fullname, TypeAttributes attr, Type parent, Type[] inte #endregion #region Private Members - private FieldBuilder DefineDataHelper(string name, byte[] data, int size, FieldAttributes attributes) { string strValueClassName; @@ -673,7 +661,6 @@ public bool IsCreated() { return m_hasBeenCreated; } - #endregion #region FCalls @@ -801,8 +788,8 @@ public override Guid GUID } } - public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, - Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) + public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, + object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -1030,7 +1017,7 @@ public override bool IsAssignableFrom(Type c) return m_bakedRuntimeType.IsAssignableFrom(fromRuntimeType); } - // So if c is not a runtimeType nor TypeBuilder. We don't know how to deal with it. + // So if c is not a runtimeType nor TypeBuilder. We don't know how to deal with it. // return false then. if (fromTypeBuilder == null) return false; @@ -1192,7 +1179,7 @@ public override Type MakeArrayType(int rank) #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -1200,7 +1187,7 @@ public override Object[] GetCustomAttributes(bool inherit) return CustomAttribute.GetCustomAttributes(m_bakedRuntimeType, typeof(object) as RuntimeType, inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (!IsCreated()) throw new NotSupportedException(SR.NotSupported_TypeNotYetCreated); @@ -1415,6 +1402,141 @@ private MethodBuilder DefineMethodNoLock(string name, MethodAttributes attribute return method; } + public MethodBuilder DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, + CallingConventions callingConvention, Type returnType, Type[] parameterTypes, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + MethodBuilder method = DefinePInvokeMethodHelper( + name, dllName, name, attributes, callingConvention, returnType, null, null, + parameterTypes, null, null, nativeCallConv, nativeCharSet); + return method; + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, + CallingConventions callingConvention, Type returnType, Type[] parameterTypes, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + MethodBuilder method = DefinePInvokeMethodHelper( + name, dllName, entryName, attributes, callingConvention, returnType, null, null, + parameterTypes, null, null, nativeCallConv, nativeCharSet); + return method; + } + + public MethodBuilder DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, + CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + MethodBuilder method = DefinePInvokeMethodHelper( + name, dllName, entryName, attributes, callingConvention, returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, nativeCallConv, nativeCharSet); + return method; + } + + private MethodBuilder DefinePInvokeMethodHelper( + string name, string dllName, string importName, MethodAttributes attributes, CallingConventions callingConvention, + Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers, + Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers, + CallingConvention nativeCallConv, CharSet nativeCharSet) + { + CheckContext(returnType); + CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes); + CheckContext(parameterTypeRequiredCustomModifiers); + CheckContext(parameterTypeOptionalCustomModifiers); + + lock (SyncRoot) + { + if (name == null) + throw new ArgumentNullException(nameof(name)); + + if (name.Length == 0) + throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); + + if (dllName == null) + throw new ArgumentNullException(nameof(dllName)); + + if (dllName.Length == 0) + throw new ArgumentException(SR.Argument_EmptyName, nameof(dllName)); + + if (importName == null) + throw new ArgumentNullException(nameof(importName)); + + if (importName.Length == 0) + throw new ArgumentException(SR.Argument_EmptyName, nameof(importName)); + + if ((attributes & MethodAttributes.Abstract) != 0) + throw new ArgumentException(SR.Argument_BadPInvokeMethod); + + if ((m_iAttr & TypeAttributes.ClassSemanticsMask) == TypeAttributes.Interface) + throw new ArgumentException(SR.Argument_BadPInvokeOnInterface); + + ThrowIfCreated(); + + attributes = attributes | MethodAttributes.PinvokeImpl; + MethodBuilder method = new MethodBuilder(name, attributes, callingConvention, + returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, + parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers, + m_module, this, false); + + //The signature grabbing code has to be up here or the signature won't be finished + //and our equals check won't work. + int sigLength; + byte[] sigBytes = method.GetMethodSignature().InternalGetSignature(out sigLength); + + if (m_listMethods.Contains(method)) + { + throw new ArgumentException(SR.Argument_MethodRedefined); + } + m_listMethods.Add(method); + + MethodToken token = method.GetToken(); + + int linkFlags = 0; + switch (nativeCallConv) + { + case CallingConvention.Winapi: + linkFlags = (int)PInvokeMap.CallConvWinapi; + break; + case CallingConvention.Cdecl: + linkFlags = (int)PInvokeMap.CallConvCdecl; + break; + case CallingConvention.StdCall: + linkFlags = (int)PInvokeMap.CallConvStdcall; + break; + case CallingConvention.ThisCall: + linkFlags = (int)PInvokeMap.CallConvThiscall; + break; + case CallingConvention.FastCall: + linkFlags = (int)PInvokeMap.CallConvFastcall; + break; + } + switch (nativeCharSet) + { + case CharSet.None: + linkFlags |= (int)PInvokeMap.CharSetNotSpec; + break; + case CharSet.Ansi: + linkFlags |= (int)PInvokeMap.CharSetAnsi; + break; + case CharSet.Unicode: + linkFlags |= (int)PInvokeMap.CharSetUnicode; + break; + case CharSet.Auto: + linkFlags |= (int)PInvokeMap.CharSetAuto; + break; + } + + SetPInvokeData(m_module.GetNativeHandle(), + dllName, + importName, + token.Token, + linkFlags); + method.SetToken(token); + + return method; + } + } #endregion #region Define Constructor @@ -1940,7 +2062,7 @@ private TypeInfo CreateTypeNoLock() if (meth.IsGenericMethodDefinition) - meth.GetToken(); // Doubles as "CreateMethod" for MethodBuilder -- analagous to CreateType() + meth.GetToken(); // Doubles as "CreateMethod" for MethodBuilder -- analogous to CreateType() methodAttrs = meth.Attributes; @@ -2063,7 +2185,7 @@ public void SetParent(Type parent) { if ((m_iAttr & TypeAttributes.Interface) != TypeAttributes.Interface) { - m_typeParent = typeof(Object); + m_typeParent = typeof(object); } else { diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs index 677f51c6102d..0b3d75cca316 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeBuilderInstantiation.cs @@ -102,7 +102,7 @@ public override Type MakeArrayType(int rank) return SymbolType.FormCompoundType(s, this, 0); } public override Guid GUID { get { throw new NotSupportedException(); } } - public override Object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } + public override object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters) { throw new NotSupportedException(); } public override Assembly Assembly { get { return m_type.Assembly; } } public override RuntimeTypeHandle TypeHandle { get { throw new NotSupportedException(); } } public override string FullName @@ -230,9 +230,9 @@ public override bool IsSubclassOf(Type c) #endregion #region ICustomAttributeProvider Implementation - public override Object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } + public override object[] GetCustomAttributes(bool inherit) { throw new NotSupportedException(); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { throw new NotSupportedException(); } public override bool IsDefined(Type attributeType, bool inherit) { throw new NotSupportedException(); } #endregion diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs index 15a0816a503c..4825a04f244f 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/TypeToken.cs @@ -41,7 +41,7 @@ public override int GetHashCode() return m_class; } - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (obj is TypeToken) return Equals((TypeToken)obj); diff --git a/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs b/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs index 715fe01f549d..633811232fe4 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/Emit/XXXOnTypeBuilderInstantiation.cs @@ -44,11 +44,11 @@ internal override Type[] GetParameterTypes() #region MemberInfo Overrides public override MemberTypes MemberType { get { return m_method.MemberType; } } - public override String Name { get { return m_method.Name; } } + public override string Name { get { return m_method.Name; } } public override Type DeclaringType { get { return m_type; } } public override Type ReflectedType { get { return m_type; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); } + public override object[] GetCustomAttributes(bool inherit) { return m_method.GetCustomAttributes(inherit); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_method.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_method.IsDefined(attributeType, inherit); } public override Module Module { get { return m_method.Module; } } #endregion @@ -58,7 +58,7 @@ internal override Type[] GetParameterTypes() public override MethodImplAttributes GetMethodImplementationFlags() { return m_method.GetMethodImplementationFlags(); } public override RuntimeMethodHandle MethodHandle { get { return m_method.MethodHandle; } } public override MethodAttributes Attributes { get { return m_method.Attributes; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(); } @@ -123,11 +123,11 @@ internal override Type GetReturnType() #region MemberInfo Overrides public override MemberTypes MemberType { get { return m_ctor.MemberType; } } - public override String Name { get { return m_ctor.Name; } } + public override string Name { get { return m_ctor.Name; } } public override Type DeclaringType { get { return m_type; } } public override Type ReflectedType { get { return m_type; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_ctor.GetCustomAttributes(attributeType, inherit); } + public override object[] GetCustomAttributes(bool inherit) { return m_ctor.GetCustomAttributes(inherit); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_ctor.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_ctor.IsDefined(attributeType, inherit); } internal int MetadataTokenInternal { @@ -152,7 +152,7 @@ internal int MetadataTokenInternal public override MethodImplAttributes GetMethodImplementationFlags() { return m_ctor.GetMethodImplementationFlags(); } public override RuntimeMethodHandle MethodHandle { get { return m_ctor.MethodHandle; } } public override MethodAttributes Attributes { get { return m_ctor.Attributes; } } - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new NotSupportedException(); } @@ -165,7 +165,7 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder #endregion #region ConstructorInfo Members - public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { throw new InvalidOperationException(); } @@ -224,11 +224,11 @@ internal FieldOnTypeBuilderInstantiation(FieldInfo field, TypeBuilderInstantiati #region MemberInfo Overrides public override MemberTypes MemberType { get { return System.Reflection.MemberTypes.Field; } } - public override String Name { get { return m_field.Name; } } + public override string Name { get { return m_field.Name; } } public override Type DeclaringType { get { return m_type; } } public override Type ReflectedType { get { return m_type; } } - public override Object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_field.GetCustomAttributes(attributeType, inherit); } + public override object[] GetCustomAttributes(bool inherit) { return m_field.GetCustomAttributes(inherit); } + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { return m_field.GetCustomAttributes(attributeType, inherit); } public override bool IsDefined(Type attributeType, bool inherit) { return m_field.IsDefined(attributeType, inherit); } internal int MetadataTokenInternal { @@ -251,11 +251,11 @@ internal int MetadataTokenInternal #region Public Abstract\Virtual Members public override Type[] GetRequiredCustomModifiers() { return m_field.GetRequiredCustomModifiers(); } public override Type[] GetOptionalCustomModifiers() { return m_field.GetOptionalCustomModifiers(); } - public override void SetValueDirect(TypedReference obj, Object value) + public override void SetValueDirect(TypedReference obj, object value) { throw new NotImplementedException(); } - public override Object GetValueDirect(TypedReference obj) + public override object GetValueDirect(TypedReference obj) { throw new NotImplementedException(); } @@ -264,8 +264,8 @@ public override RuntimeFieldHandle FieldHandle get { throw new NotImplementedException(); } } public override Type FieldType { get { throw new NotImplementedException(); } } - public override Object GetValue(Object obj) { throw new InvalidOperationException(); } - public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new InvalidOperationException(); } + public override object GetValue(object obj) { throw new InvalidOperationException(); } + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new InvalidOperationException(); } public override FieldAttributes Attributes { get { return m_field.Attributes; } } #endregion } diff --git a/src/System.Private.CoreLib/src/System/Reflection/LoaderAllocator.cs b/src/System.Private.CoreLib/src/System/Reflection/LoaderAllocator.cs index 54477734c270..1119f07fa4ef 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/LoaderAllocator.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/LoaderAllocator.cs @@ -43,10 +43,9 @@ internal sealed class LoaderAllocatorScout // Assemblies and LoaderAllocators will be cleaned up during AppDomain shutdown in // unmanaged code - // So it is ok to skip reregistration and cleanup for finalization during appdomain shutdown. + // So it is ok to skip reregistration and cleanup for finalization during shutdown. // We also avoid early finalization of LoaderAllocatorScout due to AD unload when the object was inside DelayedFinalizationList. - if (!Environment.HasShutdownStarted && - !AppDomain.CurrentDomain.IsFinalizingForUnload()) + if (!Environment.HasShutdownStarted) { // Destroy returns false if the managed LoaderAllocator is still alive. if (!Destroy(m_nativeLoaderAllocator)) diff --git a/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs b/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs index b959b2ccf176..a2fd72ecc38d 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MdConstant.cs @@ -10,7 +10,7 @@ namespace System.Reflection { internal static class MdConstant { - public static unsafe Object GetValue(MetadataImport scope, int token, RuntimeTypeHandle fieldTypeHandle, bool raw) + public static unsafe object GetValue(MetadataImport scope, int token, RuntimeTypeHandle fieldTypeHandle, bool raw) { CorElementType corElementType = 0; long buffer = 0; diff --git a/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs index 94416d7aa3ef..517b2285c568 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MdFieldInfo.cs @@ -43,7 +43,7 @@ internal override bool CacheEquals(object o) #endregion #region MemberInfo Overrides - public override String Name + public override string Name { get { @@ -68,32 +68,32 @@ public override String Name [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object GetValueDirect(TypedReference obj) + public override object GetValueDirect(TypedReference obj) { return GetValue(null); } [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValueDirect(TypedReference obj, Object value) + public override void SetValueDirect(TypedReference obj, object value) { throw new FieldAccessException(SR.Acc_ReadOnly); } [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public unsafe override Object GetValue(Object obj) + public unsafe override object GetValue(object obj) { return GetValue(false); } - public unsafe override Object GetRawConstantValue() { return GetValue(true); } + public unsafe override object GetRawConstantValue() { return GetValue(true); } - private unsafe Object GetValue(bool raw) + private unsafe object GetValue(bool raw) { // Cannot cache these because they could be user defined non-agile enumerations - Object value = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_tkField, FieldType.GetTypeHandleInternal(), raw); + object value = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_tkField, FieldType.GetTypeHandleInternal(), raw); if (value == DBNull.Value) throw new NotSupportedException(SR.Arg_EnumLitValueNotFound); @@ -103,7 +103,7 @@ private unsafe Object GetValue(bool raw) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { throw new FieldAccessException(SR.Acc_ReadOnly); } diff --git a/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs index 09d35201203f..c6f01c67f61c 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/MethodBase.CoreCLR.cs @@ -127,16 +127,16 @@ internal virtual Type[] GetParameterTypes() return parameterTypes; } - internal Object[] CheckArguments(Object[] parameters, Binder binder, + internal object[] CheckArguments(object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig) { // copy the arguments in a different array so we detach from any user changes - Object[] copyOfParameters = new Object[parameters.Length]; + object[] copyOfParameters = new object[parameters.Length]; ParameterInfo[] p = null; for (int i = 0; i < parameters.Length; i++) { - Object arg = parameters[i]; + object arg = parameters[i]; RuntimeType argRT = sig.Arguments[i]; if (arg == Type.Missing) diff --git a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs index 0ebed6ee0010..6172ec469aca 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RtFieldInfo.cs @@ -13,7 +13,7 @@ namespace System.Reflection internal unsafe sealed class RtFieldInfo : RuntimeFieldInfo, IRuntimeFieldInfo { #region Private Data Members - // agressive caching + // aggressive caching private IntPtr m_fieldHandle; private FieldAttributes m_fieldAttributes; // lazy caching @@ -43,7 +43,7 @@ internal INVOCATION_FLAGS InvocationFlags } // If the invocationFlags are still 0, then - // this should be an usable field, determine the other flags + // this should be an usable field, determine the other flags if (invocationFlags == 0) { if ((m_fieldAttributes & FieldAttributes.InitOnly) != (FieldAttributes)0) @@ -89,7 +89,7 @@ RuntimeFieldHandleInternal IRuntimeFieldInfo.Value #endregion #region Internal Members - internal void CheckConsistency(Object target) + internal void CheckConsistency(object target) { // only test instance fields if ((m_fieldAttributes & FieldAttributes.Static) != FieldAttributes.Static) @@ -122,7 +122,7 @@ internal override bool CacheEquals(object o) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - internal void InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, ref StackCrawlMark stackMark) + internal void InternalSetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, ref StackCrawlMark stackMark) { INVOCATION_FLAGS invocationFlags = InvocationFlags; RuntimeType declaringType = DeclaringType as RuntimeType; @@ -159,12 +159,12 @@ internal void InternalSetValue(Object obj, Object value, BindingFlags invokeAttr // UnsafeSetValue doesn't perform any consistency or visibility check. // It is the caller's responsibility to ensure the operation is safe. // When the caller needs to perform visibility checks they should call - // InternalSetValue() instead. When the caller needs to perform - // consistency checks they should call CheckConsistency() before + // InternalSetValue() instead. When the caller needs to perform + // consistency checks they should call CheckConsistency() before // calling this method. [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - internal void UnsafeSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) + internal void UnsafeSetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { RuntimeType declaringType = DeclaringType as RuntimeType; RuntimeType fieldType = (RuntimeType)FieldType; @@ -185,7 +185,7 @@ internal void UnsafeSetValue(Object obj, Object value, BindingFlags invokeAttr, [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - internal Object InternalGetValue(Object obj, ref StackCrawlMark stackMark) + internal object InternalGetValue(object obj, ref StackCrawlMark stackMark) { INVOCATION_FLAGS invocationFlags = InvocationFlags; RuntimeType declaringType = DeclaringType as RuntimeType; @@ -209,12 +209,12 @@ internal Object InternalGetValue(Object obj, ref StackCrawlMark stackMark) // UnsafeGetValue doesn't perform any consistency or visibility check. // It is the caller's responsibility to ensure the operation is safe. // When the caller needs to perform visibility checks they should call - // InternalGetValue() instead. When the caller needs to perform - // consistency checks they should call CheckConsistency() before + // InternalGetValue() instead. When the caller needs to perform + // consistency checks they should call CheckConsistency() before // calling this method. [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - internal Object UnsafeGetValue(Object obj) + internal object UnsafeGetValue(object obj) { RuntimeType declaringType = DeclaringType as RuntimeType; @@ -268,8 +268,8 @@ internal override RuntimeModule GetRuntimeModule() #endregion - #region FieldInfo Overrides - public override Object GetValue(Object obj) + #region FieldInfo Overrides + public override object GetValue(object obj) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return InternalGetValue(obj, ref stackMark); @@ -279,7 +279,7 @@ public override Object GetValue(Object obj) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object GetValueDirect(TypedReference obj) + public override object GetValueDirect(TypedReference obj) { if (obj.IsNull) throw new ArgumentException(SR.Arg_TypedReference_Null); @@ -293,7 +293,7 @@ public override Object GetValueDirect(TypedReference obj) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; InternalSetValue(obj, value, invokeAttr, binder, culture, ref stackMark); @@ -301,7 +301,7 @@ public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValueDirect(TypedReference obj, Object value) + public override void SetValueDirect(TypedReference obj, object value) { if (obj.IsNull) throw new ArgumentException(SR.Arg_TypedReference_Null); diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs index f7fc0848d0ae..ae2e79f84408 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeAssembly.cs @@ -167,7 +167,7 @@ public override Type GetType(string name, bool throwOnError, bool ignoreCase) throw new ArgumentNullException(nameof(name)); RuntimeType type = null; - Object keepAlive = null; + object keepAlive = null; GetType(GetNativeHandle(), name, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack(ref type), JitHelpers.GetObjectHandleOnStack(ref keepAlive)); GC.KeepAlive(keepAlive); @@ -232,12 +232,12 @@ public override Module ManifestModule } } - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -502,7 +502,7 @@ public override bool GlobalAssemblyCache } } - public override Int64 HostContext + public override long HostContext { get { @@ -583,7 +583,7 @@ internal unsafe Stream GetManifestResourceStream(string name, ref StackCrawlMark if (pbInMemoryResource != null) { //Console.WriteLine("Creating an unmanaged memory stream of length "+length); - if (length > Int64.MaxValue) + if (length > long.MaxValue) throw new NotImplementedException(SR.NotImplemented_ResourcesLongerThanInt64Max); return new UnmanagedMemoryStream(pbInMemoryResource, (long)length, (long)length, FileAccess.Read); diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs index 59f3b5093ce7..5e9d5e33a8b1 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeConstructorInfo.cs @@ -120,7 +120,7 @@ private RuntimeType ReflectedTypeInternal } } - private void CheckConsistency(Object target) + private void CheckConsistency(object target) { if (target == null && IsStatic) return; @@ -149,12 +149,12 @@ public override string ToString() #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -335,8 +335,8 @@ internal void ThrowNoInvokeException() [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object Invoke( - Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke( + object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { INVOCATION_FLAGS invocationFlags = InvocationFlags; @@ -358,8 +358,8 @@ public override Object Invoke( bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0; if (actualCount > 0) { - Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); - Object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, sig, false, wrapExceptions); + object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); + object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, sig, false, wrapExceptions); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) parameters[index] = arguments[index]; @@ -403,7 +403,7 @@ public override bool ContainsGenericParameters #region ConstructorInfo Overrides [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { INVOCATION_FLAGS invocationFlags = InvocationFlags; @@ -428,8 +428,8 @@ public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] p bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0; if (actualCount > 0) { - Object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); - Object retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, true, wrapExceptions); + object[] arguments = CheckArguments(parameters, binder, invokeAttr, culture, sig); + object retValue = RuntimeMethodHandle.InvokeMethod(null, arguments, sig, true, wrapExceptions); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) parameters[index] = arguments[index]; diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs index 4152f2bdd6df..ef287b4b5f32 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeEventInfo.cs @@ -70,7 +70,7 @@ internal override bool CacheEquals(object o) #endregion #region Object Overrides - public override String ToString() + public override string ToString() { if (m_addMethod == null || m_addMethod.GetParametersNoCopy().Length == 0) throw new InvalidOperationException(SR.InvalidOperation_NoPublicAddMethod); @@ -80,12 +80,12 @@ public override String ToString() #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -119,7 +119,7 @@ public override IList GetCustomAttributesData() #region MemberInfo Overrides public override MemberTypes MemberType { get { return MemberTypes.Event; } } - public override String Name + public override string Name { get { diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs index 56f89e618fe7..7b35cd701ef1 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeFieldInfo.cs @@ -71,19 +71,19 @@ public override Type DeclaringType #endregion #region Object Overrides - public unsafe override String ToString() + public unsafe override string ToString() { return FieldType.FormatTypeName() + " " + Name; } #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs index 8bebfb3e704c..b58f95645a91 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeMethodInfo.cs @@ -194,7 +194,7 @@ internal RuntimeType GetDeclaringTypeInternal() #endregion #region Object Overrides - public override String ToString() + public override string ToString() { if (m_toString == null) m_toString = ReturnType.FormatTypeName() + " " + FormatNameAndSig(); @@ -255,12 +255,12 @@ public override bool Equals(object obj) #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType as RuntimeType, inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -293,7 +293,7 @@ public override IList GetCustomAttributesData() #endregion #region MemberInfo Overrides - public override String Name + public override string Name { get { @@ -410,7 +410,7 @@ public override MethodBody GetMethodBody() #endregion #region Invocation Logic(On MemberBase) - private void CheckConsistency(Object target) + private void CheckConsistency(object target) { // only test instance methods if ((m_methodAttributes & MethodAttributes.Static) != MethodAttributes.Static) @@ -467,7 +467,7 @@ private void ThrowNoInvokeException() [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + public override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { object[] arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture); @@ -476,7 +476,7 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder return RuntimeMethodHandle.InvokeMethod(obj, null, Signature, false, wrapExceptions); else { - Object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, Signature, false, wrapExceptions); + object retValue = RuntimeMethodHandle.InvokeMethod(obj, arguments, Signature, false, wrapExceptions); // copy out. This should be made only if ByRef are present. for (int index = 0; index < arguments.Length; index++) @@ -488,7 +488,7 @@ public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - private object[] InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) + private object[] InvokeArgumentsCheck(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture) { Signature sig = Signature; @@ -580,7 +580,7 @@ public override Delegate CreateDelegate(Type delegateType) DelegateBindingFlags.OpenDelegateOnly | DelegateBindingFlags.RelaxedSignature); } - public override Delegate CreateDelegate(Type delegateType, Object target) + public override Delegate CreateDelegate(Type delegateType, object target) { // This API is new in Whidbey and allows the full range of delegate // flexability (open or closed delegates binding to static or @@ -593,7 +593,7 @@ public override Delegate CreateDelegate(Type delegateType, Object target) DelegateBindingFlags.RelaxedSignature); } - private Delegate CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags) + private Delegate CreateDelegateInternal(Type delegateType, object firstArgument, DelegateBindingFlags bindingFlags) { // Validate the parameters. if (delegateType == null) diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs index 600147c77ddf..b33f004198ae 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeModule.cs @@ -400,12 +400,12 @@ internal MetadataImport MetadataImport #endregion #region ICustomAttributeProvider Members - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -450,7 +450,7 @@ public override Type GetType(string className, bool throwOnError, bool ignoreCas throw new ArgumentNullException(nameof(className)); RuntimeType retType = null; - Object keepAlive = null; + object keepAlive = null; GetType(GetNativeHandle(), className, throwOnError, ignoreCase, JitHelpers.GetObjectHandleOnStack(ref retType), JitHelpers.GetObjectHandleOnStack(ref keepAlive)); GC.KeepAlive(keepAlive); return retType; diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs index 1bd053ee823a..2762ecf02a33 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimeParameterInfo.cs @@ -201,7 +201,7 @@ private RuntimeParameterInfo( } // ctor for no metadata MethodInfo in the DynamicMethod and RuntimeMethodInfo cases - internal RuntimeParameterInfo(MethodInfo owner, String name, Type parameterType, int position) + internal RuntimeParameterInfo(MethodInfo owner, string name, Type parameterType, int position) { MemberImpl = owner; NameImpl = name; @@ -238,7 +238,7 @@ public override Type ParameterType } } - public override String Name + public override string Name { get { @@ -274,10 +274,10 @@ public override bool HasDefaultValue } } - public override Object DefaultValue { get { return GetDefaultValue(false); } } - public override Object RawDefaultValue { get { return GetDefaultValue(true); } } + public override object DefaultValue { get { return GetDefaultValue(false); } } + public override object RawDefaultValue { get { return GetDefaultValue(true); } } - private Object GetDefaultValue(bool raw) + private object GetDefaultValue(bool raw) { // OLD COMMENT (Is this even true?) // Cannot cache because default value could be non-agile user defined enumeration. @@ -303,7 +303,7 @@ private Object GetDefaultValue(bool raw) } // returns DBNull.Value if the parameter doesn't have a default value - private Object GetDefaultValueInternal(bool raw) + private object GetDefaultValueInternal(bool raw) { Debug.Assert(!m_noMetadata); @@ -371,7 +371,7 @@ private Object GetDefaultValueInternal(bool raw) } else { - Object[] CustomAttrs = GetCustomAttributes(s_CustomConstantAttributeType, false); + object[] CustomAttrs = GetCustomAttributes(s_CustomConstantAttributeType, false); if (CustomAttrs.Length != 0) { defaultValue = ((CustomConstantAttribute)CustomAttrs[0]).Value; @@ -394,7 +394,7 @@ private Object GetDefaultValueInternal(bool raw) return defaultValue; } - private static Decimal GetRawDecimalConstant(CustomAttributeData attr) + private static decimal GetRawDecimalConstant(CustomAttributeData attr) { Debug.Assert(attr.Constructor.DeclaringType == typeof(DecimalConstantAttribute)); @@ -404,7 +404,7 @@ private static Decimal GetRawDecimalConstant(CustomAttributeData attr) { // This is not possible because Decimal cannot be represented directly in the metadata. Debug.Fail("Decimal cannot be represented directly in the metadata."); - return (Decimal)namedArgument.TypedValue.Value; + return (decimal)namedArgument.TypedValue.Value; } } @@ -417,9 +417,9 @@ private static Decimal GetRawDecimalConstant(CustomAttributeData attr) if (parameters[2].ParameterType == typeof(uint)) { // DecimalConstantAttribute(byte scale, byte sign, uint hi, uint mid, uint low) - int low = (int)(UInt32)args[4].Value; - int mid = (int)(UInt32)args[3].Value; - int hi = (int)(UInt32)args[2].Value; + int low = (int)(uint)args[4].Value; + int mid = (int)(uint)args[3].Value; + int hi = (int)(uint)args[2].Value; byte sign = (byte)args[1].Value; byte scale = (byte)args[0].Value; @@ -505,21 +505,21 @@ public override Type[] GetOptionalCustomModifiers() #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { if (MdToken.IsNullToken(m_tkParamDef)) - return Array.Empty(); + return Array.Empty(); return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); if (MdToken.IsNullToken(m_tkParamDef)) - return Array.Empty(); + return Array.Empty(); RuntimeType attributeRuntimeType = attributeType.UnderlyingSystemType as RuntimeType; diff --git a/src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs b/src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs index 1e64da212302..880e826bbcb4 100644 --- a/src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs +++ b/src/System.Private.CoreLib/src/System/Reflection/RuntimePropertyInfo.cs @@ -120,7 +120,7 @@ internal bool EqualsSig(RuntimePropertyInfo target) #endregion #region Object Overrides - public override String ToString() + public override string ToString() { return FormatNameAndSig(false); } @@ -145,12 +145,12 @@ private string FormatNameAndSig(bool serialization) #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, typeof(object) as RuntimeType); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if (attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -184,7 +184,7 @@ public override IList GetCustomAttributesData() #region MemberInfo Overrides public override MemberTypes MemberType { get { return MemberTypes.Property; } } - public override String Name + public override string Name { get { @@ -242,7 +242,7 @@ public override Type[] GetOptionalCustomModifiers() internal object GetConstantValue(bool raw) { - Object defaultValue = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_token, PropertyType.GetTypeHandleInternal(), raw); + object defaultValue = MdConstant.GetValue(GetRuntimeModule().MetadataImport, m_token, PropertyType.GetTypeHandleInternal(), raw); if (defaultValue == DBNull.Value) // Arg_EnumLitValueNotFound -> "Literal value was not found." @@ -385,7 +385,7 @@ public override bool CanWrite #region Dynamic [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object GetValue(Object obj, Object[] index) + public override object GetValue(object obj, object[] index) { return GetValue(obj, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static, null, index, null); @@ -393,7 +393,7 @@ public override Object GetValue(Object obj, Object[] index) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) + public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { MethodInfo m = GetGetMethod(true); if (m == null) @@ -403,7 +403,7 @@ public override Object GetValue(Object obj, BindingFlags invokeAttr, Binder bind [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValue(Object obj, Object value, Object[] index) + public override void SetValue(object obj, object value, object[] index) { SetValue(obj, value, @@ -415,18 +415,18 @@ public override void SetValue(Object obj, Object value, Object[] index) [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture) + public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture) { MethodInfo m = GetSetMethod(true); if (m == null) throw new ArgumentException(System.SR.Arg_SetMethNotFnd); - Object[] args = null; + object[] args = null; if (index != null) { - args = new Object[index.Length + 1]; + args = new object[index.Length + 1]; for (int i = 0; i < index.Length; i++) args[i] = index[i]; @@ -435,7 +435,7 @@ public override void SetValue(Object obj, Object value, BindingFlags invokeAttr, } else { - args = new Object[1]; + args = new object[1]; args[0] = value; } diff --git a/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs index 12e0832f61c1..eafffd34cfd1 100644 --- a/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/FileBasedResourceGroveler.cs @@ -34,16 +34,16 @@ public FileBasedResourceGroveler(ResourceManager.ResourceManagerMediator mediato // Consider modifying IResourceGroveler interface (hence this method signature) when we figure out // serialization compat story for moving ResourceManager members to either file-based or // manifest-based classes. Want to continue tightening the design to get rid of unused params. - public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) + public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark) { Debug.Assert(culture != null, "culture shouldn't be null; check caller"); - String fileName = null; + string fileName = null; ResourceSet rs = null; // Don't use Assembly manifest, but grovel on disk for a file. // Create new ResourceSet, if a file exists on disk for it. - String tempFileName = _mediator.GetResourceFileName(culture); + string tempFileName = _mediator.GetResourceFileName(culture); fileName = FindResourceFile(culture, tempFileName); if (fileName == null) { @@ -73,7 +73,7 @@ public ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, + ResourceSet GrovelForResourceSet(CultureInfo culture, Dictionary localResourceSets, bool tryParents, bool createIfNotExists, ref StackCrawlMark stackMark); } } diff --git a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs index 024889252eeb..22d5445a9271 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ManifestBasedResourceGroveler.cs @@ -178,7 +178,7 @@ internal static CultureInfo GetNeutralResourcesLanguage(Assembly a, ref Ultimate // Note we could go into infinite loops if mscorlib's // NeutralResourcesLanguageAttribute is mangled. If this assert // fires, please fix the build process for the BCL directory. - if (a == typeof(Object).Assembly) + if (a == typeof(object).Assembly) { Debug.Fail(System.CoreLib.Name + "'s NeutralResourcesLanguageAttribute is a malformed culture name! name: \"" + cultureName + "\" Exception: " + e); return CultureInfo.InvariantCulture; @@ -204,7 +204,7 @@ internal ResourceSet CreateResourceSet(Stream store, Assembly assembly) // not disposing because we want to leave stream open BinaryReader br = new BinaryReader(store); - // Look for our magic number as a little endian Int32. + // Look for our magic number as a little endian int. int bytes = br.ReadInt32(); if (bytes == ResourceManager.MagicNumber) { @@ -251,11 +251,11 @@ internal ResourceSet CreateResourceSet(Stream store, Assembly assembly) { // we do not want to use partial binding here. Type readerType = Type.GetType(readerTypeName, true); - Object[] args = new Object[1]; + object[] args = new object[1]; args[0] = store; IResourceReader reader = (IResourceReader)Activator.CreateInstance(readerType, args); - Object[] resourceSetArgs = new Object[1]; + object[] resourceSetArgs = new object[1]; resourceSetArgs[0] = reader; Type resSetType; @@ -287,7 +287,7 @@ internal ResourceSet CreateResourceSet(Stream store, Assembly assembly) } else { - Object[] args = new Object[2]; + object[] args = new object[2]; args[0] = store; args[1] = assembly; try @@ -301,7 +301,7 @@ internal ResourceSet CreateResourceSet(Stream store, Assembly assembly) } catch (MissingMethodException) { } - args = new Object[1]; + args = new object[1]; args[0] = store; rs = (ResourceSet)Activator.CreateInstance(_mediator.UserResourceSet, args); @@ -501,7 +501,7 @@ private void HandleSatelliteMissing() private void HandleResourceStreamMissing(string fileName) { // Keep people from bothering me about resources problems - if (_mediator.MainAssembly == typeof(Object).Assembly && _mediator.BaseName.Equals(System.CoreLib.Name)) + if (_mediator.MainAssembly == typeof(object).Assembly && _mediator.BaseName.Equals(System.CoreLib.Name)) { // This would break CultureInfo & all our exceptions. Debug.Fail("Couldn't get " + System.CoreLib.Name + ResourceManager.ResFileExtension + " from " + System.CoreLib.Name + "'s assembly" + Environment.NewLine + Environment.NewLine + "Are you building the runtime on your machine? Chances are the BCL directory didn't build correctly. Type 'build -c' in the BCL directory. If you get build errors, look at buildd.log. If you then can't figure out what's wrong (and you aren't changing the assembly-related metadata code), ask a BCL dev.\n\nIf you did NOT build the runtime, you shouldn't be seeing this and you've found a bug."); diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs index 18a751c69ab6..49b01734a725 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceManager.cs @@ -30,38 +30,9 @@ namespace System.Resources using System.Collections.Generic; using System.Runtime.Versioning; using System.Diagnostics; - #if FEATURE_APPX - // - // This is implemented in System.Runtime.WindowsRuntime as function System.Resources.WindowsRuntimeResourceManager, - // allowing us to ask for a WinRT-specific ResourceManager. - // It is important to have WindowsRuntimeResourceManagerBase as regular class with virtual methods and default implementations. - // Defining WindowsRuntimeResourceManagerBase as abstract class or interface will cause issues when adding more methods to it - // because it'll create dependency between mscorlib and System.Runtime.WindowsRuntime which will require always shipping both DLLs together. - // - // [FriendAccessAllowed] - internal abstract class WindowsRuntimeResourceManagerBase - { - public abstract bool Initialize(string libpath, string reswFilename, out PRIExceptionInfo exceptionInfo); - - public abstract string GetString(string stringName, string startingCulture, string neutralResourcesCulture); - - public abstract CultureInfo GlobalResourceContextBestFitCultureInfo - { - get; - } - - public abstract bool SetGlobalResourceContextDefaultCulture(CultureInfo ci); - } - - // [FriendAccessAllowed] - internal class PRIExceptionInfo - { - public string _PackageSimpleName; - public string _ResWFile; - } -#endif // FEATURE_APPX - + using Internal.Resources; +#endif // Resource Manager exposes an assembly's resources to an application for // the correct CultureInfo. An example would be localizing text for a // user-visible message. Create a set of resource files listing a name @@ -292,7 +263,7 @@ public ResourceManager(string baseName, Assembly assembly) // This isn't for security reasons, but to ensure we can make // breaking changes to mscorlib's internal resources without // assuming users may have taken a dependency on them. - if (assembly == typeof(Object).Assembly && _callingAssembly != assembly) + if (assembly == typeof(object).Assembly && _callingAssembly != assembly) { _callingAssembly = null; } @@ -322,7 +293,7 @@ public ResourceManager(string baseName, Assembly assembly, Type usingResourceSet // This isn't for security reasons, but to ensure we can make // breaking changes to mscorlib's internal resources without // assuming users may have taken a dependency on them. - if (assembly == typeof(Object).Assembly && _callingAssembly != assembly) + if (assembly == typeof(object).Assembly && _callingAssembly != assembly) _callingAssembly = null; } @@ -345,7 +316,7 @@ public ResourceManager(Type resourceSource) _callingAssembly = (RuntimeAssembly)Assembly.GetCallingAssembly(); // Special case for mscorlib - protect mscorlib's private resources. - if (MainAssembly == typeof(Object).Assembly && _callingAssembly != MainAssembly) + if (MainAssembly == typeof(object).Assembly && _callingAssembly != MainAssembly) { _callingAssembly = null; } @@ -645,7 +616,7 @@ private static void AddResourceSet(Dictionary localResource ResourceSet lostRace; if (localResourceSets.TryGetValue(cultureName, out lostRace)) { - if (!Object.ReferenceEquals(lostRace, rs)) + if (!object.ReferenceEquals(lostRace, rs)) { // Note: In certain cases, we can be trying to add a ResourceSet for multiple // cultures on one thread, while a second thread added another ResourceSet for one @@ -705,15 +676,15 @@ internal static bool CompareNames(string asmTypeName1, // Now, compare assembly display names (IGNORES VERSION AND PROCESSORARCHITECTURE) // also, for mscorlib ignores everything, since that's what the binder is going to do - while (Char.IsWhiteSpace(asmTypeName1[++comma])) ; + while (char.IsWhiteSpace(asmTypeName1[++comma])) ; // case insensitive AssemblyName an1 = new AssemblyName(asmTypeName1.Substring(comma)); - if (string.Compare(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase) != 0) + if (!string.Equals(an1.Name, asmName2.Name, StringComparison.OrdinalIgnoreCase)) return false; // to match IsMscorlib() in VM - if (string.Compare(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase) == 0) + if (string.Equals(an1.Name, System.CoreLib.Name, StringComparison.OrdinalIgnoreCase)) return true; @@ -797,7 +768,7 @@ internal static WindowsRuntimeResourceManagerBase GetWinRTResourceManager() // contains the PRI resources. private bool ShouldUseSatelliteAssemblyResourceLookupUnderAppX(RuntimeAssembly resourcesAssembly) { - bool fUseSatelliteAssemblyResourceLookupUnderAppX = typeof(Object).Assembly == resourcesAssembly; + bool fUseSatelliteAssemblyResourceLookupUnderAppX = typeof(object).Assembly == resourcesAssembly; if (!fUseSatelliteAssemblyResourceLookupUnderAppX) { @@ -844,7 +815,7 @@ private void SetAppXConfiguration() if (resourcesAssembly != null) { - if (resourcesAssembly != typeof(Object).Assembly) // We are not loading resources for mscorlib + if (resourcesAssembly != typeof(object).Assembly) // We are not loading resources for mscorlib { // Cannot load the WindowsRuntimeResourceManager when in a compilation process, since it // lives in System.Runtime.WindowsRuntime and only mscorlib may be loaded for execution. @@ -919,7 +890,6 @@ private void SetAppXConfiguration() try { _PRIonAppXInitialized = _WinRTResourceManager.Initialize(resourcesAssembly.Location, reswFilename, out _PRIExceptionInfo); - // Note that _PRIExceptionInfo might be null - this is OK. // In that case we will just throw the generic // MissingManifestResource_NoPRIresources exception. @@ -1004,7 +974,7 @@ public virtual string GetString(string name, CultureInfo culture) // match, since CultureInfo objects can't represent all the different languages the AppX resource model supports. // For classic resources, this causes us to ignore the languages list and instead use the older Win32 behavior, // which is the design choice we've made. (See the call a little later to GetCurrentUICultureNoAppX()). - if (Object.ReferenceEquals(culture, CultureInfo.CurrentUICulture)) + if (object.ReferenceEquals(culture, CultureInfo.CurrentUICulture)) { culture = null; } @@ -1016,8 +986,8 @@ public virtual string GetString(string name, CultureInfo culture) { // Always throw if we did not fully succeed in initializing the WinRT Resource Manager. - if (_PRIExceptionInfo != null && _PRIExceptionInfo._PackageSimpleName != null && _PRIExceptionInfo._ResWFile != null) - throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_ResWFileNotLoaded, _PRIExceptionInfo._ResWFile, _PRIExceptionInfo._PackageSimpleName)); + if (_PRIExceptionInfo != null && _PRIExceptionInfo.PackageSimpleName != null && _PRIExceptionInfo.ResWFile != null) + throw new MissingManifestResourceException(SR.Format(SR.MissingManifestResource_ResWFileNotLoaded, _PRIExceptionInfo.ResWFile, _PRIExceptionInfo.PackageSimpleName)); throw new MissingManifestResourceException(SR.MissingManifestResource_NoPRIresources); } @@ -1087,7 +1057,7 @@ public virtual string GetString(string name, CultureInfo culture) // current thread's CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. // - public virtual Object GetObject(string name) + public virtual object GetObject(string name) { return GetObject(name, (CultureInfo)null, true); } @@ -1095,12 +1065,12 @@ public virtual Object GetObject(string name) // Looks up a resource value for a particular name. Looks in the // specified CultureInfo, and if not found, all parent CultureInfos. // Returns null if the resource wasn't found. - public virtual Object GetObject(string name, CultureInfo culture) + public virtual object GetObject(string name, CultureInfo culture) { return GetObject(name, culture, true); } - private Object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMemStream) + private object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMemStream) { if (null == name) throw new ArgumentNullException(nameof(name)); @@ -1111,7 +1081,7 @@ private Object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMem // If the caller explictily passed in a culture that was obtained by calling CultureInfo.CurrentUICulture, // null it out, so that we re-compute it based on the Win32 value and not the AppX language list value. // (See the call a little later to GetCurrentUICultureNoAppX()). - if (Object.ReferenceEquals(culture, CultureInfo.CurrentUICulture)) + if (object.ReferenceEquals(culture, CultureInfo.CurrentUICulture)) { culture = null; } @@ -1128,7 +1098,7 @@ private Object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMem ResourceSet last = GetFirstResourceSet(culture); if (last != null) { - Object value = last.GetObject(name, _ignoreCase); + object value = last.GetObject(name, _ignoreCase); if (value != null) { @@ -1158,7 +1128,7 @@ private Object GetObject(string name, CultureInfo culture, bool wrapUnmanagedMem if (rs != last) { - Object value = rs.GetObject(name, _ignoreCase); + object value = rs.GetObject(name, _ignoreCase); if (value != null) { // update the last used ResourceSet @@ -1192,7 +1162,7 @@ public UnmanagedMemoryStream GetStream(string name) public UnmanagedMemoryStream GetStream(string name, CultureInfo culture) { - Object obj = GetObject(name, culture, false); + object obj = GetObject(name, culture, false); UnmanagedMemoryStream ums = obj as UnmanagedMemoryStream; if (ums == null && obj != null) throw new InvalidOperationException(SR.Format(SR.InvalidOperation_ResourceNotStream_Name, name)); diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs index f22d3b82d92d..70e655f2a73f 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceReader.cs @@ -40,10 +40,10 @@ namespace System.Resources internal struct ResourceLocator { - internal Object _value; // Can be null. Consider WeakReference instead? + internal object _value; // Can be null. Consider WeakReference instead? internal int _dataPos; - internal ResourceLocator(int dataPos, Object value) + internal ResourceLocator(int dataPos, object value) { _dataPos = dataPos; _value = value; @@ -57,7 +57,7 @@ internal int DataPosition // Allows adding in profiling data in a future version, or a special // resource profiling build. We could also use WeakReference. - internal Object Value + internal object Value { get { return _value; } set { _value = value; } @@ -438,7 +438,7 @@ private unsafe string AllocateStringForNameIndex(int index, out int dataOffset) // This is used in the enumerator. The enumerator iterates from 0 to n // of our resources and this returns the resource value for a particular // index. The parameter is NOT a virtual offset. - private Object GetValueForNameIndex(int index) + private object GetValueForNameIndex(int index) { Debug.Assert(_store != null, "ResourceReader is closed!"); long nameVA = GetNamePosition(index); @@ -497,7 +497,7 @@ internal string LoadString(int pos) } // Called from RuntimeResourceSet - internal Object LoadObject(int pos) + internal object LoadObject(int pos) { if (_version == 1) return LoadObjectV1(pos); @@ -505,11 +505,11 @@ internal Object LoadObject(int pos) return LoadObjectV2(pos, out typeCode); } - internal Object LoadObject(int pos, out ResourceTypeCode typeCode) + internal object LoadObject(int pos, out ResourceTypeCode typeCode) { if (_version == 1) { - Object o = LoadObjectV1(pos); + object o = LoadObjectV1(pos); typeCode = (o is string) ? ResourceTypeCode.String : ResourceTypeCode.StartOfUserTypes; return o; } @@ -520,7 +520,7 @@ internal Object LoadObject(int pos, out ResourceTypeCode typeCode) // from that location. // Anyone who calls LoadObject should make sure they take a lock so // no one can cause us to do a seek in here. - internal Object LoadObjectV1(int pos) + internal object LoadObjectV1(int pos) { Debug.Assert(_store != null, "ResourceReader is closed!"); Debug.Assert(_version == 1, ".resources file was not a V1 .resources file!"); @@ -541,7 +541,7 @@ internal Object LoadObjectV1(int pos) } } - private Object _LoadObjectV1(int pos) + private object _LoadObjectV1(int pos) { _store.BaseStream.Seek(_dataSectionOffset + pos, SeekOrigin.Begin); int typeIndex = _store.Read7BitEncodedInt(); @@ -554,25 +554,25 @@ private Object _LoadObjectV1(int pos) if (type == typeof(string)) return _store.ReadString(); - else if (type == typeof(Int32)) + else if (type == typeof(int)) return _store.ReadInt32(); - else if (type == typeof(Byte)) + else if (type == typeof(byte)) return _store.ReadByte(); - else if (type == typeof(SByte)) + else if (type == typeof(sbyte)) return _store.ReadSByte(); - else if (type == typeof(Int16)) + else if (type == typeof(short)) return _store.ReadInt16(); - else if (type == typeof(Int64)) + else if (type == typeof(long)) return _store.ReadInt64(); - else if (type == typeof(UInt16)) + else if (type == typeof(ushort)) return _store.ReadUInt16(); - else if (type == typeof(UInt32)) + else if (type == typeof(uint)) return _store.ReadUInt32(); - else if (type == typeof(UInt64)) + else if (type == typeof(ulong)) return _store.ReadUInt64(); - else if (type == typeof(Single)) + else if (type == typeof(float)) return _store.ReadSingle(); - else if (type == typeof(Double)) + else if (type == typeof(double)) return _store.ReadDouble(); else if (type == typeof(DateTime)) { @@ -582,12 +582,12 @@ private Object _LoadObjectV1(int pos) } else if (type == typeof(TimeSpan)) return new TimeSpan(_store.ReadInt64()); - else if (type == typeof(Decimal)) + else if (type == typeof(decimal)) { int[] bits = new int[4]; for (int i = 0; i < bits.Length; i++) bits[i] = _store.ReadInt32(); - return new Decimal(bits); + return new decimal(bits); } else { @@ -595,7 +595,7 @@ private Object _LoadObjectV1(int pos) } } - internal Object LoadObjectV2(int pos, out ResourceTypeCode typeCode) + internal object LoadObjectV2(int pos, out ResourceTypeCode typeCode) { Debug.Assert(_store != null, "ResourceReader is closed!"); Debug.Assert(_version >= 2, ".resources file was not a V2 (or higher) .resources file!"); @@ -616,7 +616,7 @@ internal Object LoadObjectV2(int pos, out ResourceTypeCode typeCode) } } - private Object _LoadObjectV2(int pos, out ResourceTypeCode typeCode) + private object _LoadObjectV2(int pos, out ResourceTypeCode typeCode) { _store.BaseStream.Seek(_dataSectionOffset + pos, SeekOrigin.Begin); typeCode = (ResourceTypeCode)_store.Read7BitEncodedInt(); @@ -670,11 +670,11 @@ private Object _LoadObjectV2(int pos, out ResourceTypeCode typeCode) case ResourceTypeCode.DateTime: // Use DateTime's ToBinary & FromBinary. - Int64 data = _store.ReadInt64(); + long data = _store.ReadInt64(); return DateTime.FromBinary(data); case ResourceTypeCode.TimeSpan: - Int64 ticks = _store.ReadInt64(); + long ticks = _store.ReadInt64(); return new TimeSpan(ticks); // Special types @@ -1062,7 +1062,7 @@ private string TypeNameFromTypeCode(ResourceTypeCode typeCode) internal sealed class ResourceEnumerator : IDictionaryEnumerator { - private const int ENUM_DONE = Int32.MinValue; + private const int ENUM_DONE = int.MinValue; private const int ENUM_NOT_STARTED = -1; private ResourceReader _reader; @@ -1090,7 +1090,7 @@ public bool MoveNext() return true; } - public Object Key + public object Key { get { @@ -1102,7 +1102,7 @@ public Object Key } } - public Object Current + public object Current { get { @@ -1128,7 +1128,7 @@ public DictionaryEntry Entry if (_reader._resCache == null) throw new InvalidOperationException(SR.ResourceReaderIsClosed); string key; - Object value = null; + object value = null; lock (_reader) { // locks should be taken in the same order as in RuntimeResourceSet.GetObject to avoid deadlock lock (_reader._resCache) @@ -1157,7 +1157,7 @@ public DictionaryEntry Entry } } - public Object Value + public object Value { get { diff --git a/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs b/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs index 9e5a72c43153..2d33f3a8b086 100644 --- a/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs +++ b/src/System.Private.CoreLib/src/System/Resources/ResourceSet.cs @@ -49,7 +49,7 @@ internal ResourceSet(bool junk) // implementation. Use this constructor to open & read from a file // on disk. // - public ResourceSet(String fileName) + public ResourceSet(string fileName) { Reader = new ResourceReader(fileName); CommonInit(); @@ -147,12 +147,12 @@ private IDictionaryEnumerator GetEnumeratorHelper() // Look up a string value for a resource given its name. // - public virtual String GetString(String name) + public virtual string GetString(string name) { - Object obj = GetObjectInternal(name); + object obj = GetObjectInternal(name); try { - return (String)obj; + return (string)obj; } catch (InvalidCastException) { @@ -160,16 +160,16 @@ public virtual String GetString(String name) } } - public virtual String GetString(String name, bool ignoreCase) + public virtual string GetString(string name, bool ignoreCase) { - Object obj; - String s; + object obj; + string s; // Case-sensitive lookup obj = GetObjectInternal(name); try { - s = (String)obj; + s = (string)obj; } catch (InvalidCastException) { @@ -186,7 +186,7 @@ public virtual String GetString(String name, bool ignoreCase) obj = GetCaseInsensitiveObjectInternal(name); try { - return (String)obj; + return (string)obj; } catch (InvalidCastException) { @@ -196,14 +196,14 @@ public virtual String GetString(String name, bool ignoreCase) // Look up an object value for a resource given its name. // - public virtual Object GetObject(String name) + public virtual object GetObject(string name) { return GetObjectInternal(name); } - public virtual Object GetObject(String name, bool ignoreCase) + public virtual object GetObject(string name, bool ignoreCase) { - Object obj = GetObjectInternal(name); + object obj = GetObjectInternal(name); if (obj != null || !ignoreCase) return obj; @@ -216,14 +216,14 @@ protected virtual void ReadResources() IDictionaryEnumerator en = Reader.GetEnumerator(); while (en.MoveNext()) { - Object value = en.Value; + object value = en.Value; Table.Add(en.Key, value); } // While technically possible to close the Reader here, don't close it // to help with some WinRes lifetime issues. } - private Object GetObjectInternal(String name) + private object GetObjectInternal(string name) { if (name == null) throw new ArgumentNullException(nameof(name)); @@ -236,7 +236,7 @@ private Object GetObjectInternal(String name) return copyOfTable[name]; } - private Object GetCaseInsensitiveObjectInternal(String name) + private object GetCaseInsensitiveObjectInternal(string name) { Hashtable copyOfTable = Table; // Avoid a race with Dispose diff --git a/src/System.Private.CoreLib/src/System/RtType.cs b/src/System.Private.CoreLib/src/System/RtType.cs index c910bf52e4f1..62e0b2b80c7c 100644 --- a/src/System.Private.CoreLib/src/System/RtType.cs +++ b/src/System.Private.CoreLib/src/System/RtType.cs @@ -35,7 +35,7 @@ namespace System // see how it compares to the current implementation. // This delegate will disappear at some point in favor of calli - internal delegate void CtorDelegate(Object instance); + internal delegate void CtorDelegate(object instance); // Keep this in sync with FormatFlags defined in typestring.h internal enum TypeNameFormatFlags @@ -119,7 +119,7 @@ public T[] ToArray() return _items; } - public void CopyTo(Object[] array, int index) + public void CopyTo(object[] array, int index) { if (_count == 0) return; @@ -363,7 +363,7 @@ private unsafe T[] GetListByName(char* pName, int cNameLen, byte* pUtf8Name, int Encoding.UTF8.GetBytes(pName, cNameLen, pUtf8Name, cUtf8Name); Filter filter = new Filter(pUtf8Name, cUtf8Name, listType); - Object list = null; + object list = null; switch (cacheType) { @@ -1459,9 +1459,9 @@ internal RuntimeType ReflectedType private MemberInfoCache m_propertyInfoCache; private MemberInfoCache m_eventInfoCache; private static CerHashtable s_methodInstantiations; - private static Object s_methodInstantiationsLock; + private static object s_methodInstantiationsLock; private string m_defaultMemberName; - private Object m_genericCache; // Generic cache for rare scenario specific data. It is used to cache Enum names and values. + private object m_genericCache; // Generic cache for rare scenario specific data. It is used to cache Enum names and values. #endregion #region Constructor @@ -1509,7 +1509,7 @@ private MemberInfoCache GetMemberCache(ref MemberInfoCache m_cache) #region Internal Members - internal Object GenericCache + internal object GenericCache { get { return m_genericCache; } set { m_genericCache = value; } @@ -1619,7 +1619,7 @@ internal string GetDefaultMemberName() IList attrs = CustomAttributeData.GetCustomAttributes(t); for (int i = 0; i < attrs.Count; i++) { - if (Object.ReferenceEquals(attrs[i].Constructor.DeclaringType, DefaultMemberAttrType)) + if (object.ReferenceEquals(attrs[i].Constructor.DeclaringType, DefaultMemberAttrType)) { attr = attrs[i]; break; @@ -1660,7 +1660,7 @@ internal MethodInfo GetGenericMethodInfo(RuntimeMethodHandleInternal genericMeth return crmi; if (s_methodInstantiationsLock == null) - Interlocked.CompareExchange(ref s_methodInstantiationsLock, new Object(), null); + Interlocked.CompareExchange(ref s_methodInstantiationsLock, new object(), null); bool lockTaken = false; RuntimeHelpers.PrepareConstrainedRegions(); @@ -1911,7 +1911,7 @@ internal static unsafe MethodBase GetMethodBase(RuntimeType reflectedType, Runti return retval; } - internal Object GenericCache + internal object GenericCache { get { return Cache.GenericCache; } set { Cache.GenericCache = value; } @@ -2190,7 +2190,7 @@ private static bool FilterApplyBase( } #endregion - bool isInherited = !Object.ReferenceEquals(memberInfo.DeclaringType, memberInfo.ReflectedType); + bool isInherited = !object.ReferenceEquals(memberInfo.DeclaringType, memberInfo.ReflectedType); #region Filter by DeclaredOnly if ((bindingFlags & BindingFlags.DeclaredOnly) != 0 && isInherited) @@ -2941,7 +2941,7 @@ public override FieldInfo GetField(string name, BindingFlags bindingAttr) { if (match != null) { - if (Object.ReferenceEquals(fieldInfo.DeclaringType, match.DeclaringType)) + if (object.ReferenceEquals(fieldInfo.DeclaringType, match.DeclaringType)) throw new AmbiguousMatchException(SR.Arg_AmbiguousMatchException); if ((match.DeclaringType.IsInterface == true) && (fieldInfo.DeclaringType.IsInterface == true)) @@ -3228,7 +3228,7 @@ public override MethodBase DeclaringMethod #endregion #region Hierarchy - public override bool IsInstanceOfType(Object o) + public override bool IsInstanceOfType(object o) { return RuntimeTypeHandle.IsInstanceOfType(this, o); } @@ -3271,7 +3271,7 @@ public override bool IsAssignableFrom(Type c) if ((object)c == null) return false; - if (Object.ReferenceEquals(c, this)) + if (object.ReferenceEquals(c, this)) return true; RuntimeType fromType = c.UnderlyingSystemType as RuntimeType; @@ -3580,7 +3580,7 @@ public override Array GetEnumValues() for (int i = 0; i < values.Length; i++) { - Object val = Enum.ToObject(this, values[i]); + object val = Enum.ToObject(this, values[i]); ret.SetValue(val, i); } @@ -3838,9 +3838,9 @@ public override StructLayoutAttribute StructLayoutAttribute private static extern bool CanValueSpecialCast(RuntimeType valueType, RuntimeType targetType); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern Object AllocateValueType(RuntimeType type, object value, bool fForceTypeChange); + private static extern object AllocateValueType(RuntimeType type, object value, bool fForceTypeChange); - internal unsafe Object CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) + internal unsafe object CheckValue(object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) { // this method is used by invocation in reflection to check whether a value can be assigned to type. if (IsInstanceOfType(value)) @@ -3851,7 +3851,7 @@ internal unsafe Object CheckValue(Object value, Binder binder, CultureInfo cultu Type type = value.GetType(); - if (!Object.ReferenceEquals(type, this) && RuntimeTypeHandle.IsValueType(this)) + if (!object.ReferenceEquals(type, this) && RuntimeTypeHandle.IsValueType(this)) { // must be an equivalent type, re-box to the target type return AllocateValueType(this, value, true); @@ -3909,7 +3909,7 @@ internal unsafe Object CheckValue(Object value, Binder binder, CultureInfo cultu } // Factored out of CheckValue to reduce code complexity. - private Object TryChangeType(Object value, Binder binder, CultureInfo culture, bool needsSpecialCast) + private object TryChangeType(object value, Binder binder, CultureInfo culture, bool needsSpecialCast) { if (binder != null && binder != Type.DefaultBinder) { @@ -3970,9 +3970,9 @@ public override MemberInfo[] GetDefaultMembers() #endif [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - public override Object InvokeMember( - string name, BindingFlags bindingFlags, Binder binder, Object target, - Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParams) + public override object InvokeMember( + string name, BindingFlags bindingFlags, Binder binder, object target, + object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParams) { if (IsGenericParameter) throw new InvalidOperationException(SR.Arg_GenericParameter); @@ -4149,7 +4149,7 @@ public override Object InvokeMember( if (selFld != null) { #region Invocation on a field - if (selFld.FieldType.IsArray || Object.ReferenceEquals(selFld.FieldType, typeof(System.Array))) + if (selFld.FieldType.IsArray || object.ReferenceEquals(selFld.FieldType, typeof(System.Array))) { #region Invocation of an array Field int idxCnt; @@ -4391,9 +4391,9 @@ public override Object InvokeMember( finalists = new MethodInfo[] { finalist }; if (providedArgs == null) - providedArgs = Array.Empty(); + providedArgs = Array.Empty(); - Object state = null; + object state = null; MethodBase invokeMethod = null; @@ -4407,7 +4407,7 @@ public override Object InvokeMember( //if (useCache && argCnt == invokeMethod.GetParameters().Length) // AddMethodToCache(name, bindingFlags, argCnt, providedArgs, invokeMethod); - Object result = ((MethodInfo)invokeMethod).Invoke(target, bindingFlags, binder, providedArgs, culture); + object result = ((MethodInfo)invokeMethod).Invoke(target, bindingFlags, binder, providedArgs, culture); if (state != null) binder.ReorderArgumentArray(ref providedArgs, state); @@ -4441,19 +4441,19 @@ public override string ToString() #endregion #region ICloneable - public Object Clone() + public object Clone() { return this; } #endregion #region ICustomAttributeProvider - public override Object[] GetCustomAttributes(bool inherit) + public override object[] GetCustomAttributes(bool inherit) { return CustomAttribute.GetCustomAttributes(this, RuntimeType.ObjectType, inherit); } - public override Object[] GetCustomAttributes(Type attributeType, bool inherit) + public override object[] GetCustomAttributes(Type attributeType, bool inherit) { if ((object)attributeType == null) throw new ArgumentNullException(nameof(attributeType)); @@ -4585,22 +4585,22 @@ private void CreateInstanceCheckThis() Type elementType = this.GetRootElementType(); - if (Object.ReferenceEquals(elementType, typeof(ArgIterator))) + if (object.ReferenceEquals(elementType, typeof(ArgIterator))) throw new NotSupportedException(SR.Acc_CreateArgIterator); - if (Object.ReferenceEquals(elementType, typeof(void))) + if (object.ReferenceEquals(elementType, typeof(void))) throw new NotSupportedException(SR.Acc_CreateVoid); } - internal Object CreateInstanceImpl( - BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) + internal object CreateInstanceImpl( + BindingFlags bindingAttr, Binder binder, object[] args, CultureInfo culture, object[] activationAttributes) { CreateInstanceCheckThis(); - Object server = null; + object server = null; if (args == null) - args = Array.Empty(); + args = Array.Empty(); int argCnt = args.Length; @@ -4649,7 +4649,7 @@ internal Object CreateInstanceImpl( } MethodBase invokeMethod; - Object state = null; + object state = null; try { @@ -4718,7 +4718,7 @@ private class ActivatorCache private void InitializeDelegateCreator() { - ConstructorInfo ctorInfo = typeof(CtorDelegate).GetConstructor(new Type[] { typeof(Object), typeof(IntPtr) }); + ConstructorInfo ctorInfo = typeof(CtorDelegate).GetConstructor(new Type[] { typeof(object), typeof(IntPtr) }); delegateCtorInfo = ctorInfo; // this assignment should be last } @@ -4732,7 +4732,7 @@ private void InitializeCacheEntry(ActivatorCacheEntry ace) InitializeDelegateCreator(); // No synchronization needed here. In the worst case we create extra garbage - CtorDelegate ctor = (CtorDelegate)delegateCtorInfo.Invoke(new Object[] { null, RuntimeMethodHandle.GetFunctionPointer(ace.m_hCtorMethodHandle) }); + CtorDelegate ctor = (CtorDelegate)delegateCtorInfo.Invoke(new object[] { null, RuntimeMethodHandle.GetFunctionPointer(ace.m_hCtorMethodHandle) }); ace.m_ctor = ctor; } ace.m_bFullyInitialized = true; @@ -4767,7 +4767,7 @@ internal void SetEntry(ActivatorCacheEntry ace) private static volatile ActivatorCache s_ActivatorCache; // the slow path of CreateInstanceDefaultCtor - internal Object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool skipCheckThis, bool fillCache) + internal object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool skipCheckThis, bool fillCache) { RuntimeMethodHandleInternal runtime_ctor = default; bool bCanBeCached = false; @@ -4775,7 +4775,7 @@ internal Object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool sk if (!skipCheckThis) CreateInstanceCheckThis(); - Object instance = RuntimeTypeHandle.CreateInstance(this, publicOnly, wrapExceptions, ref bCanBeCached, ref runtime_ctor); + object instance = RuntimeTypeHandle.CreateInstance(this, publicOnly, wrapExceptions, ref bCanBeCached, ref runtime_ctor); if (bCanBeCached && fillCache) { @@ -4799,7 +4799,7 @@ internal Object CreateInstanceSlow(bool publicOnly, bool wrapExceptions, bool sk // fillCache is set in the SL2/3 compat mode or when called from Marshal.PtrToStructure. [DebuggerStepThroughAttribute] [Diagnostics.DebuggerHidden] - internal Object CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, bool fillCache, bool wrapExceptions) + internal object CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, bool fillCache, bool wrapExceptions) { if (GetType() == typeof(ReflectionOnlyType)) throw new InvalidOperationException(SR.InvalidOperation_NotAllowedInReflectionOnly); @@ -4820,7 +4820,7 @@ internal Object CreateInstanceDefaultCtor(bool publicOnly, bool skipCheckThis, b } // Allocate empty object - Object instance = RuntimeTypeHandle.Allocate(this); + object instance = RuntimeTypeHandle.Allocate(this); // if m_ctor is null, this type doesn't have a default ctor Debug.Assert(ace.m_ctor != null || this.IsValueType); @@ -4856,16 +4856,16 @@ internal bool IsGenericCOMObjectImpl() #region Legacy internal static [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern Object _CreateEnum(RuntimeType enumType, long value); - internal static Object CreateEnum(RuntimeType enumType, long value) + private static extern object _CreateEnum(RuntimeType enumType, long value); + internal static object CreateEnum(RuntimeType enumType, long value) { return _CreateEnum(enumType, value); } #if FEATURE_COMINTEROP [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern Object InvokeDispMethod( - string name, BindingFlags invokeAttr, Object target, Object[] args, + private extern object InvokeDispMethod( + string name, BindingFlags invokeAttr, object target, object[] args, bool[] byrefModifiers, int culture, string[] namedParameters); #endif // FEATURE_COMINTEROP diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs index ec8af8c086b9..201389d40acb 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs @@ -799,36 +799,36 @@ internal static Task GetTaskForResult(TResult result) // is recognized and optimized by both 32-bit and 64-bit JITs. // For Boolean, we cache all possible values. - if (typeof(TResult) == typeof(Boolean)) // only the relevant branches are kept for each value-type generic instantiation + if (typeof(TResult) == typeof(bool)) // only the relevant branches are kept for each value-type generic instantiation { - Boolean value = (Boolean)(object)result; - Task task = value ? AsyncTaskCache.TrueTask : AsyncTaskCache.FalseTask; + bool value = (bool)(object)result; + Task task = value ? AsyncTaskCache.TrueTask : AsyncTaskCache.FalseTask; return Unsafe.As>(task); // UnsafeCast avoids type check we know will succeed } // For Int32, we cache a range of common values, e.g. [-1,4). - else if (typeof(TResult) == typeof(Int32)) + else if (typeof(TResult) == typeof(int)) { // Compare to constants to avoid static field access if outside of cached range. // We compare to the upper bound first, as we're more likely to cache miss on the upper side than on the // lower side, due to positive values being more common than negative as return values. - Int32 value = (Int32)(object)result; + int value = (int)(object)result; if (value < AsyncTaskCache.EXCLUSIVE_INT32_MAX && value >= AsyncTaskCache.INCLUSIVE_INT32_MIN) { - Task task = AsyncTaskCache.Int32Tasks[value - AsyncTaskCache.INCLUSIVE_INT32_MIN]; + Task task = AsyncTaskCache.Int32Tasks[value - AsyncTaskCache.INCLUSIVE_INT32_MIN]; return Unsafe.As>(task); // UnsafeCast avoids a type check we know will succeed } } // For other known value types, we only special-case 0 / default(TResult). else if ( - (typeof(TResult) == typeof(UInt32) && default == (UInt32)(object)result) || - (typeof(TResult) == typeof(Byte) && default(Byte) == (Byte)(object)result) || - (typeof(TResult) == typeof(SByte) && default(SByte) == (SByte)(object)result) || - (typeof(TResult) == typeof(Char) && default(Char) == (Char)(object)result) || - (typeof(TResult) == typeof(Int64) && default == (Int64)(object)result) || - (typeof(TResult) == typeof(UInt64) && default == (UInt64)(object)result) || - (typeof(TResult) == typeof(Int16) && default(Int16) == (Int16)(object)result) || - (typeof(TResult) == typeof(UInt16) && default(UInt16) == (UInt16)(object)result) || + (typeof(TResult) == typeof(uint) && default == (uint)(object)result) || + (typeof(TResult) == typeof(byte) && default(byte) == (byte)(object)result) || + (typeof(TResult) == typeof(sbyte) && default(sbyte) == (sbyte)(object)result) || + (typeof(TResult) == typeof(char) && default(char) == (char)(object)result) || + (typeof(TResult) == typeof(long) && default == (long)(object)result) || + (typeof(TResult) == typeof(ulong) && default == (ulong)(object)result) || + (typeof(TResult) == typeof(short) && default(short) == (short)(object)result) || + (typeof(TResult) == typeof(ushort) && default(ushort) == (ushort)(object)result) || (typeof(TResult) == typeof(IntPtr) && default == (IntPtr)(object)result) || (typeof(TResult) == typeof(UIntPtr) && default == (UIntPtr)(object)result)) { @@ -851,21 +851,21 @@ internal static class AsyncTaskCache // All static members are initialized inline to ensure type is beforefieldinit /// A cached Task{Boolean}.Result == true. - internal readonly static Task TrueTask = CreateCacheableTask(true); + internal readonly static Task TrueTask = CreateCacheableTask(true); /// A cached Task{Boolean}.Result == false. - internal readonly static Task FalseTask = CreateCacheableTask(false); + internal readonly static Task FalseTask = CreateCacheableTask(false); /// The cache of Task{Int32}. - internal readonly static Task[] Int32Tasks = CreateInt32Tasks(); + internal readonly static Task[] Int32Tasks = CreateInt32Tasks(); /// The minimum value, inclusive, for which we want a cached task. - internal const Int32 INCLUSIVE_INT32_MIN = -1; + internal const int INCLUSIVE_INT32_MIN = -1; /// The maximum value, exclusive, for which we want a cached task. - internal const Int32 EXCLUSIVE_INT32_MAX = 9; + internal const int EXCLUSIVE_INT32_MAX = 9; /// Creates an array of cached tasks for the values in the range [INCLUSIVE_MIN,EXCLUSIVE_MAX). - private static Task[] CreateInt32Tasks() + private static Task[] CreateInt32Tasks() { Debug.Assert(EXCLUSIVE_INT32_MAX >= INCLUSIVE_INT32_MIN, "Expected max to be at least min"); - var tasks = new Task[EXCLUSIVE_INT32_MAX - INCLUSIVE_INT32_MIN]; + var tasks = new Task[EXCLUSIVE_INT32_MAX - INCLUSIVE_INT32_MIN]; for (int i = 0; i < tasks.Length; i++) { tasks[i] = CreateCacheableTask(i + INCLUSIVE_INT32_MIN); diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs index 2f0cca9c8864..f4e502adc565 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/ConditionalWeakTable.cs @@ -466,7 +466,7 @@ private void CreateEntry(TKey key, TValue value) // // - Used with live key (linked into a bucket list where _buckets[hashCode & (_buckets.Length - 1)] points to first entry) // depHnd.IsAllocated == true, depHnd.GetPrimary() != null - // hashCode == RuntimeHelpers.GetHashCode(depHnd.GetPrimary()) & Int32.MaxValue + // hashCode == RuntimeHelpers.GetHashCode(depHnd.GetPrimary()) & int.MaxValue // next links to next Entry in bucket. // // - Used with dead key (linked into a bucket list where _buckets[hashCode & (_buckets.Length - 1)] points to first entry) diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs index 8f06008bb431..53b284808450 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs @@ -26,7 +26,7 @@ public static class RuntimeHelpers { // Exposed here as a more appropriate place than on FormatterServices itself, // which is a high level reflection heavy type. - public static Object GetUninitializedObject(Type type) + public static object GetUninitializedObject(Type type) { return FormatterServices.GetUninitializedObject(type); } @@ -48,7 +48,7 @@ public static Object GetUninitializedObject(Type type) // Of course, reference types are not cloned. // [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object GetObjectValue(Object obj); + public static extern object GetObjectValue(object obj); // RunClassConstructor causes the class constructor for the given type to be triggered // in the current domain. After this call returns, the class constructor is guaranteed to @@ -117,10 +117,10 @@ public static void PrepareContractedDelegate(Delegate d) { } public static extern void PrepareDelegate(Delegate d); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern int GetHashCode(Object o); + public static extern int GetHashCode(object o); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public new static extern bool Equals(Object o1, Object o2); + public new static extern bool Equals(object o1, object o2); public static int OffsetToStringData { @@ -175,14 +175,14 @@ public static void PrepareConstrainedRegionsNoOP() { } - public delegate void TryCode(Object userData); + public delegate void TryCode(object userData); - public delegate void CleanupCode(Object userData, bool exceptionThrown); + public delegate void CleanupCode(object userData, bool exceptionThrown); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData); + public static extern void ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, object userData); - internal static void ExecuteBackoutCodeHelper(Object backoutCode, Object userData, bool exceptionThrown) + internal static void ExecuteBackoutCodeHelper(object backoutCode, object userData, bool exceptionThrown) { ((CleanupCode)backoutCode)(userData, exceptionThrown); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/jithelpers.cs b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/jithelpers.cs index 42fe79d83b5c..dd491dc1e585 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/jithelpers.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/CompilerServices/jithelpers.cs @@ -171,10 +171,10 @@ internal static IntPtr UnsafeCastToStackPointer(ref T val) // Set the given element in the array without any type or range checks [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void UnsafeSetArrayElement(Object[] target, int index, Object element); + internal static extern void UnsafeSetArrayElement(object[] target, int index, object element); // Used for unsafe pinning of arbitrary objects. - internal static PinningHelper GetPinningHelper(Object o) + internal static PinningHelper GetPinningHelper(object o) { return Unsafe.As(o); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs b/src/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs index 0a379667d7fd..ad8e47b31944 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/ExceptionServices/ExceptionDispatchInfo.cs @@ -35,7 +35,7 @@ public sealed class ExceptionDispatchInfo private object m_stackTrace; private object m_dynamicMethods; private UIntPtr m_IPForWatsonBuckets; - private Object m_WatsonBuckets; + private object m_WatsonBuckets; private ExceptionDispatchInfo(Exception exception) { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayWithOffset.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayWithOffset.cs index e009db277fda..dd2ec7bd9d2b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayWithOffset.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ArrayWithOffset.cs @@ -2,21 +2,13 @@ // 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.Runtime.Versioning; namespace System.Runtime.InteropServices { public struct ArrayWithOffset { - //private ArrayWithOffset() - //{ - // throw new Exception(); - //} - - public ArrayWithOffset(Object array, int offset) + public ArrayWithOffset(object array, int offset) { m_array = array; m_offset = offset; @@ -24,27 +16,15 @@ public ArrayWithOffset(Object array, int offset) m_count = CalculateCount(); } - public Object GetArray() - { - return m_array; - } + public object GetArray() => m_array; - public int GetOffset() - { - return m_offset; - } + public int GetOffset() => m_offset; - public override int GetHashCode() - { - return m_count + m_offset; - } + public override int GetHashCode() => m_count + m_offset; - public override bool Equals(Object obj) + public override bool Equals(object obj) { - if (obj is ArrayWithOffset) - return Equals((ArrayWithOffset)obj); - else - return false; + return obj is ArrayWithOffset && Equals((ArrayWithOffset)obj); } public bool Equals(ArrayWithOffset obj) @@ -62,10 +42,10 @@ public bool Equals(ArrayWithOffset obj) return !(a == b); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] private extern int CalculateCount(); - private Object m_array; + private object m_array; private int m_offset; private int m_count; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Attributes.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Attributes.cs index 41412021294a..d1396d7d2cbc 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Attributes.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Attributes.cs @@ -2,13 +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; -using System.Reflection; -using System.Diagnostics; - namespace System.Runtime.InteropServices { [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] @@ -17,11 +10,11 @@ public sealed class TypeIdentifierAttribute : Attribute public TypeIdentifierAttribute() { } public TypeIdentifierAttribute(string scope, string identifier) { Scope_ = scope; Identifier_ = identifier; } - public String Scope { get { return Scope_; } } - public String Identifier { get { return Identifier_; } } + public string Scope { get { return Scope_; } } + public string Identifier { get { return Identifier_; } } - internal String Scope_; - internal String Identifier_; + internal string Scope_; + internal string Identifier_; } // To be used on methods that sink reverse P/Invoke calls. @@ -38,11 +31,13 @@ public AllowReversePInvokeCallsAttribute() public sealed class DispIdAttribute : Attribute { internal int _val; + public DispIdAttribute(int dispId) { _val = dispId; } - public int Value { get { return _val; } } + + public int Value => _val; } public enum ComInterfaceType @@ -58,15 +53,18 @@ public enum ComInterfaceType public sealed class InterfaceTypeAttribute : Attribute { internal ComInterfaceType _val; + public InterfaceTypeAttribute(ComInterfaceType interfaceType) { _val = interfaceType; } + public InterfaceTypeAttribute(short interfaceType) { _val = (ComInterfaceType)interfaceType; } - public ComInterfaceType Value { get { return _val; } } + + public ComInterfaceType Value => _val; } [AttributeUsage(AttributeTargets.Class, Inherited = false)] @@ -79,7 +77,7 @@ public ComDefaultInterfaceAttribute(Type defaultInterface) _val = defaultInterface; } - public Type Value { get { return _val; } } + public Type Value => _val; } public enum ClassInterfaceType @@ -93,64 +91,77 @@ public enum ClassInterfaceType public sealed class ClassInterfaceAttribute : Attribute { internal ClassInterfaceType _val; + public ClassInterfaceAttribute(ClassInterfaceType classInterfaceType) { _val = classInterfaceType; } + public ClassInterfaceAttribute(short classInterfaceType) { _val = (ClassInterfaceType)classInterfaceType; } - public ClassInterfaceType Value { get { return _val; } } + + public ClassInterfaceType Value => _val; } [AttributeUsage(AttributeTargets.Method, Inherited = false)] public sealed class LCIDConversionAttribute : Attribute { internal int _val; + public LCIDConversionAttribute(int lcid) { _val = lcid; } - public int Value { get { return _val; } } + + public int Value => _val; } [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ProgIdAttribute : Attribute { - internal String _val; - public ProgIdAttribute(String progId) + internal string _val; + + public ProgIdAttribute(string progId) { _val = progId; } - public String Value { get { return _val; } } + + public string Value => _val; } [AttributeUsage(AttributeTargets.Class, Inherited = true)] public sealed class ComSourceInterfacesAttribute : Attribute { - internal String _val; - public ComSourceInterfacesAttribute(String sourceInterfaces) + internal string _val; + + public ComSourceInterfacesAttribute(string sourceInterfaces) { _val = sourceInterfaces; } + public ComSourceInterfacesAttribute(Type sourceInterface) { _val = sourceInterface.FullName; } + public ComSourceInterfacesAttribute(Type sourceInterface1, Type sourceInterface2) { _val = sourceInterface1.FullName + "\0" + sourceInterface2.FullName; } + public ComSourceInterfacesAttribute(Type sourceInterface1, Type sourceInterface2, Type sourceInterface3) { _val = sourceInterface1.FullName + "\0" + sourceInterface2.FullName + "\0" + sourceInterface3.FullName; } + public ComSourceInterfacesAttribute(Type sourceInterface1, Type sourceInterface2, Type sourceInterface3, Type sourceInterface4) { _val = sourceInterface1.FullName + "\0" + sourceInterface2.FullName + "\0" + sourceInterface3.FullName + "\0" + sourceInterface4.FullName; } - public String Value { get { return _val; } } + + public string Value => _val; } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, Inherited = false)] @@ -171,7 +182,6 @@ public CoClassAttribute(Type coClass) _CoClass = coClass; } - public Type CoClass { get { return _CoClass; } } + public Type CoClass => _CoClass; } } - diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/BStrWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/BStrWrapper.cs index 586b03b366e7..ae7e6e445c13 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/BStrWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/BStrWrapper.cs @@ -2,41 +2,25 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_BSTR. -** -** -=============================================================================*/ - - -using System; -using System.Security; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_BSTR. + /// public sealed class BStrWrapper { - public BStrWrapper(String value) + public BStrWrapper(string value) { m_WrappedObject = value; } - public BStrWrapper(Object value) + public BStrWrapper(object value) { - m_WrappedObject = (String)value; + m_WrappedObject = (string)value; } - public String WrappedObject - { - get - { - return m_WrappedObject; - } - } + public string WrappedObject => m_WrappedObject; - private String m_WrappedObject; + private string m_WrappedObject; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs index c31a1576c404..f1ddf6588874 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/COMException.cs @@ -2,27 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Exception class for all errors from COM Interop where we don't -** recognize the HResult. -** -** -=============================================================================*/ - -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Globalization; -using System.Security; -using Microsoft.Win32; namespace System.Runtime.InteropServices { // Exception for COM Interop errors where we don't recognize the HResult. + /// + /// Exception class for all errors from COM Interop where we don't + /// recognize the HResult. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class COMException : ExternalException { public COMException() @@ -31,19 +23,19 @@ public COMException() HResult = HResults.E_FAIL; } - public COMException(String message) + public COMException(string message) : base(message) { HResult = HResults.E_FAIL; } - public COMException(String message, Exception inner) + public COMException(string message, Exception inner) : base(message, inner) { HResult = HResults.E_FAIL; } - public COMException(String message, int errorCode) + public COMException(string message, int errorCode) : base(message) { HResult = errorCode; @@ -53,11 +45,11 @@ protected COMException(SerializationInfo info, StreamingContext context) : base( { } - public override String ToString() + public override string ToString() { - String message = Message; - String s; - String _className = GetType().ToString(); + string message = Message; + string s; + string _className = GetType().ToString(); s = _className + " (0x" + HResult.ToString("X8", CultureInfo.InvariantCulture) + ")"; if (!(message == null || message.Length <= 0)) diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComMemberType.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComMemberType.cs index 2de01465d38a..4be75b03b9f6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComMemberType.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComMemberType.cs @@ -2,11 +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; - namespace System.Runtime.InteropServices { public enum ComMemberType diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IBindCtx.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IBindCtx.cs index 152f1cd65523..a535b94f88f3 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IBindCtx.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IBindCtx.cs @@ -2,21 +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. -/*============================================================================= -** -** -** -** Purpose: IBindCtx interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [StructLayout(LayoutKind.Sequential)] - public struct BIND_OPTS { public int cbStruct; @@ -26,20 +14,20 @@ public struct BIND_OPTS } [Guid("0000000e-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IBindCtx { - void RegisterObjectBound([MarshalAs(UnmanagedType.Interface)] Object punk); - void RevokeObjectBound([MarshalAs(UnmanagedType.Interface)] Object punk); + void RegisterObjectBound([MarshalAs(UnmanagedType.Interface)] object punk); + void RevokeObjectBound([MarshalAs(UnmanagedType.Interface)] object punk); void ReleaseBoundObjects(); void SetBindOptions([In()] ref BIND_OPTS pbindopts); void GetBindOptions(ref BIND_OPTS pbindopts); void GetRunningObjectTable(out IRunningObjectTable pprot); - void RegisterObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey, [MarshalAs(UnmanagedType.Interface)] Object punk); - void GetObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey, [MarshalAs(UnmanagedType.Interface)] out Object ppunk); + void RegisterObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey, [MarshalAs(UnmanagedType.Interface)] object punk); + void GetObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey, [MarshalAs(UnmanagedType.Interface)] out object ppunk); void EnumObjectParam(out IEnumString ppenum); [PreserveSig] - int RevokeObjectParam([MarshalAs(UnmanagedType.LPWStr)] String pszKey); + int RevokeObjectParam([MarshalAs(UnmanagedType.LPWStr)] string pszKey); } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPoint.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPoint.cs index 3933d528a9ad..fcca685ad82f 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPoint.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPoint.cs @@ -2,17 +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. -/*============================================================================= -** -** -** -** Purpose: IConnectionPoint interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("B196B286-BAB4-101A-B69C-00AA00341D07")] @@ -22,7 +11,7 @@ public interface IConnectionPoint { void GetConnectionInterface(out Guid pIID); void GetConnectionPointContainer(out IConnectionPointContainer ppCPC); - void Advise([MarshalAs(UnmanagedType.Interface)] Object pUnkSink, out int pdwCookie); + void Advise([MarshalAs(UnmanagedType.Interface)] object pUnkSink, out int pdwCookie); void Unadvise(int dwCookie); void EnumConnections(out IEnumConnections ppEnum); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPointContainer.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPointContainer.cs index 881dd8acfef2..84c590d4365b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPointContainer.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IConnectionPointContainer.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IConnectionPointContainer interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("B196B284-BAB4-101A-B69C-00AA00341D07")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IConnectionPointContainer { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnectionPoints.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnectionPoints.cs index 32ad1f7f06b3..99df6ac60e44 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnectionPoints.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnectionPoints.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IEnumConnectionPoints interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("B196B285-BAB4-101A-B69C-00AA00341D07")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IEnumConnectionPoints { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnections.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnections.cs index 1acfe546576a..951685beff7e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnections.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumConnections.cs @@ -2,30 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IEnumConnections interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct CONNECTDATA { [MarshalAs(UnmanagedType.Interface)] - public Object pUnk; + public object pUnk; public int dwCookie; } [Guid("B196B287-BAB4-101A-B69C-00AA00341D07")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IEnumConnections { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumMoniker.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumMoniker.cs index 4513bc86ffb7..9a63ba0a11a3 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumMoniker.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumMoniker.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IEnumMoniker interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00000102-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IEnumMoniker { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumString.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumString.cs index 5738a427512f..57fc59121f00 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumString.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumString.cs @@ -2,26 +2,15 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IEnumString interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00000101-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IEnumString { [PreserveSig] - int Next(int celt, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0), Out] String[] rgelt, IntPtr pceltFetched); + int Next(int celt, [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 0), Out] string[] rgelt, IntPtr pceltFetched); [PreserveSig] int Skip(int celt); void Reset(); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumVARIANT.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumVARIANT.cs index b94ac5e4c991..8440c060bb53 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumVARIANT.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IEnumVARIANT.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IEnumVARIANT interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00020404-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IEnumVARIANT { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IMoniker.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IMoniker.cs index ea45149b2975..7a2dd57d163b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IMoniker.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IMoniker.cs @@ -2,21 +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. -/*============================================================================= -** -** -** -** Purpose: IMoniker interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [StructLayout(LayoutKind.Sequential)] - public struct FILETIME { public int dwLowDateTime; @@ -24,7 +12,7 @@ public struct FILETIME } [Guid("0000000f-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IMoniker { @@ -36,11 +24,11 @@ public interface IMoniker int IsDirty(); void Load(IStream pStm); void Save(IStream pStm, [MarshalAs(UnmanagedType.Bool)] bool fClearDirty); - void GetSizeMax(out Int64 pcbSize); + void GetSizeMax(out long pcbSize); // IMoniker portion - void BindToObject(IBindCtx pbc, IMoniker pmkToLeft, [In()] ref Guid riidResult, [MarshalAs(UnmanagedType.Interface)] out Object ppvResult); - void BindToStorage(IBindCtx pbc, IMoniker pmkToLeft, [In()] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out Object ppvObj); + void BindToObject(IBindCtx pbc, IMoniker pmkToLeft, [In()] ref Guid riidResult, [MarshalAs(UnmanagedType.Interface)] out object ppvResult); + void BindToStorage(IBindCtx pbc, IMoniker pmkToLeft, [In()] ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppvObj); void Reduce(IBindCtx pbc, int dwReduceHowFar, ref IMoniker ppmkToLeft, out IMoniker ppmkReduced); void ComposeWith(IMoniker pmkRight, [MarshalAs(UnmanagedType.Bool)] bool fOnlyIfNotGeneric, out IMoniker ppmkComposite); void Enum([MarshalAs(UnmanagedType.Bool)] bool fForward, out IEnumMoniker ppenumMoniker); @@ -53,8 +41,8 @@ public interface IMoniker void Inverse(out IMoniker ppmk); void CommonPrefixWith(IMoniker pmkOther, out IMoniker ppmkPrefix); void RelativePathTo(IMoniker pmkOther, out IMoniker ppmkRelPath); - void GetDisplayName(IBindCtx pbc, IMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] out String ppszDisplayName); - void ParseDisplayName(IBindCtx pbc, IMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] String pszDisplayName, out int pchEaten, out IMoniker ppmkOut); + void GetDisplayName(IBindCtx pbc, IMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] out string ppszDisplayName); + void ParseDisplayName(IBindCtx pbc, IMoniker pmkToLeft, [MarshalAs(UnmanagedType.LPWStr)] string pszDisplayName, out int pchEaten, out IMoniker ppmkOut); [PreserveSig] int IsSystemMoniker(out int pdwMksys); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IPersistFile.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IPersistFile.cs index 467a9e3a6a89..cb24d985dcdd 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IPersistFile.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IPersistFile.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IPersistFile interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("0000010b-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IPersistFile { @@ -26,9 +15,9 @@ public interface IPersistFile // IPersistFile portion [PreserveSig] int IsDirty(); - void Load([MarshalAs(UnmanagedType.LPWStr)] String pszFileName, int dwMode); - void Save([MarshalAs(UnmanagedType.LPWStr)] String pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember); - void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] String pszFileName); - void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out String ppszFileName); + void Load([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, int dwMode); + void Save([MarshalAs(UnmanagedType.LPWStr)] string pszFileName, [MarshalAs(UnmanagedType.Bool)] bool fRemember); + void SaveCompleted([MarshalAs(UnmanagedType.LPWStr)] string pszFileName); + void GetCurFile([MarshalAs(UnmanagedType.LPWStr)] out string ppszFileName); } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IRunningObjectTable.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IRunningObjectTable.cs index ffca35ae83ef..1884fcc99b50 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IRunningObjectTable.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IRunningObjectTable.cs @@ -2,30 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IRunningObjectTable interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00000010-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IRunningObjectTable { - int Register(int grfFlags, [MarshalAs(UnmanagedType.Interface)] Object punkObject, IMoniker pmkObjectName); + int Register(int grfFlags, [MarshalAs(UnmanagedType.Interface)] object punkObject, IMoniker pmkObjectName); void Revoke(int dwRegister); [PreserveSig] int IsRunning(IMoniker pmkObjectName); [PreserveSig] - int GetObject(IMoniker pmkObjectName, [MarshalAs(UnmanagedType.Interface)] out Object ppunkObject); + int GetObject(IMoniker pmkObjectName, [MarshalAs(UnmanagedType.Interface)] out object ppunkObject); void NoteChangeTime(int dwRegister, ref FILETIME pfiletime); [PreserveSig] int GetTimeOfLastChange(IMoniker pmkObjectName, out FILETIME pfiletime); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IStream.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IStream.cs index 1a2d81f7ea9b..09b284041e72 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IStream.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/IStream.cs @@ -2,26 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: IStream interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct STATSTG { - public String pwcsName; + public string pwcsName; public int type; - public Int64 cbSize; + public long cbSize; public FILETIME mtime; public FILETIME ctime; public FILETIME atime; @@ -33,22 +21,22 @@ public struct STATSTG } [Guid("0000000c-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface IStream { // ISequentialStream portion - void Read([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] Byte[] pv, int cb, IntPtr pcbRead); - void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] Byte[] pv, int cb, IntPtr pcbWritten); + void Read([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] byte[] pv, int cb, IntPtr pcbRead); + void Write([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, int cb, IntPtr pcbWritten); // IStream portion - void Seek(Int64 dlibMove, int dwOrigin, IntPtr plibNewPosition); - void SetSize(Int64 libNewSize); - void CopyTo(IStream pstm, Int64 cb, IntPtr pcbRead, IntPtr pcbWritten); + void Seek(long dlibMove, int dwOrigin, IntPtr plibNewPosition); + void SetSize(long libNewSize); + void CopyTo(IStream pstm, long cb, IntPtr pcbRead, IntPtr pcbWritten); void Commit(int grfCommitFlags); void Revert(); - void LockRegion(Int64 libOffset, Int64 cb, int dwLockType); - void UnlockRegion(Int64 libOffset, Int64 cb, int dwLockType); + void LockRegion(long libOffset, long cb, int dwLockType); + void UnlockRegion(long libOffset, long cb, int dwLockType); void Stat(out STATSTG pstatstg, int grfStatFlag); void Clone(out IStream ppstm); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs index ae403d138c88..7e6379361518 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeComp.cs @@ -2,17 +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. -/*============================================================================= -** -** -** -** Purpose: ITypeComp interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { public enum DESCKIND @@ -26,7 +15,6 @@ public enum DESCKIND } [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] - public struct BINDPTR { [FieldOffset(0)] @@ -38,11 +26,11 @@ public struct BINDPTR } [Guid("00020403-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface ITypeComp { - void Bind([MarshalAs(UnmanagedType.LPWStr)] String szName, int lHashVal, Int16 wFlags, out ITypeInfo ppTInfo, out DESCKIND pDescKind, out BINDPTR pBindPtr); - void BindType([MarshalAs(UnmanagedType.LPWStr)] String szName, int lHashVal, out ITypeInfo ppTInfo, out ITypeComp ppTComp); + void Bind([MarshalAs(UnmanagedType.LPWStr)] string szName, int lHashVal, short wFlags, out ITypeInfo ppTInfo, out DESCKIND pDescKind, out BINDPTR pBindPtr); + void BindType([MarshalAs(UnmanagedType.LPWStr)] string szName, int lHashVal, out ITypeInfo ppTInfo, out ITypeComp ppTComp); } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs index 4cd102f76e17..61776e446d5b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo.cs @@ -2,17 +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. -/*============================================================================= -** -** -** -** Purpose: ITypeInfo interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { public enum TYPEKIND @@ -28,7 +17,7 @@ public enum TYPEKIND TKIND_MAX = TKIND_UNION + 1 } - [Flags()] + [Flags] public enum TYPEFLAGS : short { TYPEFLAG_FAPPOBJECT = 0x1, @@ -48,7 +37,7 @@ public enum TYPEFLAGS : short TYPEFLAG_FPROXY = 0x4000 } - [Flags()] + [Flags] public enum IMPLTYPEFLAGS { IMPLTYPEFLAG_FDEFAULT = 0x1, @@ -58,7 +47,6 @@ public enum IMPLTYPEFLAGS } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct TYPEATTR { // Constant used with the memid fields. @@ -66,27 +54,26 @@ public struct TYPEATTR // Actual fields of the TypeAttr struct. public Guid guid; - public Int32 lcid; - public Int32 dwReserved; - public Int32 memidConstructor; - public Int32 memidDestructor; + public int lcid; + public int dwReserved; + public int memidConstructor; + public int memidDestructor; public IntPtr lpstrSchema; - public Int32 cbSizeInstance; + public int cbSizeInstance; public TYPEKIND typekind; - public Int16 cFuncs; - public Int16 cVars; - public Int16 cImplTypes; - public Int16 cbSizeVft; - public Int16 cbAlignment; + public short cFuncs; + public short cVars; + public short cImplTypes; + public short cbSizeVft; + public short cbAlignment; public TYPEFLAGS wTypeFlags; - public Int16 wMajorVerNum; - public Int16 wMinorVerNum; + public short wMajorVerNum; + public short wMinorVerNum; public TYPEDESC tdescAlias; public IDLDESC idldescType; } [StructLayout(LayoutKind.Sequential)] - public struct FUNCDESC { public int memid; //MEMBERID memid; @@ -95,15 +82,15 @@ public struct FUNCDESC public FUNCKIND funckind; //FUNCKIND funckind; public INVOKEKIND invkind; //INVOKEKIND invkind; public CALLCONV callconv; //CALLCONV callconv; - public Int16 cParams; //short cParams; - public Int16 cParamsOpt; //short cParamsOpt; - public Int16 oVft; //short oVft; - public Int16 cScodes; //short cScodes; + public short cParams; //short cParams; + public short cParamsOpt; //short cParamsOpt; + public short oVft; //short oVft; + public short cScodes; //short cScodes; public ELEMDESC elemdescFunc; //ELEMDESC elemdescFunc; - public Int16 wFuncFlags; //WORD wFuncFlags; + public short wFuncFlags; //WORD wFuncFlags; } - [Flags()] + [Flags] public enum IDLFLAG : short { IDLFLAG_NONE = PARAMFLAG.PARAMFLAG_NONE, @@ -114,14 +101,13 @@ public enum IDLFLAG : short } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct IDLDESC { public IntPtr dwReserved; public IDLFLAG wIDLFlags; } - [Flags()] + [Flags] public enum PARAMFLAG : short { PARAMFLAG_NONE = 0, @@ -135,7 +121,6 @@ public enum PARAMFLAG : short } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct PARAMDESC { public IntPtr lpVarValue; @@ -143,21 +128,18 @@ public struct PARAMDESC } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct TYPEDESC { public IntPtr lpValue; - public Int16 vt; + public short vt; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct ELEMDESC { public TYPEDESC tdesc; - [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] - + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] public struct DESCUNION { [FieldOffset(0)] @@ -181,10 +163,9 @@ public enum VARKIND : int public struct VARDESC { public int memid; - public String lpstrSchema; - - [System.Runtime.InteropServices.StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] + public string lpstrSchema; + [StructLayout(LayoutKind.Explicit, CharSet = CharSet.Unicode)] public struct DESCUNION { [FieldOffset(0)] @@ -201,7 +182,6 @@ public struct DESCUNION } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct DISPPARAMS { public IntPtr rgvarg; @@ -211,18 +191,17 @@ public struct DISPPARAMS } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct EXCEPINFO { - public Int16 wCode; - public Int16 wReserved; - [MarshalAs(UnmanagedType.BStr)] public String bstrSource; - [MarshalAs(UnmanagedType.BStr)] public String bstrDescription; - [MarshalAs(UnmanagedType.BStr)] public String bstrHelpFile; + public short wCode; + public short wReserved; + [MarshalAs(UnmanagedType.BStr)] public string bstrSource; + [MarshalAs(UnmanagedType.BStr)] public string bstrDescription; + [MarshalAs(UnmanagedType.BStr)] public string bstrHelpFile; public int dwHelpContext; public IntPtr pvReserved; public IntPtr pfnDeferredFillIn; - public Int32 scode; + public int scode; } public enum FUNCKIND : int @@ -257,7 +236,7 @@ public enum CALLCONV : int CC_MAX = 9 } - [Flags()] + [Flags] public enum FUNCFLAGS : short { FUNCFLAG_FRESTRICTED = 0x1, @@ -275,7 +254,7 @@ public enum FUNCFLAGS : short FUNCFLAG_FIMMEDIATEBIND = 0x1000 } - [Flags()] + [Flags] public enum VARFLAGS : short { VARFLAG_FREADONLY = 0x1, @@ -294,7 +273,7 @@ public enum VARFLAGS : short } [Guid("00020401-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface ITypeInfo { @@ -302,17 +281,17 @@ public interface ITypeInfo void GetTypeComp(out ITypeComp ppTComp); void GetFuncDesc(int index, out IntPtr ppFuncDesc); void GetVarDesc(int index, out IntPtr ppVarDesc); - void GetNames(int memid, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] String[] rgBstrNames, int cMaxNames, out int pcNames); + void GetNames(int memid, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] string[] rgBstrNames, int cMaxNames, out int pcNames); void GetRefTypeOfImplType(int index, out int href); void GetImplTypeFlags(int index, out IMPLTYPEFLAGS pImplTypeFlags); - void GetIDsOfNames([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1), In] String[] rgszNames, int cNames, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] int[] pMemId); - void Invoke([MarshalAs(UnmanagedType.IUnknown)] Object pvInstance, int memid, Int16 wFlags, ref DISPPARAMS pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, out int puArgErr); - void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile); + void GetIDsOfNames([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1), In] string[] rgszNames, int cNames, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] int[] pMemId); + void Invoke([MarshalAs(UnmanagedType.IUnknown)] object pvInstance, int memid, short wFlags, ref DISPPARAMS pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, out int puArgErr); + void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile); void GetDllEntry(int memid, INVOKEKIND invKind, IntPtr pBstrDllName, IntPtr pBstrName, IntPtr pwOrdinal); void GetRefTypeInfo(int hRef, out ITypeInfo ppTI); void AddressOfMember(int memid, INVOKEKIND invKind, out IntPtr ppv); - void CreateInstance([MarshalAs(UnmanagedType.IUnknown)] Object pUnkOuter, [In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out Object ppvObj); - void GetMops(int memid, out String pBstrMops); + void CreateInstance([MarshalAs(UnmanagedType.IUnknown)] object pUnkOuter, [In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out object ppvObj); + void GetMops(int memid, out string pBstrMops); void GetContainingTypeLib(out ITypeLib ppTLB, out int pIndex); [PreserveSig] void ReleaseTypeAttr(IntPtr pTypeAttr); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo2.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo2.cs index 7bb7138c4616..bad4f6cbbe79 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo2.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeInfo2.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: ITypeInfo2 interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00020412-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface ITypeInfo2 : ITypeInfo { @@ -24,17 +13,17 @@ public interface ITypeInfo2 : ITypeInfo new void GetTypeComp(out ITypeComp ppTComp); new void GetFuncDesc(int index, out IntPtr ppFuncDesc); new void GetVarDesc(int index, out IntPtr ppVarDesc); - new void GetNames(int memid, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] String[] rgBstrNames, int cMaxNames, out int pcNames); + new void GetNames(int memid, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2), Out] string[] rgBstrNames, int cMaxNames, out int pcNames); new void GetRefTypeOfImplType(int index, out int href); new void GetImplTypeFlags(int index, out IMPLTYPEFLAGS pImplTypeFlags); - new void GetIDsOfNames([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1), In] String[] rgszNames, int cNames, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] int[] pMemId); - new void Invoke([MarshalAs(UnmanagedType.IUnknown)] Object pvInstance, int memid, Int16 wFlags, ref DISPPARAMS pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, out int puArgErr); - new void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile); + new void GetIDsOfNames([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1), In] string[] rgszNames, int cNames, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1), Out] int[] pMemId); + new void Invoke([MarshalAs(UnmanagedType.IUnknown)] object pvInstance, int memid, short wFlags, ref DISPPARAMS pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, out int puArgErr); + new void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile); new void GetDllEntry(int memid, INVOKEKIND invKind, IntPtr pBstrDllName, IntPtr pBstrName, IntPtr pwOrdinal); new void GetRefTypeInfo(int hRef, out ITypeInfo ppTI); new void AddressOfMember(int memid, INVOKEKIND invKind, out IntPtr ppv); - new void CreateInstance([MarshalAs(UnmanagedType.IUnknown)] Object pUnkOuter, [In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out Object ppvObj); - new void GetMops(int memid, out String pBstrMops); + new void CreateInstance([MarshalAs(UnmanagedType.IUnknown)] object pUnkOuter, [In] ref Guid riid, [MarshalAs(UnmanagedType.IUnknown), Out] out object ppvObj); + new void GetMops(int memid, out string pBstrMops); new void GetContainingTypeLib(out ITypeLib ppTLB, out int pIndex); [PreserveSig] new void ReleaseTypeAttr(IntPtr pTypeAttr); @@ -46,13 +35,13 @@ public interface ITypeInfo2 : ITypeInfo void GetTypeFlags(out int pTypeFlags); void GetFuncIndexOfMemId(int memid, INVOKEKIND invKind, out int pFuncIndex); void GetVarIndexOfMemId(int memid, out int pVarIndex); - void GetCustData(ref Guid guid, out Object pVarVal); - void GetFuncCustData(int index, ref Guid guid, out Object pVarVal); - void GetParamCustData(int indexFunc, int indexParam, ref Guid guid, out Object pVarVal); - void GetVarCustData(int index, ref Guid guid, out Object pVarVal); - void GetImplTypeCustData(int index, ref Guid guid, out Object pVarVal); - [LCIDConversionAttribute(1)] - void GetDocumentation2(int memid, out String pbstrHelpString, out int pdwHelpStringContext, out String pbstrHelpStringDll); + void GetCustData(ref Guid guid, out object pVarVal); + void GetFuncCustData(int index, ref Guid guid, out object pVarVal); + void GetParamCustData(int indexFunc, int indexParam, ref Guid guid, out object pVarVal); + void GetVarCustData(int index, ref Guid guid, out object pVarVal); + void GetImplTypeCustData(int index, ref Guid guid, out object pVarVal); + [LCIDConversion(1)] + void GetDocumentation2(int memid, out string pbstrHelpString, out int pdwHelpStringContext, out string pbstrHelpStringDll); void GetAllCustData(IntPtr pCustData); void GetAllFuncCustData(int index, IntPtr pCustData); void GetAllParamCustData(int indexFunc, int indexParam, IntPtr pCustData); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs index 05a9e3f17636..6cab58e117dc 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib.cs @@ -2,17 +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. -/*============================================================================= -** -** -** -** Purpose: ITypeLib interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { public enum SYSKIND @@ -23,7 +12,7 @@ public enum SYSKIND SYS_WIN64 = SYS_MAC + 1 } - [Flags()] + [Flags] public enum LIBFLAGS : short { LIBFLAG_FRESTRICTED = 0x1, @@ -38,13 +27,13 @@ public struct TYPELIBATTR public Guid guid; public int lcid; public SYSKIND syskind; - public Int16 wMajorVerNum; - public Int16 wMinorVerNum; + public short wMajorVerNum; + public short wMinorVerNum; public LIBFLAGS wLibFlags; } [Guid("00020402-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface ITypeLib { @@ -55,10 +44,10 @@ public interface ITypeLib void GetTypeInfoOfGuid(ref Guid guid, out ITypeInfo ppTInfo); void GetLibAttr(out IntPtr ppTLibAttr); void GetTypeComp(out ITypeComp ppTComp); - void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile); + void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile); [return: MarshalAs(UnmanagedType.Bool)] - bool IsName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal); - void FindName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal, [MarshalAs(UnmanagedType.LPArray), Out] ITypeInfo[] ppTInfo, [MarshalAs(UnmanagedType.LPArray), Out] int[] rgMemId, ref Int16 pcFound); + bool IsName([MarshalAs(UnmanagedType.LPWStr)] string szNameBuf, int lHashVal); + void FindName([MarshalAs(UnmanagedType.LPWStr)] string szNameBuf, int lHashVal, [MarshalAs(UnmanagedType.LPArray), Out] ITypeInfo[] ppTInfo, [MarshalAs(UnmanagedType.LPArray), Out] int[] rgMemId, ref short pcFound); [PreserveSig] void ReleaseTLibAttr(IntPtr pTLibAttr); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib2.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib2.cs index 48f4fb378220..76ff8a9be5bb 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib2.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ComTypes/ITypeLib2.cs @@ -2,21 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: ITypeLib2 interface definition. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices.ComTypes { [Guid("00020411-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport] public interface ITypeLib2 : ITypeLib { @@ -27,15 +16,15 @@ public interface ITypeLib2 : ITypeLib new void GetTypeInfoOfGuid(ref Guid guid, out ITypeInfo ppTInfo); new void GetLibAttr(out IntPtr ppTLibAttr); new void GetTypeComp(out ITypeComp ppTComp); - new void GetDocumentation(int index, out String strName, out String strDocString, out int dwHelpContext, out String strHelpFile); + new void GetDocumentation(int index, out string strName, out string strDocString, out int dwHelpContext, out string strHelpFile); [return: MarshalAs(UnmanagedType.Bool)] - new bool IsName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal); - new void FindName([MarshalAs(UnmanagedType.LPWStr)] String szNameBuf, int lHashVal, [MarshalAs(UnmanagedType.LPArray), Out] ITypeInfo[] ppTInfo, [MarshalAs(UnmanagedType.LPArray), Out] int[] rgMemId, ref Int16 pcFound); + new bool IsName([MarshalAs(UnmanagedType.LPWStr)] string szNameBuf, int lHashVal); + new void FindName([MarshalAs(UnmanagedType.LPWStr)] string szNameBuf, int lHashVal, [MarshalAs(UnmanagedType.LPArray), Out] ITypeInfo[] ppTInfo, [MarshalAs(UnmanagedType.LPArray), Out] int[] rgMemId, ref short pcFound); [PreserveSig] new void ReleaseTLibAttr(IntPtr pTLibAttr); - void GetCustData(ref Guid guid, out Object pVarVal); + void GetCustData(ref Guid guid, out object pVarVal); [LCIDConversionAttribute(1)] - void GetDocumentation2(int index, out String pbstrHelpString, out int pdwHelpStringContext, out String pbstrHelpStringDll); + void GetDocumentation2(int index, out string pbstrHelpString, out int pdwHelpStringContext, out string pbstrHelpStringDll); void GetLibStatistics(IntPtr pcUniqueNames, out int pcchUniqueNames); void GetAllCustData(IntPtr pCustData); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CurrencyWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CurrencyWrapper.cs index 590925aafe64..429e65f0afb1 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CurrencyWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/CurrencyWrapper.cs @@ -2,42 +2,30 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_CURRENCY. -** -** -=============================================================================*/ - - -using System; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_CURRENCY. + /// public sealed class CurrencyWrapper { - public CurrencyWrapper(Decimal obj) + public CurrencyWrapper(decimal obj) { m_WrappedObject = obj; } - public CurrencyWrapper(Object obj) - { - if (!(obj is Decimal)) - throw new ArgumentException(SR.Arg_MustBeDecimal, nameof(obj)); - m_WrappedObject = (Decimal)obj; - } - - public Decimal WrappedObject + public CurrencyWrapper(object obj) { - get + if (!(obj is decimal)) { - return m_WrappedObject; + throw new ArgumentException(SR.Arg_MustBeDecimal, nameof(obj)); } + + m_WrappedObject = (decimal)obj; } - private Decimal m_WrappedObject; + public decimal WrappedObject => m_WrappedObject; + + private decimal m_WrappedObject; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/DispatchWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/DispatchWrapper.cs index 5fb78c56add0..b96ba43a0e61 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/DispatchWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/DispatchWrapper.cs @@ -2,24 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_DISPATCH. -** -** -=============================================================================*/ - - -using System; -using System.Security; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_DISPATCH. + /// public sealed class DispatchWrapper { - public DispatchWrapper(Object obj) + public DispatchWrapper(object obj) { if (obj != null) { @@ -32,14 +22,8 @@ public DispatchWrapper(Object obj) m_WrappedObject = obj; } - public Object WrappedObject - { - get - { - return m_WrappedObject; - } - } + public object WrappedObject => m_WrappedObject; - private Object m_WrappedObject; + private object m_WrappedObject; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ErrorWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ErrorWrapper.cs index 34237d539a6f..af139f83fa09 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ErrorWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ErrorWrapper.cs @@ -2,20 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_ERROR. -** -** -=============================================================================*/ - - -using System; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_ERROR. + /// public sealed class ErrorWrapper { public ErrorWrapper(int errorCode) @@ -23,10 +14,13 @@ public ErrorWrapper(int errorCode) m_ErrorCode = errorCode; } - public ErrorWrapper(Object errorCode) + public ErrorWrapper(object errorCode) { if (!(errorCode is int)) + { throw new ArgumentException(SR.Arg_MustBeInt32, nameof(errorCode)); + } + m_ErrorCode = (int)errorCode; } @@ -35,13 +29,7 @@ public ErrorWrapper(Exception e) m_ErrorCode = Marshal.GetHRForException(e); } - public int ErrorCode - { - get - { - return m_ErrorCode; - } - } + public int ErrorCode => m_ErrorCode; private int m_ErrorCode; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Expando/IExpando.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Expando/IExpando.cs index 2bd398b7a94f..909aac1a69f1 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Expando/IExpando.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Expando/IExpando.cs @@ -2,29 +2,27 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// IExpando is an interface which allows Objects implemeningt this interface -// support the ability to modify the object by adding and removing members, -// represented by MemberInfo objects. -// -// -// The IExpando Interface. - -using System; using System.Reflection; namespace System.Runtime.InteropServices.Expando { + /// + /// IExpando is an interface which allows Objects implementing this interface to + /// support the ability to modify the object by adding and removing members, + /// represented by MemberInfo objects. + /// [Guid("AFBF15E6-C37C-11d2-B88E-00A0C9B471B8")] internal interface IExpando : IReflect { - // Add a new Field to the reflection object. The field has - // name as its name. - FieldInfo AddField(String name); + /// + /// Add a new Field to the reflection object. The field has + /// name as its name. + /// + FieldInfo AddField(string name); - // Removes the specified member. + /// + /// Removes the specified member. + /// void RemoveMember(MemberInfo m); } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/GcHandle.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/GcHandle.cs index cec32bbd8c43..85ed6601762a 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/GcHandle.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/GcHandle.cs @@ -55,7 +55,7 @@ static GCHandle() #endif // Allocate a handle storing the object and the type. - internal GCHandle(Object value, GCHandleType type) + internal GCHandle(object value, GCHandleType type) { // Make sure the type parameter is within the valid range for the enum. if ((uint)type > (uint)MaxHandleType) @@ -84,12 +84,12 @@ internal GCHandle(IntPtr handle) // type - The type of GC handle to create. // // returns a new GC handle that protects the object. - public static GCHandle Alloc(Object value) + public static GCHandle Alloc(object value) { return new GCHandle(value, GCHandleType.Normal); } - public static GCHandle Alloc(Object value, GCHandleType type) + public static GCHandle Alloc(object value, GCHandleType type) { return new GCHandle(value, type); } @@ -112,7 +112,7 @@ public void Free() } // Target property - allows getting / updating of the handle's referent. - public Object Target + public object Target { get { @@ -201,7 +201,7 @@ public override int GetHashCode() return m_handle.GetHashCode(); } - public override bool Equals(Object o) + public override bool Equals(object o) { GCHandle hnd; @@ -243,15 +243,15 @@ internal bool IsPinned() // Internal native calls that this implementation uses. [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern IntPtr InternalAlloc(Object value, GCHandleType type); + internal static extern IntPtr InternalAlloc(object value, GCHandleType type); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern void InternalFree(IntPtr handle); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object InternalGet(IntPtr handle); + internal static extern object InternalGet(IntPtr handle); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void InternalSet(IntPtr handle, Object value, bool isPinned); + internal static extern void InternalSet(IntPtr handle, object value, bool isPinned); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object InternalCompareExchange(IntPtr handle, Object value, Object oldValue, bool isPinned); + internal static extern object InternalCompareExchange(IntPtr handle, object value, object oldValue, bool isPinned); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern IntPtr InternalAddrOfPinnedObject(IntPtr handle); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomAdapter.cs index f47d34869976..9ef34004c62e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomAdapter.cs @@ -2,22 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: This the base interface that custom adapters can chose to implement -** when they want to expose the underlying object. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices { + /// + /// The base interface that custom adapters can chose to implement + /// when they want to expose the underlying object. + /// public interface ICustomAdapter { - [return: MarshalAs(UnmanagedType.IUnknown)] Object GetUnderlyingObject(); + [return: MarshalAs(UnmanagedType.IUnknown)] object GetUnderlyingObject(); } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomFactory.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomFactory.cs index e7bfc47281e9..799db6a2d3a6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomFactory.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomFactory.cs @@ -2,11 +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; - namespace System.Runtime.InteropServices { public interface ICustomFactory diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomMarshaler.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomMarshaler.cs index 571d78dfe394..164304512a7b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomMarshaler.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomMarshaler.cs @@ -2,29 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: This the base interface that must be implemented by all custom -** marshalers. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices { + /// + /// The base interface that must be implemented by all custom marshalers. + /// public interface ICustomMarshaler { - Object MarshalNativeToManaged(IntPtr pNativeData); + object MarshalNativeToManaged(IntPtr pNativeData); - IntPtr MarshalManagedToNative(Object ManagedObj); + IntPtr MarshalManagedToNative(object ManagedObj); void CleanUpNativeData(IntPtr pNativeData); - void CleanUpManagedData(Object ManagedObj); + void CleanUpManagedData(object ManagedObj); int GetNativeDataSize(); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs index f0aa35e7ddb1..b0e6534aab22 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/ICustomQueryInterface.cs @@ -2,23 +2,11 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: This the interface that be implemented by class that want to -** customize the behavior of QueryInterface. -** -** -=============================================================================*/ - -using System; - namespace System.Runtime.InteropServices { - //==================================================================== - // The enum of the return value of IQuerable.GetInterface - //==================================================================== + /// + /// The enum of the return value of IQuerable.GetInterface. + /// public enum CustomQueryInterfaceResult { Handled = 0, @@ -26,9 +14,10 @@ public enum CustomQueryInterfaceResult Failed = 2, } - //==================================================================== - // The interface for customizing IQueryInterface - //==================================================================== + /// + /// the interface that be implemented by class that want to + /// customize the behavior of QueryInterface. + /// public interface ICustomQueryInterface { CustomQueryInterfaceResult GetInterface([In]ref Guid iid, out IntPtr ppv); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs index d1ae2e2a9111..02f1728c3814 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidComObjectException.cs @@ -2,23 +2,18 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** Purpose: This exception is thrown when an invalid COM object is used. This -** happens when a the __ComObject type is used directly without -** having a backing class factory. -** -=============================================================================*/ - - -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Runtime.InteropServices { + /// + /// The exception thrown when an invalid COM object is used. This happens + /// when a the __ComObject type is used directly without having a backing + /// class factory. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class InvalidComObjectException : SystemException { public InvalidComObjectException() @@ -27,13 +22,13 @@ public InvalidComObjectException() HResult = HResults.COR_E_INVALIDCOMOBJECT; } - public InvalidComObjectException(String message) + public InvalidComObjectException(string message) : base(message) { HResult = HResults.COR_E_INVALIDCOMOBJECT; } - public InvalidComObjectException(String message, Exception inner) + public InvalidComObjectException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_INVALIDCOMOBJECT; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs index 74029081add8..9ec47dd87fbc 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/InvalidOleVariantTypeException.cs @@ -2,22 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** Purpose: The type of an OLE variant that was passed into the runtime is -** invalid. -** -=============================================================================*/ - - -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Runtime.InteropServices { + /// + /// Exception thrown when the type of an OLE variant that was passed into the + /// runtime is invalid. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class InvalidOleVariantTypeException : SystemException { public InvalidOleVariantTypeException() @@ -26,13 +21,13 @@ public InvalidOleVariantTypeException() HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; } - public InvalidOleVariantTypeException(String message) + public InvalidOleVariantTypeException(string message) : base(message) { HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; } - public InvalidOleVariantTypeException(String message, Exception inner) + public InvalidOleVariantTypeException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_INVALIDOLEVARIANTTYPE; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs index d4eb69e54ee6..74d1e6e64988 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/Marshal.cs @@ -2,57 +2,36 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: This class contains methods that are mainly used to marshal -** between unmanaged and managed types. -** -** -=============================================================================*/ +using System.Collections.Generic; +using System.Reflection; +using System.Reflection.Emit; +using System.Security; +using System.Text; +using System.Runtime.CompilerServices; +using System.Runtime.ConstrainedExecution; +using Win32Native = Microsoft.Win32.Win32Native; +using System.Diagnostics; +using System.Runtime.InteropServices.ComTypes; +using System.StubHelpers; namespace System.Runtime.InteropServices { - using System; - using System.Runtime; - using System.Collections.Generic; - using System.Reflection; - using System.Reflection.Emit; - using System.Security; - using System.Text; - using System.Threading; - using System.Runtime.CompilerServices; - using System.Globalization; - using System.Runtime.ConstrainedExecution; - using System.Runtime.Versioning; - using Win32Native = Microsoft.Win32.Win32Native; - using Microsoft.Win32.SafeHandles; - using System.Diagnostics; - using System.Runtime.InteropServices.ComTypes; - using System.StubHelpers; - public enum CustomQueryInterfaceMode { Ignore = 0, Allow = 1 } - //======================================================================== - // All public methods, including PInvoke, are protected with linkchecks. - // Remove the default demands for all PInvoke methods with this global - // declaration on the class. - //======================================================================== - + /// + /// This class contains methods that are mainly used to marshal between unmanaged + /// and managed types. + /// public static partial class Marshal { - //==================================================================== - // Defines used inside the Marshal class. - //==================================================================== private const int LMEM_FIXED = 0; private const int LMEM_MOVEABLE = 2; #if !FEATURE_PAL - private const long HIWORDMASK = unchecked((long)0xffffffffffff0000L); + private const long HiWordMask = unchecked((long)0xffffffffffff0000L); #endif //!FEATURE_PAL #if FEATURE_COMINTEROP private static Guid IID_IUnknown = new Guid("00000000-0000-0000-C000-000000000046"); @@ -70,46 +49,25 @@ private static bool IsWin32Atom(IntPtr ptr) return false; #else long lPtr = (long)ptr; - return 0 == (lPtr & HIWORDMASK); -#endif - } - - private static bool IsNotWin32Atom(IntPtr ptr) - { -#if FEATURE_PAL - return true; -#else - long lPtr = (long)ptr; - return 0 != (lPtr & HIWORDMASK); + return 0 == (lPtr & HiWordMask); #endif } - //==================================================================== - // The default character size for the system. This is always 2 because - // the framework only runs on UTF-16 systems. - //==================================================================== + /// + /// The default character size for the system. This is always 2 because + /// the framework only runs on UTF-16 systems. + /// public static readonly int SystemDefaultCharSize = 2; - //==================================================================== - // The max DBCS character size for the system. - //==================================================================== + /// + /// The max DBCS character size for the system. + /// public static readonly int SystemMaxDBCSCharSize = GetSystemMaxDBCSCharSize(); - - //==================================================================== - // The name, title and description of the assembly that will contain - // the dynamically generated interop types. - //==================================================================== - private const string s_strConvertedTypeInfoAssemblyName = "InteropDynamicTypes"; - private const string s_strConvertedTypeInfoAssemblyTitle = "Interop Dynamic Types"; - private const string s_strConvertedTypeInfoAssemblyDesc = "Type dynamically generated from ITypeInfo's"; - private const string s_strConvertedTypeInfoNameSpace = "InteropDynamicTypes"; - - - //==================================================================== - // Helper method to retrieve the system's maximum DBCS character size. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// Helper method to retrieve the system's maximum DBCS character size. + /// + [MethodImpl(MethodImplOptions.InternalCall)] private static extern int GetSystemMaxDBCSCharSize(); public static unsafe string PtrToStringAnsi(IntPtr ptr) @@ -122,26 +80,26 @@ public static unsafe string PtrToStringAnsi(IntPtr ptr) { return null; } - else + + int nb = Win32Native.lstrlenA(ptr); + if (nb == 0) { - int nb = Win32Native.lstrlenA(ptr); - if (nb == 0) - { - return string.Empty; - } - else - { - return new string((sbyte*)ptr); - } + return string.Empty; } + + return new string((sbyte*)ptr); } public static unsafe string PtrToStringAnsi(IntPtr ptr, int len) { if (ptr == IntPtr.Zero) + { throw new ArgumentNullException(nameof(ptr)); + } if (len < 0) + { throw new ArgumentException(null, nameof(len)); + } return new string((sbyte*)ptr, 0, len); } @@ -149,9 +107,13 @@ public static unsafe string PtrToStringAnsi(IntPtr ptr, int len) public static unsafe string PtrToStringUni(IntPtr ptr, int len) { if (ptr == IntPtr.Zero) + { throw new ArgumentNullException(nameof(ptr)); + } if (len < 0) - throw new ArgumentException(null, nameof(len)); + { + throw new ArgumentException(SR.ArgumentOutOfRange_NeedNonNegNum, nameof(len)); + } return new string((char*)ptr, 0, len); } @@ -172,10 +134,8 @@ public static unsafe string PtrToStringUni(IntPtr ptr) { return null; } - else - { - return new string((char*)ptr); - } + + return new string((char*)ptr); } public static string PtrToStringAuto(IntPtr ptr) @@ -190,11 +150,9 @@ public static unsafe string PtrToStringUTF8(IntPtr ptr) { return null; } - else - { - int nbBytes = System.StubHelpers.StubHelpers.strlen((sbyte*)ptr.ToPointer()); - return PtrToStringUTF8(ptr, nbBytes); - } + + int nbBytes = StubHelpers.StubHelpers.strlen((sbyte*)ptr.ToPointer()); + return PtrToStringUTF8(ptr, nbBytes); } public static unsafe string PtrToStringUTF8(IntPtr ptr, int byteLen) @@ -215,84 +173,78 @@ public static unsafe string PtrToStringUTF8(IntPtr ptr, int byteLen) { return string.Empty; } - else - { - byte* pByte = (byte*)ptr.ToPointer(); - return Encoding.UTF8.GetString(pByte, byteLen); - } + + byte* pByte = (byte*)ptr.ToPointer(); + return Encoding.UTF8.GetString(pByte, byteLen); } - //==================================================================== - // SizeOf() - //==================================================================== - public static int SizeOf(Object structure) + public static int SizeOf(object structure) { if (structure == null) + { throw new ArgumentNullException(nameof(structure)); - // we never had a check for generics here + } return SizeOfHelper(structure.GetType(), true); } - public static int SizeOf(T structure) - { - return SizeOf((object)structure); - } + public static int SizeOf(T structure) => SizeOf((object)structure); public static int SizeOf(Type t) { if (t == null) + { throw new ArgumentNullException(nameof(t)); + } if (!(t is RuntimeType)) + { throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t)); + } if (t.IsGenericType) + { throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); + } - return SizeOfHelper(t, true); + return SizeOfHelper(t, throwIfNotMarshalable: true); } - public static int SizeOf() - { - return SizeOf(typeof(T)); - } + public static int SizeOf() => SizeOf(typeof(T)); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern int SizeOfHelper(Type t, bool throwIfNotMarshalable); - //==================================================================== - // OffsetOf() - //==================================================================== public static IntPtr OffsetOf(Type t, string fieldName) { if (t == null) + { throw new ArgumentNullException(nameof(t)); + } FieldInfo f = t.GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (f == null) + { throw new ArgumentException(SR.Format(SR.Argument_OffsetOfFieldNotFound, t.FullName), nameof(fieldName)); - RtFieldInfo rtField = f as RtFieldInfo; - if (rtField == null) + } + + if (!(f is RtFieldInfo rtField)) + { throw new ArgumentException(SR.Argument_MustBeRuntimeFieldInfo, nameof(fieldName)); + } return OffsetOfHelper(rtField); } - public static IntPtr OffsetOf(string fieldName) - { - return OffsetOf(typeof(T), fieldName); - } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + public static IntPtr OffsetOf(string fieldName) => OffsetOf(typeof(T), fieldName); + + [MethodImpl(MethodImplOptions.InternalCall)] private static extern IntPtr OffsetOfHelper(IRuntimeFieldInfo f); - //==================================================================== - // UnsafeAddrOfPinnedArrayElement() - // - // IMPORTANT NOTICE: This method does not do any verification on the - // array. It must be used with EXTREME CAUTION since passing in - // an array that is not pinned or in the fixed heap can cause - // unexpected results ! - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// IMPORTANT NOTICE: This method does not do any verification on the array. + /// It must be used with EXTREME CAUTION since passing in an array that is + /// not pinned or in the fixed heap can cause unexpected results. + /// + [MethodImpl(MethodImplOptions.InternalCall)] public static extern IntPtr UnsafeAddrOfPinnedArrayElement(Array arr, int index); public static IntPtr UnsafeAddrOfPinnedArrayElement(T[] arr, int index) @@ -300,88 +252,95 @@ public static IntPtr UnsafeAddrOfPinnedArrayElement(T[] arr, int index) return UnsafeAddrOfPinnedArrayElement((Array)arr, index); } - //==================================================================== - // Copy blocks from CLR arrays to native memory. - //==================================================================== public static void Copy(int[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(char[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(short[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(long[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(float[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(double[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(byte[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } + public static void Copy(IntPtr[] source, int startIndex, IntPtr destination, int length) { CopyToNative(source, startIndex, destination, length); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void CopyToNative(Object source, int startIndex, IntPtr destination, int length); - //==================================================================== - // Copy blocks from native memory to CLR arrays - //==================================================================== + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern void CopyToNative(object source, int startIndex, IntPtr destination, int length); + public static void Copy(IntPtr source, int[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, char[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, short[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, long[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, float[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, double[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, byte[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } + public static void Copy(IntPtr source, IntPtr[] destination, int startIndex, int length) { CopyToManaged(source, destination, startIndex, length); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void CopyToManaged(IntPtr source, Object destination, int startIndex, int length); - //==================================================================== - // Read from memory - //==================================================================== - public static byte ReadByte(Object ptr, int ofs) + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern void CopyToManaged(IntPtr source, object destination, int startIndex, int length); + + public static byte ReadByte(object ptr, int ofs) { - return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadByte(nativeHome, offset)); + return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadByte(nativeHome, offset)); } public static unsafe byte ReadByte(IntPtr ptr, int ofs) @@ -398,14 +357,11 @@ public static unsafe byte ReadByte(IntPtr ptr, int ofs) } } - public static byte ReadByte(IntPtr ptr) - { - return ReadByte(ptr, 0); - } + public static byte ReadByte(IntPtr ptr) => ReadByte(ptr, 0); - public static short ReadInt16(Object ptr, int ofs) + public static short ReadInt16(object ptr, int ofs) { - return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt16(nativeHome, offset)); + return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt16(nativeHome, offset)); } public static unsafe short ReadInt16(IntPtr ptr, int ofs) @@ -435,14 +391,11 @@ public static unsafe short ReadInt16(IntPtr ptr, int ofs) } } - public static short ReadInt16(IntPtr ptr) - { - return ReadInt16(ptr, 0); - } + public static short ReadInt16(IntPtr ptr) => ReadInt16(ptr, 0); public static int ReadInt32(object ptr, int ofs) { - return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt32(nativeHome, offset)); + return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt32(nativeHome, offset)); } public static unsafe int ReadInt32(IntPtr ptr, int ofs) @@ -474,17 +427,14 @@ public static unsafe int ReadInt32(IntPtr ptr, int ofs) } } - public static int ReadInt32(IntPtr ptr) - { - return ReadInt32(ptr, 0); - } + public static int ReadInt32(IntPtr ptr) => ReadInt32(ptr, 0); - public static IntPtr ReadIntPtr(Object ptr, int ofs) + public static IntPtr ReadIntPtr(object ptr, int ofs) { #if BIT64 return (IntPtr)ReadInt64(ptr, ofs); #else // 32 - return (IntPtr) ReadInt32(ptr, ofs); + return (IntPtr)ReadInt32(ptr, ofs); #endif } @@ -493,22 +443,15 @@ public static IntPtr ReadIntPtr(IntPtr ptr, int ofs) #if BIT64 return (IntPtr)ReadInt64(ptr, ofs); #else // 32 - return (IntPtr) ReadInt32(ptr, ofs); + return (IntPtr)ReadInt32(ptr, ofs); #endif } - public static IntPtr ReadIntPtr(IntPtr ptr) - { -#if BIT64 - return (IntPtr)ReadInt64(ptr, 0); -#else // 32 - return (IntPtr) ReadInt32(ptr, 0); -#endif - } + public static IntPtr ReadIntPtr(IntPtr ptr) => ReadIntPtr(ptr, 0); - public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] Object ptr, int ofs) + public static long ReadInt64([MarshalAs(UnmanagedType.AsAny), In] object ptr, int ofs) { - return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => Marshal.ReadInt64(nativeHome, offset)); + return ReadValueSlow(ptr, ofs, (IntPtr nativeHome, int offset) => ReadInt64(nativeHome, offset)); } public static unsafe long ReadInt64(IntPtr ptr, int ofs) @@ -544,50 +487,43 @@ public static unsafe long ReadInt64(IntPtr ptr, int ofs) } } - public static long ReadInt64(IntPtr ptr) - { - return ReadInt64(ptr, 0); - } + public static long ReadInt64(IntPtr ptr) => ReadInt64(ptr, 0); //==================================================================== // Read value from marshaled object (marshaled using AsAny) // It's quite slow and can return back dangling pointers // It's only there for backcompact - // I don't think we should spend time optimizing it - // People should really call the IntPtr overload instead + // People should instead use the IntPtr overloads //==================================================================== private static unsafe T ReadValueSlow(object ptr, int ofs, Func readValueHelper) { - // We AV on desktop if passing NULL. So this is technically a breaking change but is an improvement + // Consumers of this method are documented to throw AccessViolationException on any AV if (ptr == null) - throw new ArgumentNullException(nameof(ptr)); + { + throw new AccessViolationException(); + } - int dwFlags = + const int Flags = (int)AsAnyMarshaler.AsAnyFlags.In | (int)AsAnyMarshaler.AsAnyFlags.IsAnsi | (int)AsAnyMarshaler.AsAnyFlags.IsBestFit; - MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState(); + MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState(); AsAnyMarshaler marshaler = new AsAnyMarshaler(new IntPtr(&nativeArrayMarshalerState)); - + IntPtr pNativeHome = IntPtr.Zero; try { - pNativeHome = marshaler.ConvertToNative(ptr, dwFlags); + pNativeHome = marshaler.ConvertToNative(ptr, Flags); return readValueHelper(pNativeHome, ofs); } finally { marshaler.ClearNative(pNativeHome); - } + } } - - - //==================================================================== - // Write to memory - //==================================================================== public static unsafe void WriteByte(IntPtr ptr, int ofs, byte val) { try @@ -602,15 +538,12 @@ public static unsafe void WriteByte(IntPtr ptr, int ofs, byte val) } } - public static void WriteByte(Object ptr, int ofs, byte val) + public static void WriteByte(object ptr, int ofs, byte val) { - WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, byte value) => Marshal.WriteByte(nativeHome, offset, value)); + WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, byte value) => WriteByte(nativeHome, offset, value)); } - public static void WriteByte(IntPtr ptr, byte val) - { - WriteByte(ptr, 0, val); - } + public static void WriteByte(IntPtr ptr, byte val) => WriteByte(ptr, 0, val); public static unsafe void WriteInt16(IntPtr ptr, int ofs, short val) { @@ -637,30 +570,18 @@ public static unsafe void WriteInt16(IntPtr ptr, int ofs, short val) } } - public static void WriteInt16(Object ptr, int ofs, short val) + public static void WriteInt16(object ptr, int ofs, short val) { WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, short value) => Marshal.WriteInt16(nativeHome, offset, value)); } - public static void WriteInt16(IntPtr ptr, short val) - { - WriteInt16(ptr, 0, val); - } + public static void WriteInt16(IntPtr ptr, short val) => WriteInt16(ptr, 0, val); - public static void WriteInt16(IntPtr ptr, int ofs, char val) - { - WriteInt16(ptr, ofs, (short)val); - } + public static void WriteInt16(IntPtr ptr, int ofs, char val) => WriteInt16(ptr, ofs, (short)val); - public static void WriteInt16([In, Out]Object ptr, int ofs, char val) - { - WriteInt16(ptr, ofs, (short)val); - } + public static void WriteInt16([In, Out]object ptr, int ofs, char val) => WriteInt16(ptr, ofs, (short)val); - public static void WriteInt16(IntPtr ptr, char val) - { - WriteInt16(ptr, 0, (short)val); - } + public static void WriteInt16(IntPtr ptr, char val) => WriteInt16(ptr, 0, (short)val); public static unsafe void WriteInt32(IntPtr ptr, int ofs, int val) { @@ -689,42 +610,32 @@ public static unsafe void WriteInt32(IntPtr ptr, int ofs, int val) } } - public static void WriteInt32(Object ptr, int ofs, int val) + public static void WriteInt32(object ptr, int ofs, int val) { WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, int value) => Marshal.WriteInt32(nativeHome, offset, value)); } - public static void WriteInt32(IntPtr ptr, int val) - { - WriteInt32(ptr, 0, val); - } + public static void WriteInt32(IntPtr ptr, int val) => WriteInt32(ptr, 0, val); public static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val) { #if BIT64 WriteInt64(ptr, ofs, (long)val); #else // 32 - WriteInt32(ptr, ofs, (int)val); + WriteInt32(ptr, ofs, (int)val); #endif } - public static void WriteIntPtr(Object ptr, int ofs, IntPtr val) + public static void WriteIntPtr(object ptr, int ofs, IntPtr val) { #if BIT64 WriteInt64(ptr, ofs, (long)val); #else // 32 - WriteInt32(ptr, ofs, (int)val); + WriteInt32(ptr, ofs, (int)val); #endif } - public static void WriteIntPtr(IntPtr ptr, IntPtr val) - { -#if BIT64 - WriteInt64(ptr, 0, (long)val); -#else // 32 - WriteInt32(ptr, 0, (int)val); -#endif - } + public static void WriteIntPtr(IntPtr ptr, IntPtr val) => WriteIntPtr(ptr, 0, val); public static unsafe void WriteInt64(IntPtr ptr, int ofs, long val) { @@ -757,91 +668,76 @@ public static unsafe void WriteInt64(IntPtr ptr, int ofs, long val) } } - public static void WriteInt64(Object ptr, int ofs, long val) + public static void WriteInt64(object ptr, int ofs, long val) { WriteValueSlow(ptr, ofs, val, (IntPtr nativeHome, int offset, long value) => Marshal.WriteInt64(nativeHome, offset, value)); } - public static void WriteInt64(IntPtr ptr, long val) - { - WriteInt64(ptr, 0, val); - } + public static void WriteInt64(IntPtr ptr, long val) => WriteInt64(ptr, 0, val); - //==================================================================== - // Write value into marshaled object (marshaled using AsAny) and - // propagate the value back - // It's quite slow and is only there for backcompact - // I don't think we should spend time optimizing it - // People should really call the IntPtr overload instead - //==================================================================== + /// + /// Write value into marshaled object (marshaled using AsAny) and propagate the + /// value back. This is quite slow and can return back dangling pointers. It is + /// only here for backcompat. People should instead use the IntPtr overloads. + /// private static unsafe void WriteValueSlow(object ptr, int ofs, T val, Action writeValueHelper) { - // We AV on desktop if passing NULL. So this is technically a breaking change but is an improvement + // Consumers of this method are documented to throw AccessViolationException on any AV if (ptr == null) - throw new ArgumentNullException(nameof(ptr)); - - int dwFlags = + { + throw new AccessViolationException(); + } + + const int Flags = (int)AsAnyMarshaler.AsAnyFlags.In | (int)AsAnyMarshaler.AsAnyFlags.Out | (int)AsAnyMarshaler.AsAnyFlags.IsAnsi | (int)AsAnyMarshaler.AsAnyFlags.IsBestFit; - MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState(); + MngdNativeArrayMarshaler.MarshalerState nativeArrayMarshalerState = new MngdNativeArrayMarshaler.MarshalerState(); AsAnyMarshaler marshaler = new AsAnyMarshaler(new IntPtr(&nativeArrayMarshalerState)); - + IntPtr pNativeHome = IntPtr.Zero; try { - pNativeHome = marshaler.ConvertToNative(ptr, dwFlags); + pNativeHome = marshaler.ConvertToNative(ptr, Flags); writeValueHelper(pNativeHome, ofs, val); marshaler.ConvertToManaged(ptr, pNativeHome); } finally { marshaler.ClearNative(pNativeHome); - } + } } - //==================================================================== - // GetLastWin32Error - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int GetLastWin32Error(); - - //==================================================================== - // SetLastWin32Error - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void SetLastWin32Error(int error); - - //==================================================================== - // GetHRForLastWin32Error - //==================================================================== public static int GetHRForLastWin32Error() { int dwLastError = GetLastWin32Error(); if ((dwLastError & 0x80000000) == 0x80000000) + { return dwLastError; - else - return (dwLastError & 0x0000FFFF) | unchecked((int)0x80070000); + } + + return (dwLastError & 0x0000FFFF) | unchecked((int)0x80070000); } - - //==================================================================== - // Prelink - //==================================================================== public static void Prelink(MethodInfo m) { if (m == null) + { throw new ArgumentNullException(nameof(m)); - - RuntimeMethodInfo rmi = m as RuntimeMethodInfo; - - if (rmi == null) - throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo); + } + if (!(m is RuntimeMethodInfo rmi)) + { + throw new ArgumentException(SR.Argument_MustBeRuntimeMethodInfo, nameof(m)); + } InternalPrelink(rmi); } @@ -852,7 +748,9 @@ public static void Prelink(MethodInfo m) public static void PrelinkAll(Type c) { if (c == null) + { throw new ArgumentNullException(nameof(c)); + } MethodInfo[] mi = c.GetMethods(); if (mi != null) @@ -864,32 +762,31 @@ public static void PrelinkAll(Type c) } } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern /* struct _EXCEPTION_POINTERS* */ IntPtr GetExceptionPointers(); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int GetExceptionCode(); - - //==================================================================== - // Marshals data from a structure class to a native memory block. - // If the structure contains pointers to allocated blocks and - // "fDeleteOld" is true, this routine will call DestroyStructure() first. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] - public static extern void StructureToPtr(Object structure, IntPtr ptr, bool fDeleteOld); + /// + /// Marshals data from a structure class to a native memory block. If the + /// structure contains pointers to allocated blocks and "fDeleteOld" is + /// true, this routine will call DestroyStructure() first. + /// + [MethodImpl(MethodImplOptions.InternalCall), ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)] + public static extern void StructureToPtr(object structure, IntPtr ptr, bool fDeleteOld); public static void StructureToPtr(T structure, IntPtr ptr, bool fDeleteOld) { StructureToPtr((object)structure, ptr, fDeleteOld); } - //==================================================================== - // Marshals data from a native memory block to a preallocated structure class. - //==================================================================== - public static void PtrToStructure(IntPtr ptr, Object structure) + /// + /// Marshals data from a native memory block to a preallocated structure class. + /// + public static void PtrToStructure(IntPtr ptr, object structure) { - PtrToStructureHelper(ptr, structure, false); + PtrToStructureHelper(ptr, structure, allowValueClasses: false); } public static void PtrToStructure(IntPtr ptr, T structure) @@ -897,75 +794,74 @@ public static void PtrToStructure(IntPtr ptr, T structure) PtrToStructure(ptr, (object)structure); } - //==================================================================== - // Creates a new instance of "structuretype" and marshals data from a - // native memory block to it. - //==================================================================== - public static Object PtrToStructure(IntPtr ptr, Type structureType) + /// + /// Creates a new instance of "structuretype" and marshals data from a + /// native memory block to it. + /// + public static object PtrToStructure(IntPtr ptr, Type structureType) { - if (ptr == IntPtr.Zero) return null; + if (ptr == IntPtr.Zero) + { + return null; + } if (structureType == null) + { throw new ArgumentNullException(nameof(structureType)); - + } if (structureType.IsGenericType) + { throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(structureType)); - - RuntimeType rt = structureType.UnderlyingSystemType as RuntimeType; - - if (rt == null) + } + if (!(structureType.UnderlyingSystemType is RuntimeType rt)) + { throw new ArgumentException(SR.Arg_MustBeType, nameof(structureType)); + } - Object structure = rt.CreateInstanceDefaultCtor(false /*publicOnly*/, false /*skipCheckThis*/, false /*fillCache*/, true /*wrapExceptions*/); - PtrToStructureHelper(ptr, structure, true); + object structure = rt.CreateInstanceDefaultCtor(publicOnly: false, skipCheckThis: false, fillCache: false, wrapExceptions: true); + PtrToStructureHelper(ptr, structure, allowValueClasses: true); return structure; } - public static T PtrToStructure(IntPtr ptr) - { - return (T)PtrToStructure(ptr, typeof(T)); - } - - //==================================================================== - // Helper function to copy a pointer into a preallocated structure. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void PtrToStructureHelper(IntPtr ptr, Object structure, bool allowValueClasses); + public static T PtrToStructure(IntPtr ptr) => (T)PtrToStructure(ptr, typeof(T)); + /// + /// Helper function to copy a pointer into a preallocated structure. + /// + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern void PtrToStructureHelper(IntPtr ptr, object structure, bool allowValueClasses); - //==================================================================== - // Freeds all substructures pointed to by the native memory block. - // "structureclass" is used to provide layout information. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// Frees all substructures pointed to by the native memory block. + /// "structuretype" is used to provide layout information. + /// + [MethodImpl(MethodImplOptions.InternalCall)] public static extern void DestroyStructure(IntPtr ptr, Type structuretype); - public static void DestroyStructure(IntPtr ptr) - { - DestroyStructure(ptr, typeof(T)); - } + public static void DestroyStructure(IntPtr ptr) => DestroyStructure(ptr, typeof(T)); #if FEATURE_COMINTEROP - //==================================================================== - // Returns the HInstance for this module. Returns -1 if the module - // doesn't have an HInstance. In Memory (Dynamic) Modules won't have - // an HInstance. - //==================================================================== + /// + /// Returns the HInstance for this module. Returns -1 if the module doesn't have + /// an HInstance. In Memory (Dynamic) Modules won't have an HInstance. + /// public static IntPtr GetHINSTANCE(Module m) { if (m == null) + { throw new ArgumentNullException(nameof(m)); + } RuntimeModule rtModule = m as RuntimeModule; - if (rtModule == null) + if (rtModule == null && m is ModuleBuilder mb) { - ModuleBuilder mb = m as ModuleBuilder; - if (mb != null) - rtModule = mb.InternalModule; + rtModule = mb.InternalModule; } if (rtModule == null) + { throw new ArgumentNullException(nameof(m), SR.Argument_MustBeRuntimeModule); + } return GetHINSTANCE(rtModule.GetNativeHandle()); } @@ -974,53 +870,58 @@ public static IntPtr GetHINSTANCE(Module m) private static extern IntPtr GetHINSTANCE(RuntimeModule m); #endif // FEATURE_COMINTEROP - //==================================================================== - // Throws a CLR exception based on the HRESULT. - //==================================================================== + + /// + /// Throws a CLR exception based on the HRESULT. + /// public static void ThrowExceptionForHR(int errorCode) { if (errorCode < 0) + { ThrowExceptionForHRInternal(errorCode, IntPtr.Zero); + } } + public static void ThrowExceptionForHR(int errorCode, IntPtr errorInfo) { if (errorCode < 0) + { ThrowExceptionForHRInternal(errorCode, errorInfo); + } } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void ThrowExceptionForHRInternal(int errorCode, IntPtr errorInfo); - - //==================================================================== - // Converts the HRESULT to a CLR exception. - //==================================================================== + /// + /// Converts the HRESULT to a CLR exception. + /// public static Exception GetExceptionForHR(int errorCode) { - if (errorCode < 0) - return GetExceptionForHRInternal(errorCode, IntPtr.Zero); - else + if (errorCode >= 0) + { return null; + } + + return GetExceptionForHRInternal(errorCode, IntPtr.Zero); } public static Exception GetExceptionForHR(int errorCode, IntPtr errorInfo) { - if (errorCode < 0) - return GetExceptionForHRInternal(errorCode, errorInfo); - else + if (errorCode >= 0) + { return null; + } + + return GetExceptionForHRInternal(errorCode, errorInfo); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern Exception GetExceptionForHRInternal(int errorCode, IntPtr errorInfo); - - //==================================================================== - // Memory allocation and deallocation. - //==================================================================== public static IntPtr AllocHGlobal(IntPtr cb) { // For backwards compatibility on 32 bit platforms, ensure we pass values between - // Int32.MaxValue and UInt32.MaxValue to Windows. If the binary has had the + // int.MaxValue and uint.MaxValue to Windows. If the binary has had the // LARGEADDRESSAWARE bit set in the PE header, it may get 3 or 4 GB of user mode // address space. It is remotely that those allocations could have succeeded, // though I couldn't reproduce that. In either case, that means we should continue @@ -1033,22 +934,19 @@ public static IntPtr AllocHGlobal(IntPtr cb) #endif IntPtr pNewMem = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, unchecked(numBytes)); - if (pNewMem == IntPtr.Zero) { throw new OutOfMemoryException(); } + return pNewMem; } - public static IntPtr AllocHGlobal(int cb) - { - return AllocHGlobal((IntPtr)cb); - } + public static IntPtr AllocHGlobal(int cb) => AllocHGlobal((IntPtr)cb); public static void FreeHGlobal(IntPtr hglobal) { - if (IsNotWin32Atom(hglobal)) + if (!IsWin32Atom(hglobal)) { if (IntPtr.Zero != Win32Native.LocalFree(hglobal)) { @@ -1064,40 +962,34 @@ public static IntPtr ReAllocHGlobal(IntPtr pv, IntPtr cb) { throw new OutOfMemoryException(); } + return pNewMem; } - - - //==================================================================== - // String convertions. - //==================================================================== + public static unsafe IntPtr StringToHGlobalAnsi(string s) { if (s == null) { return IntPtr.Zero; } - else - { - int nb = (s.Length + 1) * SystemMaxDBCSCharSize; - // Overflow checking - if (nb < s.Length) - throw new ArgumentOutOfRangeException(nameof(s)); + int nb = (s.Length + 1) * SystemMaxDBCSCharSize; - UIntPtr len = new UIntPtr((uint)nb); - IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); + // Overflow checking + if (nb < s.Length) + { + throw new ArgumentOutOfRangeException(nameof(s)); + } - if (hglobal == IntPtr.Zero) - { - throw new OutOfMemoryException(); - } - else - { - s.ConvertToAnsi((byte*)hglobal, nb, false, false); - return hglobal; - } + UIntPtr len = new UIntPtr((uint)nb); + IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); + if (hglobal == IntPtr.Zero) + { + throw new OutOfMemoryException(); } + + s.ConvertToAnsi((byte*)hglobal, nb, false, false); + return hglobal; } public static unsafe IntPtr StringToHGlobalUni(string s) @@ -1106,30 +998,27 @@ public static unsafe IntPtr StringToHGlobalUni(string s) { return IntPtr.Zero; } - else - { - int nb = (s.Length + 1) * 2; - // Overflow checking - if (nb < s.Length) - throw new ArgumentOutOfRangeException(nameof(s)); + int nb = (s.Length + 1) * 2; - UIntPtr len = new UIntPtr((uint)nb); - IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); + // Overflow checking + if (nb < s.Length) + { + throw new ArgumentOutOfRangeException(nameof(s)); + } - if (hglobal == IntPtr.Zero) - { - throw new OutOfMemoryException(); - } - else - { - fixed (char* firstChar = s) - { - string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); - } - return hglobal; - } + UIntPtr len = new UIntPtr((uint)nb); + IntPtr hglobal = Win32Native.LocalAlloc_NoSafeHandle(LMEM_FIXED, len); + if (hglobal == IntPtr.Zero) + { + throw new OutOfMemoryException(); + } + + fixed (char* firstChar = s) + { + string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); } + return hglobal; } public static IntPtr StringToHGlobalAuto(string s) @@ -1139,154 +1028,126 @@ public static IntPtr StringToHGlobalAuto(string s) } #if FEATURE_COMINTEROP - - //==================================================================== - // Converts the CLR exception to an HRESULT. This function also sets - // up an IErrorInfo for the exception. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// Converts the CLR exception to an HRESULT. This function also sets + /// up an IErrorInfo for the exception. + /// + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int GetHRForException(Exception e); - //==================================================================== - // Converts the CLR exception to an HRESULT. This function also sets - // up an IErrorInfo for the exception. - // This function is only used in WinRT and converts ObjectDisposedException - // to RO_E_CLOSED - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// Converts the CLR exception to an HRESULT. This function also sets + /// up an IErrorInfo for the exception. + /// This function is only used in WinRT and converts ObjectDisposedException + /// to RO_E_CLOSED + /// + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern int GetHRForException_WinRT(Exception e); - internal static readonly Guid ManagedNameGuid = new Guid("{0F21F359-AB84-41E8-9A78-36D110E6D2F9}"); - - //==================================================================== - // Given a managed object that wraps an ITypeInfo, return its name - //==================================================================== + /// + /// Given a managed object that wraps an ITypeInfo, return its name. + /// public static string GetTypeInfoName(ITypeInfo typeInfo) { if (typeInfo == null) + { throw new ArgumentNullException(nameof(typeInfo)); + } - string strTypeLibName = null; - string strDocString = null; - int dwHelpContext = 0; - string strHelpFile = null; - - typeInfo.GetDocumentation(-1, out strTypeLibName, out strDocString, out dwHelpContext, out strHelpFile); - + typeInfo.GetDocumentation(-1, out string strTypeLibName, out _, out _, out _); return strTypeLibName; } // This method is identical to Type.GetTypeFromCLSID. Since it's interop specific, we expose it // on Marshal for more consistent API surface. - public static Type GetTypeFromCLSID(Guid clsid) - { - return RuntimeType.GetTypeFromCLSIDImpl(clsid, null, false); - } + public static Type GetTypeFromCLSID(Guid clsid) => RuntimeType.GetTypeFromCLSIDImpl(clsid, null, throwOnError: false); - //==================================================================== - // return the IUnknown* for an Object if the current context - // is the one where the RCW was first seen. Will return null - // otherwise. - //==================================================================== - public static IntPtr /* IUnknown* */ GetIUnknownForObject(Object o) + /// + /// Return the IUnknown* for an Object if the current context is the one + /// where the RCW was first seen. Will return null otherwise. + /// + public static IntPtr /* IUnknown* */ GetIUnknownForObject(object o) { return GetIUnknownForObjectNative(o, false); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern IntPtr /* IUnknown* */ GetIUnknownForObjectNative(Object o, bool onlyInContext); + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern IntPtr /* IUnknown* */ GetIUnknownForObjectNative(object o, bool onlyInContext); - //==================================================================== - // return the raw IUnknown* for a COM Object not related to current - // context - // Does not call AddRef - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern IntPtr /* IUnknown* */ GetRawIUnknownForComObjectNoAddRef(Object o); + /// + /// Return the raw IUnknown* for a COM Object not related to current. + /// Does not call AddRef. + /// + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern IntPtr /* IUnknown* */ GetRawIUnknownForComObjectNoAddRef(object o); #endif // FEATURE_COMINTEROP - //==================================================================== - // return the IDispatch* for an Object - //==================================================================== - public static IntPtr /* IDispatch */ GetIDispatchForObject(Object o) - { - throw new PlatformNotSupportedException(); - } + public static IntPtr /* IDispatch */ GetIDispatchForObject(object o) => throw new PlatformNotSupportedException(); #if FEATURE_COMINTEROP - - //==================================================================== - // return the IUnknown* representing the interface for the Object - // Object o should support Type T - //==================================================================== - public static IntPtr /* IUnknown* */ GetComInterfaceForObject(Object o, Type T) + /// + /// Return the IUnknown* representing the interface for the Object. + /// Object o should support Type T + /// + public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o, Type T) { return GetComInterfaceForObjectNative(o, T, false, true); } - public static IntPtr GetComInterfaceForObject(T o) - { - return GetComInterfaceForObject(o, typeof(TInterface)); - } + public static IntPtr GetComInterfaceForObject(T o) => GetComInterfaceForObject(o, typeof(TInterface)); - //==================================================================== - // return the IUnknown* representing the interface for the Object - // Object o should support Type T, it refer the value of mode to - // invoke customized QueryInterface or not - //==================================================================== - public static IntPtr /* IUnknown* */ GetComInterfaceForObject(Object o, Type T, CustomQueryInterfaceMode mode) + /// + /// Return the IUnknown* representing the interface for the Object. + /// Object o should support Type T, it refer the value of mode to + /// invoke customized QueryInterface or not. + /// + public static IntPtr /* IUnknown* */ GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode) { bool bEnableCustomizedQueryInterface = ((mode == CustomQueryInterfaceMode.Allow) ? true : false); return GetComInterfaceForObjectNative(o, T, false, bEnableCustomizedQueryInterface); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern IntPtr /* IUnknown* */ GetComInterfaceForObjectNative(Object o, Type t, bool onlyInContext, bool fEnalbeCustomizedQueryInterface); + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern IntPtr /* IUnknown* */ GetComInterfaceForObjectNative(object o, Type t, bool onlyInContext, bool fEnalbeCustomizedQueryInterface); - //==================================================================== - // return an Object for IUnknown - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object GetObjectForIUnknown(IntPtr /* IUnknown* */ pUnk); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern object GetObjectForIUnknown(IntPtr /* IUnknown* */ pUnk); - //==================================================================== - // Return a unique Object given an IUnknown. This ensures that you - // receive a fresh object (we will not look in the cache to match up this - // IUnknown to an already existing object). This is useful in cases - // where you want to be able to call ReleaseComObject on a RCW - // and not worry about other active uses of said RCW. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object GetUniqueObjectForIUnknown(IntPtr unknown); + /// + /// Return a unique Object given an IUnknown. This ensures that you receive a fresh + /// object (we will not look in the cache to match up this IUnknown to an already + /// existing object). This is useful in cases where you want to be able to call + /// ReleaseComObject on a RCW and not worry about other active uses ofsaid RCW. + /// + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern object GetUniqueObjectForIUnknown(IntPtr unknown); - //==================================================================== - // return an Object for IUnknown, using the Type T, - // NOTE: - // Type T should be either a COM imported Type or a sub-type of COM - // imported Type - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object GetTypedObjectForIUnknown(IntPtr /* IUnknown* */ pUnk, Type t); + /// + /// Return an Object for IUnknown, using the Type T. + /// Type T should be either a COM imported Type or a sub-type of COM imported Type + /// + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern object GetTypedObjectForIUnknown(IntPtr /* IUnknown* */ pUnk, Type t); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern IntPtr CreateAggregatedObject(IntPtr pOuter, Object o); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern IntPtr CreateAggregatedObject(IntPtr pOuter, object o); public static IntPtr CreateAggregatedObject(IntPtr pOuter, T o) { return CreateAggregatedObject(pOuter, (object)o); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern void CleanupUnusedObjectsInCurrentContext(); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern bool AreComObjectsAvailableForCleanup(); - //==================================================================== - // check if the object is classic COM component - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern bool IsComObject(Object o); + /// + /// Checks if the object is classic COM component. + /// + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern bool IsComObject(object o); #endif // FEATURE_COMINTEROP @@ -1297,6 +1158,7 @@ public static IntPtr AllocCoTaskMem(int cb) { throw new OutOfMemoryException(); } + return pNewMem; } @@ -1306,29 +1168,26 @@ public static unsafe IntPtr StringToCoTaskMemUni(string s) { return IntPtr.Zero; } - else - { - int nb = (s.Length + 1) * 2; - // Overflow checking - if (nb < s.Length) - throw new ArgumentOutOfRangeException(nameof(s)); + int nb = (s.Length + 1) * 2; - IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); + // Overflow checking + if (nb < s.Length) + { + throw new ArgumentOutOfRangeException(nameof(s)); + } - if (hglobal == IntPtr.Zero) - { - throw new OutOfMemoryException(); - } - else - { - fixed (char* firstChar = s) - { - string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); - } - return hglobal; - } + IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); + if (hglobal == IntPtr.Zero) + { + throw new OutOfMemoryException(); } + + fixed (char* firstChar = s) + { + string.wstrcpy((char*)hglobal, firstChar, s.Length + 1); + } + return hglobal; } public static unsafe IntPtr StringToCoTaskMemUTF8(string s) @@ -1337,27 +1196,21 @@ public static unsafe IntPtr StringToCoTaskMemUTF8(string s) { return IntPtr.Zero; } - else - { - int nb = Encoding.UTF8.GetMaxByteCount(s.Length); - IntPtr pMem = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb + 1)); + int nb = Encoding.UTF8.GetMaxByteCount(s.Length); + IntPtr pMem = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb + 1)); + if (pMem == IntPtr.Zero) + { + throw new OutOfMemoryException(); + } - if (pMem == IntPtr.Zero) - { - throw new OutOfMemoryException(); - } - else - { - fixed (char* firstChar = s) - { - byte* pbMem = (byte*)pMem; - int nbWritten = Encoding.UTF8.GetBytes(firstChar, s.Length, pbMem, nb); - pbMem[nbWritten] = 0; - } - return pMem; - } + fixed (char* firstChar = s) + { + byte* pbMem = (byte*)pMem; + int nbWritten = Encoding.UTF8.GetBytes(firstChar, s.Length, pbMem, nb); + pbMem[nbWritten] = 0; } + return pMem; } public static IntPtr StringToCoTaskMemAuto(string s) @@ -1372,31 +1225,28 @@ public static unsafe IntPtr StringToCoTaskMemAnsi(string s) { return IntPtr.Zero; } - else - { - int nb = (s.Length + 1) * SystemMaxDBCSCharSize; - // Overflow checking - if (nb < s.Length) - throw new ArgumentOutOfRangeException(nameof(s)); + int nb = (s.Length + 1) * SystemMaxDBCSCharSize; - IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); + // Overflow checking + if (nb < s.Length) + { + throw new ArgumentOutOfRangeException(nameof(s)); + } - if (hglobal == IntPtr.Zero) - { - throw new OutOfMemoryException(); - } - else - { - s.ConvertToAnsi((byte*)hglobal, nb, false, false); - return hglobal; - } + IntPtr hglobal = Win32Native.CoTaskMemAlloc(new UIntPtr((uint)nb)); + if (hglobal == IntPtr.Zero) + { + throw new OutOfMemoryException(); } + + s.ConvertToAnsi((byte*)hglobal, nb, false, false); + return hglobal; } public static void FreeCoTaskMem(IntPtr ptr) { - if (IsNotWin32Atom(ptr)) + if (!IsWin32Atom(ptr)) { Win32Native.CoTaskMemFree(ptr); } @@ -1409,15 +1259,13 @@ public static IntPtr ReAllocCoTaskMem(IntPtr pv, int cb) { throw new OutOfMemoryException(); } + return pNewMem; } - //==================================================================== - // BSTR allocation and dealocation. - //==================================================================== public static void FreeBSTR(IntPtr ptr) { - if (IsNotWin32Atom(ptr)) + if (!IsWin32Atom(ptr)) { Win32Native.SysFreeString(ptr); } @@ -1426,15 +1274,21 @@ public static void FreeBSTR(IntPtr ptr) public static IntPtr StringToBSTR(string s) { if (s == null) + { return IntPtr.Zero; + } // Overflow checking if (s.Length + 1 < s.Length) + { throw new ArgumentOutOfRangeException(nameof(s)); + } IntPtr bstr = Win32Native.SysAllocStringLen(s, s.Length); if (bstr == IntPtr.Zero) + { throw new OutOfMemoryException(); + } return bstr; } @@ -1445,20 +1299,13 @@ public static string PtrToStringBSTR(IntPtr ptr) } #if FEATURE_COMINTEROP - //==================================================================== - // release the COM component and if the reference hits 0 zombie this object - // further usage of this Object might throw an exception - //==================================================================== - public static int ReleaseComObject(Object o) + /// + /// Release the COM component and if the reference hits 0 zombie this object. + /// Further usage of this Object might throw an exception + /// + public static int ReleaseComObject(object o) { - __ComObject co = null; - - // Make sure the obj is an __ComObject. - try - { - co = (__ComObject)o; - } - catch (InvalidCastException) + if (!(o is __ComObject co)) { throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); } @@ -1466,93 +1313,128 @@ public static int ReleaseComObject(Object o) return co.ReleaseSelf(); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern int InternalReleaseComObject(Object o); - + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern int InternalReleaseComObject(object o); - //==================================================================== - // release the COM component and zombie this object - // further usage of this Object might throw an exception - //==================================================================== - public static Int32 FinalReleaseComObject(Object o) + /// + /// Release the COM component and zombie this object. + /// Further usage of this Object might throw an exception + /// + public static int FinalReleaseComObject(object o) { if (o == null) - throw new ArgumentNullException(nameof(o)); - - __ComObject co = null; - - // Make sure the obj is an __ComObject. - try { - co = (__ComObject)o; + throw new ArgumentNullException(nameof(o)); } - catch (InvalidCastException) + if (!(o is __ComObject co)) { throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); } co.FinalReleaseSelf(); - return 0; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void InternalFinalReleaseComObject(Object o); -#endif // FEATURE_COMINTEROP + [MethodImpl(MethodImplOptions.InternalCall)] + internal static extern void InternalFinalReleaseComObject(object o); - //==================================================================== - // This method retrieves data from the COM object. - //==================================================================== - public static Object GetComObjectData(Object obj, Object key) + public static object GetComObjectData(object obj, object key) { - throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); + if (obj == null) + { + throw new ArgumentNullException(nameof(obj)); + } + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + if (!(obj is __ComObject co)) + { + throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(obj)); + } + if (obj.GetType().IsWindowsRuntimeObject) + { + throw new ArgumentException(SR.Argument_ObjIsWinRTObject, nameof(obj)); + } + + // Retrieve the data from the __ComObject. + return co.GetData(key); } - //==================================================================== - // This method sets data on the COM object. The data can only be set - // once for a given key and cannot be removed. This function returns - // true if the data has been added, false if the data could not be - // added because there already was data for the specified key. - //==================================================================== - public static bool SetComObjectData(Object obj, Object key, Object data) + /// + /// Sets data on the COM object. The data can only be set once for a given key + /// and cannot be removed. This function returns true if the data has been added, + /// false if the data could not be added because there already was data for the + /// specified key. + /// + public static bool SetComObjectData(object obj, object key, object data) { - throw new PlatformNotSupportedException(SR.Arg_PlatformNotSupported); + if (obj == null) + { + throw new ArgumentNullException(nameof(obj)); + } + if (key == null) + { + throw new ArgumentNullException(nameof(key)); + } + if (!(obj is __ComObject co)) + { + throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(obj)); + } + if (obj.GetType().IsWindowsRuntimeObject) + { + throw new ArgumentException(SR.Argument_ObjIsWinRTObject, nameof(obj)); + } + + // Retrieve the data from the __ComObject. + return co.SetData(key, data); } -#if FEATURE_COMINTEROP - //==================================================================== - // This method takes the given COM object and wraps it in an object - // of the specified type. The type must be derived from __ComObject. - //==================================================================== - public static Object CreateWrapperOfType(Object o, Type t) + /// + /// This method takes the given COM object and wraps it in an object + /// of the specified type. The type must be derived from __ComObject. + /// + public static object CreateWrapperOfType(object o, Type t) { - // Validate the arguments. if (t == null) + { throw new ArgumentNullException(nameof(t)); + } if (!t.IsCOMObject) + { throw new ArgumentException(SR.Argument_TypeNotComObject, nameof(t)); + } if (t.IsGenericType) + { throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); - + } if (t.IsWindowsRuntimeObject) + { throw new ArgumentException(SR.Argument_TypeIsWinRTType, nameof(t)); + } - // Check for the null case. if (o == null) + { return null; + } - // Make sure the object is a COM object. if (!o.GetType().IsCOMObject) + { throw new ArgumentException(SR.Argument_ObjNotComObject, nameof(o)); + } if (o.GetType().IsWindowsRuntimeObject) + { throw new ArgumentException(SR.Argument_ObjIsWinRTObject, nameof(o)); + } - // Check to see if the type of the object is the requested type. + // Check to see if we have nothing to do. if (o.GetType() == t) + { return o; + } // Check to see if we already have a cached wrapper for this type. - Object Wrapper = GetComObjectData(o, t); + object Wrapper = GetComObjectData(o, t); if (Wrapper == null) { // Create the wrapper for the specified type. @@ -1574,41 +1456,36 @@ public static TWrapper CreateWrapperOfType(T o) return (TWrapper)CreateWrapperOfType(o, typeof(TWrapper)); } - //==================================================================== - // Helper method called from CreateWrapperOfType. - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern Object InternalCreateWrapperOfType(Object o, Type t); + [MethodImpl(MethodImplOptions.InternalCall)] + private static extern object InternalCreateWrapperOfType(object o, Type t); - //==================================================================== - // IUnknown Helpers - //==================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int /* HRESULT */ QueryInterface(IntPtr /* IUnknown */ pUnk, ref Guid iid, out IntPtr ppv); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int /* ULONG */ AddRef(IntPtr /* IUnknown */ pUnk); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int /* ULONG */ Release(IntPtr /* IUnknown */ pUnk); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void GetNativeVariantForObject(Object obj, /* VARIANT * */ IntPtr pDstNativeVariant); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern void GetNativeVariantForObject(object obj, /* VARIANT * */ IntPtr pDstNativeVariant); public static void GetNativeVariantForObject(T obj, IntPtr pDstNativeVariant) { GetNativeVariantForObject((object)obj, pDstNativeVariant); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object GetObjectForNativeVariant(/* VARIANT * */ IntPtr pSrcNativeVariant); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern object GetObjectForNativeVariant(/* VARIANT * */ IntPtr pSrcNativeVariant); public static T GetObjectForNativeVariant(IntPtr pSrcNativeVariant) { return (T)GetObjectForNativeVariant(pSrcNativeVariant); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object[] GetObjectsForNativeVariants(/* VARIANT * */ IntPtr aSrcNativeVariant, int cVars); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern object[] GetObjectsForNativeVariants(/* VARIANT * */ IntPtr aSrcNativeVariant, int cVars); public static T[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars) { @@ -1628,36 +1505,36 @@ public static T[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int c /// Returns the first valid COM slot that GetMethodInfoForSlot will work on /// This will be 3 for IUnknown based interfaces and 7 for IDispatch based interfaces. /// - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] public static extern int GetStartComSlot(Type t); - #endif // FEATURE_COMINTEROP - //==================================================================== - // This method generates a GUID for the specified type. If the type - // has a GUID in the metadata then it is returned otherwise a stable - // guid GUID is generated based on the fully qualified name of the - // type. - //==================================================================== - public static Guid GenerateGuidForType(Type type) - { - return type.GUID; - } + /// + /// Generates a GUID for the specified type. If the type has a GUID in the + /// metadata then it is returned otherwise a stable guid is generated based + /// on the fully qualified name of the type. + /// + public static Guid GenerateGuidForType(Type type) => type.GUID; - //==================================================================== - // This method generates a PROGID for the specified type. If the type - // has a PROGID in the metadata then it is returned otherwise a stable - // PROGID is generated based on the fully qualified name of the - // type. - //==================================================================== + /// + /// This method generates a PROGID for the specified type. If the type has + /// a PROGID in the metadata then it is returned otherwise a stable PROGID + /// is generated based on the fully qualified name of the type. + /// public static string GenerateProgIdForType(Type type) { if (type == null) + { throw new ArgumentNullException(nameof(type)); + } if (type.IsImport) + { throw new ArgumentException(SR.Argument_TypeMustNotBeComImport, nameof(type)); + } if (type.IsGenericType) + { throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(type)); + } IList cas = CustomAttributeData.GetCustomAttributes(type); for (int i = 0; i < cas.Count; i++) @@ -1685,78 +1562,77 @@ public static string GenerateProgIdForType(Type type) } #if FEATURE_COMINTEROP - //==================================================================== - // This method binds to the specified moniker. - //==================================================================== - public static Object BindToMoniker(string monikerName) + public static object BindToMoniker(string monikerName) { - Object obj = null; - IBindCtx bindctx = null; - CreateBindCtx(0, out bindctx); + CreateBindCtx(0, out IBindCtx bindctx); - UInt32 cbEaten; - IMoniker pmoniker = null; - MkParseDisplayName(bindctx, monikerName, out cbEaten, out pmoniker); + MkParseDisplayName(bindctx, monikerName, out _, out IMoniker pmoniker); + BindMoniker(pmoniker, 0, ref IID_IUnknown, out object obj); - BindMoniker(pmoniker, 0, ref IID_IUnknown, out obj); return obj; } [DllImport(Interop.Libraries.Ole32, PreserveSig = false)] - private static extern void CreateBindCtx(UInt32 reserved, out IBindCtx ppbc); + private static extern void CreateBindCtx(uint reserved, out IBindCtx ppbc); [DllImport(Interop.Libraries.Ole32, PreserveSig = false)] - private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out UInt32 pchEaten, out IMoniker ppmk); + private static extern void MkParseDisplayName(IBindCtx pbc, [MarshalAs(UnmanagedType.LPWStr)] string szUserName, out uint pchEaten, out IMoniker ppmk); [DllImport(Interop.Libraries.Ole32, PreserveSig = false)] - private static extern void BindMoniker(IMoniker pmk, UInt32 grfOpt, ref Guid iidResult, [MarshalAs(UnmanagedType.Interface)] out Object ppvResult); + private static extern void BindMoniker(IMoniker pmk, uint grfOpt, ref Guid iidResult, [MarshalAs(UnmanagedType.Interface)] out object ppvResult); - //======================================================================== - // Private method called from EE upon use of license/ICF2 marshaling. - //======================================================================== + /// + /// Private method called from EE upon use of license/ICF2 marshaling. + /// private static IntPtr LoadLicenseManager() { Type t = Type.GetType("System.ComponentModel.LicenseManager, System", throwOnError: true); return t.TypeHandle.Value; } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void ChangeWrapperHandleStrength(Object otp, bool fIsWeak); + [MethodImpl(MethodImplOptions.InternalCall)] + public static extern void ChangeWrapperHandleStrength(object otp, bool fIsWeak); - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void InitializeWrapperForWinRT(object o, ref IntPtr pUnk); #if FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern void InitializeManagedWinRTFactoryObject(object o, RuntimeType runtimeClassType); #endif - //======================================================================== - // Create activation factory and wraps it with a unique RCW - //======================================================================== - [MethodImplAttribute(MethodImplOptions.InternalCall)] + /// + /// Create activation factory and wraps it with a unique RCW. + /// + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern object GetNativeActivationFactory(Type type); #endif // FEATURE_COMINTEROP public static Delegate GetDelegateForFunctionPointer(IntPtr ptr, Type t) { - // Validate the parameters if (ptr == IntPtr.Zero) + { throw new ArgumentNullException(nameof(ptr)); - + } if (t == null) + { throw new ArgumentNullException(nameof(t)); - - if ((t as RuntimeType) == null) + } + if (!(t is RuntimeType)) + { throw new ArgumentException(SR.Argument_MustBeRuntimeType, nameof(t)); - + } if (t.IsGenericType) + { throw new ArgumentException(SR.Argument_NeedNonGenericType, nameof(t)); + } Type c = t.BaseType; if (c == null || (c != typeof(Delegate) && c != typeof(MulticastDelegate))) + { throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(t)); + } return GetDelegateForFunctionPointerInternal(ptr, t); } @@ -1766,13 +1642,15 @@ public static TDelegate GetDelegateForFunctionPointer(IntPtr ptr) return (TDelegate)(object)GetDelegateForFunctionPointer(ptr, typeof(TDelegate)); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern Delegate GetDelegateForFunctionPointerInternal(IntPtr ptr, Type t); public static IntPtr GetFunctionPointerForDelegate(Delegate d) { if (d == null) + { throw new ArgumentNullException(nameof(d)); + } return GetFunctionPointerForDelegateInternal(d); } @@ -1782,7 +1660,7 @@ public static IntPtr GetFunctionPointerForDelegate(TDelegate d) return GetFunctionPointerForDelegate((Delegate)(object)d); } - [MethodImplAttribute(MethodImplOptions.InternalCall)] + [MethodImpl(MethodImplOptions.InternalCall)] internal static extern IntPtr GetFunctionPointerForDelegateInternal(Delegate d); public static IntPtr SecureStringToBSTR(SecureString s) @@ -1872,4 +1750,3 @@ public static void ZeroFreeGlobalAllocUnicode(IntPtr s) } } } - diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs index d0ab0d946019..ae38c17fa66c 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeCallableAttribute.cs @@ -2,26 +2,29 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** Any method marked with NativeCallableAttribute can be directly called from -** native code.The function token can be loaded to a local variable using LDFTN and -** passed as a callback to native method. -=============================================================================*/ - -using System; -using System.Runtime.CompilerServices; - namespace System.Runtime.InteropServices { + /// + /// Any method marked with NativeCallableAttribute can be directly called from + /// native code. The function token can be loaded to a local variable using LDFTN + /// and passed as a callback to native method. + /// [AttributeUsage(AttributeTargets.Method)] public sealed class NativeCallableAttribute : Attribute { public NativeCallableAttribute() { } - // Optional. If omitted , compiler will choose one for you. + + // + /// + /// Optional. If omitted , compiler will choose one for you. + /// public CallingConvention CallingConvention; - // Optional. If omitted, then the method is native callable, but no EAT is emitted. + + /// + /// Optional. If omitted, then the method is native callable, but no EAT is emitted. + /// public string EntryPoint; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMethods.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMethods.cs index ccc8d2015d9b..bd7e9e5421a4 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMethods.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMethods.cs @@ -2,25 +2,19 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. - -/*============================================================ -** -** -** Purpose: part of ComEventHelpers APIs which allow binding -** managed delegates to COM's connection point based events. -** -**/ #if FEATURE_COMINTEROP namespace System.Runtime.InteropServices { + /// + /// Part of ComEventHelpers APIs which allow binding managed delegates + /// to COM's connection point based events. + /// internal static class NativeMethods { - [ - ComImport, - InterfaceType(ComInterfaceType.InterfaceIsIUnknown), - Guid("00020400-0000-0000-C000-000000000046") - ] + [ComImport] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [Guid("00020400-0000-0000-C000-000000000046")] internal interface IDispatch { } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NonPortable.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NonPortable.cs index 59229ed52816..c3403767e17a 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NonPortable.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/NonPortable.cs @@ -4,26 +4,26 @@ // Dummy implementations of non-portable interop methods that just throw PlatformNotSupportedException +using System.Reflection; +using System.Runtime.InteropServices.ComTypes; + namespace System.Runtime.InteropServices { - public static partial class Marshal + public static partial class Marshal { public static int GetHRForException(Exception e) { return (e != null) ? e.HResult : 0; } - public static int AddRef(System.IntPtr pUnk) + public static int AddRef(IntPtr pUnk) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static bool AreComObjectsAvailableForCleanup() - { - return false; - } + public static bool AreComObjectsAvailableForCleanup() => false; - public static System.IntPtr CreateAggregatedObject(System.IntPtr pOuter, object o) + public static IntPtr CreateAggregatedObject(IntPtr pOuter, object o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } @@ -32,18 +32,18 @@ public static Object BindToMoniker(String monikerName) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - + public static void CleanupUnusedObjectsInCurrentContext() { - return; + return; } - public static System.IntPtr CreateAggregatedObject(System.IntPtr pOuter, T o) + public static IntPtr CreateAggregatedObject(IntPtr pOuter, T o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static object CreateWrapperOfType(object o, System.Type t) + public static object CreateWrapperOfType(object o, Type t) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } @@ -56,98 +56,104 @@ public static TWrapper CreateWrapperOfType(T o) public static void ChangeWrapperHandleStrength(Object otp, bool fIsWeak) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); - } + } public static int FinalReleaseComObject(object o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.IntPtr GetComInterfaceForObject(object o, System.Type T) + public static IntPtr GetComInterfaceForObject(object o, Type T) + { + throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + } + + public static IntPtr GetComInterfaceForObject(object o, Type T, CustomQueryInterfaceMode mode) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.IntPtr GetComInterfaceForObject(object o, System.Type T, System.Runtime.InteropServices.CustomQueryInterfaceMode mode) + public static IntPtr GetComInterfaceForObject(T o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.IntPtr GetComInterfaceForObject(T o) + public static object GetComObjectData(object obj, object key) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.IntPtr GetHINSTANCE(System.Reflection.Module m) + public static IntPtr GetHINSTANCE(Module m) { if (m == null) { throw new ArgumentNullException(nameof(m)); } - return (System.IntPtr) (-1); + + return (IntPtr) (-1); } - public static System.IntPtr GetIUnknownForObject(object o) + public static IntPtr GetIUnknownForObject(object o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static void GetNativeVariantForObject(object obj, System.IntPtr pDstNativeVariant) + public static void GetNativeVariantForObject(object obj, IntPtr pDstNativeVariant) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static void GetNativeVariantForObject(T obj, System.IntPtr pDstNativeVariant) + public static void GetNativeVariantForObject(T obj, IntPtr pDstNativeVariant) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static Object GetTypedObjectForIUnknown(System.IntPtr pUnk, System.Type t) + public static Object GetTypedObjectForIUnknown(IntPtr pUnk, Type t) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static object GetObjectForIUnknown(System.IntPtr pUnk) + public static object GetObjectForIUnknown(IntPtr pUnk) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static object GetObjectForNativeVariant(System.IntPtr pSrcNativeVariant) + public static object GetObjectForNativeVariant(IntPtr pSrcNativeVariant) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static T GetObjectForNativeVariant(System.IntPtr pSrcNativeVariant) + public static T GetObjectForNativeVariant(IntPtr pSrcNativeVariant) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static object[] GetObjectsForNativeVariants(System.IntPtr aSrcNativeVariant, int cVars) + public static object[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static T[] GetObjectsForNativeVariants(System.IntPtr aSrcNativeVariant, int cVars) + public static T[] GetObjectsForNativeVariants(IntPtr aSrcNativeVariant, int cVars) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static int GetStartComSlot(System.Type t) + public static int GetStartComSlot(Type t) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.Type GetTypeFromCLSID(System.Guid clsid) + public static Type GetTypeFromCLSID(Guid clsid) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static string GetTypeInfoName(System.Runtime.InteropServices.ComTypes.ITypeInfo typeInfo) + public static string GetTypeInfoName(ITypeInfo typeInfo) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static object GetUniqueObjectForIUnknown(System.IntPtr unknown) + public static object GetUniqueObjectForIUnknown(IntPtr unknown) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } @@ -162,12 +168,12 @@ public static bool IsComObject(object o) return false; } - public static int QueryInterface(System.IntPtr pUnk, ref System.Guid iid, out System.IntPtr ppv) + public static int QueryInterface(IntPtr pUnk, ref Guid iid, out IntPtr ppv) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static int Release(System.IntPtr pUnk) + public static int Release(IntPtr pUnk) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } @@ -176,6 +182,11 @@ public static int ReleaseComObject(object o) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } + + public static bool SetComObjectData(object obj, object key, object data) + { + throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); + } } public class DispatchWrapper @@ -185,26 +196,19 @@ public DispatchWrapper(object obj) throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public object WrappedObject - { - get - { - throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); - } - } + public object WrappedObject => throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } public static class ComEventsHelper { - public static void Combine(object rcw, System.Guid iid, int dispid, System.Delegate d) + public static void Combine(object rcw, Guid iid, int dispid, Delegate d) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } - public static System.Delegate Remove(object rcw, System.Guid iid, int dispid, System.Delegate d) + public static Delegate Remove(object rcw, Guid iid, int dispid, Delegate d) { throw new PlatformNotSupportedException(SR.PlatformNotSupported_ComInterop); } } } - diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/PInvokeMap.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/PInvokeMap.cs index 33f1b5f09c30..c0db0111bcf9 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/PInvokeMap.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/PInvokeMap.cs @@ -2,20 +2,12 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -//////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////// -// -// PInvokeMap is an enum that defines the PInvoke attributes. These -// values are defined in CorHdr.h. -// -// - -using System.Runtime.InteropServices; -using System; - namespace System.Runtime.InteropServices { - // This Enum matchs the CorPinvokeMap defined in CorHdr.h + /// + /// An enum that defines the PInvoke attributes. These values + /// values are defined in and must match CorHdr.h. + /// internal enum PInvokeMap { NoMangle = 0x0001, // Pinvoke is to use the member name as specified. diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs index d421636c4b0d..8afc4708298d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/RuntimeEnvironment.cs @@ -27,9 +27,9 @@ namespace System.Runtime.InteropServices internal static class RuntimeEnvironment { [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern String GetModuleFileName(); + internal static extern string GetModuleFileName(); - public static String GetSystemVersion() + public static string GetSystemVersion() { return Assembly.GetExecutingAssembly().ImageRuntimeVersion; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs index 039059e7e8a6..846ea4ea3d81 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SEHException.cs @@ -11,15 +11,16 @@ ** =============================================================================*/ -using System.Runtime.InteropServices; -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Runtime.InteropServices { - // Exception for Structured Exception Handler exceptions. + /// + /// Exception for Structured Exception Handler exceptions. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class SEHException : ExternalException { public SEHException() @@ -28,13 +29,13 @@ public SEHException() HResult = HResults.E_FAIL; } - public SEHException(String message) + public SEHException(string message) : base(message) { HResult = HResults.E_FAIL; } - public SEHException(String message, Exception inner) + public SEHException(string message, Exception inner) : base(message, inner) { HResult = HResults.E_FAIL; @@ -52,9 +53,6 @@ protected SEHException(SerializationInfo info, StreamingContext context) : base( // Resumable exceptions aren't implemented in this version, // but this method exists and always returns false. // - public virtual bool CanResume() - { - return false; - } + public virtual bool CanResume() => false; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs index 7f6a24f59393..661810cf0215 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayRankMismatchException.cs @@ -2,22 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** Purpose: This exception is thrown when the runtime rank of a safe array -** is different than the array rank specified in the metadata. -** -=============================================================================*/ - - -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Runtime.InteropServices { + /// + /// The exception is thrown when the runtime rank of a safe array is different + /// than the array rank specified in the metadata. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class SafeArrayRankMismatchException : SystemException { public SafeArrayRankMismatchException() @@ -26,13 +21,13 @@ public SafeArrayRankMismatchException() HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; } - public SafeArrayRankMismatchException(String message) + public SafeArrayRankMismatchException(string message) : base(message) { HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; } - public SafeArrayRankMismatchException(String message, Exception inner) + public SafeArrayRankMismatchException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_SAFEARRAYRANKMISMATCH; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs index e155dcf64dc6..c094ec162a4e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeArrayTypeMismatchException.cs @@ -2,23 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** Purpose: This exception is thrown when the runtime type of an array -** is different than the safe array sub type specified in the -** metadata. -** -=============================================================================*/ - - -using System; +using System.Runtime.CompilerServices; using System.Runtime.Serialization; namespace System.Runtime.InteropServices { + /// + /// The exception is thrown when the runtime type of an array is different + /// than the safe array sub type specified in the metadata. + /// [Serializable] - [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] + [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public class SafeArrayTypeMismatchException : SystemException { public SafeArrayTypeMismatchException() @@ -27,13 +21,13 @@ public SafeArrayTypeMismatchException() HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; } - public SafeArrayTypeMismatchException(String message) + public SafeArrayTypeMismatchException(string message) : base(message) { HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; } - public SafeArrayTypeMismatchException(String message, Exception inner) + public SafeArrayTypeMismatchException(string message, Exception inner) : base(message, inner) { HResult = HResults.COR_E_SAFEARRAYTYPEMISMATCH; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs index a8bfbdcaea76..54107803bd82 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/SafeHandle.cs @@ -186,7 +186,7 @@ protected void SetHandle(IntPtr handle) // compatibility to support the handle properties returning IntPtrs on // many of our Framework classes. // Note that this method is dangerous for two reasons: - // 1) If the handle has been marked invalid with SetHandleasInvalid, + // 1) If the handle has been marked invalid with SetHandleAsInvalid, // DangerousGetHandle will still return the original handle value. // 2) The handle returned may be recycled at any point. At best this means // the handle might stop working suddenly. At worst, if the handle or diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnknownWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnknownWrapper.cs index de06cbf1a8ec..4f5a6b3bcd15 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnknownWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnknownWrapper.cs @@ -2,35 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_UNKNOWN. -** -** -=============================================================================*/ - - -using System; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_UNKNOWN. + /// public sealed class UnknownWrapper { - public UnknownWrapper(Object obj) + public UnknownWrapper(object obj) { m_WrappedObject = obj; } - public Object WrappedObject - { - get - { - return m_WrappedObject; - } - } + public object WrappedObject => m_WrappedObject; - private Object m_WrappedObject; + private object m_WrappedObject; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VariantWrapper.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VariantWrapper.cs index 455f0759fe1e..02669873162d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VariantWrapper.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VariantWrapper.cs @@ -2,35 +2,20 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================================= -** -** -** -** Purpose: Wrapper that is converted to a variant with VT_BYREF | VT_VARIANT. -** -** -=============================================================================*/ - - -using System; - namespace System.Runtime.InteropServices { + /// + /// Wrapper that is converted to a variant with VT_BYREF | VT_VARIANT. + /// public sealed class VariantWrapper { - public VariantWrapper(Object obj) + public VariantWrapper(object obj) { m_WrappedObject = obj; } - public Object WrappedObject - { - get - { - return m_WrappedObject; - } - } + public object WrappedObject => m_WrappedObject; - private Object m_WrappedObject; + private object m_WrappedObject; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs index d11b436b3c98..b8376e445fb6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/Attributes.cs @@ -2,8 +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; namespace System.Runtime.InteropServices.WindowsRuntime @@ -19,10 +17,7 @@ public DefaultInterfaceAttribute(Type defaultInterface) m_defaultInterface = defaultInterface; } - public Type DefaultInterface - { - get { return m_defaultInterface; } - } + public Type DefaultInterface => m_defaultInterface; } // WindowsRuntimeImport is a pseudo custom attribute which causes us to emit the tdWindowsRuntime bit @@ -32,11 +27,9 @@ public Type DefaultInterface // implement the CLR's support for WinRT, so this type is internal as marking tdWindowsRuntime should // generally be done via winmdexp for user code. [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Struct | AttributeTargets.Delegate, Inherited = false)] - // [System.Runtime.CompilerServices.FriendAccessAllowed] internal sealed class WindowsRuntimeImportAttribute : Attribute { - internal WindowsRuntimeImportAttribute() - { } + internal WindowsRuntimeImportAttribute() { } } // This attribute is applied to class interfaces in a generated projection assembly. It is used by Visual Studio @@ -54,30 +47,15 @@ public InterfaceImplementedInVersionAttribute(Type interfaceType, byte majorVers m_revisionVersion = revisionVersion; } - public Type InterfaceType - { - get { return m_interfaceType; } - } + public Type InterfaceType => m_interfaceType; - public byte MajorVersion - { - get { return m_majorVersion; } - } + public byte MajorVersion => m_majorVersion; - public byte MinorVersion - { - get { return m_minorVersion; } - } + public byte MinorVersion => m_minorVersion; - public byte BuildVersion - { - get { return m_buildVersion; } - } + public byte BuildVersion => m_buildVersion; - public byte RevisionVersion - { - get { return m_revisionVersion; } - } + public byte RevisionVersion => m_revisionVersion; private Type m_interfaceType; private byte m_majorVersion; @@ -100,8 +78,6 @@ public sealed class WriteOnlyArrayAttribute : Attribute public WriteOnlyArrayAttribute() { } } - - // This attribute is applied on the return value to specify the name of the return value. // In WindowsRuntime all parameters including return value need to have unique names. // This is essential in JS as one of the ways to get at the results of a method in JavaScript is via a Dictionary object keyed by parameter name. @@ -109,14 +85,12 @@ public WriteOnlyArrayAttribute() { } public sealed class ReturnValueNameAttribute : Attribute { private string m_Name; + public ReturnValueNameAttribute(string name) { m_Name = name; } - public string Name - { - get { return m_Name; } - } + public string Name => m_Name; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs index e34e4f62fa9e..ce4be3415e7c 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToCollectionAdapter.cs @@ -36,7 +36,7 @@ internal int Count() { IBindableVector _this = Unsafe.As(this); uint size = _this.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs index eb9fbc4f1c0a..f14aaa60e5d9 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/BindableVectorToListAdapter.cs @@ -58,7 +58,7 @@ internal int Add(object value) _this.Append(value); uint size = _this.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } @@ -105,7 +105,7 @@ internal int IndexOf(object item) if (!exists) return -1; - if (((uint)Int32.MaxValue) < index) + if (((uint)int.MaxValue) < index) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } @@ -133,7 +133,7 @@ internal void Remove(object item) if (exists) { - if (((uint)Int32.MaxValue) < index) + if (((uint)int.MaxValue) < index) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs index 44b42e4ca3b5..17bb6f43d47e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIPropertyValueImpl.cs @@ -14,12 +14,12 @@ namespace System.Runtime.InteropServices.WindowsRuntime internal class CLRIPropertyValueImpl : IPropertyValue { private PropertyType _type; - private Object _data; + private object _data; // Numeric scalar types which participate in coersion private static volatile Tuple[] s_numericScalarTypes; - internal CLRIPropertyValueImpl(PropertyType type, Object data) + internal CLRIPropertyValueImpl(PropertyType type, object data) { _type = type; _data = data; @@ -32,15 +32,15 @@ private static Tuple[] NumericScalarTypes if (s_numericScalarTypes == null) { Tuple[] numericScalarTypes = new Tuple[] { - new Tuple(typeof(Byte), PropertyType.UInt8), - new Tuple(typeof(Int16), PropertyType.Int16), - new Tuple(typeof(UInt16), PropertyType.UInt16), - new Tuple(typeof(Int32), PropertyType.Int32), - new Tuple(typeof(UInt32), PropertyType.UInt32), - new Tuple(typeof(Int64), PropertyType.Int64), - new Tuple(typeof(UInt64), PropertyType.UInt64), - new Tuple(typeof(Single), PropertyType.Single), - new Tuple(typeof(Double), PropertyType.Double) + new Tuple(typeof(byte), PropertyType.UInt8), + new Tuple(typeof(short), PropertyType.Int16), + new Tuple(typeof(ushort), PropertyType.UInt16), + new Tuple(typeof(int), PropertyType.Int32), + new Tuple(typeof(uint), PropertyType.UInt32), + new Tuple(typeof(long), PropertyType.Int64), + new Tuple(typeof(ulong), PropertyType.UInt64), + new Tuple(typeof(float), PropertyType.Single), + new Tuple(typeof(double), PropertyType.Double) }; s_numericScalarTypes = numericScalarTypes; @@ -75,49 +75,49 @@ public override string ToString() } } - public Byte GetUInt8() + public byte GetUInt8() { - return CoerceScalarValue(PropertyType.UInt8); + return CoerceScalarValue(PropertyType.UInt8); } - public Int16 GetInt16() + public short GetInt16() { - return CoerceScalarValue(PropertyType.Int16); + return CoerceScalarValue(PropertyType.Int16); } - public UInt16 GetUInt16() + public ushort GetUInt16() { - return CoerceScalarValue(PropertyType.UInt16); + return CoerceScalarValue(PropertyType.UInt16); } - public Int32 GetInt32() + public int GetInt32() { - return CoerceScalarValue(PropertyType.Int32); + return CoerceScalarValue(PropertyType.Int32); } - public UInt32 GetUInt32() + public uint GetUInt32() { - return CoerceScalarValue(PropertyType.UInt32); + return CoerceScalarValue(PropertyType.UInt32); } - public Int64 GetInt64() + public long GetInt64() { - return CoerceScalarValue(PropertyType.Int64); + return CoerceScalarValue(PropertyType.Int64); } - public UInt64 GetUInt64() + public ulong GetUInt64() { - return CoerceScalarValue(PropertyType.UInt64); + return CoerceScalarValue(PropertyType.UInt64); } - public Single GetSingle() + public float GetSingle() { - return CoerceScalarValue(PropertyType.Single); + return CoerceScalarValue(PropertyType.Single); } - public Double GetDouble() + public double GetDouble() { - return CoerceScalarValue(PropertyType.Double); + return CoerceScalarValue(PropertyType.Double); } public char GetChar16() @@ -127,16 +127,16 @@ public char GetChar16() return (char)_data; } - public Boolean GetBoolean() + public bool GetBoolean() { if (this.Type != PropertyType.Boolean) throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean"), HResults.TYPE_E_TYPEMISMATCH); return (bool)_data; } - public String GetString() + public string GetString() { - return CoerceScalarValue(PropertyType.String); + return CoerceScalarValue(PropertyType.String); } @@ -184,49 +184,49 @@ public Rect GetRect() return Unbox(IReferenceFactory.s_rectType); } - public Byte[] GetUInt8Array() + public byte[] GetUInt8Array() { - return CoerceArrayValue(PropertyType.UInt8Array); + return CoerceArrayValue(PropertyType.UInt8Array); } - public Int16[] GetInt16Array() + public short[] GetInt16Array() { - return CoerceArrayValue(PropertyType.Int16Array); + return CoerceArrayValue(PropertyType.Int16Array); } - public UInt16[] GetUInt16Array() + public ushort[] GetUInt16Array() { - return CoerceArrayValue(PropertyType.UInt16Array); + return CoerceArrayValue(PropertyType.UInt16Array); } - public Int32[] GetInt32Array() + public int[] GetInt32Array() { - return CoerceArrayValue(PropertyType.Int32Array); + return CoerceArrayValue(PropertyType.Int32Array); } - public UInt32[] GetUInt32Array() + public uint[] GetUInt32Array() { - return CoerceArrayValue(PropertyType.UInt32Array); + return CoerceArrayValue(PropertyType.UInt32Array); } - public Int64[] GetInt64Array() + public long[] GetInt64Array() { - return CoerceArrayValue(PropertyType.Int64Array); + return CoerceArrayValue(PropertyType.Int64Array); } - public UInt64[] GetUInt64Array() + public ulong[] GetUInt64Array() { - return CoerceArrayValue(PropertyType.UInt64Array); + return CoerceArrayValue(PropertyType.UInt64Array); } - public Single[] GetSingleArray() + public float[] GetSingleArray() { - return CoerceArrayValue(PropertyType.SingleArray); + return CoerceArrayValue(PropertyType.SingleArray); } - public Double[] GetDoubleArray() + public double[] GetDoubleArray() { - return CoerceArrayValue(PropertyType.DoubleArray); + return CoerceArrayValue(PropertyType.DoubleArray); } public char[] GetChar16Array() @@ -236,23 +236,23 @@ public char[] GetChar16Array() return (char[])_data; } - public Boolean[] GetBooleanArray() + public bool[] GetBooleanArray() { if (this.Type != PropertyType.BooleanArray) throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Boolean[]"), HResults.TYPE_E_TYPEMISMATCH); return (bool[])_data; } - public String[] GetStringArray() + public string[] GetStringArray() { - return CoerceArrayValue(PropertyType.StringArray); + return CoerceArrayValue(PropertyType.StringArray); } - public Object[] GetInspectableArray() + public object[] GetInspectableArray() { if (this.Type != PropertyType.InspectableArray) throw new InvalidCastException(SR.Format(SR.InvalidCast_WinRTIPropertyValueElement, this.Type, "Inspectable[]"), HResults.TYPE_E_TYPEMISMATCH); - return (Object[])_data; + return (object[])_data; } public Guid[] GetGuidArray() @@ -367,7 +367,7 @@ private static T CoerceScalarValue(PropertyType type, object value) { return (T)(object)Guid.Parse((string)value); } - else if (type == PropertyType.Guid && typeof(T) == typeof(String)) + else if (type == PropertyType.Guid && typeof(T) == typeof(string)) { return (T)(object)((Guid)value).ToString("D", System.Globalization.CultureInfo.InvariantCulture); } @@ -401,39 +401,39 @@ private static T CoerceScalarValue(PropertyType type, object value) IPropertyValue ipv = value as IPropertyValue; if (type == PropertyType.Inspectable && ipv != null) { - if (typeof(T) == typeof(Byte)) + if (typeof(T) == typeof(byte)) { return (T)(object)ipv.GetUInt8(); } - else if (typeof(T) == typeof(Int16)) + else if (typeof(T) == typeof(short)) { return (T)(object)ipv.GetInt16(); } - else if (typeof(T) == typeof(UInt16)) + else if (typeof(T) == typeof(ushort)) { return (T)(object)ipv.GetUInt16(); } - else if (typeof(T) == typeof(Int32)) + else if (typeof(T) == typeof(int)) { return (T)(object)ipv.GetUInt32(); } - else if (typeof(T) == typeof(UInt32)) + else if (typeof(T) == typeof(uint)) { return (T)(object)ipv.GetUInt32(); } - else if (typeof(T) == typeof(Int64)) + else if (typeof(T) == typeof(long)) { return (T)(object)ipv.GetInt64(); } - else if (typeof(T) == typeof(UInt64)) + else if (typeof(T) == typeof(ulong)) { return (T)(object)ipv.GetUInt64(); } - else if (typeof(T) == typeof(Single)) + else if (typeof(T) == typeof(float)) { return (T)(object)ipv.GetSingle(); } - else if (typeof(T) == typeof(Double)) + else if (typeof(T) == typeof(double)) { return (T)(object)ipv.GetDouble(); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs index 9e1a9f39e581..7b70047e6d5f 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/CLRIReferenceImpl.cs @@ -50,7 +50,7 @@ object IGetProxyTarget.GetTarget() // to the managed object, and free the native method. Also we want the return value boxed (aka normal value type boxing). // // This method is called by VM. - internal static Object UnboxHelper(Object wrapper) + internal static object UnboxHelper(object wrapper) { Debug.Assert(wrapper != null); IReference reference = (IReference)wrapper; @@ -105,10 +105,10 @@ IEnumerator IEnumerable.GetEnumerator() } // - // IList & ICollection methods. + // IList & ICollection methods. // This enables two-way data binding and index access in Jupiter // - Object IList.this[int index] + object IList.this[int index] { get { @@ -121,12 +121,12 @@ Object IList.this[int index] } } - int IList.Add(Object value) + int IList.Add(object value) { return _list.Add(value); } - bool IList.Contains(Object value) + bool IList.Contains(object value) { return _list.Contains(value); } @@ -152,17 +152,17 @@ bool IList.IsFixedSize } } - int IList.IndexOf(Object value) + int IList.IndexOf(object value) { return _list.IndexOf(value); } - void IList.Insert(int index, Object value) + void IList.Insert(int index, object value) { _list.Insert(index, value); } - void IList.Remove(Object value) + void IList.Remove(object value) { _list.Remove(value); } @@ -185,7 +185,7 @@ int ICollection.Count } } - Object ICollection.SyncRoot + object ICollection.SyncRoot { get { @@ -211,7 +211,7 @@ object IGetProxyTarget.GetTarget() // to the managed object, and free the native method. // // This method is called by VM. - internal static Object UnboxHelper(Object wrapper) + internal static object UnboxHelper(object wrapper) { Debug.Assert(wrapper != null); IReferenceArray reference = (IReferenceArray)wrapper; @@ -228,7 +228,7 @@ internal static class IReferenceFactory internal static readonly Type s_rectType = Type.GetType("Windows.Foundation.Rect, System.Runtime.WindowsRuntime"); internal static readonly Type s_sizeType = Type.GetType("Windows.Foundation.Size, System.Runtime.WindowsRuntime"); - internal static Object CreateIReference(Object obj) + internal static object CreateIReference(object obj) { Debug.Assert(obj != null, "Null should not be boxed."); @@ -239,8 +239,8 @@ internal static Object CreateIReference(Object obj) if (type == typeof(int)) return new CLRIReferenceImpl(PropertyType.Int32, (int)obj); - if (type == typeof(String)) - return new CLRIReferenceImpl(PropertyType.String, (String)obj); + if (type == typeof(string)) + return new CLRIReferenceImpl(PropertyType.String, (string)obj); if (type == typeof(byte)) return new CLRIReferenceImpl(PropertyType.UInt8, (byte)obj); if (type == typeof(short)) @@ -267,8 +267,8 @@ internal static Object CreateIReference(Object obj) return new CLRIReferenceImpl(PropertyType.DateTime, (DateTimeOffset)obj); if (type == typeof(TimeSpan)) return new CLRIReferenceImpl(PropertyType.TimeSpan, (TimeSpan)obj); - if (type == typeof(Object)) - return new CLRIReferenceImpl(PropertyType.Inspectable, (Object)obj); + if (type == typeof(object)) + return new CLRIReferenceImpl(PropertyType.Inspectable, (object)obj); if (type == typeof(RuntimeType)) { // If the type is System.RuntimeType, we want to use System.Type marshaler (it's parent of the type) return new CLRIReferenceImpl(PropertyType.Other, (Type)obj); @@ -296,14 +296,14 @@ internal static Object CreateIReference(Object obj) if (propType.HasValue) { Type specificType = typeof(CLRIReferenceImpl<>).MakeGenericType(type); - return Activator.CreateInstance(specificType, new Object[] { propType.Value, obj }); + return Activator.CreateInstance(specificType, new object[] { propType.Value, obj }); } Debug.Fail("We should not see non-WinRT type here"); return null; } - internal static Object CreateIReferenceArray(Array obj) + internal static object CreateIReferenceArray(Array obj) { Debug.Assert(obj != null); Debug.Assert(obj.GetType().IsArray); @@ -314,8 +314,8 @@ internal static Object CreateIReferenceArray(Array obj) if (type == typeof(int)) return new CLRIReferenceArrayImpl(PropertyType.Int32Array, (int[])obj); - if (type == typeof(String)) - return new CLRIReferenceArrayImpl(PropertyType.StringArray, (String[])obj); + if (type == typeof(string)) + return new CLRIReferenceArrayImpl(PropertyType.StringArray, (string[])obj); if (type == typeof(byte)) return new CLRIReferenceArrayImpl(PropertyType.UInt8Array, (byte[])obj); if (type == typeof(short)) @@ -367,7 +367,7 @@ internal static Object CreateIReferenceArray(Array obj) if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(System.Collections.Generic.KeyValuePair<,>)) { - Object[] objArray = new Object[obj.Length]; + object[] objArray = new object[obj.Length]; for (int i = 0; i < objArray.Length; i++) { objArray[i] = obj.GetValue(i); @@ -389,12 +389,12 @@ internal static Object CreateIReferenceArray(Array obj) { // All WinRT value type will be Property.Other Type specificType = typeof(CLRIReferenceArrayImpl<>).MakeGenericType(type); - return Activator.CreateInstance(specificType, new Object[] { propType.Value, obj }); + return Activator.CreateInstance(specificType, new object[] { propType.Value, obj }); } else { - // All WinRT reference type (including arbitary managed type) will be PropertyType.ObjectArray - return new CLRIReferenceArrayImpl(PropertyType.InspectableArray, (Object[])obj); + // All WinRT reference type (including arbitrary managed type) will be PropertyType.ObjectArray + return new CLRIReferenceArrayImpl(PropertyType.InspectableArray, (object[])obj); } } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs index e65025d839ab..a21d6a03b6ba 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs @@ -28,7 +28,7 @@ private class KeyValuePairComparator : IComparer> { private static readonly IComparer keyComparator = Comparer.Default; - public Int32 Compare(KeyValuePair x, KeyValuePair y) + public int Compare(KeyValuePair x, KeyValuePair y) { return keyComparator.Compare(x.Key, y.Key); } @@ -52,7 +52,7 @@ internal ConstantSplittableMap(IReadOnlyDictionary data) } - private ConstantSplittableMap(KeyValuePair[] items, Int32 firstItemIndex, Int32 lastItemIndex) + private ConstantSplittableMap(KeyValuePair[] items, int firstItemIndex, int lastItemIndex) { this.items = items; this.firstItemIndex = firstItemIndex; @@ -60,11 +60,11 @@ private ConstantSplittableMap(KeyValuePair[] items, Int32 firstIte } - private KeyValuePair[] CreateKeyValueArray(Int32 count, IEnumerator> data) + private KeyValuePair[] CreateKeyValueArray(int count, IEnumerator> data) { KeyValuePair[] kvArray = new KeyValuePair[count]; - Int32 i = 0; + int i = 0; while (data.MoveNext()) kvArray[i++] = data.Current; @@ -84,11 +84,11 @@ public int Count // [CLSCompliant(false)] - public UInt32 Size + public uint Size { get { - return (UInt32)(lastItemIndex - firstItemIndex + 1); + return (uint)(lastItemIndex - firstItemIndex + 1); } } @@ -140,7 +140,7 @@ public void Split(out IMapView firstPartition, out IMapView(items, firstItemIndex, pivot); secondPartition = new ConstantSplittableMap(items, pivot + 1, lastItemIndex); @@ -208,7 +208,7 @@ public IKeyValuePair Current } } - Object IEnumerator.Current + object IEnumerator.Current { get { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs index f2434ce91deb..2751209638b1 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryKeyCollection.cs @@ -106,7 +106,7 @@ public bool MoveNext() return enumeration.MoveNext(); } - Object IEnumerator.Current + object IEnumerator.Current { get { return ((IEnumerator)this).Current; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs index d441a2fbf84a..b1d9c8cb3a8b 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/DictionaryValueCollection.cs @@ -113,7 +113,7 @@ public bool MoveNext() return enumeration.MoveNext(); } - Object IEnumerator.Current + object IEnumerator.Current { get { return ((IEnumerator)this).Current; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs index 3f3d8a99d681..5299af3b93ec 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EnumeratorToIteratorAdapter.cs @@ -156,7 +156,7 @@ public int GetMany(T[] items) { string[] stringItems = items as string[]; - // Fill the rest of the array with String.Empty to avoid marshaling failure + // Fill the rest of the array with string.Empty to avoid marshaling failure for (int i = index; i < items.Length; ++i) stringItems[i] = string.Empty; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs index 1a210a05cb03..0fb88950391e 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/EventRegistrationTokenTable.cs @@ -92,24 +92,6 @@ private EventRegistrationToken AddEventHandlerNoLock(T handler) return token; } - // Get the delegate associated with an event registration token if it exists. Additionally, - // remove the registration from the table at the same time. If the token is not registered, - // Extract returns null and does not modify the table. - // [System.Runtime.CompilerServices.FriendAccessAllowed] - internal T ExtractHandler(EventRegistrationToken token) - { - T handler = null; - lock (m_tokens) - { - if (m_tokens.TryGetValue(token, out handler)) - { - RemoveEventHandlerNoLock(token); - } - } - - return handler; - } - // Generate a token that may be used for a particular event handler. We will frequently be called // upon to look up a token value given only a delegate to start from. Therefore, we want to make // an initial token value that is easily determined using only the delegate instance itself. Although @@ -169,6 +151,23 @@ private static EventRegistrationToken GetPreferredToken(T handler) return new EventRegistrationToken(tokenValue); } + // Remove the event handler from the table and + // Get the delegate associated with an event registration token if it exists + // If the event registration token is not registered, returns false + public bool RemoveEventHandler(EventRegistrationToken token, out T handler) + { + lock (m_tokens) + { + if (m_tokens.TryGetValue(token, out handler)) + { + RemoveEventHandlerNoLock(token); + return true; + } + } + + return false; + } + public void RemoveEventHandler(EventRegistrationToken token) { // The 0 token is assigned to null handlers, so there's nothing to do diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs index f4f6ab9d4bed..674bb51d23f6 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IMapViewToIReadOnlyDictionaryAdapter.cs @@ -199,7 +199,7 @@ public bool MoveNext() return enumeration.MoveNext(); } - Object IEnumerator.Current + object IEnumerator.Current { get { return ((IEnumerator)this).Current; } } @@ -298,7 +298,7 @@ public bool MoveNext() return enumeration.MoveNext(); } - Object IEnumerator.Current + object IEnumerator.Current { get { return ((IEnumerator)this).Current; } } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs index 8a67119496f2..aefa7be4d1db 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IPropertyValue.cs @@ -23,29 +23,29 @@ bool IsNumericScalar get; } - Byte GetUInt8(); + byte GetUInt8(); - Int16 GetInt16(); + short GetInt16(); - UInt16 GetUInt16(); + ushort GetUInt16(); - Int32 GetInt32(); + int GetInt32(); - UInt32 GetUInt32(); + uint GetUInt32(); - Int64 GetInt64(); + long GetInt64(); - UInt64 GetUInt64(); + ulong GetUInt64(); - Single GetSingle(); + float GetSingle(); - Double GetDouble(); + double GetDouble(); char GetChar16(); - Boolean GetBoolean(); + bool GetBoolean(); - String GetString(); + string GetString(); Guid GetGuid(); @@ -59,29 +59,29 @@ bool IsNumericScalar Rect GetRect(); - Byte[] GetUInt8Array(); + byte[] GetUInt8Array(); - Int16[] GetInt16Array(); + short[] GetInt16Array(); - UInt16[] GetUInt16Array(); + ushort[] GetUInt16Array(); - Int32[] GetInt32Array(); + int[] GetInt32Array(); - UInt32[] GetUInt32Array(); + uint[] GetUInt32Array(); - Int64[] GetInt64Array(); + long[] GetInt64Array(); - UInt64[] GetUInt64Array(); + ulong[] GetUInt64Array(); - Single[] GetSingleArray(); + float[] GetSingleArray(); - Double[] GetDoubleArray(); + double[] GetDoubleArray(); char[] GetChar16Array(); - Boolean[] GetBooleanArray(); + bool[] GetBooleanArray(); - String[] GetStringArray(); + string[] GetStringArray(); object[] GetInspectableArray(); diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs index 3f1c02871d58..6269f2e20010 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IReadOnlyListToIVectorViewAdapter.cs @@ -110,7 +110,7 @@ internal uint GetMany(uint startIndex, T[] items) { string[] stringItems = items as string[]; - // Fill in the rest of the array with String.Empty to avoid marshaling failure + // Fill in the rest of the array with string.Empty to avoid marshaling failure for (uint i = itemCount; i < items.Length; ++i) stringItems[i] = string.Empty; } @@ -122,9 +122,9 @@ internal uint GetMany(uint startIndex, T[] items) private static void EnsureIndexInt32(uint index, int listCapacity) { - // We use '<=' and not '<' because Int32.MaxValue == index would imply - // that Size > Int32.MaxValue: - if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) + // We use '<=' and not '<' because int.MaxValue == index would imply + // that Size > int.MaxValue: + if (((uint)int.MaxValue) <= index || index >= (uint)listCapacity) { Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.HResult = HResults.E_BOUNDS; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs index ca19d94c76cc..03faef0adbd3 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/IRestrictedErrorInfo.cs @@ -8,7 +8,6 @@ namespace System.Runtime.InteropServices.WindowsRuntime { - // [System.Runtime.CompilerServices.FriendAccessAllowed] [ComImport] [Guid("82BA7092-4C88-427D-A7BC-16DD93FEB67E")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs index d7527c1ba9e3..08eb22b8e9de 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorAdapter.cs @@ -40,7 +40,7 @@ internal object GetAt(uint index) try { - return _this[(Int32)index]; + return _this[(int)index]; } catch (ArgumentOutOfRangeException ex) { @@ -123,7 +123,7 @@ internal void RemoveAt(uint index) try { - _this.RemoveAt((Int32)index); + _this.RemoveAt((int)index); } catch (ArgumentOutOfRangeException ex) { @@ -166,9 +166,9 @@ internal void Clear() private static void EnsureIndexInt32(uint index, int listCapacity) { - // We use '<=' and not '<' becasue Int32.MaxValue == index would imply - // that Size > Int32.MaxValue: - if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) + // We use '<=' and not '<' becasue int.MaxValue == index would imply + // that Size > int.MaxValue: + if (((uint)int.MaxValue) <= index || index >= (uint)listCapacity) { Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.HResult = HResults.E_BOUNDS; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs index b453d90ba129..98beaf22f238 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToBindableVectorViewAdapter.cs @@ -32,9 +32,9 @@ internal ListToBindableVectorViewAdapter(IList list) private static void EnsureIndexInt32(uint index, int listCapacity) { - // We use '<=' and not '<' becasue Int32.MaxValue == index would imply - // that Size > Int32.MaxValue: - if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) + // We use '<=' and not '<' becasue int.MaxValue == index would imply + // that Size > int.MaxValue: + if (((uint)int.MaxValue) <= index || index >= (uint)listCapacity) { Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.HResult = HResults.E_BOUNDS; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs index 2b146b7a4f42..b6260dc52eee 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ListToVectorAdapter.cs @@ -40,7 +40,7 @@ internal T GetAt(uint index) try { - return _this[(Int32)index]; + return _this[(int)index]; } catch (ArgumentOutOfRangeException ex) { @@ -132,7 +132,7 @@ internal void RemoveAt(uint index) try { - _this.RemoveAt((Int32)index); + _this.RemoveAt((int)index); } catch (ArgumentOutOfRangeException ex) { @@ -197,9 +197,9 @@ internal void ReplaceAll(T[] items) private static void EnsureIndexInt32(uint index, int listCapacity) { - // We use '<=' and not '<' becasue Int32.MaxValue == index would imply - // that Size > Int32.MaxValue: - if (((uint)Int32.MaxValue) <= index || index >= (uint)listCapacity) + // We use '<=' and not '<' becasue int.MaxValue == index would imply + // that Size > int.MaxValue: + if (((uint)int.MaxValue) <= index || index >= (uint)listCapacity) { Exception e = new ArgumentOutOfRangeException(nameof(index), SR.ArgumentOutOfRange_IndexLargerThanMaxValue); e.HResult = HResults.E_BOUNDS; @@ -233,7 +233,7 @@ private static uint GetManyHelper(IList sourceList, uint startIndex, T[] i { string[] stringItems = items as string[]; - // Fill in rest of the array with String.Empty to avoid marshaling failure + // Fill in rest of the array with string.Empty to avoid marshaling failure for (uint i = itemCount; i < items.Length; ++i) stringItems[i] = string.Empty; } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs index c64703b80af7..2ec85bb3f0a7 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapToCollectionAdapter.cs @@ -43,7 +43,7 @@ internal int Count() { uint size = _this_map.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingDictionaryTooLarge); } @@ -55,7 +55,7 @@ internal int Count() IVector> _this_vector = Unsafe.As>>(this); uint size = _this_vector.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } @@ -171,7 +171,7 @@ internal bool Remove(KeyValuePair item) if (!exists) return false; - if (((uint)Int32.MaxValue) < index) + if (((uint)int.MaxValue) < index) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs index e1323dade408..880bffb623cd 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/MapViewToReadOnlyCollectionAdapter.cs @@ -43,7 +43,7 @@ internal int Count() { uint size = _this_map.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingDictionaryTooLarge); } @@ -55,7 +55,7 @@ internal int Count() IVectorView> _this_vector = Unsafe.As>>(this); uint size = _this_vector.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs index 35b77b26d344..bda5168814a4 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToCollectionAdapter.cs @@ -35,7 +35,7 @@ internal int Count() { IVector _this = Unsafe.As>(this); uint size = _this.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } @@ -107,7 +107,7 @@ internal bool Remove(T item) if (!exists) return false; - if (((uint)Int32.MaxValue) < index) + if (((uint)int.MaxValue) < index) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs index ab3cb9c6351e..ee2c7df6701a 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorToListAdapter.cs @@ -61,7 +61,7 @@ internal int IndexOf(T item) if (!exists) return -1; - if (((uint)Int32.MaxValue) < index) + if (((uint)int.MaxValue) < index) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } @@ -109,7 +109,7 @@ internal static T GetAt(IVector _this, uint index) } } - private static void SetAt(IVector _this, UInt32 index, T value) + private static void SetAt(IVector _this, uint index, T value) { try { diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs index 58ec1dda929a..bc87efa6dcb2 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/VectorViewToReadOnlyCollectionAdapter.cs @@ -35,7 +35,7 @@ internal int Count() { IVectorView _this = Unsafe.As>(this); uint size = _this.Size; - if (((uint)Int32.MaxValue) < size) + if (((uint)int.MaxValue) < size) { throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge); } diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs index e0633c068c2d..ad04b25dd27d 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/WindowsRuntimeMarshal.cs @@ -133,7 +133,7 @@ internal EventRegistrationTokenList(EventRegistrationToken token) } // Push a new token into this list - // Returns true if you need to copy back this list into the dictionary (so that you + // Returns true if you need to copy back this list into the dictionary (so that you // don't lose change outside the dictionary). false otherwise. public bool Push(EventRegistrationToken token) { @@ -186,25 +186,25 @@ internal static class ManagedEventRegistrationImpl // // The full structure of this table is: // object the event is being registered on -> - // Table [RemoveMethod] -> + // Table [RemoveMethod] -> // Table [Handler] -> Token // // Note: There are a couple of optimizations I didn't do here because they don't make sense for managed events: // 1. Flatten the event cache (see EventCacheKey in native WinRT event implementation below) // - // This is because managed events use ConditionalWeakTable to hold Objects->(Event->(Handler->Tokens)), - // and when object goes away everything else will be nicely cleaned up. If I flatten it like native WinRT events, - // I'll have to use Dictionary (as ConditionalWeakTable won't work - nobody will hold the new key alive anymore) - // instead, and that means I'll have to add more code from native WinRT events into managed WinRT event to support - // self-cleanup in the finalization, as well as reader/writer lock to protect against race conditions in the finalization, + // This is because managed events use ConditionalWeakTable to hold Objects->(Event->(Handler->Tokens)), + // and when object goes away everything else will be nicely cleaned up. If I flatten it like native WinRT events, + // I'll have to use Dictionary (as ConditionalWeakTable won't work - nobody will hold the new key alive anymore) + // instead, and that means I'll have to add more code from native WinRT events into managed WinRT event to support + // self-cleanup in the finalization, as well as reader/writer lock to protect against race conditions in the finalization, // which adds a lot more complexity and doesn't really worth it. - // - // 2. Use conditionalWeakTable to hold Handler->Tokens. - // - // The reason is very simple - managed object use dictionary (see EventRegistrationTokenTable) to hold delegates alive. - // If the delegates aren't alive, it means either they have been unsubscribed, or the object itself is gone, + // + // 2. Use conditionalWeakTable to hold Handler->Tokens. + // + // The reason is very simple - managed object use dictionary (see EventRegistrationTokenTable) to hold delegates alive. + // If the delegates aren't alive, it means either they have been unsubscribed, or the object itself is gone, // and in either case, they've been already taken care of. - // + // internal volatile static ConditionalWeakTable>> s_eventRegistrations = new ConditionalWeakTable>>(); @@ -290,12 +290,12 @@ internal static void RemoveEventHandler(Action remove // Select a registration token to unregister // We don't care which one but I'm returning the last registered token to be consistent - // with native event registration implementation + // with native event registration implementation bool moreItems = tokens.Pop(out token); if (!moreItems) { // Remove it from cache if this list become empty - // This must be done because EventRegistrationTokenList now becomes invalid + // This must be done because EventRegistrationTokenList now becomes invalid // (mostly because there is no safe default value for EventRegistrationToken to express 'no token') // NOTE: We should try to remove registrationTokens itself from cache if it is empty, otherwise // we could run into a race condition where one thread removes it from cache and another thread adds @@ -363,7 +363,7 @@ public override string ToString() public bool Equals(EventCacheKey other) { - return (Object.Equals(target, other.target) && Object.Equals(method, other.method)); + return (object.Equals(target, other.target) && object.Equals(method, other.method)); } public int GetHashCode(EventCacheKey key) @@ -374,11 +374,11 @@ public int GetHashCode(EventCacheKey key) // // EventRegistrationTokenListWithCount - // + // // A list of EventRegistrationTokens that maintains a count // // The reason this needs to be a separate class is that we need a finalizer for this class - // If the delegate is collected, it will take this list away with it (due to dependent handles), + // If the delegate is collected, it will take this list away with it (due to dependent handles), // and we need to remove the PerInstancEntry from cache // See ~EventRegistrationTokenListWithCount for more details // @@ -495,7 +495,7 @@ internal struct EventCacheEntry // // The full structure of this table is: // EventCacheKey (instanceKey, eventMethod) -> EventCacheEntry (Handler->tokens) - // + // // A InstanceKey is the IUnknown * or static type instance // // Couple of things to note: @@ -503,12 +503,12 @@ internal struct EventCacheEntry // based on the same COM object. For example: // m_canvas.GetAt(0).Event += Func; // m_canvas.GetAt(0).Event -= Func; // GetAt(0) might create a new RCW - // + // // 2. Handler->Token is a ConditionalWeakTable because we don't want to keep the delegate alive - // and we want EventRegistrationTokenListWithCount to be finalized after the delegate is no longer alive + // and we want EventRegistrationTokenListWithCount to be finalized after the delegate is no longer alive // 3. It is possible another COM object is created at the same address - // before the entry in cache is destroyed. More specifically, - // a. The same delegate is being unsubscribed. In this case we'll give them a + // before the entry in cache is destroyed. More specifically, + // a. The same delegate is being unsubscribed. In this case we'll give them a // stale token - unlikely to be a problem // b. The same delegate is subscribed then unsubscribed. We need to make sure give // them the latest token in this case. This is guaranteed by always giving the last token and always use equality to @@ -535,7 +535,7 @@ private static object FindEquivalentKeyUnsafe(ConditionalWeakTable item in registrationTable) { - if (Object.Equals(item.Key, handler)) + if (object.Equals(item.Key, handler)) { tokens = item.Value; return item.Key; @@ -553,7 +553,7 @@ internal static void AddEventHandler(Func addMetho object instanceKey = GetInstanceKey(removeMethod); // Call addMethod outside of RW lock - // At this point we don't need to worry about race conditions and we can avoid deadlocks + // At this point we don't need to worry about race conditions and we can avoid deadlocks // if addMethod waits on finalizer thread // If we later throw we need to remove the method EventRegistrationToken token = addMethod(handler); @@ -579,7 +579,7 @@ internal static void AddEventHandler(Func addMetho // // We need to find the key that equals to this handler // Suppose we have 3 handlers A, B, C that are equal (refer to the same object and method), - // the first handler (let's say A) will be used as the key and holds all the tokens. + // the first handler (let's say A) will be used as the key and holds all the tokens. // We don't need to hold onto B and C, because the COM object itself will keep them alive, // and they won't die anyway unless the COM object dies or they get unsubscribed. // It may appear that it is fine to hold A, B, C, and add them and their corresponding tokens @@ -711,7 +711,7 @@ internal static void RemoveEventHandler(Action remove // (but with the same object/method), so we need to find the first delegate that matches // and unsubscribe it // It actually doesn't matter which delegate - as long as it matches - // Note that inside TryGetValueWithValueEquality we assumes that any delegate + // Note that inside TryGetValueWithValueEquality we assumes that any delegate // with the same value equality would have the same hash code object key = FindEquivalentKeyUnsafe(registrationTokens, handler, out tokens); Debug.Assert((key != null && tokens != null) || (key == null && tokens == null), @@ -736,7 +736,7 @@ internal static void RemoveEventHandler(Action remove { // Remove it from (handler)->(tokens) // NOTE: We should not check whether registrationTokens has 0 entries and remove it from the cache - // (just like managed event implementation), because this might have raced with the finalizer of + // (just like managed event implementation), because this might have raced with the finalizer of // EventRegistrationTokenList registrationTokens.Remove(key); } @@ -750,7 +750,7 @@ internal static void RemoveEventHandler(Action remove } // Call removeMethod outside of RW lock - // At this point we don't need to worry about race conditions and we can avoid deadlocks + // At this point we don't need to worry about race conditions and we can avoid deadlocks // if removeMethod waits on finalizer thread removeMethod(token); } @@ -814,13 +814,13 @@ internal class ReaderWriterLockTimedOutException : ApplicationException /// /// /// A reader-writer lock implementation that is intended to be simple, yet very - /// efficient. In particular only 1 interlocked operation is taken for any lock + /// efficient. In particular only 1 interlocked operation is taken for any lock /// operation (we use spin locks to achieve this). The spin lock is never held /// for more than a few instructions (in particular, we never call event APIs - /// or in fact any non-trivial API while holding the spin lock). - /// - /// Currently this ReaderWriterLock does not support recursion, however it is - /// not hard to add + /// or in fact any non-trivial API while holding the spin lock). + /// + /// Currently this ReaderWriterLock does not support recursion, however it is + /// not hard to add /// internal class MyReaderWriterLock { @@ -830,20 +830,20 @@ internal class MyReaderWriterLock private int myLock; // Who owns the lock owners > 0 => readers - // owners = -1 means there is one writer. Owners must be >= -1. + // owners = -1 means there is one writer. Owners must be >= -1. private int owners; - // These variables allow use to avoid Setting events (which is expensive) if we don't have to. - private uint numWriteWaiters; // maximum number of threads that can be doing a WaitOne on the writeEvent + // These variables allow use to avoid Setting events (which is expensive) if we don't have to. + private uint numWriteWaiters; // maximum number of threads that can be doing a WaitOne on the writeEvent private uint numReadWaiters; // maximum number of threads that can be doing a WaitOne on the readEvent - // conditions we wait on. - private EventWaitHandle writeEvent; // threads waiting to aquire a write lock go here. - private EventWaitHandle readEvent; // threads waiting to aquire a read lock go here (will be released in bulk) + // conditions we wait on. + private EventWaitHandle writeEvent; // threads waiting to acquire a write lock go here. + private EventWaitHandle readEvent; // threads waiting to acquire a read lock go here (will be released in bulk) internal MyReaderWriterLock() { - // All state can start out zeroed. + // All state can start out zeroed. } internal void AcquireReaderLock(int millisecondsTimeout) @@ -852,7 +852,7 @@ internal void AcquireReaderLock(int millisecondsTimeout) for (;;) { // We can enter a read lock if there are only read-locks have been given out - // and a writer is not trying to get in. + // and a writer is not trying to get in. if (owners >= 0 && numWriteWaiters == 0) { // Good case, there is no contention, we are basically done @@ -860,11 +860,11 @@ internal void AcquireReaderLock(int millisecondsTimeout) break; } - // Drat, we need to wait. Mark that we have waiters and wait. - if (readEvent == null) // Create the needed event + // Drat, we need to wait. Mark that we have waiters and wait. + if (readEvent == null) // Create the needed event { LazyCreateEvent(ref readEvent, false); - continue; // since we left the lock, start over. + continue; // since we left the lock, start over. } WaitOnEvent(readEvent, ref numReadWaiters, millisecondsTimeout); @@ -888,7 +888,7 @@ internal void AcquireWriterLock(int millisecondsTimeout) if (writeEvent == null) // create the needed event. { LazyCreateEvent(ref writeEvent, true); - continue; // since we left the lock, start over. + continue; // since we left the lock, start over. } WaitOnEvent(writeEvent, ref numWriteWaiters, millisecondsTimeout); @@ -916,7 +916,7 @@ internal void ReleaseWriterLock() /// A routine for lazily creating a event outside the lock (so if errors /// happen they are outside the lock and that we don't do much work /// while holding a spin lock). If all goes well, reenter the lock and - /// set 'waitEvent' + /// set 'waitEvent' /// private void LazyCreateEvent(ref EventWaitHandle waitEvent, bool makeAutoResetEvent) { @@ -930,12 +930,12 @@ private void LazyCreateEvent(ref EventWaitHandle waitEvent, bool makeAutoResetEv else newEvent = new ManualResetEvent(false); EnterMyLock(); - if (waitEvent == null) // maybe someone snuck in. + if (waitEvent == null) // maybe someone snuck in. waitEvent = newEvent; } /// - /// Waits on 'waitEvent' with a timeout of 'millisceondsTimeout. + /// Waits on 'waitEvent' with a timeout of 'millisceondsTimeout. /// Before the wait 'numWaiters' is incremented and is restored before leaving this routine. /// private void WaitOnEvent(EventWaitHandle waitEvent, ref uint numWaiters, int millisecondsTimeout) @@ -946,7 +946,7 @@ private void WaitOnEvent(EventWaitHandle waitEvent, ref uint numWaiters, int mil numWaiters++; bool waitSuccessful = false; - ExitMyLock(); // Do the wait outside of any lock + ExitMyLock(); // Do the wait outside of any lock try { if (!waitEvent.WaitOne(millisecondsTimeout, false)) @@ -958,13 +958,13 @@ private void WaitOnEvent(EventWaitHandle waitEvent, ref uint numWaiters, int mil { EnterMyLock(); --numWaiters; - if (!waitSuccessful) // We are going to throw for some reason. Exit myLock. + if (!waitSuccessful) // We are going to throw for some reason. Exit myLock. ExitMyLock(); } } /// - /// Determines the appropriate events to set, leaves the locks, and sets the events. + /// Determines the appropriate events to set, leaves the locks, and sets the events. /// private void ExitAndWakeUpAppropriateWaiters() { @@ -973,12 +973,12 @@ private void ExitAndWakeUpAppropriateWaiters() if (owners == 0 && numWriteWaiters > 0) { ExitMyLock(); // Exit before signaling to improve efficiency (wakee will need the lock) - writeEvent.Set(); // release one writer. + writeEvent.Set(); // release one writer. } else if (owners >= 0 && numReadWaiters != 0) { ExitMyLock(); // Exit before signaling to improve efficiency (wakee will need the lock) - readEvent.Set(); // release all readers. + readEvent.Set(); // release all readers. } else ExitMyLock(); @@ -995,9 +995,9 @@ private void EnterMyLockSpin() for (int i = 0; ; i++) { if (i < 3 && Environment.ProcessorCount > 1) - Thread.SpinWait(20); // Wait a few dozen instructions to let another processor release lock. + Thread.SpinWait(20); // Wait a few dozen instructions to let another processor release lock. else - Thread.Sleep(0); // Give up my quantum. + Thread.Sleep(0); // Give up my quantum. if (Interlocked.CompareExchange(ref myLock, 1, 0) == 0) return; @@ -1050,7 +1050,7 @@ internal static unsafe string HStringToString(IntPtr hstring) { uint length; char* rawBuffer = UnsafeNativeMethods.WindowsGetStringRawBuffer(hstring, &length); - return new String(rawBuffer, 0, checked((int)length)); + return new string(rawBuffer, 0, checked((int)length)); } } @@ -1122,7 +1122,6 @@ private static void RoReportUnhandledError(IRestrictedErrorInfo error) /// for the application to be invoked to process the error. /// /// true if the error was reported, false if not (ie running on Win8) - // [FriendAccessAllowed] internal static bool ReportUnhandledError(Exception e) { // Only report to the WinRT global exception handler in modern apps @@ -1210,8 +1209,8 @@ internal static ManagedActivationFactory GetManagedActivationFactory(Type type) // // Get activation factory object for a specified WinRT type // If the WinRT type is a native type, we'll always create a unique RCW for it, - // This is necessary because WinRT factories are often implemented as a singleton, - // and getting back a RCW for such WinRT factory would usually get back a RCW from + // This is necessary because WinRT factories are often implemented as a singleton, + // and getting back a RCW for such WinRT factory would usually get back a RCW from // another apartment, even if the interface pointe returned from GetActivationFactory // is a raw pointer. As a result, user would randomly get back RCWs for activation // factories from other apartments and make transiton to those apartments and cause @@ -1230,7 +1229,7 @@ public static IActivationFactory GetActivationFactory(Type type) { #if FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION return GetManagedActivationFactory(type); -#else +#else // Managed factories are not supported so as to minimize public surface (and test effort) throw new NotSupportedException(); #endif @@ -1239,7 +1238,7 @@ public static IActivationFactory GetActivationFactory(Type type) // HSTRING marshaling methods: - public static IntPtr StringToHString(String s) + public static IntPtr StringToHString(string s) { if (!Environment.IsWinRTSupported) throw new PlatformNotSupportedException(SR.PlatformNotSupported_WinRT); diff --git a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs index cf5fc3cb1186..addd8f851676 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/Loader/AssemblyLoadContext.cs @@ -69,8 +69,8 @@ public static Assembly[] GetLoadedAssemblies() return AppDomain.CurrentDomain.GetAssemblies(false); } - // These are helpers that can be used by AssemblyLoadContext derivations. - // They are used to load assemblies in DefaultContext. + // These methods load assemblies into the current AssemblyLoadContext + // They may be used in the implementation of an AssemblyLoadContext derivation public Assembly LoadFromAssemblyPath(string assemblyPath) { if (assemblyPath == null) @@ -295,7 +295,7 @@ protected IntPtr LoadUnmanagedDllFromPath(string unmanagedDllPath) // Custom AssemblyLoadContext implementations can override this // method to perform the load of unmanaged native dll // This function needs to return the HMODULE of the dll it loads - protected virtual IntPtr LoadUnmanagedDll(String unmanagedDllName) + protected virtual IntPtr LoadUnmanagedDll(string unmanagedDllName) { //defer to default coreclr policy of loading unmanaged dll return IntPtr.Zero; @@ -303,7 +303,7 @@ protected virtual IntPtr LoadUnmanagedDll(String unmanagedDllName) // This method is invoked by the VM when using the host-provided assembly load context // implementation. - private static IntPtr ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) + private static IntPtr ResolveUnmanagedDll(string unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) { AssemblyLoadContext context = (AssemblyLoadContext)(GCHandle.FromIntPtr(gchManagedAssemblyLoadContext).Target); return context.LoadUnmanagedDll(unmanagedDllName); @@ -412,7 +412,7 @@ private void OnAppContextUnloading(object sender, EventArgs e) private static volatile AssemblyLoadContext s_DefaultAssemblyLoadContext; // Synchronization primitive for controlling initialization of Default load context - private static readonly object s_initLock = new Object(); + private static readonly object s_initLock = new object(); // Occurs when an Assembly is loaded public static event AssemblyLoadEventHandler AssemblyLoad diff --git a/src/System.Private.CoreLib/src/System/Runtime/Serialization/FormatterServices.cs b/src/System.Private.CoreLib/src/System/Runtime/Serialization/FormatterServices.cs index 1377350b80c5..7642f1eb9efe 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/Serialization/FormatterServices.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/Serialization/FormatterServices.cs @@ -38,7 +38,7 @@ internal static class FormatterServices // will not create an unitialized string because it is non-sensical to create an empty // instance of an immutable type. // - public static Object GetUninitializedObject(Type type) + public static object GetUninitializedObject(Type type) { if ((object)type == null) { @@ -54,7 +54,7 @@ public static Object GetUninitializedObject(Type type) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern Object nativeGetUninitializedObject(RuntimeType type); + private static extern object nativeGetUninitializedObject(RuntimeType type); } } diff --git a/src/System.Private.CoreLib/src/System/RuntimeHandles.cs b/src/System.Private.CoreLib/src/System/RuntimeHandles.cs index dc659e3dee89..f07ce90e5200 100644 --- a/src/System.Private.CoreLib/src/System/RuntimeHandles.cs +++ b/src/System.Private.CoreLib/src/System/RuntimeHandles.cs @@ -45,7 +45,7 @@ internal RuntimeType GetTypeChecked() } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern bool IsInstanceOfType(RuntimeType type, Object o); + internal static extern bool IsInstanceOfType(RuntimeType type, object o); internal static unsafe Type GetTypeHelper(Type typeStart, Type[] genericArgs, IntPtr pModifiers, int cModifiers) { @@ -219,16 +219,16 @@ internal static IntPtr[] CopyRuntimeTypeHandles(Type[] inHandles, out int length } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object CreateInstance(RuntimeType type, bool publicOnly, bool wrapExceptions, ref bool canBeCached, ref RuntimeMethodHandleInternal ctor); + internal static extern object CreateInstance(RuntimeType type, bool publicOnly, bool wrapExceptions, ref bool canBeCached, ref RuntimeMethodHandleInternal ctor); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor); + internal static extern object CreateCaInstance(RuntimeType type, IRuntimeMethodInfo ctor); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object Allocate(RuntimeType type); + internal static extern object Allocate(RuntimeType type); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object CreateInstanceForAnotherGenericParameter(RuntimeType type, RuntimeType genericParameter); + internal static extern object CreateInstanceForAnotherGenericParameter(RuntimeType type, RuntimeType genericParameter); internal RuntimeType GetRuntimeType() { @@ -448,7 +448,7 @@ internal static RuntimeType GetTypeByName(string name, bool throwOnError, bool i RuntimeType type = null; - Object keepAlive = null; + object keepAlive = null; GetTypeByName(name, throwOnError, ignoreCase, reflectionOnly, JitHelpers.GetStackCrawlMarkHandle(ref stackMark), pPrivHostBinder, @@ -1121,7 +1121,7 @@ public unsafe bool Equals(RuntimeFieldHandle handle) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern String GetName(RtFieldInfo field); + internal static extern string GetName(RtFieldInfo field); [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern unsafe void* _GetUtf8Name(RuntimeFieldHandleInternal field); @@ -1148,16 +1148,16 @@ internal static RuntimeType GetApproxDeclaringType(IRuntimeFieldInfo field) internal static extern int GetToken(RtFieldInfo field); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object GetValue(RtFieldInfo field, Object instance, RuntimeType fieldType, RuntimeType declaringType, ref bool domainInitialized); + internal static extern object GetValue(RtFieldInfo field, object instance, RuntimeType fieldType, RuntimeType declaringType, ref bool domainInitialized); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern Object GetValueDirect(RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, RuntimeType contextType); + internal static extern object GetValueDirect(RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, RuntimeType contextType); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void SetValue(RtFieldInfo field, Object obj, Object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized); + internal static extern void SetValue(RtFieldInfo field, object obj, object value, RuntimeType fieldType, FieldAttributes fieldAttr, RuntimeType declaringType, ref bool domainInitialized); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void SetValueDirect(RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, Object value, RuntimeType contextType); + internal static extern void SetValueDirect(RtFieldInfo field, RuntimeType fieldType, void* pTypedRef, object value, RuntimeType contextType); [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern RuntimeFieldHandleInternal GetStaticFieldForGenericType(RuntimeFieldHandleInternal field, RuntimeType declaringType); @@ -1528,7 +1528,7 @@ internal struct CORINFO_EH_CLAUSE internal abstract unsafe void GetEHInfo(int EHNumber, void* exception); internal abstract unsafe byte[] GetRawEHInfo(); // token resolution - internal abstract String GetStringLiteral(int token); + internal abstract string GetStringLiteral(int token); internal abstract void ResolveToken(int token, out IntPtr typeHandle, out IntPtr methodHandle, out IntPtr fieldHandle); internal abstract byte[] ResolveSignature(int token, int fromMethod); // diff --git a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs index a9688fe8a862..40a37c19c1be 100644 --- a/src/System.Private.CoreLib/src/System/String.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/String.CoreCLR.cs @@ -29,7 +29,7 @@ public partial class String // We need to call the String constructor so that the compiler doesn't mark this as a literal. // Marking this as a literal would mean that it doesn't show up as a field which we can access // from native. - public static readonly String Empty; + public static readonly string Empty; // Gets the character at a specified position. // @@ -54,7 +54,7 @@ public extern int Length } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern String FastAllocateString(int length); + internal static extern string FastAllocateString(int length); // Is this a string that can be compared quickly (that is it has only characters > 0x80 // and not a - or ' @@ -73,7 +73,7 @@ public extern int Length internal extern bool TryGetTrailByte(out byte data); #endif - public static String Intern(String str) + public static string Intern(string str) { if (str == null) { @@ -83,7 +83,7 @@ public static String Intern(String str) return Thread.GetDomain().GetOrInternString(str); } - public static String IsInterned(String str) + public static string IsInterned(string str) { if (str == null) { @@ -94,7 +94,7 @@ public static String IsInterned(String str) } // Copies the source String (byte buffer) to the destination IntPtr memory allocated with len bytes. - internal static unsafe void InternalCopy(String src, IntPtr dest, int len) + internal static unsafe void InternalCopy(string src, IntPtr dest, int len) { if (len == 0) return; diff --git a/src/System.Private.CoreLib/src/System/StubHelpers.cs b/src/System.Private.CoreLib/src/System/StubHelpers.cs index f64fcd4d633f..6d9e7a8cea1b 100644 --- a/src/System.Private.CoreLib/src/System/StubHelpers.cs +++ b/src/System.Private.CoreLib/src/System/StubHelpers.cs @@ -110,7 +110,7 @@ internal static unsafe string ConvertToManaged(IntPtr cstr) if (IntPtr.Zero == cstr) return null; else - return new String((sbyte*)cstr); + return new string((sbyte*)cstr); } internal static void ClearNative(IntPtr pNative) @@ -307,12 +307,12 @@ internal static unsafe string ConvertToManaged(IntPtr bstr) // In the empty string case, we need to use FastAllocateString rather than the // String .ctor, since newing up a 0 sized string will always return String.Emtpy. // When we marshal that out as a bstr, it can wind up getting modified which - // corrupts String.Empty. + // corrupts string.Empty. ret = string.FastAllocateString(0); } else { - ret = new String((char*)bstr, 0, (int)(length / 2)); + ret = new string((char*)bstr, 0, (int)(length / 2)); } if ((length & 1) == 1) @@ -387,7 +387,7 @@ internal static unsafe string ConvertToManaged(IntPtr pNative, int cch) return null; } - return new String((sbyte*)pNative, 0, cch); + return new string((sbyte*)pNative, 0, cch); } internal static unsafe void ClearNative(IntPtr pNative) @@ -437,7 +437,7 @@ internal static unsafe string ConvertToManaged(IntPtr bstr) // We intentionally ignore the length field of the BSTR for back compat reasons. // Unfortunately VB.NET uses Ansi BSTR marshaling when a string is passed ByRef // and we cannot afford to break this common scenario. - return new String((sbyte*)bstr); + return new string((sbyte*)bstr); } } @@ -480,24 +480,24 @@ internal static void ClearNative(IntPtr pNative) [StructLayout(LayoutKind.Sequential)] internal struct DateTimeNative { - public Int64 UniversalTime; + public long UniversalTime; }; internal static class DateTimeOffsetMarshaler { // Numer of ticks counted between 0001-01-01, 00:00:00 and 1601-01-01, 00:00:00. // You can get this through: (new DateTimeOffset(1601, 1, 1, 0, 0, 1, TimeSpan.Zero)).Ticks; - private const Int64 ManagedUtcTicksAtNativeZero = 504911232000000000; + private const long ManagedUtcTicksAtNativeZero = 504911232000000000; internal static void ConvertToNative(ref DateTimeOffset managedDTO, out DateTimeNative dateTime) { - Int64 managedUtcTicks = managedDTO.UtcTicks; + long managedUtcTicks = managedDTO.UtcTicks; dateTime.UniversalTime = managedUtcTicks - ManagedUtcTicksAtNativeZero; } internal static void ConvertToManaged(out DateTimeOffset managedLocalDTO, ref DateTimeNative nativeTicks) { - Int64 managedUtcTicks = ManagedUtcTicksAtNativeZero + nativeTicks.UniversalTime; + long managedUtcTicks = ManagedUtcTicksAtNativeZero + nativeTicks.UniversalTime; DateTimeOffset managedUtcDTO = new DateTimeOffset(managedUtcTicks, TimeSpan.Zero); // Some Utc times cannot be represented in local time in certain timezones. E.g. 0001-01-01 12:00:00 AM cannot @@ -609,7 +609,6 @@ internal static class DateMarshaler } // class DateMarshaler #if FEATURE_COMINTEROP - // [FriendAccessAllowed] internal static class InterfaceMarshaler { [MethodImplAttribute(MethodImplOptions.InternalCall)] @@ -621,7 +620,6 @@ internal static class InterfaceMarshaler [DllImport(JitHelpers.QCall)] internal static extern void ClearNative(IntPtr pUnk); - // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern object ConvertToManagedWithoutUnboxing(IntPtr pNative); } // class InterfaceMarshaler @@ -645,41 +643,6 @@ internal static unsafe IntPtr CreateNativeUriInstance(string rawUri) } } // class InterfaceMarshaler - // [FriendAccessAllowed] - internal static class EventArgsMarshaler - { - // [FriendAccessAllowed] - internal static IntPtr CreateNativeNCCEventArgsInstance(int action, object newItems, object oldItems, int newIndex, int oldIndex) - { - IntPtr newItemsIP = IntPtr.Zero; - IntPtr oldItemsIP = IntPtr.Zero; - - RuntimeHelpers.PrepareConstrainedRegions(); - try - { - if (newItems != null) - newItemsIP = Marshal.GetComInterfaceForObject(newItems, typeof(IBindableVector)); - if (oldItems != null) - oldItemsIP = Marshal.GetComInterfaceForObject(oldItems, typeof(IBindableVector)); - - return CreateNativeNCCEventArgsInstanceHelper(action, newItemsIP, oldItemsIP, newIndex, oldIndex); - } - finally - { - if (oldItemsIP != IntPtr.Zero) - Marshal.Release(oldItemsIP); - if (newItemsIP != IntPtr.Zero) - Marshal.Release(newItemsIP); - } - } - - // [FriendAccessAllowed] - [DllImport(JitHelpers.QCall)] - static internal extern IntPtr CreateNativePCEventArgsInstance([MarshalAs(UnmanagedType.HString)]string name); - - [DllImport(JitHelpers.QCall)] - static internal extern IntPtr CreateNativeNCCEventArgsInstanceHelper(int action, IntPtr newItem, IntPtr oldItem, int newIndex, int oldIndex); - } #endif // FEATURE_COMINTEROP internal static class MngdNativeArrayMarshaler @@ -779,7 +742,7 @@ internal static unsafe void ConvertContentsToNative_Exception(ref Exception[] ma { if (managedArray != null) { - Int32* nativeBuffer = *(Int32**)pNativeHome; + int* nativeBuffer = *(int**)pNativeHome; for (int i = 0; i < managedArray.Length; i++) { nativeBuffer[i] = HResultExceptionMarshaler.ConvertToNative(managedArray[i]); @@ -846,7 +809,7 @@ internal static unsafe void ConvertContentsToManaged_Exception(ref Exception[] m { if (managedArray != null) { - Int32* nativeBuffer = *(Int32**)pNativeHome; + int* nativeBuffer = *(int**)pNativeHome; for (int i = 0; i < managedArray.Length; i++) { managedArray[i] = HResultExceptionMarshaler.ConvertToManaged(nativeBuffer[i]); @@ -1491,7 +1454,7 @@ internal struct NativeVariant private IntPtr data1; private IntPtr data2; #else - Int64 data1; + long data1; #endif } // struct NativeVariant @@ -1731,9 +1694,6 @@ internal static void CheckStringLength(uint length) [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern unsafe int strlen(sbyte* ptr); - [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern void DecimalCanonicalizeInternal(ref Decimal dec); - [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern unsafe void FmtClassUpdateNativeInternal(object obj, byte* pNative, ref CleanupWorkList pCleanupWorkList); [MethodImplAttribute(MethodImplOptions.InternalCall)] diff --git a/src/System.Private.CoreLib/src/System/Text/CodePageDataItem.cs b/src/System.Private.CoreLib/src/System/Text/CodePageDataItem.cs index 6c7171a3e9be..488537641ae5 100644 --- a/src/System.Private.CoreLib/src/System/Text/CodePageDataItem.cs +++ b/src/System.Private.CoreLib/src/System/Text/CodePageDataItem.cs @@ -21,9 +21,9 @@ internal class CodePageDataItem { internal int m_dataIndex; internal int m_uiFamilyCodePage; - internal String m_webName; - internal String m_headerName; - internal String m_bodyName; + internal string m_webName; + internal string m_headerName; + internal string m_bodyName; internal uint m_flags; internal unsafe CodePageDataItem(int dataIndex) @@ -33,7 +33,7 @@ internal unsafe CodePageDataItem(int dataIndex) m_flags = EncodingTable.codePageDataPtr[dataIndex].flags; } - internal static unsafe String CreateString(sbyte* pStrings, uint index) + internal static unsafe string CreateString(sbyte* pStrings, uint index) { if (pStrings[0] == '|') // |str1|str2|str3 { @@ -47,7 +47,7 @@ internal static unsafe String CreateString(sbyte* pStrings, uint index) { if (index == 0) { - return new String(pStrings, start, i - start); + return new string(pStrings, start, i - start); } index--; @@ -64,11 +64,11 @@ internal static unsafe String CreateString(sbyte* pStrings, uint index) } else { - return new String(pStrings); + return new string(pStrings); } } - public unsafe String WebName + public unsafe string WebName { get { @@ -88,7 +88,7 @@ public virtual int UIFamilyCodePage } } - public unsafe String HeaderName + public unsafe string HeaderName { get { @@ -100,7 +100,7 @@ public unsafe String HeaderName } } - public unsafe String BodyName + public unsafe string BodyName { get { diff --git a/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs b/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs index 6925be2200fd..c1795ed5b01b 100644 --- a/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs +++ b/src/System.Private.CoreLib/src/System/Text/EncodingTable.cs @@ -51,7 +51,7 @@ internal static class EncodingTable // Find the data item by binary searching the table that we have in native. // nativeCompareOrdinalWC is an internal-only function. - private static unsafe int internalGetCodePageFromName(String name) + private static unsafe int internalGetCodePageFromName(string name) { int left = 0; int right = lastEncodingItem; @@ -133,14 +133,14 @@ internal static unsafe EncodingInfo[] GetEncodings() ** internalGetCodePageFromName will throw ArgumentException if name is not a valid encoding name. ============================================================================*/ - internal static int GetCodePageFromName(String name) + internal static int GetCodePageFromName(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } - Object codePageObj; + object codePageObj; // // The name is case-insensitive, but ToLower isn't free. Check for @@ -217,7 +217,7 @@ internal static unsafe CodePageDataItem GetCodePageDataItem(int codepage) //This will not work in case-insensitive mode for any character greater than 0x7F. //We'll throw an ArgumentException. [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern unsafe int nativeCompareOrdinalIgnoreCaseWC(String strA, sbyte* strBBytes); + private static extern unsafe int nativeCompareOrdinalIgnoreCaseWC(string strA, sbyte* strBBytes); } /*=================================InternalEncodingDataItem========================== @@ -231,7 +231,7 @@ internal static unsafe CodePageDataItem GetCodePageDataItem(int codepage) internal unsafe struct InternalEncodingDataItem { internal sbyte* webName; - internal UInt16 codePage; + internal ushort codePage; } /*=================================InternalCodePageDataItem========================== @@ -242,8 +242,8 @@ internal unsafe struct InternalEncodingDataItem [System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)] internal unsafe struct InternalCodePageDataItem { - internal UInt16 codePage; - internal UInt16 uiFamilyCodePage; + internal ushort codePage; + internal ushort uiFamilyCodePage; internal uint flags; internal sbyte* Names; } diff --git a/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs index 1092ae377a10..716c5cccafa3 100644 --- a/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Text/StringBuilder.CoreCLR.cs @@ -81,9 +81,7 @@ internal unsafe void ReplaceBufferAnsiInternal(sbyte* newBuffer, int newLength) // Both MultiByteToWideChar and the UTF8Encoding instance used on Unix-like // platforms default to replacing invalid characters with the Unicode replacement // character U+FFFD. -#if PLATFORM_UNIX - convertedChars = Encoding.UTF8.GetChars((byte*)newBuffer, newLength, pChunkChars, newLength); -#else +#if PLATFORM_WINDOWS convertedChars = Interop.Kernel32.MultiByteToWideChar( Interop.Kernel32.CP_ACP, Interop.Kernel32.MB_PRECOMPOSED, @@ -91,6 +89,8 @@ internal unsafe void ReplaceBufferAnsiInternal(sbyte* newBuffer, int newLength) newLength, pChunkChars, newLength); +#else + convertedChars = Encoding.UTF8.GetChars((byte*)newBuffer, newLength, pChunkChars, newLength); #endif } diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs index 67ec05c8ed22..815c9ccef18c 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs +++ b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenRegistration.cs @@ -47,7 +47,7 @@ public void Dispose() /// Disposes of the registration and unregisters the target callback from the associated /// CancellationToken. /// - internal bool Unregister() // corefx currently has an InternalsVisibleTo dependency on this + public bool Unregister() { CancellationTokenSource.CallbackNode node = _node; return node != null && node.Partition.Unregister(_id, node); diff --git a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs index 7eb1a3026aa3..d38ffc966e3a 100644 --- a/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs +++ b/src/System.Private.CoreLib/src/System/Threading/CancellationTokenSource.cs @@ -147,7 +147,7 @@ internal WaitHandle WaitHandle /// /// The time span to wait before canceling this /// - /// The exception that is thrown when is less than -1 or greater than Int32.MaxValue. + /// The exception that is thrown when is less than -1 or greater than int.MaxValue. /// /// /// @@ -205,7 +205,7 @@ public CancellationTokenSource(int millisecondsDelay) private void InitializeWithTimer(int millisecondsDelay) { _state = NotCanceledState; - _timer = new Timer(s_timerCallback, this, millisecondsDelay, -1); + _timer = new Timer(s_timerCallback, this, millisecondsDelay, -1, flowExecutionContext: false); } /// Communicates a request for cancellation. @@ -268,7 +268,7 @@ public void Cancel(bool throwOnFirstException) /// /// /// The exception thrown when is less than -1 or - /// greater than Int32.MaxValue. + /// greater than int.MaxValue. /// /// /// @@ -345,7 +345,7 @@ public void CancelAfter(int millisecondsDelay) // Initially set to "never go off" because we don't want to take a // chance on a timer "losing" the initialization and then // cancelling the token before it (the timer) can be disposed. - Timer newTimer = new Timer(s_timerCallback, this, -1, -1); + Timer newTimer = new Timer(s_timerCallback, this, -1, -1, flowExecutionContext: false); if (Interlocked.CompareExchange(ref _timer, newTimer, null) != null) { // We did not initialize the timer. Dispose the new timer. @@ -725,8 +725,6 @@ public static CancellationTokenSource CreateLinkedTokenSource(params Cancellatio } } - - /// /// Wait for a single callback to complete (or, more specifically, to not be running). /// It is ok to call this method if the callback has already finished. @@ -790,17 +788,17 @@ private sealed class LinkedNCancellationTokenSource : CancellationTokenSource { internal static readonly Action s_linkedTokenCancelDelegate = s => ((CancellationTokenSource)s).NotifyCancellation(throwOnFirstException: false); // skip ThrowIfDisposed() check in Cancel() - private CancellationTokenRegistration[] m_linkingRegistrations; + private CancellationTokenRegistration[] _linkingRegistrations; internal LinkedNCancellationTokenSource(params CancellationToken[] tokens) { - m_linkingRegistrations = new CancellationTokenRegistration[tokens.Length]; + _linkingRegistrations = new CancellationTokenRegistration[tokens.Length]; for (int i = 0; i < tokens.Length; i++) { if (tokens[i].CanBeCanceled) { - m_linkingRegistrations[i] = tokens[i].InternalRegisterWithoutEC(s_linkedTokenCancelDelegate, this); + _linkingRegistrations[i] = tokens[i].InternalRegisterWithoutEC(s_linkedTokenCancelDelegate, this); } // Empty slots in the array will be default(CancellationTokenRegistration), which are nops to Dispose. // Based on usage patterns, such occurrences should also be rare, such that it's not worth resizing @@ -815,10 +813,10 @@ protected override void Dispose(bool disposing) return; } - CancellationTokenRegistration[] linkingRegistrations = m_linkingRegistrations; + CancellationTokenRegistration[] linkingRegistrations = _linkingRegistrations; if (linkingRegistrations != null) { - m_linkingRegistrations = null; // release for GC once we're done enumerating + _linkingRegistrations = null; // release for GC once we're done enumerating for (int i = 0; i < linkingRegistrations.Length; i++) { linkingRegistrations[i].Dispose(); diff --git a/src/System.Private.CoreLib/src/System/Threading/EventWaitHandle.cs b/src/System.Private.CoreLib/src/System/Threading/EventWaitHandle.cs deleted file mode 100644 index c2ffb8c5b118..000000000000 --- a/src/System.Private.CoreLib/src/System/Threading/EventWaitHandle.cs +++ /dev/null @@ -1,232 +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: Base class for representing Events -** -** -=============================================================================*/ - - -namespace System.Security.AccessControl -{ - internal class EventWaitHandleSecurity - { - } - internal enum EventWaitHandleRights - { - } -} - -namespace System.Threading -{ - using System; - using System.Threading; - using System.Runtime.CompilerServices; - using System.IO; - using Microsoft.Win32; - using Microsoft.Win32.SafeHandles; - using System.Runtime.InteropServices; - using System.Runtime.Versioning; - using System.Security.AccessControl; - - [ComVisibleAttribute(true)] - public class EventWaitHandle : WaitHandle - { - private const uint AccessRights = - (uint)Win32Native.MAXIMUM_ALLOWED | Win32Native.SYNCHRONIZE | Win32Native.EVENT_MODIFY_STATE; - - public EventWaitHandle(bool initialState, EventResetMode mode) : this(initialState, mode, null) { } - - public EventWaitHandle(bool initialState, EventResetMode mode, string name) - { - if (name != null) - { -#if PLATFORM_UNIX - throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); -#else - if (Interop.Kernel32.MAX_PATH < name.Length) - { - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); - } -#endif - } - - uint eventFlags = initialState ? Win32Native.CREATE_EVENT_INITIAL_SET : 0; - switch (mode) - { - case EventResetMode.ManualReset: - eventFlags |= Win32Native.CREATE_EVENT_MANUAL_RESET; - break; - - case EventResetMode.AutoReset: - break; - - default: - throw new ArgumentException(SR.Format(SR.Argument_InvalidFlag, name)); - }; - - SafeWaitHandle _handle = Win32Native.CreateEventEx(null, name, eventFlags, AccessRights); - - if (_handle.IsInvalid) - { - int errorCode = Marshal.GetLastWin32Error(); - - _handle.SetHandleAsInvalid(); - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - throw Win32Marshal.GetExceptionForWin32Error(errorCode, name); - } - SetHandleInternal(_handle); - } - - public EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew) - : this(initialState, mode, name, out createdNew, null) - { - } - - internal unsafe EventWaitHandle(bool initialState, EventResetMode mode, string name, out bool createdNew, EventWaitHandleSecurity eventSecurity) - { - if (name != null) - { -#if PLATFORM_UNIX - throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); -#else - if (Interop.Kernel32.MAX_PATH < name.Length) - { - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); - } -#endif - } - Win32Native.SECURITY_ATTRIBUTES secAttrs = null; - - uint eventFlags = initialState ? Win32Native.CREATE_EVENT_INITIAL_SET : 0; - switch (mode) - { - case EventResetMode.ManualReset: - eventFlags |= Win32Native.CREATE_EVENT_MANUAL_RESET; - break; - - case EventResetMode.AutoReset: - break; - - default: - throw new ArgumentException(SR.Format(SR.Argument_InvalidFlag, name)); - }; - - SafeWaitHandle _handle = Win32Native.CreateEventEx(secAttrs, name, eventFlags, AccessRights); - - int errorCode = Marshal.GetLastWin32Error(); - if (_handle.IsInvalid) - { - _handle.SetHandleAsInvalid(); - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - throw Win32Marshal.GetExceptionForWin32Error(errorCode, name); - } - createdNew = errorCode != Interop.Errors.ERROR_ALREADY_EXISTS; - SetHandleInternal(_handle); - } - - private EventWaitHandle(SafeWaitHandle handle) - { - SetHandleInternal(handle); - } - - public static EventWaitHandle OpenExisting(string name) - { - return OpenExisting(name, (EventWaitHandleRights)0); - } - - internal static EventWaitHandle OpenExisting(string name, EventWaitHandleRights rights) - { - EventWaitHandle result; - switch (OpenExistingWorker(name, rights, out result)) - { - case OpenExistingResult.NameNotFound: - throw new WaitHandleCannotBeOpenedException(); - - case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - case OpenExistingResult.PathNotFound: - throw Win32Marshal.GetExceptionForWin32Error(Interop.Errors.ERROR_PATH_NOT_FOUND, ""); - - default: - return result; - } - } - - public static bool TryOpenExisting(string name, out EventWaitHandle result) - { - return OpenExistingWorker(name, (EventWaitHandleRights)0, out result) == OpenExistingResult.Success; - } - - private static OpenExistingResult OpenExistingWorker(string name, EventWaitHandleRights rights, out EventWaitHandle result) - { -#if PLATFORM_UNIX - throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); -#else - if (name == null) - { - throw new ArgumentNullException(nameof(name)); - } - - if (name.Length == 0) - { - throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); - } - - if (null != name && Interop.Kernel32.MAX_PATH < name.Length) - { - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); - } - - - result = null; - - SafeWaitHandle myHandle = Win32Native.OpenEvent(AccessRights, false, name); - - if (myHandle.IsInvalid) - { - int errorCode = Marshal.GetLastWin32Error(); - - if (Interop.Errors.ERROR_FILE_NOT_FOUND == errorCode || Interop.Errors.ERROR_INVALID_NAME == errorCode) - return OpenExistingResult.NameNotFound; - if (Interop.Errors.ERROR_PATH_NOT_FOUND == errorCode) - return OpenExistingResult.PathNotFound; - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - return OpenExistingResult.NameInvalid; - //this is for passed through Win32Native Errors - throw Win32Marshal.GetExceptionForWin32Error(errorCode, ""); - } - result = new EventWaitHandle(myHandle); - return OpenExistingResult.Success; -#endif - } - public bool Reset() - { - bool res = Win32Native.ResetEvent(safeWaitHandle); - if (!res) - throw Win32Marshal.GetExceptionForLastWin32Error(); - return res; - } - public bool Set() - { - bool res = Win32Native.SetEvent(safeWaitHandle); - - if (!res) - throw Win32Marshal.GetExceptionForLastWin32Error(); - - return res; - } - } -} - diff --git a/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs b/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs index 898b0b182332..c4fc750a5cf9 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Interlocked.cs @@ -70,7 +70,7 @@ public static long Decrement(ref long location) public static extern double Exchange(ref double location1, double value); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object Exchange(ref Object location1, Object value); + public static extern object Exchange(ref object location1, object value); [MethodImplAttribute(MethodImplOptions.InternalCall)] public static extern IntPtr Exchange(ref IntPtr location1, IntPtr value); @@ -106,7 +106,7 @@ public static T Exchange(ref T location1, T value) where T : class public static extern double CompareExchange(ref double location1, double value, double comparand); [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern Object CompareExchange(ref Object location1, Object value, Object comparand); + public static extern object CompareExchange(ref object location1, object value, object comparand); [MethodImplAttribute(MethodImplOptions.InternalCall)] public static extern IntPtr CompareExchange(ref IntPtr location1, IntPtr value, IntPtr comparand); diff --git a/src/System.Private.CoreLib/src/System/Threading/Monitor.cs b/src/System.Private.CoreLib/src/System/Threading/Monitor.cs index be7bded199d6..2837d908c6c6 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Monitor.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Monitor.cs @@ -36,7 +36,7 @@ public static class Monitor ** Exceptions: ArgumentNullException if object is null. =========================================================================*/ [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void Enter(Object obj); + public static extern void Enter(object obj); // Use a ref bool instead of out to ensure that unverifiable code must @@ -44,7 +44,7 @@ public static class Monitor // could be uninitialized if we threw an exception in our prolog. // The JIT should inline this method to allow check of lockTaken argument to be optimized out // in the typical case. Note that the method has to be transparent for inlining to be allowed by the VM. - public static void Enter(Object obj, ref bool lockTaken) + public static void Enter(object obj, ref bool lockTaken) { if (lockTaken) ThrowLockTakenException(); @@ -59,7 +59,7 @@ private static void ThrowLockTakenException() } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void ReliableEnter(Object obj, ref bool lockTaken); + private static extern void ReliableEnter(object obj, ref bool lockTaken); @@ -73,7 +73,7 @@ private static void ThrowLockTakenException() ** own the lock. =========================================================================*/ [MethodImplAttribute(MethodImplOptions.InternalCall)] - public static extern void Exit(Object obj); + public static extern void Exit(object obj); /*========================================================================= ** Similar to Enter, but will never block. That is, if the current thread can @@ -82,7 +82,7 @@ private static void ThrowLockTakenException() ** ** Exceptions: ArgumentNullException if object is null. =========================================================================*/ - public static bool TryEnter(Object obj) + public static bool TryEnter(object obj) { bool lockTaken = false; TryEnter(obj, 0, ref lockTaken); @@ -91,7 +91,7 @@ public static bool TryEnter(Object obj) // The JIT should inline this method to allow check of lockTaken argument to be optimized out // in the typical case. Note that the method has to be transparent for inlining to be allowed by the VM. - public static void TryEnter(Object obj, ref bool lockTaken) + public static void TryEnter(object obj, ref bool lockTaken) { if (lockTaken) ThrowLockTakenException(); @@ -109,7 +109,7 @@ public static void TryEnter(Object obj, ref bool lockTaken) =========================================================================*/ // The JIT should inline this method to allow check of lockTaken argument to be optimized out // in the typical case. Note that the method has to be transparent for inlining to be allowed by the VM. - public static bool TryEnter(Object obj, int millisecondsTimeout) + public static bool TryEnter(object obj, int millisecondsTimeout) { bool lockTaken = false; TryEnter(obj, millisecondsTimeout, ref lockTaken); @@ -119,19 +119,19 @@ public static bool TryEnter(Object obj, int millisecondsTimeout) private static int MillisecondsTimeoutFromTimeSpan(TimeSpan timeout) { long tm = (long)timeout.TotalMilliseconds; - if (tm < -1 || tm > (long)Int32.MaxValue) + if (tm < -1 || tm > (long)int.MaxValue) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); return (int)tm; } - public static bool TryEnter(Object obj, TimeSpan timeout) + public static bool TryEnter(object obj, TimeSpan timeout) { return TryEnter(obj, MillisecondsTimeoutFromTimeSpan(timeout)); } // The JIT should inline this method to allow check of lockTaken argument to be optimized out // in the typical case. Note that the method has to be transparent for inlining to be allowed by the VM. - public static void TryEnter(Object obj, int millisecondsTimeout, ref bool lockTaken) + public static void TryEnter(object obj, int millisecondsTimeout, ref bool lockTaken) { if (lockTaken) ThrowLockTakenException(); @@ -139,7 +139,7 @@ public static void TryEnter(Object obj, int millisecondsTimeout, ref bool lockTa ReliableEnterTimeout(obj, millisecondsTimeout, ref lockTaken); } - public static void TryEnter(Object obj, TimeSpan timeout, ref bool lockTaken) + public static void TryEnter(object obj, TimeSpan timeout, ref bool lockTaken) { if (lockTaken) ThrowLockTakenException(); @@ -148,7 +148,7 @@ public static void TryEnter(Object obj, TimeSpan timeout, ref bool lockTaken) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void ReliableEnterTimeout(Object obj, int timeout, ref bool lockTaken); + private static extern void ReliableEnterTimeout(object obj, int timeout, ref bool lockTaken); public static bool IsEntered(object obj) { @@ -159,7 +159,7 @@ public static bool IsEntered(object obj) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool IsEnteredNative(Object obj); + private static extern bool IsEnteredNative(object obj); /*======================================================================== ** Waits for notification from the object (via a Pulse/PulseAll). @@ -173,31 +173,31 @@ public static bool IsEntered(object obj) ** Exceptions: ArgumentNullException if object is null. ========================================================================*/ [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool ObjWait(bool exitContext, int millisecondsTimeout, Object obj); + private static extern bool ObjWait(bool exitContext, int millisecondsTimeout, object obj); - public static bool Wait(Object obj, int millisecondsTimeout, bool exitContext) + public static bool Wait(object obj, int millisecondsTimeout, bool exitContext) { if (obj == null) throw (new ArgumentNullException(nameof(obj))); return ObjWait(exitContext, millisecondsTimeout, obj); } - public static bool Wait(Object obj, TimeSpan timeout, bool exitContext) + public static bool Wait(object obj, TimeSpan timeout, bool exitContext) { return Wait(obj, MillisecondsTimeoutFromTimeSpan(timeout), exitContext); } - public static bool Wait(Object obj, int millisecondsTimeout) + public static bool Wait(object obj, int millisecondsTimeout) { return Wait(obj, millisecondsTimeout, false); } - public static bool Wait(Object obj, TimeSpan timeout) + public static bool Wait(object obj, TimeSpan timeout) { return Wait(obj, MillisecondsTimeoutFromTimeSpan(timeout), false); } - public static bool Wait(Object obj) + public static bool Wait(object obj) { return Wait(obj, Timeout.Infinite, false); } @@ -208,9 +208,9 @@ public static bool Wait(Object obj) * a synchronized block of code. ========================================================================*/ [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void ObjPulse(Object obj); + private static extern void ObjPulse(object obj); - public static void Pulse(Object obj) + public static void Pulse(object obj) { if (obj == null) { @@ -223,9 +223,9 @@ public static void Pulse(Object obj) ** Sends a notification to all waiting objects. ========================================================================*/ [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern void ObjPulseAll(Object obj); + private static extern void ObjPulseAll(object obj); - public static void PulseAll(Object obj) + public static void PulseAll(object obj) { if (obj == null) { diff --git a/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs b/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs index 51df27f735c0..d43c78d8f7e8 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Overlapped.cs @@ -6,11 +6,9 @@ /* * This files defines the following types: - * - NativeOverlapped * - _IOCompletionCallback * - OverlappedData * - Overlapped - * - OverlappedDataCache */ /*============================================================================= @@ -24,36 +22,11 @@ =============================================================================*/ -using System; -using System.Runtime.InteropServices; -using System.Runtime.CompilerServices; -using System.Runtime.Versioning; -using System.Security; -using System.Runtime.ConstrainedExecution; using System.Diagnostics; -using System.Collections.Concurrent; +using System.Runtime.CompilerServices; namespace System.Threading { - #region struct NativeOverlapped - - // Valuetype that represents the (unmanaged) Win32 OVERLAPPED structure - // the layout of this structure must be identical to OVERLAPPED. - // The first five matches OVERLAPPED structure. - // The remaining are reserved at the end - [System.Runtime.InteropServices.StructLayout(LayoutKind.Sequential)] - public struct NativeOverlapped - { - public IntPtr InternalLow; - public IntPtr InternalHigh; - public int OffsetLow; - public int OffsetHigh; - public IntPtr EventHandle; - } - - #endregion struct NativeOverlapped - - #region class _IOCompletionCallback internal unsafe class _IOCompletionCallback @@ -62,7 +35,7 @@ internal unsafe class _IOCompletionCallback private ExecutionContext _executionContext; private uint _errorCode; // Error code private uint _numBytes; // No. of bytes transferred - private NativeOverlapped* _pOVERLAP; + private NativeOverlapped* _pNativeOverlapped; internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, ExecutionContext executionContext) { @@ -71,46 +44,39 @@ internal _IOCompletionCallback(IOCompletionCallback ioCompletionCallback, Execut } // Context callback: same sig for SendOrPostCallback and ContextCallback internal static ContextCallback _ccb = new ContextCallback(IOCompletionCallback_Context); - internal static void IOCompletionCallback_Context(Object state) + internal static void IOCompletionCallback_Context(object state) { _IOCompletionCallback helper = (_IOCompletionCallback)state; Debug.Assert(helper != null, "_IOCompletionCallback cannot be null"); - helper._ioCompletionCallback(helper._errorCode, helper._numBytes, helper._pOVERLAP); + helper._ioCompletionCallback(helper._errorCode, helper._numBytes, helper._pNativeOverlapped); } // call back helper - internal static unsafe void PerformIOCompletionCallback(uint errorCode, // Error code - uint numBytes, // No. of bytes transferred - NativeOverlapped* pOVERLAP // ptr to OVERLAP structure - ) + internal static unsafe void PerformIOCompletionCallback(uint errorCode, uint numBytes, NativeOverlapped* pNativeOverlapped) { - Overlapped overlapped; - _IOCompletionCallback helper; - do { - overlapped = OverlappedData.GetOverlappedFromNative(pOVERLAP).m_overlapped; - helper = overlapped.iocbHelper; + OverlappedData overlapped = OverlappedData.GetOverlappedFromNative(pNativeOverlapped); - if (helper == null || helper._executionContext == null || helper._executionContext.IsDefault) + if (overlapped._callback is IOCompletionCallback iocb) { // We got here because of UnsafePack (or) Pack with EC flow suppressed - IOCompletionCallback callback = overlapped.UserCallback; - callback(errorCode, numBytes, pOVERLAP); + iocb(errorCode, numBytes, pNativeOverlapped); } else { // We got here because of Pack + var helper = (_IOCompletionCallback)overlapped._callback; helper._errorCode = errorCode; helper._numBytes = numBytes; - helper._pOVERLAP = pOVERLAP; + helper._pNativeOverlapped = pNativeOverlapped; ExecutionContext.RunInternal(helper._executionContext, _ccb, helper); } //Quickly check the VM again, to see if a packet has arrived. - OverlappedData.CheckVMForIOPacket(out pOVERLAP, out errorCode, out numBytes); - } while (pOVERLAP != null); + OverlappedData.CheckVMForIOPacket(out pNativeOverlapped, out errorCode, out numBytes); + } while (pNativeOverlapped != null); } } @@ -119,50 +85,28 @@ internal static unsafe void PerformIOCompletionCallback(uint errorCode, // Error #region class OverlappedData - sealed internal class OverlappedData + sealed internal unsafe class OverlappedData { // ! If you make any change to the layout here, you need to make matching change - // ! to OverlappedObject in vm\nativeoverlapped.h - internal IAsyncResult m_asyncResult; - internal IOCompletionCallback m_iocb; - internal _IOCompletionCallback m_iocbHelper; - internal Overlapped m_overlapped; - private Object m_userObject; - private IntPtr m_pinSelf; - private IntPtr m_userObjectInternal; - private int m_AppDomainId; -#pragma warning disable 414 // Field is not used from managed. -#pragma warning disable 169 - private byte m_isArray; - private byte m_toBeCleaned; -#pragma warning restore 414 -#pragma warning restore 169 - internal NativeOverlapped m_nativeOverlapped; - - // Adding an empty default ctor for annotation purposes - internal OverlappedData() { } - - internal void ReInitialize() - { - m_asyncResult = null; - m_iocb = null; - m_iocbHelper = null; - m_overlapped = null; - m_userObject = null; - Debug.Assert(m_pinSelf == IntPtr.Zero, "OverlappedData has not been freed: m_pinSelf"); - m_pinSelf = IntPtr.Zero; - m_userObjectInternal = IntPtr.Zero; - Debug.Assert(m_AppDomainId == 0 || m_AppDomainId == AppDomain.CurrentDomain.Id, "OverlappedData is not in the current domain"); - m_AppDomainId = 0; - m_nativeOverlapped.EventHandle = IntPtr.Zero; - m_isArray = 0; - m_nativeOverlapped.InternalLow = IntPtr.Zero; - m_nativeOverlapped.InternalHigh = IntPtr.Zero; - } - - internal unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, Object userData) + // ! to OverlappedDataObject in vm\nativeoverlapped.h + internal IAsyncResult _asyncResult; + internal object _callback; // IOCompletionCallback or _IOCompletionCallback + internal Overlapped _overlapped; + private object _userObject; + private NativeOverlapped * _pNativeOverlapped; + private IntPtr _eventHandle; + private int _offsetLow; + private int _offsetHigh; + + internal ref IAsyncResult AsyncResult => ref _asyncResult; + + internal ref int OffsetLow => ref (_pNativeOverlapped != null) ? ref _pNativeOverlapped->OffsetLow : ref _offsetLow; + internal ref int OffsetHigh => ref (_pNativeOverlapped != null) ? ref _pNativeOverlapped->OffsetHigh : ref _offsetHigh; + internal ref IntPtr EventHandle => ref (_pNativeOverlapped != null) ? ref _pNativeOverlapped->EventHandle : ref _eventHandle; + + internal unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData) { - if (m_pinSelf != IntPtr.Zero) + if (_pNativeOverlapped != null) { throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack); } @@ -170,69 +114,38 @@ internal void ReInitialize() if (iocb != null) { ExecutionContext ec = ExecutionContext.Capture(); - m_iocbHelper = ec != null ? new _IOCompletionCallback(iocb, ec) : null; - m_iocb = iocb; + _callback = (ec != null && !ec.IsDefault) ? new _IOCompletionCallback(iocb, ec) : (object)iocb; } else { - m_iocbHelper = null; - m_iocb = null; - } - m_userObject = userData; - if (m_userObject != null) - { - if (m_userObject.GetType() == typeof(Object[])) - { - m_isArray = 1; - } - else - { - m_isArray = 0; - } + _callback = null; } + _userObject = userData; return AllocateNativeOverlapped(); } - internal unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData) + internal unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, object userData) { - if (m_pinSelf != IntPtr.Zero) + if (_pNativeOverlapped != null) { throw new InvalidOperationException(SR.InvalidOperation_Overlapped_Pack); } - m_userObject = userData; - if (m_userObject != null) - { - if (m_userObject.GetType() == typeof(Object[])) - { - m_isArray = 1; - } - else - { - m_isArray = 0; - } - } - m_iocb = iocb; - m_iocbHelper = null; + _userObject = userData; + _callback = iocb; return AllocateNativeOverlapped(); } - internal IntPtr UserHandle - { - get { return m_nativeOverlapped.EventHandle; } - set { m_nativeOverlapped.EventHandle = value; } - } - [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern unsafe NativeOverlapped* AllocateNativeOverlapped(); + private extern NativeOverlapped* AllocateNativeOverlapped(); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern unsafe void FreeNativeOverlapped(NativeOverlapped* nativeOverlappedPtr); + internal static extern void FreeNativeOverlapped(NativeOverlapped* nativeOverlappedPtr); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern unsafe OverlappedData GetOverlappedFromNative(NativeOverlapped* nativeOverlappedPtr); + internal static extern OverlappedData GetOverlappedFromNative(NativeOverlapped* nativeOverlappedPtr); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern unsafe void CheckVMForIOPacket(out NativeOverlapped* pOVERLAP, out uint errorCode, out uint numBytes); + internal static extern void CheckVMForIOPacket(out NativeOverlapped* pNativeOverlapped, out uint errorCode, out uint numBytes); } #endregion class OverlappedData @@ -242,23 +155,22 @@ internal IntPtr UserHandle public class Overlapped { - private OverlappedData m_overlappedData; - private static PinnableBufferCache s_overlappedDataCache = new PinnableBufferCache("System.Threading.OverlappedData", () => new OverlappedData()); + private OverlappedData _overlappedData; public Overlapped() { - m_overlappedData = (OverlappedData)s_overlappedDataCache.Allocate(); - m_overlappedData.m_overlapped = this; + // The split between Overlapped and OverlappedData should not be needed. It is required by the implementation of + // async GC handles currently. It expects OverlappedData to be a sealed type. + _overlappedData = new OverlappedData(); + _overlappedData._overlapped = this; } - public Overlapped(int offsetLo, int offsetHi, IntPtr hEvent, IAsyncResult ar) + public Overlapped(int offsetLo, int offsetHi, IntPtr hEvent, IAsyncResult ar) : this() { - m_overlappedData = (OverlappedData)s_overlappedDataCache.Allocate(); - m_overlappedData.m_overlapped = this; - m_overlappedData.m_nativeOverlapped.OffsetLow = offsetLo; - m_overlappedData.m_nativeOverlapped.OffsetHigh = offsetHi; - m_overlappedData.UserHandle = hEvent; - m_overlappedData.m_asyncResult = ar; + _overlappedData.OffsetLow = offsetLo; + _overlappedData.OffsetHigh = offsetHi; + _overlappedData.EventHandle = hEvent; + _overlappedData.AsyncResult = ar; } [Obsolete("This constructor is not 64-bit compatible. Use the constructor that takes an IntPtr for the event handle. http://go.microsoft.com/fwlink/?linkid=14202")] @@ -268,43 +180,33 @@ public Overlapped(int offsetLo, int offsetHi, IntPtr hEvent, IAsyncResult ar) public IAsyncResult AsyncResult { - get { return m_overlappedData.m_asyncResult; } - set { m_overlappedData.m_asyncResult = value; } + get { return _overlappedData.AsyncResult; } + set { _overlappedData.AsyncResult = value; } } public int OffsetLow { - get { return m_overlappedData.m_nativeOverlapped.OffsetLow; } - set { m_overlappedData.m_nativeOverlapped.OffsetLow = value; } + get { return _overlappedData.OffsetLow; } + set { _overlappedData.OffsetLow = value; } } public int OffsetHigh { - get { return m_overlappedData.m_nativeOverlapped.OffsetHigh; } - set { m_overlappedData.m_nativeOverlapped.OffsetHigh = value; } + get { return _overlappedData.OffsetHigh; } + set { _overlappedData.OffsetHigh = value; } } [Obsolete("This property is not 64-bit compatible. Use EventHandleIntPtr instead. http://go.microsoft.com/fwlink/?linkid=14202")] public int EventHandle { - get { return m_overlappedData.UserHandle.ToInt32(); } - set { m_overlappedData.UserHandle = new IntPtr(value); } + get { return EventHandleIntPtr.ToInt32(); } + set { EventHandleIntPtr = new IntPtr(value); } } public IntPtr EventHandleIntPtr { - get { return m_overlappedData.UserHandle; } - set { m_overlappedData.UserHandle = value; } - } - - internal _IOCompletionCallback iocbHelper - { - get { return m_overlappedData.m_iocbHelper; } - } - - internal IOCompletionCallback UserCallback - { - get { return m_overlappedData.m_iocb; } + get { return _overlappedData.EventHandle; } + set { _overlappedData.EventHandle = value; } } /*==================================================================== @@ -320,9 +222,9 @@ internal IOCompletionCallback UserCallback } [CLSCompliant(false)] - public unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, Object userData) + public unsafe NativeOverlapped* Pack(IOCompletionCallback iocb, object userData) { - return m_overlappedData.Pack(iocb, userData); + return _overlappedData.Pack(iocb, userData); } [Obsolete("This method is not safe. Use UnsafePack (iocb, userData) instead. http://go.microsoft.com/fwlink/?linkid=14202")] @@ -333,9 +235,9 @@ internal IOCompletionCallback UserCallback } [CLSCompliant(false)] - public unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, Object userData) + public unsafe NativeOverlapped* UnsafePack(IOCompletionCallback iocb, object userData) { - return m_overlappedData.UnsafePack(iocb, userData); + return _overlappedData.UnsafePack(iocb, userData); } /*==================================================================== @@ -348,9 +250,7 @@ public static unsafe Overlapped Unpack(NativeOverlapped* nativeOverlappedPtr) if (nativeOverlappedPtr == null) throw new ArgumentNullException(nameof(nativeOverlappedPtr)); - Overlapped overlapped = OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped; - - return overlapped; + return OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr)._overlapped; } [CLSCompliant(false)] @@ -359,14 +259,10 @@ public static unsafe void Free(NativeOverlapped* nativeOverlappedPtr) if (nativeOverlappedPtr == null) throw new ArgumentNullException(nameof(nativeOverlappedPtr)); - Overlapped overlapped = OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr).m_overlapped; + OverlappedData.GetOverlappedFromNative(nativeOverlappedPtr)._overlapped._overlappedData = null; OverlappedData.FreeNativeOverlapped(nativeOverlappedPtr); - OverlappedData overlappedData = overlapped.m_overlappedData; - overlapped.m_overlappedData = null; - overlappedData.ReInitialize(); - s_overlappedDataCache.Free(overlappedData); } } #endregion class Overlapped -} // namespace +} diff --git a/src/System.Private.CoreLib/src/System/Threading/Semaphore.cs b/src/System.Private.CoreLib/src/System/Threading/Semaphore.cs deleted file mode 100644 index 8380c56801a3..000000000000 --- a/src/System.Private.CoreLib/src/System/Threading/Semaphore.cs +++ /dev/null @@ -1,191 +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. - -using Microsoft.Win32; -using Microsoft.Win32.SafeHandles; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace System.Threading -{ - public sealed partial class Semaphore : WaitHandle - { - private const uint AccessRights = - (uint)Win32Native.MAXIMUM_ALLOWED | Win32Native.SYNCHRONIZE | Win32Native.SEMAPHORE_MODIFY_STATE; - - public Semaphore(int initialCount, int maximumCount) : this(initialCount, maximumCount, null) { } - - public Semaphore(int initialCount, int maximumCount, string name) - { - if (initialCount < 0) - { - throw new ArgumentOutOfRangeException(nameof(initialCount), SR.ArgumentOutOfRange_NeedNonNegNum); - } - - if (maximumCount < 1) - { - throw new ArgumentOutOfRangeException(nameof(maximumCount), SR.ArgumentOutOfRange_NeedPosNum); - } - - if (initialCount > maximumCount) - { - throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum); - } - - SafeWaitHandle myHandle = CreateSemaphore(initialCount, maximumCount, name); - - if (myHandle.IsInvalid) - { - int errorCode = Marshal.GetLastWin32Error(); - - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException( - SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - - throw Win32Marshal.GetExceptionForLastWin32Error(); - } - this.SafeWaitHandle = myHandle; - } - - public Semaphore(int initialCount, int maximumCount, string name, out bool createdNew) - { - if (initialCount < 0) - { - throw new ArgumentOutOfRangeException(nameof(initialCount), SR.ArgumentOutOfRange_NeedNonNegNum); - } - - if (maximumCount < 1) - { - throw new ArgumentOutOfRangeException(nameof(maximumCount), SR.ArgumentOutOfRange_NeedNonNegNum); - } - - if (initialCount > maximumCount) - { - throw new ArgumentException(SR.Argument_SemaphoreInitialMaximum); - } - - SafeWaitHandle myHandle = CreateSemaphore(initialCount, maximumCount, name); - - int errorCode = Marshal.GetLastWin32Error(); - if (myHandle.IsInvalid) - { - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - throw new WaitHandleCannotBeOpenedException( - SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - throw Win32Marshal.GetExceptionForLastWin32Error(); - } - createdNew = errorCode != Interop.Errors.ERROR_ALREADY_EXISTS; - this.SafeWaitHandle = myHandle; - } - - private Semaphore(SafeWaitHandle handle) - { - this.SafeWaitHandle = handle; - } - - private static SafeWaitHandle CreateSemaphore(int initialCount, int maximumCount, string name) - { - if (name != null) - { -#if PLATFORM_UNIX - throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); -#else - if (name.Length > Interop.Kernel32.MAX_PATH) - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); -#endif - } - - Debug.Assert(initialCount >= 0); - Debug.Assert(maximumCount >= 1); - Debug.Assert(initialCount <= maximumCount); - - return Win32Native.CreateSemaphoreEx(null, initialCount, maximumCount, name, 0, AccessRights); - } - - public static Semaphore OpenExisting(string name) - { - Semaphore result; - switch (OpenExistingWorker(name, out result)) - { - case OpenExistingResult.NameNotFound: - throw new WaitHandleCannotBeOpenedException(); - case OpenExistingResult.NameInvalid: - throw new WaitHandleCannotBeOpenedException(SR.Format(SR.Threading_WaitHandleCannotBeOpenedException_InvalidHandle, name)); - case OpenExistingResult.PathNotFound: - throw new IOException(Interop.Kernel32.GetMessage(Interop.Errors.ERROR_PATH_NOT_FOUND)); - default: - return result; - } - } - - public static bool TryOpenExisting(string name, out Semaphore result) - { - return OpenExistingWorker(name, out result) == OpenExistingResult.Success; - } - - private static OpenExistingResult OpenExistingWorker(string name, out Semaphore result) - { -#if PLATFORM_UNIX - throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives); -#else - if (name == null) - throw new ArgumentNullException(nameof(name)); - if (name.Length == 0) - throw new ArgumentException(SR.Argument_EmptyName, nameof(name)); - if (name.Length > Interop.Kernel32.MAX_PATH) - throw new ArgumentException(SR.Format(SR.Argument_WaitHandleNameTooLong, name, Interop.Kernel32.MAX_PATH), nameof(name)); - - //Pass false to OpenSemaphore to prevent inheritedHandles - SafeWaitHandle myHandle = Win32Native.OpenSemaphore(AccessRights, false, name); - - if (myHandle.IsInvalid) - { - result = null; - - int errorCode = Marshal.GetLastWin32Error(); - - if (Interop.Errors.ERROR_FILE_NOT_FOUND == errorCode || Interop.Errors.ERROR_INVALID_NAME == errorCode) - return OpenExistingResult.NameNotFound; - if (Interop.Errors.ERROR_PATH_NOT_FOUND == errorCode) - return OpenExistingResult.PathNotFound; - if (null != name && 0 != name.Length && Interop.Errors.ERROR_INVALID_HANDLE == errorCode) - return OpenExistingResult.NameInvalid; - //this is for passed through NativeMethods Errors - throw Win32Marshal.GetExceptionForLastWin32Error(); - } - - result = new Semaphore(myHandle); - return OpenExistingResult.Success; -#endif - } - - public int Release() - { - return Release(1); - } - - // increase the count on a semaphore, returns previous count - public int Release(int releaseCount) - { - if (releaseCount < 1) - { - throw new ArgumentOutOfRangeException(nameof(releaseCount), SR.ArgumentOutOfRange_NeedNonNegNum); - } - - //If ReleaseSempahore returns false when the specified value would cause - // the semaphore's count to exceed the maximum count set when Semaphore was created - //Non-Zero return - - int previousCount; - if (!Win32Native.ReleaseSemaphore(SafeWaitHandle, releaseCount, out previousCount)) - { - throw new SemaphoreFullException(); - } - - return previousCount; - } - } -} diff --git a/src/System.Private.CoreLib/src/System/Threading/SpinLock.cs b/src/System.Private.CoreLib/src/System/Threading/SpinLock.cs index 7e58a6cf890e..64dfd0c12c2e 100644 --- a/src/System.Private.CoreLib/src/System/Threading/SpinLock.cs +++ b/src/System.Private.CoreLib/src/System/Threading/SpinLock.cs @@ -224,7 +224,7 @@ public void TryEnter(ref bool lockTaken) public void TryEnter(TimeSpan timeout, ref bool lockTaken) { // Validate the timeout - Int64 totalMilliseconds = (Int64)timeout.TotalMilliseconds; + long totalMilliseconds = (long)timeout.TotalMilliseconds; if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { throw new System.ArgumentOutOfRangeException( @@ -454,7 +454,7 @@ private void ContinueTryEnterWithThreadTracking(int millisecondsTimeout, uint st /// /// /// The default overload of provides the same behavior as if calling using true as the argument, but Exit() could be slightly faster than Exit(true). + /// cref="Exit(bool)"/> using true as the argument, but Exit() could be slightly faster than Exit(true). /// /// /// Thread ownership tracking is enabled, and the current thread is not the owner of this lock. @@ -476,7 +476,7 @@ public void Exit() /// publish the exit operation to other threads. /// /// - /// Calling with the argument set to + /// Calling with the argument set to /// true will improve the fairness of the lock at the expense of some performance. The default /// overload behaves as if specifying true for . diff --git a/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs b/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs index f438e9a03d68..7b7d06c10d25 100644 --- a/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs +++ b/src/System.Private.CoreLib/src/System/Threading/SynchronizationContext.cs @@ -32,17 +32,6 @@ internal enum SynchronizationContextProperties RequireWaitNotification = 0x1 }; -#if FEATURE_COMINTEROP && FEATURE_APPX - // - // This is implemented in System.Runtime.WindowsRuntime, allowing us to ask that assembly for a WinRT-specific SyncCtx. - // - // [FriendAccessAllowed] - internal abstract class WinRTSynchronizationContextFactoryBase - { - public abstract SynchronizationContext Create(object coreDispatcher); - } -#endif //FEATURE_COMINTEROP - public class SynchronizationContext { private SynchronizationContextProperties _props = SynchronizationContextProperties.None; @@ -101,12 +90,12 @@ public bool IsWaitNotificationRequired() } - public virtual void Send(SendOrPostCallback d, Object state) + public virtual void Send(SendOrPostCallback d, object state) { d(state); } - public virtual void Post(SendOrPostCallback d, Object state) + public virtual void Post(SendOrPostCallback d, object state) { ThreadPool.QueueUserWorkItem(s => s.d(s.state), (d, state), preferLocal: false); } @@ -189,27 +178,33 @@ private static SynchronizationContext GetWinRTContext() // object dispatcher = GetWinRTDispatcherForCurrentThread(); if (dispatcher != null) - return GetWinRTSynchronizationContextFactory().Create(dispatcher); + return GetWinRTSynchronizationContext(dispatcher); return null; } - private static WinRTSynchronizationContextFactoryBase s_winRTContextFactory; + private static Func s_createSynchronizationContextDelegate = null; - private static WinRTSynchronizationContextFactoryBase GetWinRTSynchronizationContextFactory() + private static SynchronizationContext GetWinRTSynchronizationContext(object dispatcher) { // // Since we can't directly reference System.Runtime.WindowsRuntime from mscorlib, we have to get the factory via reflection. // It would be better if we could just implement WinRTSynchronizationContextFactory in mscorlib, but we can't, because // we can do very little with WinRT stuff in mscorlib. // - WinRTSynchronizationContextFactoryBase factory = s_winRTContextFactory; - if (factory == null) + Func createSynchronizationContextDelegate = s_createSynchronizationContextDelegate; + if (createSynchronizationContextDelegate == null) { Type factoryType = Type.GetType("System.Threading.WinRTSynchronizationContextFactory, System.Runtime.WindowsRuntime", throwOnError: true); - s_winRTContextFactory = factory = (WinRTSynchronizationContextFactoryBase)Activator.CreateInstance(factoryType, true); + + // Create an instance delegate for the Create static method + MethodInfo createMethodInfo = factoryType.GetMethod("Create", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public); + createSynchronizationContextDelegate = (Func)Delegate.CreateDelegate(typeof(Func), createMethodInfo, /* throwOnBindFailure */ true); + + s_createSynchronizationContextDelegate = createSynchronizationContextDelegate; } - return factory; + + return s_createSynchronizationContextDelegate(dispatcher); } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs index d1bdd13ab9c1..3acb1a01d747 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/AsyncCausalityTracer.cs @@ -20,7 +20,6 @@ namespace System.Threading.Tasks { - // [FriendAccessAllowed] internal enum CausalityTraceLevel { #if FEATURE_COMINTEROP @@ -34,7 +33,6 @@ internal enum CausalityTraceLevel #endif } - // [FriendAccessAllowed] internal enum AsyncCausalityStatus { #if FEATURE_COMINTEROP @@ -80,7 +78,6 @@ internal enum CausalitySynchronousWork #endif } - // [FriendAccessAllowed] internal static class AsyncCausalityTracer { internal static void EnableToETW(bool enabled) @@ -95,7 +92,6 @@ internal static void EnableToETW(bool enabled) internal static bool LoggingOn { - // [FriendAccessAllowed] get { #if FEATURE_COMINTEROP @@ -139,7 +135,7 @@ static AsyncCausalityTracer() //COM Interface GUID {50850B26-267E-451B-A890-AB6A370245EE} Guid guid = new Guid(0x50850B26, 0x267E, 0x451B, 0xA8, 0x90, 0XAB, 0x6A, 0x37, 0x02, 0x45, 0xEE); - Object factory = null; + object factory = null; try { @@ -161,7 +157,7 @@ static AsyncCausalityTracer() } } - private static void TracingStatusChangedHandler(Object sender, WFD.TracingStatusChangedEventArgs args) + private static void TracingStatusChangedHandler(object sender, WFD.TracingStatusChangedEventArgs args) { if (args.Enabled) f_LoggingOn |= Loggers.CausalityTracer; @@ -173,8 +169,6 @@ private static void TracingStatusChangedHandler(Object sender, WFD.TracingStatus // // The TraceXXX methods should be called only if LoggingOn property returned true // - - // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.NoInlining)] // Tracking is slow path. Disable inlining for it. internal static void TraceOperationCreation(CausalityTraceLevel traceLevel, int taskId, string operationName, ulong relatedContext) { @@ -194,7 +188,6 @@ internal static void TraceOperationCreation(CausalityTraceLevel traceLevel, int #endif } - // [FriendAccessAllowed] [MethodImplAttribute(MethodImplOptions.NoInlining)] internal static void TraceOperationCompletion(CausalityTraceLevel traceLevel, int taskId, AsyncCausalityStatus status) { diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs index 1eaa85a07972..378f1e00a30e 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs @@ -396,7 +396,7 @@ public Task StartNew(Func function, CancellationToken cancella /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state) + public Task StartNew(Func function, object state) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, m_defaultCancellationToken, @@ -425,7 +425,7 @@ public Task StartNew(Func function, Object state) /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, CancellationToken cancellationToken) + public Task StartNew(Func function, object state, CancellationToken cancellationToken) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, cancellationToken, @@ -456,7 +456,7 @@ public Task StartNew(Func function, Object state, Canc /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, TaskCreationOptions creationOptions) + public Task StartNew(Func function, object state, TaskCreationOptions creationOptions) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, m_defaultCancellationToken, @@ -498,7 +498,7 @@ public Task StartNew(Func function, Object state, Task /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) + public Task StartNew(Func function, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) { return Task.StartNew(Task.InternalCurrentIfAttached(creationOptions), function, state, cancellationToken, creationOptions, InternalTaskOptions.None, scheduler); diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/IAsyncCausalityTracerStatics.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/IAsyncCausalityTracerStatics.cs index 17dd1f8bde96..a09279c06ca1 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/IAsyncCausalityTracerStatics.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/IAsyncCausalityTracerStatics.cs @@ -42,7 +42,7 @@ internal interface ITracingStatusChangedEventArgs // We need this dummy class to satisfy a QI when the TracingStatusChangedHandler // after being stored in a GIT cookie and then called by the WinRT API. This usually - // happens when calling a MAnaged WinMD which access this feature. + // happens when calling a Managed WinMD which access this feature. [ComImport] [Guid("410B7711-FF3B-477F-9C9A-D2EFDA302DC3")] [WindowsRuntimeImport] diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs index 13347ec9fb41..bd715958cd10 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/ProducerConsumerQueues.cs @@ -119,7 +119,7 @@ internal sealed class SingleProducerSingleConsumerQueue : IProducerConsumerQu /// The initial size to use for segments (in number of elements). private const int INIT_SEGMENT_SIZE = 32; // must be a power of 2 /// The maximum size to use for segments (in number of elements). - private const int MAX_SEGMENT_SIZE = 0x1000000; // this could be made as large as Int32.MaxValue / 2 + private const int MAX_SEGMENT_SIZE = 0x1000000; // this could be made as large as int.MaxValue / 2 /// The head of the linked list of segments. private volatile Segment m_head; @@ -133,7 +133,7 @@ internal SingleProducerSingleConsumerQueue() Debug.Assert(INIT_SEGMENT_SIZE > 0, "Initial segment size must be > 0."); Debug.Assert((INIT_SEGMENT_SIZE & (INIT_SEGMENT_SIZE - 1)) == 0, "Initial segment size must be a power of 2"); Debug.Assert(INIT_SEGMENT_SIZE <= MAX_SEGMENT_SIZE, "Initial segment size should be <= maximum."); - Debug.Assert(MAX_SEGMENT_SIZE < Int32.MaxValue / 2, "Max segment size * 2 must be < Int32.MaxValue, or else overflow could occur."); + Debug.Assert(MAX_SEGMENT_SIZE < int.MaxValue / 2, "Max segment size * 2 must be < int.MaxValue, or else overflow could occur."); // Initialize the queue m_head = m_tail = new Segment(INIT_SEGMENT_SIZE); diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TPLETWProvider.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TPLETWProvider.cs index 14d5fe88c482..998102085054 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TPLETWProvider.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TPLETWProvider.cs @@ -293,7 +293,7 @@ public void TaskCompleted( unsafe { EventData* eventPayload = stackalloc EventData[4]; - Int32 isExceptionalInt = IsExceptional ? 1 : 0; + int isExceptionalInt = IsExceptional ? 1 : 0; eventPayload[0].Size = sizeof(int); eventPayload[0].DataPointer = ((IntPtr)(&OriginatingTaskSchedulerID)); eventPayload[0].Reserved = 0; diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs index b9455611c892..161540a247df 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs @@ -200,17 +200,15 @@ public class Task : IThreadPoolWorkItem, IAsyncResult, IDisposable // A private flag that would be set (only) by the debugger // When true the Async Causality logging trace is enabled as well as a dictionary to relate operation ids with Tasks - // [FriendAccessAllowed] internal static bool s_asyncDebuggingEnabled; //false by default // This dictonary relates the task id, from an operation id located in the Async Causality log to the actual // task. This is to be used by the debugger ONLY. Task in this dictionary represent current active tasks. private static readonly Dictionary s_currentActiveTasks = new Dictionary(); - private static readonly Object s_activeTasksLock = new Object(); + private static readonly object s_activeTasksLock = new object(); // These methods are a way to access the dictionary both from this class and for other classes that also // activate dummy tasks. Specifically the AsyncTaskMethodBuilder and AsyncTaskMethodBuilder<> - // [FriendAccessAllowed] internal static bool AddToActiveTasks(Task task) { Debug.Assert(task != null, "Null Task objects can't be added to the ActiveTasks collection"); @@ -222,7 +220,6 @@ internal static bool AddToActiveTasks(Task task) return true; } - // [FriendAccessAllowed] internal static void RemoveFromActiveTasks(int taskId) { lock (s_activeTasksLock) @@ -668,8 +665,8 @@ private void AssignCancellationToken(CancellationToken cancellationToken, Task a // Static delegate to be used as a cancellation callback on unstarted tasks that have a valid cancellation token. // This is necessary to transition them into canceled state if their cancellation token is signalled while they are still not queued - private readonly static Action s_taskCancelCallback = new Action(TaskCancelCallback); - private static void TaskCancelCallback(Object o) + private readonly static Action s_taskCancelCallback = new Action(TaskCancelCallback); + private static void TaskCancelCallback(object o) { var targetTask = o as Task; if (targetTask == null) @@ -2726,7 +2723,7 @@ public void Wait() public bool Wait(TimeSpan timeout) { long totalMilliseconds = (long)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } @@ -3016,7 +3013,7 @@ private bool SpinWait(int millisecondsTimeout) var spinner = new SpinWait(); while (spinner.Count < spinCount) { - spinner.SpinOnce(Threading.SpinWait.Sleep1ThresholdForSpinBeforeWait); + spinner.SpinOnce(sleep1Threshold: -1); if (IsCompleted) { @@ -3585,7 +3582,7 @@ private Task ContinueWith(Action continuationAction, TaskScheduler schedul /// /// The argument is null. /// - public Task ContinueWith(Action continuationAction, Object state) + public Task ContinueWith(Action continuationAction, object state) { return ContinueWith(continuationAction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -3611,7 +3608,7 @@ public Task ContinueWith(Action continuationAction, Object state) /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Action continuationAction, Object state, CancellationToken cancellationToken) + public Task ContinueWith(Action continuationAction, object state, CancellationToken cancellationToken) { return ContinueWith(continuationAction, state, TaskScheduler.Current, cancellationToken, TaskContinuationOptions.None); } @@ -3639,7 +3636,7 @@ public Task ContinueWith(Action continuationAction, Object state, /// /// The argument is null. /// - public Task ContinueWith(Action continuationAction, Object state, TaskScheduler scheduler) + public Task ContinueWith(Action continuationAction, object state, TaskScheduler scheduler) { return ContinueWith(continuationAction, state, scheduler, default, TaskContinuationOptions.None); } @@ -3673,7 +3670,7 @@ public Task ContinueWith(Action continuationAction, Object state, /// The argument specifies an invalid value for TaskContinuationOptions. /// - public Task ContinueWith(Action continuationAction, Object state, TaskContinuationOptions continuationOptions) + public Task ContinueWith(Action continuationAction, object state, TaskContinuationOptions continuationOptions) { return ContinueWith(continuationAction, state, TaskScheduler.Current, default, continuationOptions); } @@ -3717,14 +3714,14 @@ public Task ContinueWith(Action continuationAction, Object state, /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Action continuationAction, Object state, CancellationToken cancellationToken, + public Task ContinueWith(Action continuationAction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWith(continuationAction, state, scheduler, cancellationToken, continuationOptions); } // Same as the above overload, just with a stack mark parameter. - private Task ContinueWith(Action continuationAction, Object state, TaskScheduler scheduler, + private Task ContinueWith(Action continuationAction, object state, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) { // Throw on continuation with null action @@ -3981,7 +3978,7 @@ private Task ContinueWith(Func continuationFunc /// /// The argument is null. /// - public Task ContinueWith(Func continuationFunction, Object state) + public Task ContinueWith(Func continuationFunction, object state) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); @@ -4012,7 +4009,7 @@ public Task ContinueWith(Func continuat /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Func continuationFunction, Object state, CancellationToken cancellationToken) + public Task ContinueWith(Func continuationFunction, object state, CancellationToken cancellationToken) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, cancellationToken, TaskContinuationOptions.None); } @@ -4043,7 +4040,7 @@ public Task ContinueWith(Func continuat /// /// The argument is null. /// - public Task ContinueWith(Func continuationFunction, Object state, TaskScheduler scheduler) + public Task ContinueWith(Func continuationFunction, object state, TaskScheduler scheduler) { return ContinueWith(continuationFunction, state, scheduler, default, TaskContinuationOptions.None); } @@ -4080,7 +4077,7 @@ public Task ContinueWith(Func continuat /// The argument specifies an invalid value for TaskContinuationOptions. /// - public Task ContinueWith(Func continuationFunction, Object state, TaskContinuationOptions continuationOptions) + public Task ContinueWith(Func continuationFunction, object state, TaskContinuationOptions continuationOptions) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, continuationOptions); } @@ -4127,14 +4124,14 @@ public Task ContinueWith(Func continuat /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Func continuationFunction, Object state, CancellationToken cancellationToken, + public Task ContinueWith(Func continuationFunction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWith(continuationFunction, state, scheduler, cancellationToken, continuationOptions); } // Same as the above overload, just with a stack mark parameter. - private Task ContinueWith(Func continuationFunction, Object state, TaskScheduler scheduler, + private Task ContinueWith(Func continuationFunction, object state, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) { // Throw on continuation with null function @@ -4530,7 +4527,7 @@ public static void WaitAll(params Task[] tasks) public static bool WaitAll(Task[] tasks, TimeSpan timeout) { long totalMilliseconds = (long)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } @@ -4917,7 +4914,7 @@ public static int WaitAny(params Task[] tasks) public static int WaitAny(Task[] tasks, TimeSpan timeout) { long totalMilliseconds = (long)timeout.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.timeout); } @@ -5319,7 +5316,7 @@ public static Task Run(Func> function, Cancellat /// The time span to wait before completing the returned Task /// A Task that represents the time delay /// - /// The is less than -1 or greater than Int32.MaxValue. + /// The is less than -1 or greater than int.MaxValue. /// /// /// After the specified time delay, the Task is completed in RanToCompletion state. @@ -5336,7 +5333,7 @@ public static Task Delay(TimeSpan delay) /// The cancellation token that will be checked prior to completing the returned Task /// A Task that represents the time delay /// - /// The is less than -1 or greater than Int32.MaxValue. + /// The is less than -1 or greater than int.MaxValue. /// /// /// The provided has already been disposed. @@ -5349,7 +5346,7 @@ public static Task Delay(TimeSpan delay) public static Task Delay(TimeSpan delay, CancellationToken cancellationToken) { long totalMilliseconds = (long)delay.TotalMilliseconds; - if (totalMilliseconds < -1 || totalMilliseconds > Int32.MaxValue) + if (totalMilliseconds < -1 || totalMilliseconds > int.MaxValue) { ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.delay, ExceptionResource.Task_Delay_InvalidDelay); } @@ -5422,7 +5419,7 @@ public static Task Delay(int millisecondsDelay, CancellationToken cancellationTo // ... and create our timer and make sure that it stays rooted. if (millisecondsDelay != Timeout.Infinite) // no need to create the timer if it's an infinite timeout { - promise.Timer = new TimerQueueTimer(state => ((DelayPromise)state).Complete(), promise, (uint)millisecondsDelay, Timeout.UnsignedInfinite); + promise.Timer = new TimerQueueTimer(state => ((DelayPromise)state).Complete(), promise, (uint)millisecondsDelay, Timeout.UnsignedInfinite, flowExecutionContext: false); } // Return the timer proxy task diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs index a96852a6f00d..3046bd9db88c 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskExceptionHolder.cs @@ -13,32 +13,23 @@ // Disable the "reference to volatile field not treated as volatile" error. #pragma warning disable 0420 +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Runtime.ExceptionServices; + namespace System.Threading.Tasks { - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Diagnostics; - using System.Runtime.ExceptionServices; - using System.Security; - /// /// An exception holder manages a list of exceptions for one particular task. /// It offers the ability to aggregate, but more importantly, also offers intrinsic /// support for propagating unhandled exceptions that are never observed. It does - /// this by aggregating and throwing if the holder is ever GC'd without the holder's - /// contents ever having been requested (e.g. by a Task.Wait, Task.get_Exception, etc). - /// This behavior is prominent in .NET 4 but is suppressed by default beyond that release. + /// this by aggregating and calling UnobservedTaskException event event if the holder + /// is ever GC'd without the holder's contents ever having been requested + /// (e.g. by a Task.Wait, Task.get_Exception, etc). /// internal class TaskExceptionHolder { - /// Whether we should propagate exceptions on the finalizer. - private readonly static bool s_failFastOnUnobservedException = ShouldFailFastOnUnobservedException(); - /// Whether the AppDomain has started to unload. - private static volatile bool s_domainUnloadStarted; - /// An event handler used to notify of domain unload. - private static volatile EventHandler s_adUnloadEventHandler; - /// The task with which this holder is associated. private readonly Task m_task; /// @@ -59,28 +50,6 @@ internal TaskExceptionHolder(Task task) { Debug.Assert(task != null, "Expected a non-null task."); m_task = task; - EnsureADUnloadCallbackRegistered(); - } - - private static bool ShouldFailFastOnUnobservedException() - { - return false; - } - - private static void EnsureADUnloadCallbackRegistered() - { - if (s_adUnloadEventHandler == null && - Interlocked.CompareExchange(ref s_adUnloadEventHandler, - AppDomainUnloadCallback, - null) == null) - { - AppDomain.CurrentDomain.DomainUnload += s_adUnloadEventHandler; - } - } - - private static void AppDomainUnloadCallback(object sender, EventArgs e) - { - s_domainUnloadStarted = true; } /// @@ -92,8 +61,7 @@ private static void AppDomainUnloadCallback(object sender, EventArgs e) // We need to do this filtering because all TaskExceptionHolders will be finalized during shutdown or unload // regardles of reachability of the task (i.e. even if the user code was about to observe the task's exception), // which can otherwise lead to spurious crashes during shutdown. - if (m_faultExceptions != null && !m_isHandled && - !Environment.HasShutdownStarted && !AppDomain.CurrentDomain.IsFinalizingForUnload() && !s_domainUnloadStarted) + if (m_faultExceptions != null && !m_isHandled && !Environment.HasShutdownStarted) { // We don't want to crash the finalizer thread if any ThreadAbortExceptions // occur in the list or in any nested AggregateExceptions. @@ -122,22 +90,12 @@ private static void AppDomainUnloadCallback(object sender, EventArgs e) // other finalizer, and the Task was finalized before the holder, the holder // will have been marked as handled before even getting here. - // Give users a chance to keep this exception from crashing the process - - // First, publish the unobserved exception and allow users to observe it + // Publish the unobserved exception and allow users to observe it AggregateException exceptionToThrow = new AggregateException( SR.TaskExceptionHolder_UnhandledException, m_faultExceptions); UnobservedTaskExceptionEventArgs ueea = new UnobservedTaskExceptionEventArgs(exceptionToThrow); TaskScheduler.PublishUnobservedTaskException(m_task, ueea); - - // Now, if we are still unobserved and we're configured to crash on unobserved, throw the exception. - // We need to publish the event above even if we're not going to crash, hence - // why this check doesn't come at the beginning of the method. - if (s_failFastOnUnobservedException && !ueea.m_observed) - { - throw exceptionToThrow; - } } } diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs index 94c449d4ac96..5ce41461da9c 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskFactory.cs @@ -396,7 +396,7 @@ public Task StartNew(Action action, CancellationToken cancellationToken, TaskCre /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Action action, Object state) + public Task StartNew(Action action, object state) { Task currTask = Task.InternalCurrent; return Task.InternalStartNew(currTask, action, state, m_defaultCancellationToken, GetDefaultScheduler(currTask), @@ -425,7 +425,7 @@ public Task StartNew(Action action, Object state) /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Action action, Object state, CancellationToken cancellationToken) + public Task StartNew(Action action, object state, CancellationToken cancellationToken) { Task currTask = Task.InternalCurrent; return Task.InternalStartNew(currTask, action, state, cancellationToken, GetDefaultScheduler(currTask), @@ -455,7 +455,7 @@ public Task StartNew(Action action, Object state, CancellationToken canc /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Action action, Object state, TaskCreationOptions creationOptions) + public Task StartNew(Action action, object state, TaskCreationOptions creationOptions) { Task currTask = Task.InternalCurrent; return Task.InternalStartNew(currTask, action, state, m_defaultCancellationToken, GetDefaultScheduler(currTask), @@ -496,7 +496,7 @@ public Task StartNew(Action action, Object state, TaskCreationOptions cr /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Action action, Object state, CancellationToken cancellationToken, + public Task StartNew(Action action, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) { return Task.InternalStartNew( @@ -657,7 +657,7 @@ public Task StartNew(Func function, CancellationToken /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state) + public Task StartNew(Func function, object state) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, m_defaultCancellationToken, @@ -690,7 +690,7 @@ public Task StartNew(Func function, Object st /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, CancellationToken cancellationToken) + public Task StartNew(Func function, object state, CancellationToken cancellationToken) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, cancellationToken, @@ -724,7 +724,7 @@ public Task StartNew(Func function, Object st /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, TaskCreationOptions creationOptions) + public Task StartNew(Func function, object state, TaskCreationOptions creationOptions) { Task currTask = Task.InternalCurrent; return Task.StartNew(currTask, function, state, m_defaultCancellationToken, @@ -769,7 +769,7 @@ public Task StartNew(Func function, Object st /// However, unless creation and scheduling must be separated, StartNew is the recommended approach /// for both simplicity and performance. /// - public Task StartNew(Func function, Object state, CancellationToken cancellationToken, + public Task StartNew(Func function, object state, CancellationToken cancellationToken, TaskCreationOptions creationOptions, TaskScheduler scheduler) { return Task.StartNew( diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs index e1fda2530de3..8c929eb1ea42 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/TaskScheduler.cs @@ -155,11 +155,11 @@ public abstract class TaskScheduler /// Indicates the maximum concurrency level this /// is able to support. /// - public virtual Int32 MaximumConcurrencyLevel + public virtual int MaximumConcurrencyLevel { get { - return Int32.MaxValue; + return int.MaxValue; } } @@ -389,7 +389,7 @@ public static TaskScheduler FromCurrentSynchronizationContext() /// /// Gets the unique ID for this . /// - public Int32 Id + public int Id { get { @@ -598,7 +598,7 @@ public SystemThreadingTasks_TaskSchedulerDebugView(TaskScheduler scheduler) } // returns the scheduler�s Id - public Int32 Id + public int Id { get { return m_taskScheduler.Id; } } @@ -682,7 +682,7 @@ protected override IEnumerable GetScheduledTasks() /// By default it returns 1, because a based /// scheduler only supports execution on a single thread. /// - public override Int32 MaximumConcurrencyLevel + public override int MaximumConcurrencyLevel { get { diff --git a/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs b/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs index 352572bd9084..77e032fddb8c 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Tasks/future.cs @@ -850,7 +850,7 @@ internal Task ContinueWith(Action> continuationAction, TaskSchedul /// /// The argument is null. /// - public Task ContinueWith(Action, Object> continuationAction, Object state) + public Task ContinueWith(Action, object> continuationAction, object state) { return ContinueWith(continuationAction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -877,7 +877,7 @@ public Task ContinueWith(Action, Object> continuationAction, Objec /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Action, Object> continuationAction, Object state, CancellationToken cancellationToken) + public Task ContinueWith(Action, object> continuationAction, object state, CancellationToken cancellationToken) { return ContinueWith(continuationAction, state, TaskScheduler.Current, cancellationToken, TaskContinuationOptions.None); } @@ -906,7 +906,7 @@ public Task ContinueWith(Action, Object> continuationAction, Objec /// /// The argument is null. /// - public Task ContinueWith(Action, Object> continuationAction, Object state, TaskScheduler scheduler) + public Task ContinueWith(Action, object> continuationAction, object state, TaskScheduler scheduler) { return ContinueWith(continuationAction, state, scheduler, default, TaskContinuationOptions.None); } @@ -940,7 +940,7 @@ public Task ContinueWith(Action, Object> continuationAction, Objec /// The argument specifies an invalid value for TaskContinuationOptions. /// - public Task ContinueWith(Action, Object> continuationAction, Object state, TaskContinuationOptions continuationOptions) + public Task ContinueWith(Action, object> continuationAction, object state, TaskContinuationOptions continuationOptions) { return ContinueWith(continuationAction, state, TaskScheduler.Current, default, continuationOptions); } @@ -984,14 +984,14 @@ public Task ContinueWith(Action, Object> continuationAction, Objec /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Action, Object> continuationAction, Object state, CancellationToken cancellationToken, + public Task ContinueWith(Action, object> continuationAction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWith(continuationAction, state, scheduler, cancellationToken, continuationOptions); } // Same as the above overload, only with a stack mark. - internal Task ContinueWith(Action, Object> continuationAction, Object state, TaskScheduler scheduler, CancellationToken cancellationToken, + internal Task ContinueWith(Action, object> continuationAction, object state, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) { if (continuationAction == null) @@ -1262,7 +1262,7 @@ internal Task ContinueWith(Func, TNewResul /// /// The argument is null. /// - public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state) + public Task ContinueWith(Func, object, TNewResult> continuationFunction, object state) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, TaskContinuationOptions.None); } @@ -1292,7 +1292,7 @@ public Task ContinueWith(Func, Object, TNe /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, + public Task ContinueWith(Func, object, TNewResult> continuationFunction, object state, CancellationToken cancellationToken) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, cancellationToken, TaskContinuationOptions.None); @@ -1324,7 +1324,7 @@ public Task ContinueWith(Func, Object, TNe /// /// The argument is null. /// - public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, + public Task ContinueWith(Func, object, TNewResult> continuationFunction, object state, TaskScheduler scheduler) { return ContinueWith(continuationFunction, state, scheduler, default, TaskContinuationOptions.None); @@ -1368,7 +1368,7 @@ public Task ContinueWith(Func, Object, TNe /// The argument specifies an invalid value for TaskContinuationOptions. /// - public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, + public Task ContinueWith(Func, object, TNewResult> continuationFunction, object state, TaskContinuationOptions continuationOptions) { return ContinueWith(continuationFunction, state, TaskScheduler.Current, default, continuationOptions); @@ -1423,14 +1423,14 @@ public Task ContinueWith(Func, Object, TNe /// The provided CancellationToken /// has already been disposed. /// - public Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, + public Task ContinueWith(Func, object, TNewResult> continuationFunction, object state, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions, TaskScheduler scheduler) { return ContinueWith(continuationFunction, state, scheduler, cancellationToken, continuationOptions); } // Same as the above overload, just with a stack mark. - internal Task ContinueWith(Func, Object, TNewResult> continuationFunction, Object state, + internal Task ContinueWith(Func, object, TNewResult> continuationFunction, object state, TaskScheduler scheduler, CancellationToken cancellationToken, TaskContinuationOptions continuationOptions) { if (continuationFunction == null) diff --git a/src/System.Private.CoreLib/src/System/Threading/Thread.cs b/src/System.Private.CoreLib/src/System/Threading/Thread.cs index 14e6ecb16792..0fea39c7ef10 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Thread.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Thread.cs @@ -29,12 +29,12 @@ namespace System.Threading using System.Runtime.Versioning; using System.Diagnostics; - internal delegate Object InternalCrossContextDelegate(Object[] args); + internal delegate object InternalCrossContextDelegate(object[] args); internal class ThreadHelper { private Delegate _start; - private Object _startArg = null; + private object _startArg = null; private ExecutionContext _executionContext = null; internal ThreadHelper(Delegate start) { @@ -48,7 +48,7 @@ internal void SetExecutionContextHelper(ExecutionContext ec) internal static ContextCallback _ccb = new ContextCallback(ThreadStart_Context); - private static void ThreadStart_Context(Object state) + private static void ThreadStart_Context(object state) { ThreadHelper t = (ThreadHelper)state; if (t._start is ThreadStart) @@ -68,7 +68,7 @@ internal void ThreadStart(object obj) ExecutionContext context = _executionContext; if (context != null) { - ExecutionContext.RunInternal(context, _ccb, (Object)this); + ExecutionContext.RunInternal(context, _ccb, (object)this); } else { @@ -82,7 +82,7 @@ internal void ThreadStart() ExecutionContext context = _executionContext; if (context != null) { - ExecutionContext.RunInternal(context, _ccb, (Object)this); + ExecutionContext.RunInternal(context, _ccb, (object)this); } else { @@ -111,10 +111,10 @@ internal sealed class Thread : RuntimeThread private ExecutionContext m_ExecutionContext; // this call context follows the logical thread private SynchronizationContext m_SynchronizationContext; // On CoreCLR, this is maintained separately from ExecutionContext - private String m_Name; + private string m_Name; private Delegate m_Delegate; // Delegate - private Object m_ThreadStartArg; + private object m_ThreadStartArg; /*========================================================================= ** The base implementation of Thread is all native. The following fields @@ -307,7 +307,7 @@ internal SynchronizationContext SynchronizationContext public static void Sleep(TimeSpan timeout) { long tm = (long)timeout.TotalMilliseconds; - if (tm < -1 || tm > (long)Int32.MaxValue) + if (tm < -1 || tm > (long)int.MaxValue) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); Sleep((int)tm); } @@ -503,7 +503,7 @@ internal static int GetDomainID() // Retrieves the name of the thread. // - public new String Name + public new string Name { get { @@ -523,7 +523,7 @@ internal static int GetDomainID() } [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)] - private static extern void InformThreadNameChange(ThreadHandle t, String name, int len); + private static extern void InformThreadNameChange(ThreadHandle t, string name, int len); } // End of class Thread diff --git a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.cs b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.cs index ad70726cbe7f..d9b378a2ab91 100644 --- a/src/System.Private.CoreLib/src/System/Threading/ThreadPool.cs +++ b/src/System.Private.CoreLib/src/System/Threading/ThreadPool.cs @@ -697,7 +697,7 @@ private void CleanUp() // if we're in the process of shutting down or unloading the AD. In those cases, the work won't // execute anyway. And there are subtle race conditions involved there that would lead us to do the wrong // thing anyway. So we'll only clean up if this is a "normal" finalization. - if (!(Environment.HasShutdownStarted || AppDomain.CurrentDomain.IsFinalizingForUnload())) + if (!Environment.HasShutdownStarted) CleanUp(); } } @@ -864,9 +864,9 @@ WaitHandle waitObject // object to be notified when all callbacks to de } } - public delegate void WaitCallback(Object state); + public delegate void WaitCallback(object state); - public delegate void WaitOrTimerCallback(Object state, bool timedOut); // signaled or timed out + public delegate void WaitOrTimerCallback(object state, bool timedOut); // signaled or timed out // // This type is necessary because VS 2010's debugger looks for a method named _ThreadPoolWaitCallbacck.PerformWaitCallback @@ -902,7 +902,7 @@ internal abstract class QueueUserWorkItemCallbackBase : IThreadPoolWorkItem ~QueueUserWorkItemCallbackBase() { Debug.Assert( - executed != 0 || Environment.HasShutdownStarted || AppDomain.CurrentDomain.IsFinalizingForUnload(), + executed != 0 || Environment.HasShutdownStarted, "A QueueUserWorkItemCallback was never called!"); } @@ -1068,11 +1068,11 @@ internal class _ThreadPoolWaitOrTimerCallback { private WaitOrTimerCallback _waitOrTimerCallback; private ExecutionContext _executionContext; - private Object _state; + private object _state; private static readonly ContextCallback _ccbt = new ContextCallback(WaitOrTimerCallback_Context_t); private static readonly ContextCallback _ccbf = new ContextCallback(WaitOrTimerCallback_Context_f); - internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, Object state, bool compressStack) + internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, object state, bool compressStack) { _waitOrTimerCallback = waitOrTimerCallback; _state = state; @@ -1084,20 +1084,20 @@ internal _ThreadPoolWaitOrTimerCallback(WaitOrTimerCallback waitOrTimerCallback, } } - private static void WaitOrTimerCallback_Context_t(Object state) => + private static void WaitOrTimerCallback_Context_t(object state) => WaitOrTimerCallback_Context(state, timedOut: true); - private static void WaitOrTimerCallback_Context_f(Object state) => + private static void WaitOrTimerCallback_Context_f(object state) => WaitOrTimerCallback_Context(state, timedOut: false); - private static void WaitOrTimerCallback_Context(Object state, bool timedOut) + private static void WaitOrTimerCallback_Context(object state, bool timedOut) { _ThreadPoolWaitOrTimerCallback helper = (_ThreadPoolWaitOrTimerCallback)state; helper._waitOrTimerCallback(helper._state, timedOut); } // call back helper - internal static void PerformWaitOrTimerCallback(Object state, bool timedOut) + internal static void PerformWaitOrTimerCallback(object state, bool timedOut) { _ThreadPoolWaitOrTimerCallback helper = (_ThreadPoolWaitOrTimerCallback)state; Debug.Assert(helper != null, "Null state passed to PerformWaitOrTimerCallback!"); @@ -1152,7 +1152,7 @@ public static void GetAvailableThreads(out int workerThreads, out int completion public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) @@ -1164,7 +1164,7 @@ public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws Regis public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) @@ -1176,7 +1176,7 @@ public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws private static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, uint millisecondsTimeOutInterval, bool executeOnlyOnce, // NOTE: we do not allow other options that allow the callback to be queued as an APC bool compressStack @@ -1187,7 +1187,7 @@ bool compressStack if (callBack != null) { _ThreadPoolWaitOrTimerCallback callBackHelper = new _ThreadPoolWaitOrTimerCallback(callBack, state, compressStack); - state = (Object)callBackHelper; + state = (object)callBackHelper; // call SetWaitObject before native call so that waitObject won't be closed before threadpoolmgr registration // this could occur if callback were to fire before SetWaitObject does its addref registeredWaitHandle.SetWaitObject(waitObject); @@ -1209,59 +1209,59 @@ bool compressStack public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, int millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, true); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, int millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, false); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } public static RegisteredWaitHandle RegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, long millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, true); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, true); } public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( // throws RegisterWaitException WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, long millisecondsTimeOutInterval, bool executeOnlyOnce // NOTE: we do not allow other options that allow the callback to be queued as an APC ) { if (millisecondsTimeOutInterval < -1) throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, false); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)millisecondsTimeOutInterval, executeOnlyOnce, false); } public static RegisteredWaitHandle RegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, TimeSpan timeout, bool executeOnlyOnce ) @@ -1269,15 +1269,15 @@ bool executeOnlyOnce long tm = (long)timeout.TotalMilliseconds; if (tm < -1) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - if (tm > (long)Int32.MaxValue) + if (tm > (long)int.MaxValue) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, true); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)tm, executeOnlyOnce, true); } public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject( WaitHandle waitObject, WaitOrTimerCallback callBack, - Object state, + object state, TimeSpan timeout, bool executeOnlyOnce ) @@ -1285,9 +1285,9 @@ bool executeOnlyOnce long tm = (long)timeout.TotalMilliseconds; if (tm < -1) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - if (tm > (long)Int32.MaxValue) + if (tm > (long)int.MaxValue) throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal); - return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, false); + return RegisterWaitForSingleObject(waitObject, callBack, state, (uint)tm, executeOnlyOnce, false); } public static bool QueueUserWorkItem(WaitCallback callBack) => @@ -1333,7 +1333,7 @@ public static bool QueueUserWorkItem(Action callBack, TState sta return true; } - public static bool UnsafeQueueUserWorkItem(WaitCallback callBack, Object state) + public static bool UnsafeQueueUserWorkItem(WaitCallback callBack, object state) { if (callBack == null) { @@ -1507,7 +1507,7 @@ internal static void NotifyWorkItemProgress() [MethodImplAttribute(MethodImplOptions.InternalCall)] private static extern IntPtr RegisterWaitForSingleObjectNative( WaitHandle waitHandle, - Object state, + object state, uint timeOutInterval, bool executeOnlyOnce, RegisteredWaitHandle registeredWaitHandle diff --git a/src/System.Private.CoreLib/src/System/Threading/Timer.cs b/src/System.Private.CoreLib/src/System/Threading/Timer.cs index a58c2883bfcf..b7e0cfb10e3b 100644 --- a/src/System.Private.CoreLib/src/System/Threading/Timer.cs +++ b/src/System.Private.CoreLib/src/System/Threading/Timer.cs @@ -17,7 +17,7 @@ namespace System.Threading { - public delegate void TimerCallback(Object state); + public delegate void TimerCallback(object state); // // TimerQueue maintains a list of active timers in this AppDomain. We use a single native timer, supplied by the VM, @@ -424,7 +424,7 @@ internal sealed class TimerQueueTimer : IThreadPoolWorkItem // Info about the user's callback // private readonly TimerCallback m_timerCallback; - private readonly Object m_state; + private readonly object m_state; private readonly ExecutionContext m_executionContext; @@ -440,13 +440,16 @@ internal sealed class TimerQueueTimer : IThreadPoolWorkItem private volatile WaitHandle m_notifyWhenNoCallbacksRunning; - internal TimerQueueTimer(TimerCallback timerCallback, object state, uint dueTime, uint period) + internal TimerQueueTimer(TimerCallback timerCallback, object state, uint dueTime, uint period, bool flowExecutionContext) { m_timerCallback = timerCallback; m_state = state; m_dueTime = Timeout.UnsignedInfinite; m_period = Timeout.UnsignedInfinite; - m_executionContext = ExecutionContext.Capture(); + if (flowExecutionContext) + { + m_executionContext = ExecutionContext.Capture(); + } m_associatedTimerQueue = TimerQueue.Instances[RuntimeThread.GetCurrentProcessorId() % TimerQueue.Instances.Length]; // @@ -589,7 +592,7 @@ void IThreadPoolWorkItem.MarkAborted(ThreadAbortException tae) { } internal void SignalNoCallbacksRunning() { - Win32Native.SetEvent(m_notifyWhenNoCallbacksRunning.SafeWaitHandle); + Interop.Kernel32.SetEvent(m_notifyWhenNoCallbacksRunning.SafeWaitHandle); } internal void CallCallback() @@ -647,7 +650,7 @@ public TimerHolder(TimerQueueTimer timer) // Note that in either case, the Timer still won't fire, because ThreadPool threads won't be // allowed to run in this AppDomain. // - if (Environment.HasShutdownStarted || AppDomain.CurrentDomain.IsFinalizingForUnload()) + if (Environment.HasShutdownStarted) return; m_timer.Close(); @@ -670,25 +673,34 @@ public bool Close(WaitHandle notifyObject) public sealed class Timer : MarshalByRefObject, IDisposable { - private const UInt32 MAX_SUPPORTED_TIMEOUT = (uint)0xfffffffe; + private const uint MAX_SUPPORTED_TIMEOUT = (uint)0xfffffffe; private TimerHolder m_timer; public Timer(TimerCallback callback, - Object state, + object state, int dueTime, - int period) + int period) : + this(callback, state, dueTime, period, flowExecutionContext: true) + { + } + + internal Timer(TimerCallback callback, + object state, + int dueTime, + int period, + bool flowExecutionContext) { if (dueTime < -1) throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); if (period < -1) throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period); + TimerSetup(callback, state, (uint)dueTime, (uint)period, flowExecutionContext); } public Timer(TimerCallback callback, - Object state, + object state, TimeSpan dueTime, TimeSpan period) { @@ -704,20 +716,20 @@ public Timer(TimerCallback callback, if (periodTm > MAX_SUPPORTED_TIMEOUT) throw new ArgumentOutOfRangeException(nameof(periodTm), SR.ArgumentOutOfRange_PeriodTooLarge); - TimerSetup(callback, state, (UInt32)dueTm, (UInt32)periodTm); + TimerSetup(callback, state, (uint)dueTm, (uint)periodTm); } [CLSCompliant(false)] public Timer(TimerCallback callback, - Object state, - UInt32 dueTime, - UInt32 period) + object state, + uint dueTime, + uint period) { TimerSetup(callback, state, dueTime, period); } public Timer(TimerCallback callback, - Object state, + object state, long dueTime, long period) { @@ -729,7 +741,7 @@ public Timer(TimerCallback callback, throw new ArgumentOutOfRangeException(nameof(dueTime), SR.ArgumentOutOfRange_TimeoutTooLarge); if (period > MAX_SUPPORTED_TIMEOUT) throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge); - TimerSetup(callback, state, (UInt32)dueTime, (UInt32)period); + TimerSetup(callback, state, (uint)dueTime, (uint)period); } public Timer(TimerCallback callback) @@ -739,18 +751,19 @@ public Timer(TimerCallback callback) // for a timer to be fired before the returned value is assigned to the variable, // potentially causing the callback to reference a bogus value (if passing the timer to the callback). - TimerSetup(callback, this, (UInt32)dueTime, (UInt32)period); + TimerSetup(callback, this, (uint)dueTime, (uint)period); } private void TimerSetup(TimerCallback callback, - Object state, - UInt32 dueTime, - UInt32 period) + object state, + uint dueTime, + uint period, + bool flowExecutionContext = true) { if (callback == null) throw new ArgumentNullException(nameof(TimerCallback)); - m_timer = new TimerHolder(new TimerQueueTimer(callback, state, dueTime, period)); + m_timer = new TimerHolder(new TimerQueueTimer(callback, state, dueTime, period, flowExecutionContext)); } public bool Change(int dueTime, int period) @@ -760,7 +773,7 @@ public bool Change(int dueTime, int period) if (period < -1) throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); - return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period); + return m_timer.m_timer.Change((uint)dueTime, (uint)period); } public bool Change(TimeSpan dueTime, TimeSpan period) @@ -769,7 +782,7 @@ public bool Change(TimeSpan dueTime, TimeSpan period) } [CLSCompliant(false)] - public bool Change(UInt32 dueTime, UInt32 period) + public bool Change(uint dueTime, uint period) { return m_timer.m_timer.Change(dueTime, period); } @@ -785,7 +798,7 @@ public bool Change(long dueTime, long period) if (period > MAX_SUPPORTED_TIMEOUT) throw new ArgumentOutOfRangeException(nameof(period), SR.ArgumentOutOfRange_PeriodTooLarge); - return m_timer.m_timer.Change((UInt32)dueTime, (UInt32)period); + return m_timer.m_timer.Change((uint)dueTime, (uint)period); } public bool Dispose(WaitHandle notifyObject) diff --git a/src/System.Private.CoreLib/src/System/Threading/WaitHandle.cs b/src/System.Private.CoreLib/src/System/Threading/WaitHandle.cs index 2de388dc49cd..6f3f9d220a9f 100644 --- a/src/System.Private.CoreLib/src/System/Threading/WaitHandle.cs +++ b/src/System.Private.CoreLib/src/System/Threading/WaitHandle.cs @@ -34,7 +34,7 @@ public abstract class WaitHandle : MarshalByRefObject, IDisposable private IntPtr waitHandle; // !!! DO NOT MOVE THIS FIELD. (See defn of WAITHANDLEREF in object.h - has hard-coded access to this field.) #pragma warning restore 414 - internal volatile SafeWaitHandle safeWaitHandle; + internal volatile SafeWaitHandle _waitHandle; internal bool hasThreadAffinity; @@ -63,7 +63,7 @@ protected WaitHandle() private void Init() { - safeWaitHandle = null; + _waitHandle = null; waitHandle = InvalidHandle; hasThreadAffinity = false; } @@ -72,7 +72,7 @@ private void Init() [Obsolete("Use the SafeWaitHandle property instead.")] public virtual IntPtr Handle { - get { return safeWaitHandle == null ? InvalidHandle : safeWaitHandle.DangerousGetHandle(); } + get { return _waitHandle == null ? InvalidHandle : _waitHandle.DangerousGetHandle(); } set { if (value == InvalidHandle) @@ -83,15 +83,15 @@ public virtual IntPtr Handle // ideally do these things: // *) Expose a settable SafeHandle property on WaitHandle. // *) Expose a settable OwnsHandle property on SafeHandle. - if (safeWaitHandle != null) + if (_waitHandle != null) { - safeWaitHandle.SetHandleAsInvalid(); - safeWaitHandle = null; + _waitHandle.SetHandleAsInvalid(); + _waitHandle = null; } } else { - safeWaitHandle = new SafeWaitHandle(value, true); + _waitHandle = new SafeWaitHandle(value, true); } waitHandle = value; } @@ -101,11 +101,11 @@ public SafeWaitHandle SafeWaitHandle { get { - if (safeWaitHandle == null) + if (_waitHandle == null) { - safeWaitHandle = new SafeWaitHandle(InvalidHandle, false); + _waitHandle = new SafeWaitHandle(InvalidHandle, false); } - return safeWaitHandle; + return _waitHandle; } set @@ -120,33 +120,18 @@ public SafeWaitHandle SafeWaitHandle { if (value == null) { - safeWaitHandle = null; + _waitHandle = null; waitHandle = InvalidHandle; } else { - safeWaitHandle = value; - waitHandle = safeWaitHandle.DangerousGetHandle(); + _waitHandle = value; + waitHandle = _waitHandle.DangerousGetHandle(); } } } } - // Assembly-private version that doesn't do a security check. Reduces the - // number of link-time security checks when reading & writing to a file, - // and helps avoid a link time check while initializing security (If you - // call a Serialization method that requires security before security - // has started up, the link time check will start up security, run - // serialization code for some security attribute stuff, call into - // FileStream, which will then call Sethandle, which requires a link time - // security check.). While security has fixed that problem, we still - // don't need to do a linktime check here. - internal void SetHandleInternal(SafeWaitHandle handle) - { - safeWaitHandle = handle; - waitHandle = handle.DangerousGetHandle(); - } - public virtual bool WaitOne(int millisecondsTimeout, bool exitContext) { if (millisecondsTimeout < -1) @@ -159,7 +144,7 @@ public virtual bool WaitOne(int millisecondsTimeout, bool exitContext) public virtual bool WaitOne(TimeSpan timeout, bool exitContext) { long tm = (long)timeout.TotalMilliseconds; - if (-1 > tm || (long)Int32.MaxValue < tm) + if (-1 > tm || (long)int.MaxValue < tm) { throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } @@ -185,7 +170,7 @@ public virtual bool WaitOne(TimeSpan timeout) [SuppressMessage("Microsoft.Concurrency", "CA8001", Justification = "Reviewed for thread-safety.")] private bool WaitOne(long timeout, bool exitContext) { - return InternalWaitOne(safeWaitHandle, timeout, hasThreadAffinity, exitContext); + return InternalWaitOne(_waitHandle, timeout, hasThreadAffinity, exitContext); } internal static bool InternalWaitOne(SafeHandle waitableSafeHandle, long millisecondsTimeout, bool hasThreadAffinity, bool exitContext) @@ -207,13 +192,13 @@ internal bool WaitOneWithoutFAS() { // version of waitone without fast application switch (FAS) support // This is required to support the Wait which FAS needs (otherwise recursive dependency comes in) - if (safeWaitHandle == null) + if (_waitHandle == null) { throw new ObjectDisposedException(null, SR.ObjectDisposed_Generic); } long timeout = -1; - int ret = WaitOneNative(safeWaitHandle, (uint)timeout, hasThreadAffinity, false); + int ret = WaitOneNative(_waitHandle, (uint)timeout, hasThreadAffinity, false); if (ret == WAIT_ABANDONED) { ThrowAbandonedMutexException(); @@ -298,7 +283,7 @@ public static bool WaitAll( bool exitContext) { long tm = (long)timeout.TotalMilliseconds; - if (-1 > tm || (long)Int32.MaxValue < tm) + if (-1 > tm || (long)int.MaxValue < tm) { throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } @@ -391,7 +376,7 @@ public static int WaitAny( bool exitContext) { long tm = (long)timeout.TotalMilliseconds; - if (-1 > tm || (long)Int32.MaxValue < tm) + if (-1 > tm || (long)int.MaxValue < tm) { throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } @@ -439,7 +424,7 @@ public static bool SignalAndWait( bool exitContext) { long tm = (long)timeout.TotalMilliseconds; - if (-1 > tm || (long)Int32.MaxValue < tm) + if (-1 > tm || (long)int.MaxValue < tm) { throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1); } @@ -467,7 +452,7 @@ public static bool SignalAndWait( } //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, + int ret = SignalAndWaitOne(toSignal._waitHandle, toWaitOn._waitHandle, millisecondsTimeout, toWaitOn.hasThreadAffinity, exitContext); if (WAIT_ABANDONED == ret) @@ -508,9 +493,9 @@ public virtual void Close() protected virtual void Dispose(bool explicitDisposing) { - if (safeWaitHandle != null) + if (_waitHandle != null) { - safeWaitHandle.Close(); + _waitHandle.Close(); } } diff --git a/src/System.Private.CoreLib/src/System/ThrowHelper.cs b/src/System.Private.CoreLib/src/System/ThrowHelper.cs index 7ec7a57af535..dd9ee5073f88 100644 --- a/src/System.Private.CoreLib/src/System/ThrowHelper.cs +++ b/src/System.Private.CoreLib/src/System/ThrowHelper.cs @@ -383,11 +383,11 @@ private static string GetResourceString(ExceptionResource resource) internal static void ThrowNotSupportedExceptionIfNonNumericType() { - if (typeof(T) != typeof(Byte) && typeof(T) != typeof(SByte) && - typeof(T) != typeof(Int16) && typeof(T) != typeof(UInt16) && - typeof(T) != typeof(Int32) && typeof(T) != typeof(UInt32) && - typeof(T) != typeof(Int64) && typeof(T) != typeof(UInt64) && - typeof(T) != typeof(Single) && typeof(T) != typeof(Double)) + if (typeof(T) != typeof(byte) && typeof(T) != typeof(sbyte) && + typeof(T) != typeof(short) && typeof(T) != typeof(ushort) && + typeof(T) != typeof(int) && typeof(T) != typeof(uint) && + typeof(T) != typeof(long) && typeof(T) != typeof(ulong) && + typeof(T) != typeof(float) && typeof(T) != typeof(double)) { throw new NotSupportedException(SR.Arg_TypeNotSupported); } @@ -461,7 +461,6 @@ internal enum ExceptionArgument beginMethod, continuationOptions, continuationAction, - concurrencyLevel, text, callBack, type, @@ -470,7 +469,6 @@ internal enum ExceptionArgument values, task, s, - keyValuePair, input, pointer, start, @@ -576,15 +574,6 @@ internal enum ExceptionResource MemoryDisposed, Memory_OutstandingReferences, InvalidOperation_WrongAsyncResultOrEndCalledMultiple, - ConcurrentDictionary_ConcurrencyLevelMustBePositive, - ConcurrentDictionary_CapacityMustNotBeNegative, - ConcurrentDictionary_TypeOfValueIncorrect, - ConcurrentDictionary_TypeOfKeyIncorrect, - ConcurrentDictionary_KeyAlreadyExisted, - ConcurrentDictionary_ItemKeyIsNull, - ConcurrentDictionary_IndexIsNegative, - ConcurrentDictionary_ArrayNotLargeEnough, - ConcurrentDictionary_ArrayIncorrectType, ConcurrentCollection_SyncRoot_NotSupported, ArgumentOutOfRange_Enum, InvalidOperation_HandleIsNotInitialized, diff --git a/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs b/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs index 571f53e473ea..9717766f3cb3 100644 --- a/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs +++ b/src/System.Private.CoreLib/src/System/Type.CoreCLR.cs @@ -22,21 +22,21 @@ public bool IsInterface } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public static Type GetType(String typeName, bool throwOnError, bool ignoreCase) + public static Type GetType(string typeName, bool throwOnError, bool ignoreCase) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RuntimeType.GetType(typeName, throwOnError, ignoreCase, false, ref stackMark); } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public static Type GetType(String typeName, bool throwOnError) + public static Type GetType(string typeName, bool throwOnError) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RuntimeType.GetType(typeName, throwOnError, false, false, ref stackMark); } [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod - public static Type GetType(String typeName) + public static Type GetType(string typeName) { StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller; return RuntimeType.GetType(typeName, false, false, false, ref stackMark); @@ -84,7 +84,7 @@ public static Type GetType( // param progID: the progID of the class to retrieve // returns: the class object associated to the progID //// - public static Type GetTypeFromProgID(String progID, String server, bool throwOnError) + public static Type GetTypeFromProgID(string progID, string server, bool throwOnError) { return RuntimeType.GetTypeFromProgIDImpl(progID, server, throwOnError); } @@ -96,7 +96,7 @@ public static Type GetTypeFromProgID(String progID, String server, bool throwOnE // param CLSID: the CLSID of the class to retrieve // returns: the class object associated to the CLSID //// - public static Type GetTypeFromCLSID(Guid clsid, String server, bool throwOnError) + public static Type GetTypeFromCLSID(Guid clsid, string server, bool throwOnError) { return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, throwOnError); } diff --git a/src/System.Private.CoreLib/src/System/TypedReference.cs b/src/System.Private.CoreLib/src/System/TypedReference.cs index 748f2db46176..3f5d5acd4758 100644 --- a/src/System.Private.CoreLib/src/System/TypedReference.cs +++ b/src/System.Private.CoreLib/src/System/TypedReference.cs @@ -22,7 +22,7 @@ public ref struct TypedReference private IntPtr Type; [CLSCompliant(false)] - public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds) + public static TypedReference MakeTypedReference(object target, FieldInfo[] flds) { if (target == null) throw new ArgumentNullException(nameof(target)); @@ -70,7 +70,7 @@ public static TypedReference MakeTypedReference(Object target, FieldInfo[] flds) [MethodImplAttribute(MethodImplOptions.InternalCall)] // reference to TypedReference is banned, so have to pass result as pointer - private static extern unsafe void InternalMakeTypedReference(void* result, Object target, IntPtr[] flds, RuntimeType lastFieldType); + private static extern unsafe void InternalMakeTypedReference(void* result, object target, IntPtr[] flds, RuntimeType lastFieldType); public override int GetHashCode() { @@ -80,18 +80,18 @@ public override int GetHashCode() return __reftype(this).GetHashCode(); } - public override bool Equals(Object o) + public override bool Equals(object o) { throw new NotSupportedException(SR.NotSupported_NYI); } - public static unsafe Object ToObject(TypedReference value) + public static unsafe object ToObject(TypedReference value) { return InternalToObject(&value); } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern unsafe Object InternalToObject(void* value); + internal static extern unsafe object InternalToObject(void* value); internal bool IsNull { @@ -113,12 +113,12 @@ public static RuntimeTypeHandle TargetTypeToken(TypedReference value) // This may cause the type to be changed. [CLSCompliant(false)] - public static unsafe void SetTypedReference(TypedReference target, Object value) + public static unsafe void SetTypedReference(TypedReference target, object value) { InternalSetTypedReference(&target, value); } [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal static extern unsafe void InternalSetTypedReference(void* target, Object value); + internal static extern unsafe void InternalSetTypedReference(void* target, object value); } } diff --git a/src/System.Private.CoreLib/src/System/ValueType.cs b/src/System.Private.CoreLib/src/System/ValueType.cs index cd8d0e05aa9b..59d8bdd94b9c 100644 --- a/src/System.Private.CoreLib/src/System/ValueType.cs +++ b/src/System.Private.CoreLib/src/System/ValueType.cs @@ -22,7 +22,7 @@ namespace System [System.Runtime.CompilerServices.TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] public abstract class ValueType { - public override bool Equals(Object obj) + public override bool Equals(object obj) { if (null == obj) { @@ -36,8 +36,8 @@ public override bool Equals(Object obj) return false; } - Object thisObj = (Object)this; - Object thisResult, thatResult; + object thisObj = (object)this; + object thisResult, thatResult; // if there are no GC references in this object we can avoid reflection // and do a fast memcmp @@ -67,10 +67,10 @@ public override bool Equals(Object obj) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool CanCompareBits(Object obj); + private static extern bool CanCompareBits(object obj); [MethodImplAttribute(MethodImplOptions.InternalCall)] - private static extern bool FastEqualsCheck(Object a, Object b); + private static extern bool FastEqualsCheck(object a, object b); /*=================================GetHashCode================================== **Action: Our algorithm for returning the hashcode is a little bit complex. We look @@ -88,7 +88,7 @@ public override bool Equals(Object obj) [MethodImplAttribute(MethodImplOptions.InternalCall)] internal static extern int GetHashCodeOfPtr(IntPtr ptr); - public override String ToString() + public override string ToString() { return this.GetType().ToString(); } diff --git a/src/System.Private.CoreLib/src/System/Variant.cs b/src/System.Private.CoreLib/src/System/Variant.cs index 7717fc485fff..5d781476c6c5 100644 --- a/src/System.Private.CoreLib/src/System/Variant.cs +++ b/src/System.Private.CoreLib/src/System/Variant.cs @@ -27,7 +27,7 @@ internal struct Variant { //Do Not change the order of these fields. //They are mapped to the native VariantData * data structure. - private Object m_objref; + private object m_objref; private int m_data1; private int m_data2; private int m_flags; @@ -88,25 +88,25 @@ internal struct Variant internal static readonly Type[] ClassTypes = { typeof(System.Empty), typeof(void), - typeof(Boolean), - typeof(Char), - typeof(SByte), - typeof(Byte), - typeof(Int16), - typeof(UInt16), - typeof(Int32), - typeof(UInt32), - typeof(Int64), - typeof(UInt64), - typeof(Single), - typeof(Double), - typeof(String), + typeof(bool), + typeof(char), + typeof(sbyte), + typeof(byte), + typeof(short), + typeof(ushort), + typeof(int), + typeof(uint), + typeof(long), + typeof(ulong), + typeof(float), + typeof(double), + typeof(string), typeof(void), // ptr for the moment typeof(DateTime), typeof(TimeSpan), - typeof(Object), - typeof(Decimal), - typeof(Object), // Treat enum as Object + typeof(object), + typeof(decimal), + typeof(object), // Treat enum as Object typeof(System.Reflection.Missing), typeof(System.DBNull), }; @@ -127,7 +127,7 @@ internal struct Variant [MethodImplAttribute(MethodImplOptions.InternalCall)] internal extern void SetFieldsR8(double val); [MethodImplAttribute(MethodImplOptions.InternalCall)] - internal extern void SetFieldsObject(Object val); + internal extern void SetFieldsObject(object val); // Use this function instead of an ECALL - saves about 150 clock cycles // by avoiding the ecall transition and because the JIT inlines this. @@ -141,7 +141,7 @@ internal long GetI8FromVar() // Constructors // - internal Variant(int flags, Object or, int data1, int data2) + internal Variant(int flags, object or, int data1, int data2) { m_flags = flags; m_objref = or; @@ -153,7 +153,7 @@ public Variant(bool val) { m_objref = null; m_flags = CV_BOOLEAN; - m_data1 = (val) ? Boolean.True : Boolean.False; + m_data1 = (val) ? bool.True : bool.False; m_data2 = 0; } @@ -257,15 +257,15 @@ public Variant(DateTime val) m_data2 = (int)(ticks >> 32); } - public Variant(Decimal val) + public Variant(decimal val) { - m_objref = (Object)val; + m_objref = (object)val; m_flags = CV_DECIMAL; m_data1 = 0; m_data2 = 0; } - public Variant(Object obj) + public Variant(object obj) { m_data1 = 0; m_data2 = 0; @@ -282,7 +282,7 @@ public Variant(Object obj) return; } - if (obj is String) + if (obj is string) { m_flags = CV_STRING; m_objref = obj; @@ -330,19 +330,19 @@ public Variant(Object obj) else if (obj is ErrorWrapper) { vt = VarEnum.VT_ERROR; - obj = (Object)(((ErrorWrapper)obj).ErrorCode); + obj = (object)(((ErrorWrapper)obj).ErrorCode); Debug.Assert(obj != null, "obj != null"); } else if (obj is CurrencyWrapper) { vt = VarEnum.VT_CY; - obj = (Object)(((CurrencyWrapper)obj).WrappedObject); + obj = (object)(((CurrencyWrapper)obj).WrappedObject); Debug.Assert(obj != null, "obj != null"); } else if (obj is BStrWrapper) { vt = VarEnum.VT_BSTR; - obj = (Object)(((BStrWrapper)obj).WrappedObject); + obj = (object)(((BStrWrapper)obj).WrappedObject); } if (obj != null) @@ -365,36 +365,36 @@ internal int CVType } } - public Object ToObject() + public object ToObject() { switch (CVType) { case CV_EMPTY: return null; case CV_BOOLEAN: - return (Object)(m_data1 != 0); + return (object)(m_data1 != 0); case CV_I1: - return (Object)((sbyte)m_data1); + return (object)((sbyte)m_data1); case CV_U1: - return (Object)((byte)m_data1); + return (object)((byte)m_data1); case CV_CHAR: - return (Object)((char)m_data1); + return (object)((char)m_data1); case CV_I2: - return (Object)((short)m_data1); + return (object)((short)m_data1); case CV_U2: - return (Object)((ushort)m_data1); + return (object)((ushort)m_data1); case CV_I4: - return (Object)(m_data1); + return (object)(m_data1); case CV_U4: - return (Object)((uint)m_data1); + return (object)((uint)m_data1); case CV_I8: - return (Object)(GetI8FromVar()); + return (object)(GetI8FromVar()); case CV_U8: - return (Object)((ulong)GetI8FromVar()); + return (object)((ulong)GetI8FromVar()); case CV_R4: - return (Object)(GetR4FromVar()); + return (object)(GetR4FromVar()); case CV_R8: - return (Object)(GetR8FromVar()); + return (object)(GetR8FromVar()); case CV_DATETIME: return new DateTime(GetI8FromVar()); case CV_TIMESPAN: @@ -415,12 +415,12 @@ public Object ToObject() // This routine will return an boxed enum. [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern Object BoxEnum(); + private extern object BoxEnum(); // Helper code for marshaling managed objects to VARIANT's (we use // managed variants as an intermediate type. - internal static void MarshalHelperConvertObjectToVariant(Object o, ref Variant v) + internal static void MarshalHelperConvertObjectToVariant(object o, ref Variant v) { IConvertible ic = o as IConvertible; @@ -445,7 +445,7 @@ internal static void MarshalHelperConvertObjectToVariant(Object o, ref Variant v break; case TypeCode.Object: - v = new Variant((Object)o); + v = new Variant((object)o); break; case TypeCode.DBNull: @@ -520,7 +520,7 @@ internal static void MarshalHelperConvertObjectToVariant(Object o, ref Variant v // Helper code for marshaling VARIANTS to managed objects (we use // managed variants as an intermediate type. - internal static Object MarshalHelperConvertVariantToObject(ref Variant v) + internal static object MarshalHelperConvertVariantToObject(ref Variant v) { return v.ToObject(); } @@ -528,7 +528,7 @@ internal static Object MarshalHelperConvertVariantToObject(ref Variant v) // Helper code: on the back propagation path where a VT_BYREF VARIANT* // is marshaled to a "ref Object", we use this helper to force the // updated object back to the original type. - internal static void MarshalHelperCastVariant(Object pValue, int vt, ref Variant v) + internal static void MarshalHelperCastVariant(object pValue, int vt, ref Variant v) { IConvertible iv = pValue as IConvertible; if (iv == null) @@ -609,7 +609,7 @@ internal static void MarshalHelperCastVariant(Object pValue, int vt, ref Variant break; case 9: /*VT_DISPATCH*/ - v = new Variant(new DispatchWrapper((Object)iv)); + v = new Variant(new DispatchWrapper((object)iv)); break; case 10: /*VT_ERROR*/ @@ -621,11 +621,11 @@ internal static void MarshalHelperCastVariant(Object pValue, int vt, ref Variant break; case 12: /*VT_VARIANT*/ - v = new Variant((Object)iv); + v = new Variant((object)iv); break; case 13: /*VT_UNKNOWN*/ - v = new Variant(new UnknownWrapper((Object)iv)); + v = new Variant(new UnknownWrapper((object)iv)); break; case 14: /*VT_DECIMAL*/ diff --git a/src/System.Private.CoreLib/src/System/WeakReference.cs b/src/System.Private.CoreLib/src/System/WeakReference.cs index b99e3683a6f5..da0b1a284a83 100644 --- a/src/System.Private.CoreLib/src/System/WeakReference.cs +++ b/src/System.Private.CoreLib/src/System/WeakReference.cs @@ -37,14 +37,14 @@ protected WeakReference() // Creates a new WeakReference that keeps track of target. // Assumes a Short Weak Reference (ie TrackResurrection is false.) // - public WeakReference(Object target) + public WeakReference(object target) : this(target, false) { } //Creates a new WeakReference that keeps track of target. // - public WeakReference(Object target, bool trackResurrection) + public WeakReference(object target, bool trackResurrection) { Create(target, trackResurrection); } @@ -56,7 +56,7 @@ protected WeakReference(SerializationInfo info, StreamingContext context) throw new ArgumentNullException(nameof(info)); } - Object target = info.GetValue("TrackedObject", typeof(Object)); // Do not rename (binary serialization) + object target = info.GetValue("TrackedObject", typeof(object)); // Do not rename (binary serialization) bool trackResurrection = info.GetBoolean("TrackResurrection"); // Do not rename (binary serialization) Create(target, trackResurrection); @@ -83,7 +83,7 @@ public virtual bool TrackResurrection //Gets the Object stored in the handle if it's accessible. // Or sets it. // - public extern virtual Object Target + public extern virtual object Target { [MethodImplAttribute(MethodImplOptions.InternalCall)] get; @@ -106,12 +106,12 @@ public virtual void GetObjectData(SerializationInfo info, StreamingContext conte { throw new ArgumentNullException(nameof(info)); } - info.AddValue("TrackedObject", Target, typeof(Object)); // Do not rename (binary serialization) + info.AddValue("TrackedObject", Target, typeof(object)); // Do not rename (binary serialization) info.AddValue("TrackResurrection", IsTrackResurrection()); // Do not rename (binary serialization) } [MethodImplAttribute(MethodImplOptions.InternalCall)] - private extern void Create(Object target, bool trackResurrection); + private extern void Create(object target, bool trackResurrection); [MethodImplAttribute(MethodImplOptions.InternalCall)] private extern bool IsTrackResurrection(); diff --git a/src/System.Private.CoreLib/src/System/__ComObject.cs b/src/System.Private.CoreLib/src/System/__ComObject.cs index 412b763ab19e..509f7bbefb09 100644 --- a/src/System.Private.CoreLib/src/System/__ComObject.cs +++ b/src/System.Private.CoreLib/src/System/__ComObject.cs @@ -2,55 +2,41 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -/*============================================================ -** -** -** -** __ComObject is the root class for all COM wrappers. This class -** defines only the basics. This class is used for wrapping COM objects -** accessed from COM+ -** -** -===========================================================*/ - -using System; using System.Collections; -using System.Threading; using System.Runtime.InteropServices; using System.Runtime.InteropServices.WindowsRuntime; -using System.Runtime.CompilerServices; using System.Reflection; namespace System { + /// + /// __ComObject is the root class for all COM wrappers. This class defines only + /// the basics. This class is used for wrapping COM objects accessed from managed. + /// internal class __ComObject : MarshalByRefObject { - private Hashtable m_ObjectToDataMap; + private Hashtable m_ObjectToDataMap; // Do not rename (runtime relies on this name). - /*============================================================ - ** default constructor - ** can't instantiate this directly - =============================================================*/ + /// + /// Default constructor - can't instantiate this directly. + /// protected __ComObject() { } - //==================================================================== - // Overrides ToString() to make sure we call to IStringable if the - // COM object implements it in the case of weakly typed RCWs - //==================================================================== + /// + /// Overrides ToString() to make sure we call to IStringable if the COM + /// object implements it in the case of weakly typed RCWs + /// public override string ToString() { - // // Only do the IStringable cast when running under AppX for better compat // Otherwise we could do a IStringable cast in classic apps which could introduce - // a thread transition which would lead to deadlock - // + // a thread transition which would lead to deadlock. if (AppDomain.IsAppXModel()) { // Check whether the type implements IStringable. - IStringable stringableType = this as IStringable; - if (stringableType != null) + if (this is IStringable stringableType) { return stringableType.ToString(); } @@ -59,13 +45,12 @@ public override string ToString() return base.ToString(); } - //==================================================================== - // This method retrieves the data associated with the specified - // key if any such data exists for the current __ComObject. - //==================================================================== - internal Object GetData(Object key) + /// + /// Retrieves the data associated with the specified if such data exists. + /// + internal object GetData(object key) { - Object data = null; + object data = null; // Synchronize access to the map. lock (this) @@ -81,11 +66,10 @@ internal Object GetData(Object key) return data; } - //==================================================================== - // This method sets the data for the specified key on the current - // __ComObject. - //==================================================================== - internal bool SetData(Object key, Object data) + /// + /// Sets the data for the specified key on the current __ComObject. + /// + internal bool SetData(object key, object data) { bool bAdded = false; @@ -94,7 +78,9 @@ internal bool SetData(Object key, Object data) { // If the map hasn't been allocated yet, allocate it. if (m_ObjectToDataMap == null) + { m_ObjectToDataMap = new Hashtable(); + } // If there isn't already data in the map then add it. if (m_ObjectToDataMap[key] == null) @@ -107,10 +93,9 @@ internal bool SetData(Object key, Object data) return bAdded; } - //==================================================================== - // This method is called from within the EE and releases all the - // cached data for the __ComObject. - //==================================================================== + /// + /// Called from within the EE and releases all the cached data for the __ComObject. + /// internal void ReleaseAllData() { // Synchronize access to the map. @@ -119,19 +104,17 @@ internal void ReleaseAllData() // If the map hasn't been allocated, then there is nothing to do. if (m_ObjectToDataMap != null) { - foreach (Object o in m_ObjectToDataMap.Values) + foreach (object o in m_ObjectToDataMap.Values) { // Note: the value could be an object[] // We are fine for now as object[] doesn't implement IDisposable nor derive from __ComObject // If the object implements IDisposable, then call Dispose on it. - IDisposable DisposableObj = o as IDisposable; - if (DisposableObj != null) + if (o is IDisposable DisposableObj) DisposableObj.Dispose(); // If the object is a derived from __ComObject, then call Marshal.ReleaseComObject on it. - __ComObject ComObj = o as __ComObject; - if (ComObj != null) + if (o is __ComObject ComObj) Marshal.ReleaseComObject(ComObj); } @@ -140,45 +123,40 @@ internal void ReleaseAllData() } } } - - //==================================================================== - // This method is called from within the EE and is used to handle - // calls on methods of event interfaces. - //==================================================================== - internal Object GetEventProvider(RuntimeType t) + + /// + /// Called from within the EE and is used to handle calls on methods of event interfaces. + /// + internal object GetEventProvider(RuntimeType t) { // Check to see if we already have a cached event provider for this type. - Object EvProvider = GetData(t); + object provider = GetData(t); + if (provider != null) + { + return provider; + } // If we don't then we need to create one. - if (EvProvider == null) - EvProvider = CreateEventProvider(t); - - return EvProvider; + return CreateEventProvider(t); } - internal int ReleaseSelf() - { - return Marshal.InternalReleaseComObject(this); - } + internal int ReleaseSelf() => Marshal.InternalReleaseComObject(this); - internal void FinalReleaseSelf() - { - Marshal.InternalFinalReleaseComObject(this); - } + internal void FinalReleaseSelf() => Marshal.InternalFinalReleaseComObject(this); - private Object CreateEventProvider(RuntimeType t) + private object CreateEventProvider(RuntimeType t) { // Create the event provider for the specified type. - Object EvProvider = Activator.CreateInstance(t, Activator.ConstructorDefault | BindingFlags.NonPublic, null, new Object[] { this }, null); + object EvProvider = Activator.CreateInstance(t, Activator.ConstructorDefault | BindingFlags.NonPublic, null, new object[] { this }, null); // Attempt to cache the wrapper on the object. if (!SetData(t, EvProvider)) { // Dispose the event provider if it implements IDisposable. - IDisposable DisposableEvProv = EvProvider as IDisposable; - if (DisposableEvProv != null) + if (EvProvider is IDisposable DisposableEvProv) + { DisposableEvProv.Dispose(); + } // Another thead already cached the wrapper so use that one instead. EvProvider = GetData(t); diff --git a/src/System.Private.CoreLib/src/mscorlib.Friends.cs b/src/System.Private.CoreLib/src/mscorlib.Friends.cs deleted file mode 100644 index eadba9c97c1f..000000000000 --- a/src/System.Private.CoreLib/src/mscorlib.Friends.cs +++ /dev/null @@ -1,9 +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. - -using System.Runtime.CompilerServices; - -// Depends on things like WindowsRuntimeImportAttribute -[assembly: InternalsVisibleTo("System.Runtime.WindowsRuntime, PublicKey=00000000000000000400000000000000", AllInternalsVisible = false)] -[assembly: InternalsVisibleTo("System.Runtime.WindowsRuntime.UI.Xaml, PublicKey=00000000000000000400000000000000", AllInternalsVisible = false)] diff --git a/src/ToolBox/SOS/Strike/CMakeLists.txt b/src/ToolBox/SOS/Strike/CMakeLists.txt index 65c3f9585ef4..a9bd176dade8 100644 --- a/src/ToolBox/SOS/Strike/CMakeLists.txt +++ b/src/ToolBox/SOS/Strike/CMakeLists.txt @@ -38,6 +38,7 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) add_definitions(-DDBG_TARGET_64BIT) add_definitions(-DDBG_TARGET_WIN64=1) endif() + add_definitions(-DSTRIKE) remove_definitions(-DUNICODE) @@ -183,6 +184,11 @@ endif() list(APPEND SOS_SOURCES ${SOS_SOURCES_ARCH}) +# Add the DAC PAL export mapping file +if(CLR_CMAKE_PLATFORM_LINUX) + list(APPEND SOS_SOURCES ${PAL_REDEFINES_FILE}) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD) # Add linker exports file option set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE}) @@ -195,6 +201,10 @@ endif(CLR_CMAKE_PLATFORM_DARWIN) add_library_clr(sos SHARED ${SOS_SOURCES}) +if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(sos pal_redefines_file) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_UNIX) add_custom_target(sos_exports DEPENDS ${EXPORTS_FILE}) add_dependencies(sos sos_exports) diff --git a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt index e87ac8bf02e3..96aec3019bee 100644 --- a/src/ToolBox/SOS/lldbplugin/CMakeLists.txt +++ b/src/ToolBox/SOS/lldbplugin/CMakeLists.txt @@ -45,57 +45,72 @@ elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64) SET(REQUIRE_LLDBPLUGIN false) endif() -set(LLVM_HOST_DIR "$ENV{LLVM_HOME}") -set(WITH_LLDB_LIBS "${LLVM_HOST_DIR}/lib" CACHE PATH "Path to LLDB libraries") -set(WITH_LLDB_INCLUDES "${LLVM_HOST_DIR}/include" CACHE PATH "Path to LLDB headers") +if(NOT $ENV{LLVM_HOME} STREQUAL "") + set(LLDB_INCLUDE_DIR "$ENV{LLVM_HOME}/include") + set(LLDB_LIB_DIR "$ENV{LLVM_HOME}/lib") +else() + if(NOT $ENV{LLDB_INCLUDE_DIR} STREQUAL "") + set(LLDB_INCLUDE_DIR "$ENV{LLDB_INCLUDE_DIR}") + endif() + if(NOT $ENV{LLDB_LIB_DIR} STREQUAL "") + set(LLDB_LIB_DIR "$ENV{LLDB_LIB_DIR}") + endif() +endif() if(NOT ENABLE_LLDBPLUGIN) return() endif() -if (CLR_CMAKE_PLATFORM_DARWIN) +if(NOT $ENV{LLDB_LIB} STREQUAL "") + set(LLDB_LIB "$ENV{LLDB_LIB}") +else() # Check for LLDB library - find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) - find_library(LLDB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) - if(LLDB STREQUAL LLDB-NOTFOUND) + if(CLR_CMAKE_PLATFORM_DARWIN) + find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATHS "${WITH_LLDB_LIBS}" PATH_SUFFIXES llvm NO_DEFAULT_PATH) + find_library(LLDB_LIB NAMES LLDB lldb lldb-6.0 lldb-5.0 lldb-4.0 lldb-3.9 lldb-3.8 lldb-3.7 lldb-3.6 lldb-3.5 PATH_SUFFIXES llvm) + if(LLDB_LIB STREQUAL LLDB_LIB-NOTFOUND) + if(REQUIRE_LLDBPLUGIN) + set(MESSAGE_MODE FATAL_ERROR) + else() + set(MESSAGE_MODE WARNING) + endif() + message(${MESSAGE_MODE} "Cannot find lldb library. Try installing Xcode. You may need to set LLVM_HOME, LLDB_LIB_DIR or LLDB_LIB if the build still can't find it.") + return() + endif() + endif() +endif() + +message(STATUS "LLDB_LIB: ${LLDB_LIB}") + +if(NOT $ENV{LLDB_H} STREQUAL "") + set(LLDB_H "$ENV{LLDB_H}") +else() + # Check for LLDB headers + # Multiple versions of LLDB can install side-by-side, so we need to check for lldb in various locations. + # If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "${WITH_LLDB_INCLUDES}" NO_DEFAULT_PATH) + find_path(LLDB_H "lldb/API/LLDB.h") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-6.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-5.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-4.0/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.9/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.8/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.7/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.6/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include") + #FreeBSD + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm39/include") + find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm38/include") + + if(LLDB_H STREQUAL LLDB_H-NOTFOUND) if(REQUIRE_LLDBPLUGIN) set(MESSAGE_MODE FATAL_ERROR) else() set(MESSAGE_MODE WARNING) endif() - message(${MESSAGE_MODE} "Cannot find lldb-3.5, lldb-3.6, lldb-3.8, lldb-3.9, lldb-4.0, lldb-5.0 or lldb-6.0. Try installing liblldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") - + message(${MESSAGE_MODE} "Cannot find LLDB.h Try installing lldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME or LLDB_INCLUDE_DIR if the build still can't find it.") return() endif() - - message(STATUS "LLDB: ${LLDB}") -endif() - -# Check for LLDB headers -# Multiple versions of LLDB can install side-by-side, so we need to check for lldb in various locations. -# If the file in a directory is found the result is stored in the variable and the search will not be repeated unless the variable is cleared. -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "${WITH_LLDB_INCLUDES}" NO_DEFAULT_PATH) -find_path(LLDB_H "lldb/API/LLDB.h") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-6.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-5.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-4.0/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.9/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.8/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.7/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.6/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/lib/llvm-3.5/include") -#FreeBSD -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm39/include") -find_path(LLDB_H "lldb/API/LLDB.h" PATHS "/usr/local/llvm38/include") - -if(LLDB_H STREQUAL LLDB_H-NOTFOUND) - if(REQUIRE_LLDBPLUGIN) - set(MESSAGE_MODE FATAL_ERROR) - else() - set(MESSAGE_MODE WARNING) - endif() - message(${MESSAGE_MODE} "Cannot find LLDB.h Try installing lldb-3.9-dev (or the appropriate package for your platform). You may need to set LLVM_HOME if the build still can't find it.") - return() endif() message(STATUS "LLDB_H: ${LLDB_H}") @@ -121,7 +136,7 @@ _add_library(sosplugin SHARED ${SOURCES}) add_dependencies(sosplugin sos) if (CLR_CMAKE_PLATFORM_DARWIN) - target_link_libraries(sosplugin ${LLDB}) + target_link_libraries(sosplugin ${LLDB_LIB}) endif() # add the install targets diff --git a/src/ToolBox/superpmi/mcs/verbremovedup.cpp b/src/ToolBox/superpmi/mcs/verbremovedup.cpp index cd2ead06327e..64d5fa435b71 100644 --- a/src/ToolBox/superpmi/mcs/verbremovedup.cpp +++ b/src/ToolBox/superpmi/mcs/verbremovedup.cpp @@ -11,8 +11,8 @@ #include "methodcontextiterator.h" // We use a hash to limit the number of comparisons we need to do. - //The first level key to our hash map is ILCodeSize and the second - //level map key is just an index and the value is an existing MC Hash. +// The first level key to our hash map is ILCodeSize and the second +// level map key is just an index and the value is an existing MC Hash. LightWeightMap*>* inFile = nullptr; diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjithostimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjithostimpl.h index aac68421e737..b05046f04c35 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjithostimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjithostimpl.h @@ -23,15 +23,11 @@ // against the interface declaration. public: -// Allocate memory of the given size in bytes. All bytes of the returned block -// must be initialized to zero. If `usePageAllocator` is true, the implementation -// should use an allocator that deals in OS pages if one exists. -void* allocateMemory(size_t size, bool usePageAllocator = false); - -// Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. The -// value of the `usePageAllocator` parameter must match the value that was -// provided to the call to used to allocate the memory. -void freeMemory(void* block, bool usePageAllocator = false); +// Allocate memory of the given size in bytes. +void* allocateMemory(size_t size); + +// Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. +void freeMemory(void* block); // Return an integer config value for the given key, if any exists. int getIntConfigValue(const wchar_t* name, int defaultValue); diff --git a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h index 61d1785b51c9..6645626c240f 100644 --- a/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h +++ b/src/ToolBox/superpmi/superpmi-shared/icorjitinfoimpl.h @@ -906,6 +906,8 @@ void MethodCompileComplete(CORINFO_METHOD_HANDLE methHnd); // return a thunk that will copy the arguments for the given signature. void* getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTailCallSpecialHandling flags); +bool convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert); + // return memory manager that the JIT can use to allocate a regular memory IEEMemoryManager* getMemoryManager(); diff --git a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h index 6a8b77e246a4..df9f43587ae2 100644 --- a/src/ToolBox/superpmi/superpmi-shared/lwmlist.h +++ b/src/ToolBox/superpmi/superpmi-shared/lwmlist.h @@ -35,6 +35,7 @@ LWM(CompareTypesForCast, DLDL, DWORD) LWM(CompareTypesForEquality, DLDL, DWORD) LWM(CompileMethod, DWORD, Agnostic_CompileMethod) LWM(ConstructStringLiteral, DLD, DLD) +LWM(ConvertPInvokeCalliToCall, DLD, DWORDLONG) LWM(EmbedClassHandle, DWORDLONG, DLDL) LWM(EmbedFieldHandle, DWORDLONG, DLDL) LWM(EmbedGenericHandle, Agnostic_EmbedGenericHandle, Agnostic_CORINFO_GENERICHANDLE_RESULT) diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp index aa806c31df8f..97be26fc8d82 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.cpp @@ -2436,6 +2436,41 @@ InfoAccessType MethodContext::repConstructStringLiteral(CORINFO_MODULE_HANDLE mo return (InfoAccessType)temp2.B; } +void MethodContext::recConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert, bool result) +{ + if (ConvertPInvokeCalliToCall == nullptr) + ConvertPInvokeCalliToCall = new LightWeightMap(); + + DLD key; + ZeroMemory(&key, sizeof(DLD)); // We use the input structs as a key and use memcmp to compare.. so we need to zero + // out padding too + key.A = (DWORDLONG)pResolvedToken->tokenScope; + key.B = (DWORD)pResolvedToken->token; + + DWORDLONG value = (DWORDLONG)(result ? pResolvedToken->hMethod : 0); + + ConvertPInvokeCalliToCall->Add(key, value); + DEBUG_REC(dmpConvertPInvokeCalliToCall(key, value)); +} +void MethodContext::dmpConvertPInvokeCalliToCall(DLD key, DWORDLONG value) +{ + printf("ConvertPInvokeCalliToCall key mod-%016llX tok-%08X, value %016llX", key.A, key.B, value); +} +bool MethodContext::repConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert) +{ + DLD key; + ZeroMemory(&key, sizeof(DLD)); // We use the input structs as a key and use memcmp to compare.. so we need to zero + // out padding too + key.A = (DWORDLONG)pResolvedToken->tokenScope; + key.B = (DWORD)pResolvedToken->token; + + DWORDLONG value = ConvertPInvokeCalliToCall->Get(key); + DEBUG_REP(dmpGetArgType(key, value)); + + pResolvedToken->hMethod = (CORINFO_METHOD_HANDLE)value; + return value != 0; +} + void MethodContext::recEmptyStringLiteral(void** pValue, InfoAccessType result) { if (EmptyStringLiteral == nullptr) @@ -4327,7 +4362,8 @@ void MethodContext::dmpCanInlineTypeCheckWithObjectVTable(DWORDLONG key, DWORD v } BOOL MethodContext::repCanInlineTypeCheckWithObjectVTable(CORINFO_CLASS_HANDLE cls) { - AssertCodeMsg(CanInlineTypeCheckWithObjectVTable != nullptr, EXCEPTIONCODE_MC, "No map for CanInlineTypeCheckWithObjectVTable"); + AssertCodeMsg(CanInlineTypeCheckWithObjectVTable != nullptr, EXCEPTIONCODE_MC, + "No map for CanInlineTypeCheckWithObjectVTable"); return (BOOL)CanInlineTypeCheckWithObjectVTable->Get((DWORDLONG)cls); } diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h index b7f19a345a0b..739c1b2c0241 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontext.h +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontext.h @@ -805,6 +805,10 @@ class MethodContext void dmpConstructStringLiteral(DLD key, DLD value); InfoAccessType repConstructStringLiteral(CORINFO_MODULE_HANDLE module, mdToken metaTok, void** ppValue); + void recConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert, bool result); + void dmpConvertPInvokeCalliToCall(DLD key, DWORDLONG value); + bool repConvertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert); + void recEmptyStringLiteral(void** ppValue, InfoAccessType result); void dmpEmptyStringLiteral(DWORD key, DLD value); InfoAccessType repEmptyStringLiteral(void** ppValue); @@ -1311,6 +1315,7 @@ enum mcPackets Packet_CompareTypesForEquality = 164, // Added 10/4/17 Packet_CompileMethod = 143, // retired as 141 on 2013/07/09 Packet_ConstructStringLiteral = 15, + Packet_ConvertPInvokeCalliToCall = 169, // Added 4/29/18 Packet_EmbedClassHandle = 16, Packet_EmbedFieldHandle = 17, Packet_EmbedGenericHandle = 18, diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.cpp b/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.cpp index beadcffc2512..a978fa2c2e38 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.cpp +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.cpp @@ -83,26 +83,26 @@ MethodContextReader::MethodContextReader( { this->mutex = CreateMutexA(NULL, FALSE, nullptr); - std::string tocFileName, mchFile; + std::string tocFileName, mchFileName; // First, check to see if they passed an MCH file (look for a paired MCT file) tocFileName = MethodContextReader::CheckForPairedFile(inputFileName, ".mch", ".mct"); if (!tocFileName.empty()) { - mchFile = inputFileName; + mchFileName = inputFileName; } else { // Okay, it wasn't an MCH file, let's check to see if it was an MCT file // so check for a paired MCH file instead - mchFile = MethodContextReader::CheckForPairedFile(inputFileName, ".mct", ".mch"); - if (!mchFile.empty()) + mchFileName = MethodContextReader::CheckForPairedFile(inputFileName, ".mct", ".mch"); + if (!mchFileName.empty()) { tocFileName = inputFileName; } else { - mchFile = inputFileName; + mchFileName = inputFileName; } } @@ -110,8 +110,8 @@ MethodContextReader::MethodContextReader( this->tocFile.LoadToc(tocFileName.c_str()); // we'll get here even if we don't have a valid index file - this->fileHandle = OpenFile(mchFile.c_str(), (this->hasTOC() && this->hasIndex()) ? FILE_ATTRIBUTE_NORMAL - : FILE_FLAG_SEQUENTIAL_SCAN); + this->fileHandle = OpenFile(mchFileName.c_str(), (this->hasTOC() && this->hasIndex()) ? FILE_ATTRIBUTE_NORMAL + : FILE_FLAG_SEQUENTIAL_SCAN); if (this->fileHandle != INVALID_HANDLE_VALUE) { GetFileSizeEx(this->fileHandle, (PLARGE_INTEGER) & this->fileSize); diff --git a/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.h b/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.h index e9ee45111546..ab1c69321993 100644 --- a/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.h +++ b/src/ToolBox/superpmi/superpmi-shared/methodcontextreader.h @@ -135,6 +135,13 @@ class MethodContextReader { return curMCIndex; } + + // Return should this method context be excluded from the replay or not. + bool IsMethodExcluded(MethodContext* mc) + { + // Right now it is just a stub. + return false; + } }; #pragma pack(pop) diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp index d63a8acb90f3..32cc072d683c 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/icorjitinfo.cpp @@ -1825,6 +1825,14 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo return temp; } +bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert) +{ + mc->cr->AddCall("convertPInvokeCalliToCall"); + bool result = original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert); + mc->recConvertPInvokeCalliToCall(pResolvedToken, fMustConvert, result); + return result; +} + InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue) { mc->cr->AddCall("emptyStringLiteral"); diff --git a/src/ToolBox/superpmi/superpmi-shim-collector/jithost.cpp b/src/ToolBox/superpmi/superpmi-shim-collector/jithost.cpp index fd5c46aeee40..c3df83703428 100644 --- a/src/ToolBox/superpmi/superpmi-shim-collector/jithost.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-collector/jithost.cpp @@ -19,14 +19,14 @@ void JitHost::setMethodContext(MethodContext* methodContext) this->mc = methodContext; } -void* JitHost::allocateMemory(size_t size, bool usePageAllocator) +void* JitHost::allocateMemory(size_t size) { - return wrappedHost->allocateMemory(size, usePageAllocator); + return wrappedHost->allocateMemory(size); } -void JitHost::freeMemory(void* block, bool usePageAllocator) +void JitHost::freeMemory(void* block) { - return wrappedHost->freeMemory(block, usePageAllocator); + return wrappedHost->freeMemory(block); } int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue) diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp index 1b18072f4128..8a3e80ca4c1c 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/icorjitinfo.cpp @@ -1412,6 +1412,12 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo return original_ICorJitInfo->constructStringLiteral(module, metaTok, ppValue); } +bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert) +{ + mcs->AddCall("convertPInvokeCalliToCall"); + return original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert); +} + InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue) { mcs->AddCall("emptyStringLiteral"); diff --git a/src/ToolBox/superpmi/superpmi-shim-counter/jithost.cpp b/src/ToolBox/superpmi/superpmi-shim-counter/jithost.cpp index d4efc33c690d..4b46e0f9fffc 100644 --- a/src/ToolBox/superpmi/superpmi-shim-counter/jithost.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-counter/jithost.cpp @@ -20,14 +20,14 @@ void JitHost::setMethodCallSummarizer(MethodCallSummarizer* methodCallSummarizer this->mcs = methodCallSummarizer; } -void* JitHost::allocateMemory(size_t size, bool usePageAllocator) +void* JitHost::allocateMemory(size_t size) { - return wrappedHost->allocateMemory(size, usePageAllocator); + return wrappedHost->allocateMemory(size); } -void JitHost::freeMemory(void* block, bool usePageAllocator) +void JitHost::freeMemory(void* block) { - return wrappedHost->freeMemory(block, usePageAllocator); + return wrappedHost->freeMemory(block); } int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue) diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp index ac7a6d9f30a8..90b2fdb62876 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/icorjitinfo.cpp @@ -1266,6 +1266,11 @@ InfoAccessType interceptor_ICJI::constructStringLiteral(CORINFO_MODULE_HANDLE mo return original_ICorJitInfo->constructStringLiteral(module, metaTok, ppValue); } +bool interceptor_ICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert) +{ + return original_ICorJitInfo->convertPInvokeCalliToCall(pResolvedToken, fMustConvert); +} + InfoAccessType interceptor_ICJI::emptyStringLiteral(void** ppValue) { return original_ICorJitInfo->emptyStringLiteral(ppValue); diff --git a/src/ToolBox/superpmi/superpmi-shim-simple/jithost.cpp b/src/ToolBox/superpmi/superpmi-shim-simple/jithost.cpp index 01bff37a01ec..d864c8149b30 100644 --- a/src/ToolBox/superpmi/superpmi-shim-simple/jithost.cpp +++ b/src/ToolBox/superpmi/superpmi-shim-simple/jithost.cpp @@ -14,14 +14,14 @@ JitHost::JitHost(ICorJitHost* wrappedHost) : wrappedHost(wrappedHost) { } -void* JitHost::allocateMemory(size_t size, bool usePageAllocator) +void* JitHost::allocateMemory(size_t size) { - return wrappedHost->allocateMemory(size, usePageAllocator); + return wrappedHost->allocateMemory(size); } -void JitHost::freeMemory(void* block, bool usePageAllocator) +void JitHost::freeMemory(void* block) { - return wrappedHost->freeMemory(block, usePageAllocator); + return wrappedHost->freeMemory(block); } int JitHost::getIntConfigValue(const wchar_t* key, int defaultValue) diff --git a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp index 852b1147e6d2..31be0883aaef 100644 --- a/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp +++ b/src/ToolBox/superpmi/superpmi/icorjitinfo.cpp @@ -1580,6 +1580,12 @@ void* MyICJI::getTailCallCopyArgsThunk(CORINFO_SIG_INFO* pSig, CorInfoHelperTail return jitInstance->mc->repGetTailCallCopyArgsThunk(pSig, flags); } +bool MyICJI::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN* pResolvedToken, bool fMustConvert) +{ + jitInstance->mc->cr->AddCall("convertPInvokeCalliToCall"); + return jitInstance->mc->repConvertPInvokeCalliToCall(pResolvedToken, fMustConvert); +} + // Stuff directly on ICorJitInfo // Returns extended flags for a particular compilation instance. diff --git a/src/ToolBox/superpmi/superpmi/jithost.cpp b/src/ToolBox/superpmi/superpmi/jithost.cpp index 1b9b9a338d2a..ef2d46e74431 100644 --- a/src/ToolBox/superpmi/superpmi/jithost.cpp +++ b/src/ToolBox/superpmi/superpmi/jithost.cpp @@ -51,12 +51,12 @@ JitHost::JitHost(JitInstance& jitInstance) : jitInstance(jitInstance) { } -void* JitHost::allocateMemory(size_t size, bool usePageAllocator) +void* JitHost::allocateMemory(size_t size) { return InitIEEMemoryManager(&jitInstance)->ClrVirtualAlloc(nullptr, size, 0, 0); } -void JitHost::freeMemory(void* block, bool usePageAllocator) +void JitHost::freeMemory(void* block) { InitIEEMemoryManager(&jitInstance)->ClrVirtualFree(block, 0, 0); } diff --git a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp index 70afb5ce20e0..f58ec663808a 100644 --- a/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/parallelsuperpmi.cpp @@ -195,6 +195,7 @@ void ProcessChildStdOut(const CommandLine::Options& o, int* loaded, int* jitted, int* failed, + int* excluded, int* diffs, bool* usageError) { @@ -238,44 +239,42 @@ void ProcessChildStdOut(const CommandLine::Options& o, } else if (strncmp(buff, g_AllFormatStringFixedPrefix, strlen(g_AllFormatStringFixedPrefix)) == 0) { + int childLoaded = 0, childJitted = 0, childFailed = 0, childExcluded = 0; if (o.applyDiff) { - int temp1 = 0, temp2 = 0, temp3 = 0, temp4 = 0; - int converted = sscanf_s(buff, g_AsmDiffsSummaryFormatString, &temp1, &temp2, &temp3, &temp4); - if (converted != 4) + int childDiffs = 0; + int converted = sscanf_s(buff, g_AsmDiffsSummaryFormatString, &childLoaded, &childJitted, &childFailed, + &childExcluded, &childDiffs); + if (converted != 5) { LogError("Couldn't parse status message: \"%s\"", buff); + continue; } - else - { - *loaded += temp1; - *jitted += temp2; - *failed += temp3; - *diffs += temp4; - } + *diffs += childDiffs; } else { - int temp1 = 0, temp2 = 0, temp3 = 0; - int converted = sscanf_s(buff, g_SummaryFormatString, &temp1, &temp2, &temp3); - if (converted != 3) + int converted = + sscanf_s(buff, g_SummaryFormatString, &childLoaded, &childJitted, &childFailed, &childExcluded); + if (converted != 4) { LogError("Couldn't parse status message: \"%s\"", buff); + continue; } - else - { - *loaded += temp1; - *jitted += temp2; - *failed += temp3; - *diffs = -1; - } + *diffs = -1; } + *loaded += childLoaded; + *jitted += childJitted; + *failed += childFailed; + *excluded += childExcluded; } } Cleanup: if (fp != NULL) + { fclose(fp); + } } #ifndef FEATURE_PAL // TODO-Porting: handle Ctrl-C signals gracefully on Unix @@ -604,14 +603,14 @@ int doParallelSuperPMI(CommandLine::Options& o) bool usageError = false; // variable to flag if we hit a usage error in SuperPMI - int loaded = 0, jitted = 0, failed = 0, diffs = 0; + int loaded = 0, jitted = 0, failed = 0, excluded = 0, diffs = 0; // Read the stderr files and log them as errors // Read the stdout files and parse them for counts and log any MISSING or ISSUE errors for (int i = 0; i < o.workerCount; i++) { ProcessChildStdErr(arrStdErrorPath[i]); - ProcessChildStdOut(o, arrStdOutputPath[i], &loaded, &jitted, &failed, &diffs, &usageError); + ProcessChildStdOut(o, arrStdOutputPath[i], &loaded, &jitted, &failed, &excluded, &diffs, &usageError); if (usageError) break; } diff --git a/src/ToolBox/superpmi/superpmi/superpmi.cpp b/src/ToolBox/superpmi/superpmi/superpmi.cpp index be5476e8c38f..5e80854fa865 100644 --- a/src/ToolBox/superpmi/superpmi/superpmi.cpp +++ b/src/ToolBox/superpmi/superpmi/superpmi.cpp @@ -26,8 +26,8 @@ extern int doParallelSuperPMI(CommandLine::Options& o); // There must be a single, fixed prefix common to all strings, to ease the determination of when // to parse the string fully. const char* const g_AllFormatStringFixedPrefix = "Loaded "; -const char* const g_SummaryFormatString = "Loaded %d Jitted %d FailedCompile %d"; -const char* const g_AsmDiffsSummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Diffs %d"; +const char* const g_SummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d"; +const char* const g_AsmDiffsSummaryFormatString = "Loaded %d Jitted %d FailedCompile %d Excluded %d Diffs %d"; //#define SuperPMI_ChewMemory 0x7FFFFFFF //Amount of address space to consume on startup @@ -238,6 +238,7 @@ int __cdecl main(int argc, char* argv[]) int errorCount = 0; int missingCount = 0; int index = 0; + int excludedCount = 0; st1.Start(); NearDiffer nearDiffer(o.targetArchitecture, o.useCoreDisTools); @@ -284,7 +285,17 @@ int __cdecl main(int argc, char* argv[]) loadedCount++; if (!MethodContext::Initialize(loadedCount, mcb.buff, mcb.size, &mc)) + { return (int)SpmiResult::GeneralFailure; + } + + if (reader->IsMethodExcluded(mc)) + { + excludedCount++; + LogInfo("main method %d of size %d with was excluded from the compilation.", + reader->GetMethodContextIndex(), mc->methodSize); + continue; + } if (jit == nullptr) { @@ -552,12 +563,12 @@ int __cdecl main(int argc, char* argv[]) // NOTE: these output status strings are parsed by parallelsuperpmi.cpp::ProcessChildStdOut(). if (o.applyDiff) { - LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failToReplayCount, + LogInfo(g_AsmDiffsSummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount, jittedCount - failToReplayCount - matchCount); } else { - LogInfo(g_SummaryFormatString, loadedCount, jittedCount, failToReplayCount); + LogInfo(g_SummaryFormatString, loadedCount, jittedCount, failToReplayCount, excludedCount); } st2.Stop(); diff --git a/src/binder/assembly.cpp b/src/binder/assembly.cpp index 8fcc7cf54fa9..5d3a674a55c8 100644 --- a/src/binder/assembly.cpp +++ b/src/binder/assembly.cpp @@ -20,7 +20,7 @@ namespace BINDER_SPACE { namespace { - BOOL IsPlatformArchicture(PEKIND kArchitecture) + BOOL IsPlatformArchitecture(PEKIND kArchitecture) { return ((kArchitecture != peMSIL) && (kArchitecture != peNone)); } @@ -279,7 +279,7 @@ namespace BINDER_SPACE /* static */ BOOL Assembly::IsValidArchitecture(PEKIND kArchitecture) { - if (!IsPlatformArchicture(kArchitecture)) + if (!IsPlatformArchitecture(kArchitecture)) return TRUE; return (kArchitecture == GetSystemArchitecture()); diff --git a/src/build.proj b/src/build.proj index 167172bb01a1..4f34707c4333 100644 --- a/src/build.proj +++ b/src/build.proj @@ -26,6 +26,11 @@ $(BinDir)System.Private.CoreLib.pdb + + + + wReserved = 0; - - HELPER_METHOD_FRAME_END(); -} -FCIMPLEND diff --git a/src/classlibnative/bcltype/currency.h b/src/classlibnative/bcltype/currency.h deleted file mode 100644 index a1ba64e463c2..000000000000 --- a/src/classlibnative/bcltype/currency.h +++ /dev/null @@ -1,24 +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. -// -// File: Currency.h -// - -// - -#ifndef _CURRENCY_H_ -#define _CURRENCY_H_ - -#include -#include - -class COMCurrency -{ -public: - static FCDECL2_IV(void, DoToDecimal, DECIMAL * result, CY c); -}; - -#include - -#endif // _CURRENCY_H_ diff --git a/src/classlibnative/bcltype/decimal.cpp b/src/classlibnative/bcltype/decimal.cpp deleted file mode 100644 index 729b19f33434..000000000000 --- a/src/classlibnative/bcltype/decimal.cpp +++ /dev/null @@ -1,2534 +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. -// -// File: decimal.cpp -// - -// - -#include "common.h" -#include "object.h" -#include "excep.h" -#include "frames.h" -#include "vars.hpp" -#include "decimal.h" -#include "string.h" - -LONG g_OLEAUT32_Loaded = 0; - -unsigned int DecDivMod1E9(DECIMAL* value); -void DecMul10(DECIMAL* value); -void DecAddInt32(DECIMAL* value, unsigned int i); - -#define COPYDEC(dest, src) {DECIMAL_SIGNSCALE(dest) = DECIMAL_SIGNSCALE(src); DECIMAL_HI32(dest) = DECIMAL_HI32(src); DECIMAL_LO64_SET(dest, DECIMAL_LO64_GET(src));} - -FCIMPL2_IV(void, COMDecimal::InitSingle, DECIMAL *_this, float value) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - _ASSERTE(_this != NULL); - HRESULT hr = VarDecFromR4(value, _this); - if (FAILED(hr)) - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - _this->wReserved = 0; -} -FCIMPLEND - -FCIMPL2_IV(void, COMDecimal::InitDouble, DECIMAL *_this, double value) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - _ASSERTE(_this != NULL); - HRESULT hr = VarDecFromR8(value, _this); - if (FAILED(hr)) - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - _this->wReserved = 0; -} -FCIMPLEND - - -#ifdef _MSC_VER -// C4702: unreachable code on IA64 retail -#pragma warning(push) -#pragma warning(disable:4702) -#endif -FCIMPL2(INT32, COMDecimal::DoCompare, DECIMAL * d1, DECIMAL * d2) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - HRESULT hr = VarDecCmp(d1, d2); - if (FAILED(hr) || (int)hr == VARCMP_NULL) { - _ASSERTE(!"VarDecCmp failed in Decimal::Compare"); - FCThrowRes(kOverflowException, W("Overflow_Decimal")); - } - - INT32 retVal = ((int)hr) - 1; - FC_GC_POLL_RET (); - return retVal; -} -FCIMPLEND -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -FCIMPL1(void, COMDecimal::DoFloor, DECIMAL * d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL decRes; - HRESULT hr; - hr = VarDecInt(d, &decRes); - - // VarDecInt can't overflow, as of source for OleAut32 build 4265. - // It only returns NOERROR - _ASSERTE(hr==NOERROR); - - // copy decRes into d - COPYDEC(*d, decRes) - d->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - -FCIMPL3(void, COMDecimal::DoMultiply, DECIMAL * d1, DECIMAL * d2, CLR_BOOL * overflowed) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL decRes; - - // GC is only triggered for throwing, no need to protect result - HRESULT hr = VarDecMul(d1, d2, &decRes); - if (FAILED(hr)) { - *overflowed = true; - FC_GC_POLL(); - return; - } - - // copy decRes into d1 - COPYDEC(*d1, decRes) - d1->wReserved = 0; - *overflowed = false; - FC_GC_POLL(); -} -FCIMPLEND - - -FCIMPL2(void, COMDecimal::DoMultiplyThrow, DECIMAL * d1, DECIMAL * d2) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL decRes; - - // GC is only triggered for throwing, no need to protect result - HRESULT hr = VarDecMul(d1, d2, &decRes); - if (FAILED(hr)) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - - // copy decRes into d1 - COPYDEC(*d1, decRes) - d1->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - -FCIMPL2(void, COMDecimal::DoRound, DECIMAL * d, INT32 decimals) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL decRes; - - // GC is only triggered for throwing, no need to protect result - if (decimals < 0 || decimals > 28) - FCThrowArgumentOutOfRangeVoid(W("decimals"), W("ArgumentOutOfRange_DecimalRound")); - HRESULT hr = VarDecRound(d, decimals, &decRes); - if (FAILED(hr)) - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - - // copy decRes into d - COPYDEC(*d, decRes) - d->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - -FCIMPL2_IV(void, COMDecimal::DoToCurrency, CY * result, DECIMAL d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - // GC is only triggered for throwing, no need to protect result - HRESULT hr = VarCyFromDec(&d, result); - if (FAILED(hr)) { - _ASSERTE(hr != E_INVALIDARG); - FCThrowResVoid(kOverflowException, W("Overflow_Currency")); - } -} -FCIMPLEND - -FCIMPL1(double, COMDecimal::ToDouble, FC_DECIMAL d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - double result = 0.0; - // Note: this can fail if the input is an invalid decimal, but for compatibility we should return 0 - VarR8FromDec(&d, &result); - return result; -} -FCIMPLEND - -FCIMPL1(INT32, COMDecimal::ToInt32, FC_DECIMAL d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL result; - HRESULT hr = VarDecRound(&d, 0, &result); - if (FAILED(hr)) - FCThrowRes(kOverflowException, W("Overflow_Decimal")); - - result.wReserved = 0; - - if( DECIMAL_SCALE(result) != 0) { - d = result; - VarDecFix(&d, &result); - } - - if (DECIMAL_HI32(result) == 0 && DECIMAL_MID32(result) == 0) { - INT32 i = DECIMAL_LO32(result); - if ((INT16)DECIMAL_SIGNSCALE(result) >= 0) { - if (i >= 0) return i; - } - else { - // Int32.MinValue is represented as sign being negative - // and Lo32 being 0x80000000 (-ve number). Return that as is without - // reversing the sign of the number. - if(i == 0x80000000) return i; - i = -i; - if (i <= 0) return i; - } - } - FCThrowRes(kOverflowException, W("Overflow_Int32")); -} -FCIMPLEND - -FCIMPL1(float, COMDecimal::ToSingle, FC_DECIMAL d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - float result = 0.0f; - // Note: this can fail if the input is an invalid decimal, but for compatibility we should return 0 - VarR4FromDec(&d, &result); - return result; -} -FCIMPLEND - -FCIMPL1(void, COMDecimal::DoTruncate, DECIMAL * d) -{ - FCALL_CONTRACT; - - ENSURE_OLEAUT32_LOADED(); - - DECIMAL decRes; - - VarDecFix(d, &decRes); - - // copy decRes into d - COPYDEC(*d, decRes) - d->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - -int COMDecimal::NumberToDecimal(NUMBER* number, DECIMAL* value) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(number != NULL); - _ASSERTE(value != NULL); - - DECIMAL d; - d.wReserved = 0; - DECIMAL_SIGNSCALE(d) = 0; - DECIMAL_HI32(d) = 0; - DECIMAL_LO32(d) = 0; - DECIMAL_MID32(d) = 0; - wchar_t* p = number->digits; - _ASSERT(p != NULL); - int e = number->scale; - if (!*p) { - // To avoid risking an app-compat issue with pre 4.5 (where some app was illegally using Reflection to examine the internal scale bits), we'll only force - // the scale to 0 if the scale was previously positive - if (e > 0) { - e = 0; - } - } else { - if (e > DECIMAL_PRECISION) return 0; - while ((e > 0 || (*p && e > -28)) && - (DECIMAL_HI32(d) < 0x19999999 || (DECIMAL_HI32(d) == 0x19999999 && - (DECIMAL_MID32(d) < 0x99999999 || (DECIMAL_MID32(d) == 0x99999999 && - (DECIMAL_LO32(d) < 0x99999999 || (DECIMAL_LO32(d) == 0x99999999 && *p <= '5'))))))) { - DecMul10(&d); - if (*p) DecAddInt32(&d, *p++ - '0'); - e--; - } - if (*p++ >= '5') { - bool round = true; - if (*(p-1) == '5' && *(p-2) % 2 == 0) { // Check if previous digit is even, only if the when we are unsure whether hows to do Banker's rounding - // For digits > 5 we will be roundinp up anyway. - int count = 20; // Look at the next 20 digits to check to round - while (*p == '0' && count != 0) { - p++; - count--; - } - if (*p == '\0' || count == 0) - round = false;// Do nothing - } - - if (round) { - DecAddInt32(&d, 1); - if ((DECIMAL_HI32(d) | DECIMAL_MID32(d) | DECIMAL_LO32(d)) == 0) { - DECIMAL_HI32(d) = 0x19999999; - DECIMAL_MID32(d) = 0x99999999; - DECIMAL_LO32(d) = 0x9999999A; - e++; - } - } - } - } - if (e > 0) return 0; - if (e <= -DECIMAL_PRECISION) - { - // Parsing a large scale zero can give you more precision than fits in the decimal. - // This should only happen for actual zeros or very small numbers that round to zero. - DECIMAL_SIGNSCALE(d) = 0; - DECIMAL_HI32(d) = 0; - DECIMAL_LO32(d) = 0; - DECIMAL_MID32(d) = 0; - DECIMAL_SCALE(d) = (DECIMAL_PRECISION - 1); - } - else - { - DECIMAL_SCALE(d) = static_cast(-e); - } - DECIMAL_SIGN(d) = number->sign? DECIMAL_NEG: 0; - *value = d; - return 1; -} - -#if defined(_TARGET_X86_) - -#pragma warning(disable:4035) - -unsigned int DecDivMod1E9(DECIMAL* value) -{ - LIMITED_METHOD_CONTRACT - - _asm { - mov ebx,value - mov ecx,1000000000 - xor edx,edx - mov eax,[ebx+4] - div ecx - mov [ebx+4],eax - mov eax,[ebx+12] - div ecx - mov [ebx+12],eax - mov eax,[ebx+8] - div ecx - mov [ebx+8],eax - mov eax,edx - } -} - -void DecMul10(DECIMAL* value) -{ - LIMITED_METHOD_CONTRACT - - _asm { - mov ebx,value - mov eax,[ebx+8] - mov edx,[ebx+12] - mov ecx,[ebx+4] - shl eax,1 - rcl edx,1 - rcl ecx,1 - shl eax,1 - rcl edx,1 - rcl ecx,1 - add eax,[ebx+8] - adc edx,[ebx+12] - adc ecx,[ebx+4] - shl eax,1 - rcl edx,1 - rcl ecx,1 - mov [ebx+8],eax - mov [ebx+12],edx - mov [ebx+4],ecx - } -} - -void DecAddInt32(DECIMAL* value, unsigned int i) -{ - LIMITED_METHOD_CONTRACT - - _asm { - mov edx,value - mov eax,i - add dword ptr [edx+8],eax - adc dword ptr [edx+12],0 - adc dword ptr [edx+4],0 - } -} - -#pragma warning(default:4035) - -#else // !(defined(_TARGET_X86_) - -unsigned int D32DivMod1E9(unsigned int hi32, ULONG* lo32) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(lo32 != NULL); - - unsigned __int64 n = (unsigned __int64)hi32 << 32 | *lo32; - *lo32 = (unsigned int)(n / 1000000000); - return (unsigned int)(n % 1000000000); -} - -unsigned int DecDivMod1E9(DECIMAL* value) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(value != NULL); - - return D32DivMod1E9(D32DivMod1E9(D32DivMod1E9(0, - &DECIMAL_HI32(*value)), &DECIMAL_MID32(*value)), &DECIMAL_LO32(*value)); -} - -void DecShiftLeft(DECIMAL* value) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(value != NULL); - - unsigned int c0 = DECIMAL_LO32(*value) & 0x80000000? 1: 0; - unsigned int c1 = DECIMAL_MID32(*value) & 0x80000000? 1: 0; - DECIMAL_LO32(*value) <<= 1; - DECIMAL_MID32(*value) = DECIMAL_MID32(*value) << 1 | c0; - DECIMAL_HI32(*value) = DECIMAL_HI32(*value) << 1 | c1; -} - -int D32AddCarry(ULONG* value, unsigned int i) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(value != NULL); - - unsigned int v = *value; - unsigned int sum = v + i; - *value = sum; - return sum < v || sum < i? 1: 0; -} - -void DecAdd(DECIMAL* value, DECIMAL* d) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(value != NULL && d != NULL); - - if (D32AddCarry(&DECIMAL_LO32(*value), DECIMAL_LO32(*d))) { - if (D32AddCarry(&DECIMAL_MID32(*value), 1)) { - D32AddCarry(&DECIMAL_HI32(*value), 1); - } - } - if (D32AddCarry(&DECIMAL_MID32(*value), DECIMAL_MID32(*d))) { - D32AddCarry(&DECIMAL_HI32(*value), 1); - } - D32AddCarry(&DECIMAL_HI32(*value), DECIMAL_HI32(*d)); -} - -void DecMul10(DECIMAL* value) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(value != NULL); - - DECIMAL d = *value; - DecShiftLeft(value); - DecShiftLeft(value); - DecAdd(value, &d); - DecShiftLeft(value); -} - -void DecAddInt32(DECIMAL* value, unsigned int i) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(value != NULL); - - if (D32AddCarry(&DECIMAL_LO32(*value), i)) { - if (D32AddCarry(&DECIMAL_MID32(*value), 1)) { - D32AddCarry(&DECIMAL_HI32(*value), 1); - } - } -} - -#endif - -/*** -* -* Decimal Code ported from OleAut32 -* -***********************************************************************/ - -// This OleAut code is only used on 64-bit and rotor platforms. It is desiriable to continue -// to call the OleAut routines in X86 because of the performance of the hand-tuned assembly -// code and because there are currently no inconsistencies in behavior accross platforms. - -#ifndef UInt32x32To64 -#define UInt32x32To64(a, b) ((DWORDLONG)((DWORD)(a)) * (DWORDLONG)((DWORD)(b))) -#endif - -typedef union { - DWORDLONG int64; - struct { -#if BIGENDIAN - ULONG Hi; - ULONG Lo; -#else - ULONG Lo; - ULONG Hi; -#endif - } u; -} SPLIT64; - -#define OVFL_MAX_1_HI 429496729 -#define DEC_SCALE_MAX 28 -#define POWER10_MAX 9 - -#define OVFL_MAX_9_HI 4u -#define OVFL_MAX_9_MID 1266874889u -#define OVFL_MAX_9_LO 3047500985u - -#define OVFL_MAX_5_HI 42949 - - -const ULONG rgulPower10[POWER10_MAX+1] = {1, 10, 100, 1000, 10000, 100000, 1000000, - 10000000, 100000000, 1000000000}; - -struct DECOVFL -{ - ULONG Hi; - ULONG Mid; - ULONG Lo; -}; - -const DECOVFL PowerOvfl[] = { -// This is a table of the largest values that can be in the upper two -// ULONGs of a 96-bit number that will not overflow when multiplied -// by a given power. For the upper word, this is a table of -// 2^32 / 10^n for 1 <= n <= 9. For the lower word, this is the -// remaining fraction part * 2^32. 2^32 = 4294967296. -// - { 429496729u, 2576980377u, 2576980377u }, // 10^1 remainder 0.6 - { 42949672u, 4123168604u, 687194767u }, // 10^2 remainder 0.16 - { 4294967u, 1271310319u, 2645699854u }, // 10^3 remainder 0.616 - { 429496u, 3133608139u, 694066715u }, // 10^4 remainder 0.1616 - { 42949u, 2890341191u, 2216890319u }, // 10^5 remainder 0.51616 - { 4294u, 4154504685u, 2369172679u }, // 10^6 remainder 0.551616 - { 429u, 2133437386u, 4102387834u }, // 10^7 remainder 0.9551616 - { 42u, 4078814305u, 410238783u }, // 10^8 remainder 0.09991616 - { 4u, 1266874889u, 3047500985u }, // 10^9 remainder 0.709551616 -}; - - -/*** -* IncreaseScale -* -* Entry: -* rgulNum - Pointer to 96-bit number as array of ULONGs, least-sig first -* ulPwr - Scale factor to multiply by -* -* Purpose: -* Multiply the two numbers. The low 96 bits of the result overwrite -* the input. The last 32 bits of the product are the return value. -* -* Exit: -* Returns highest 32 bits of product. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG IncreaseScale(ULONG *rgulNum, ULONG ulPwr) -{ - LIMITED_METHOD_CONTRACT; - - SPLIT64 sdlTmp; - - sdlTmp.int64 = UInt32x32To64(rgulNum[0], ulPwr); - rgulNum[0] = sdlTmp.u.Lo; - sdlTmp.int64 = UInt32x32To64(rgulNum[1], ulPwr) + sdlTmp.u.Hi; - rgulNum[1] = sdlTmp.u.Lo; - sdlTmp.int64 = UInt32x32To64(rgulNum[2], ulPwr) + sdlTmp.u.Hi; - rgulNum[2] = sdlTmp.u.Lo; - return sdlTmp.u.Hi; -} - - -/*** -* SearchScale -* -* Entry: -* ulResHi - Top ULONG of quotient -* ulResMid - Middle ULONG of quotient -* ulResLo - Bottom ULONG of quotient -* iScale - Scale factor of quotient, range -DEC_SCALE_MAX to DEC_SCALE_MAX -* -* Purpose: -* Determine the max power of 10, <= 9, that the quotient can be scaled -* up by and still fit in 96 bits. -* -* Exit: -* Returns power of 10 to scale by, -1 if overflow error. -* -***********************************************************************/ - -int SearchScale(ULONG ulResHi, ULONG ulResMid, ULONG ulResLo, int iScale) -{ - WRAPPER_NO_CONTRACT; - - int iCurScale; - - // Quick check to stop us from trying to scale any more. - // - if (ulResHi > OVFL_MAX_1_HI || iScale >= DEC_SCALE_MAX) { - iCurScale = 0; - goto HaveScale; - } - - if (iScale > DEC_SCALE_MAX - 9) { - // We can't scale by 10^9 without exceeding the max scale factor. - // See if we can scale to the max. If not, we'll fall into - // standard search for scale factor. - // - iCurScale = DEC_SCALE_MAX - iScale; - if (ulResHi < PowerOvfl[iCurScale - 1].Hi) - goto HaveScale; - - if (ulResHi == PowerOvfl[iCurScale - 1].Hi) { - UpperEq: - if (ulResMid > PowerOvfl[iCurScale - 1].Mid || - (ulResMid == PowerOvfl[iCurScale - 1].Mid && ulResLo > PowerOvfl[iCurScale - 1].Lo)) { - iCurScale--; - } - goto HaveScale; - } - } - else if (ulResHi < OVFL_MAX_9_HI || (ulResHi == OVFL_MAX_9_HI && - ulResMid < OVFL_MAX_9_MID) || (ulResHi == OVFL_MAX_9_HI && ulResMid == OVFL_MAX_9_MID && ulResLo <= OVFL_MAX_9_LO)) - return 9; - - // Search for a power to scale by < 9. Do a binary search - // on PowerOvfl[]. - // - iCurScale = 5; - if (ulResHi < OVFL_MAX_5_HI) - iCurScale = 7; - else if (ulResHi > OVFL_MAX_5_HI) - iCurScale = 3; - else - goto UpperEq; - - // iCurScale is 3 or 7. - // - if (ulResHi < PowerOvfl[iCurScale - 1].Hi) - iCurScale++; - else if (ulResHi > PowerOvfl[iCurScale - 1].Hi) - iCurScale--; - else - goto UpperEq; - - // iCurScale is 2, 4, 6, or 8. - // - // In all cases, we already found we could not use the power one larger. - // So if we can use this power, it is the biggest, and we're done. If - // we can't use this power, the one below it is correct for all cases - // unless it's 10^1 -- we might have to go to 10^0 (no scaling). - // - if (ulResHi > PowerOvfl[iCurScale - 1].Hi) - iCurScale--; - - if (ulResHi == PowerOvfl[iCurScale - 1].Hi) - goto UpperEq; - -HaveScale: - // iCurScale = largest power of 10 we can scale by without overflow, - // iCurScale < 9. See if this is enough to make scale factor - // positive if it isn't already. - // - if (iCurScale + iScale < 0) - iCurScale = -1; - - return iCurScale; -} - -//*********************************************************************** -// -// Arithmetic Inlines -// - -#define Div64by32(num, den) ((ULONG)((DWORDLONG)(num) / (ULONG)(den))) -#define Mod64by32(num, den) ((ULONG)((DWORDLONG)(num) % (ULONG)(den))) - -inline DWORDLONG DivMod64by32(DWORDLONG num, ULONG den) -{ - WRAPPER_NO_CONTRACT; - - SPLIT64 sdl; - - sdl.u.Lo = Div64by32(num, den); - sdl.u.Hi = Mod64by32(num, den); - return sdl.int64; -} - -/*** -* Div128By96 -* -* Entry: -* rgulNum - Pointer to 128-bit dividend as array of ULONGs, least-sig first -* rgulDen - Pointer to 96-bit divisor. -* -* Purpose: -* Do partial divide, yielding 32-bit result and 96-bit remainder. -* Top divisor ULONG must be larger than top dividend ULONG. This is -* assured in the initial call because the divisor is normalized -* and the dividend can't be. In subsequent calls, the remainder -* is multiplied by 10^9 (max), so it can be no more than 1/4 of -* the divisor which is effectively multiplied by 2^32 (4 * 10^9). -* -* Exit: -* Remainder overwrites lower 96-bits of dividend. -* Returns quotient. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG Div128By96(ULONG *rgulNum, ULONG *rgulDen) -{ - LIMITED_METHOD_CONTRACT; - - SPLIT64 sdlQuo; - SPLIT64 sdlNum; - SPLIT64 sdlProd1; - SPLIT64 sdlProd2; - - sdlNum.u.Lo = rgulNum[0]; - sdlNum.u.Hi = rgulNum[1]; - - if (rgulNum[3] == 0 && rgulNum[2] < rgulDen[2]) - // Result is zero. Entire dividend is remainder. - // - return 0; - - // DivMod64by32 returns quotient in Lo, remainder in Hi. - // - sdlQuo.u.Lo = rgulNum[2]; - sdlQuo.u.Hi = rgulNum[3]; - sdlQuo.int64 = DivMod64by32(sdlQuo.int64, rgulDen[2]); - - // Compute full remainder, rem = dividend - (quo * divisor). - // - sdlProd1.int64 = UInt32x32To64(sdlQuo.u.Lo, rgulDen[0]); // quo * lo divisor - sdlProd2.int64 = UInt32x32To64(sdlQuo.u.Lo, rgulDen[1]); // quo * mid divisor - sdlProd2.int64 += sdlProd1.u.Hi; - sdlProd1.u.Hi = sdlProd2.u.Lo; - - sdlNum.int64 -= sdlProd1.int64; - rgulNum[2] = sdlQuo.u.Hi - sdlProd2.u.Hi; // sdlQuo.Hi is remainder - - // Propagate carries - // - if (sdlNum.int64 > ~sdlProd1.int64) { - rgulNum[2]--; - if (rgulNum[2] >= ~sdlProd2.u.Hi) - goto NegRem; - } - else if (rgulNum[2] > ~sdlProd2.u.Hi) { -NegRem: - // Remainder went negative. Add divisor back in until it's positive, - // a max of 2 times. - // - sdlProd1.u.Lo = rgulDen[0]; - sdlProd1.u.Hi = rgulDen[1]; - - for (;;) { - sdlQuo.u.Lo--; - sdlNum.int64 += sdlProd1.int64; - rgulNum[2] += rgulDen[2]; - - if (sdlNum.int64 < sdlProd1.int64) { - // Detected carry. Check for carry out of top - // before adding it in. - // - if (rgulNum[2]++ < rgulDen[2]) - break; - } - if (rgulNum[2] < rgulDen[2]) - break; // detected carry - } - } - - rgulNum[0] = sdlNum.u.Lo; - rgulNum[1] = sdlNum.u.Hi; - return sdlQuo.u.Lo; -} - - - -/*** -* Div96By32 -* -* Entry: -* rgulNum - Pointer to 96-bit dividend as array of ULONGs, least-sig first -* ulDen - 32-bit divisor. -* -* Purpose: -* Do full divide, yielding 96-bit result and 32-bit remainder. -* -* Exit: -* Quotient overwrites dividend. -* Returns remainder. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG Div96By32(ULONG *rgulNum, ULONG ulDen) -{ - LIMITED_METHOD_CONTRACT; - - SPLIT64 sdlTmp; - - sdlTmp.u.Hi = 0; - - if (rgulNum[2] != 0) - goto Div3Word; - - if (rgulNum[1] >= ulDen) - goto Div2Word; - - sdlTmp.u.Hi = rgulNum[1]; - rgulNum[1] = 0; - goto Div1Word; - -Div3Word: - sdlTmp.u.Lo = rgulNum[2]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulDen); - rgulNum[2] = sdlTmp.u.Lo; -Div2Word: - sdlTmp.u.Lo = rgulNum[1]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulDen); - rgulNum[1] = sdlTmp.u.Lo; -Div1Word: - sdlTmp.u.Lo = rgulNum[0]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulDen); - rgulNum[0] = sdlTmp.u.Lo; - return sdlTmp.u.Hi; -} - - -/*** -* Div96By64 -* -* Entry: -* rgulNum - Pointer to 96-bit dividend as array of ULONGs, least-sig first -* sdlDen - 64-bit divisor. -* -* Purpose: -* Do partial divide, yielding 32-bit result and 64-bit remainder. -* Divisor must be larger than upper 64 bits of dividend. -* -* Exit: -* Remainder overwrites lower 64-bits of dividend. -* Returns quotient. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG Div96By64(ULONG *rgulNum, SPLIT64 sdlDen) -{ - LIMITED_METHOD_CONTRACT; - - SPLIT64 sdlQuo; - SPLIT64 sdlNum; - SPLIT64 sdlProd; - - sdlNum.u.Lo = rgulNum[0]; - - if (rgulNum[2] >= sdlDen.u.Hi) { - // Divide would overflow. Assume a quotient of 2^32, and set - // up remainder accordingly. Then jump to loop which reduces - // the quotient. - // - sdlNum.u.Hi = rgulNum[1] - sdlDen.u.Lo; - sdlQuo.u.Lo = 0; - goto NegRem; - } - - // Hardware divide won't overflow - // - if (rgulNum[2] == 0 && rgulNum[1] < sdlDen.u.Hi) - // Result is zero. Entire dividend is remainder. - // - return 0; - - // DivMod64by32 returns quotient in Lo, remainder in Hi. - // - sdlQuo.u.Lo = rgulNum[1]; - sdlQuo.u.Hi = rgulNum[2]; - sdlQuo.int64 = DivMod64by32(sdlQuo.int64, sdlDen.u.Hi); - sdlNum.u.Hi = sdlQuo.u.Hi; // remainder - - // Compute full remainder, rem = dividend - (quo * divisor). - // - sdlProd.int64 = UInt32x32To64(sdlQuo.u.Lo, sdlDen.u.Lo); // quo * lo divisor - sdlNum.int64 -= sdlProd.int64; - - if (sdlNum.int64 > ~sdlProd.int64) { -NegRem: - // Remainder went negative. Add divisor back in until it's positive, - // a max of 2 times. - // - do { - sdlQuo.u.Lo--; - sdlNum.int64 += sdlDen.int64; - }while (sdlNum.int64 >= sdlDen.int64); - } - - rgulNum[0] = sdlNum.u.Lo; - rgulNum[1] = sdlNum.u.Hi; - return sdlQuo.u.Lo; -} - -// Add a 32 bit unsigned long to an array of 3 unsigned longs representing a 96 integer -// Returns FALSE if there is an overflow -BOOL Add32To96(ULONG *rgulNum, ULONG ulValue) { - rgulNum[0] += ulValue; - if (rgulNum[0] < ulValue) { - if (++rgulNum[1] == 0) { - if (++rgulNum[2] == 0) { - return FALSE; - } - } - } - return TRUE; -} - -// Adjust the quotient to deal with an overflow. We need to divide by 10, -// feed in the high bit to undo the overflow and then round as required, -void OverflowUnscale(ULONG *rgulQuo, BOOL fRemainder) { - LIMITED_METHOD_CONTRACT; - - SPLIT64 sdlTmp; - - // We have overflown, so load the high bit with a one. - sdlTmp.u.Hi = 1u; - sdlTmp.u.Lo = rgulQuo[2]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10u); - rgulQuo[2] = sdlTmp.u.Lo; - sdlTmp.u.Lo = rgulQuo[1]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10u); - rgulQuo[1] = sdlTmp.u.Lo; - sdlTmp.u.Lo = rgulQuo[0]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10u); - rgulQuo[0] = sdlTmp.u.Lo; - // The remainder is the last digit that does not fit, so we can use it to work out if we need to round up - if ((sdlTmp.u.Hi > 5) || ((sdlTmp.u.Hi == 5) && ( fRemainder || (rgulQuo[0] & 1)))) { - Add32To96(rgulQuo, 1u); - } -} - - - -//********************************************************************** -// -// VarDecDiv - Decimal Divide -// -//********************************************************************** - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:21000) // Suppress PREFast warning about overly large function -#endif - -FCIMPL2(void, COMDecimal::DoDivideThrow, DECIMAL * pdecL, DECIMAL * pdecR) -{ - FCALL_CONTRACT; - - ULONG rgulQuo[3]; - ULONG rgulQuoSave[3]; - ULONG rgulRem[4]; - ULONG rgulDivisor[3]; - ULONG ulPwr; - ULONG ulTmp; - ULONG ulTmp1; - SPLIT64 sdlTmp; - SPLIT64 sdlDivisor; - int iScale; - int iCurScale; - BOOL fUnscale; - - iScale = DECIMAL_SCALE(*pdecL) - DECIMAL_SCALE(*pdecR); - fUnscale = FALSE; - rgulDivisor[0] = DECIMAL_LO32(*pdecR); - rgulDivisor[1] = DECIMAL_MID32(*pdecR); - rgulDivisor[2] = DECIMAL_HI32(*pdecR); - - if (rgulDivisor[1] == 0 && rgulDivisor[2] == 0) { - // Divisor is only 32 bits. Easy divide. - // - if (rgulDivisor[0] == 0) - FCThrowVoid(kDivideByZeroException); - - rgulQuo[0] = DECIMAL_LO32(*pdecL); - rgulQuo[1] = DECIMAL_MID32(*pdecL); - rgulQuo[2] = DECIMAL_HI32(*pdecL); - rgulRem[0] = Div96By32(rgulQuo, rgulDivisor[0]); - - for (;;) { - if (rgulRem[0] == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale; - } - break; - } - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // We have computed a quotient based on the natural scale - // ( - ). We have a non-zero - // remainder, so now we should increase the scale if possible to - // include more quotient bits. - // - // If it doesn't cause overflow, we'll loop scaling by 10^9 and - // computing more quotient bits as long as the remainder stays - // non-zero. If scaling by that much would cause overflow, we'll - // drop out of the loop and scale by as much as we can. - // - // Scaling by 10^9 will overflow if rgulQuo[2].rgulQuo[1] >= 2^32 / 10^9 - // = 4.294 967 296. So the upper limit is rgulQuo[2] == 4 and - // rgulQuo[1] == 0.294 967 296 * 2^32 = 1,266,874,889.7+. Since - // quotient bits in rgulQuo[0] could be all 1's, then 1,266,874,888 - // is the largest value in rgulQuo[1] (when rgulQuo[2] == 4) that is - // assured not to overflow. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - ulTmp = rgulRem[0] << 1; - if (ulTmp < rgulRem[0] || (ulTmp >= rgulDivisor[0] && - (ulTmp > rgulDivisor[0] || (rgulQuo[0] & 1)))) { -RoundUp: - if (!Add32To96(rgulQuo, 1)) { - if (iScale == 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - iScale--; - OverflowUnscale(rgulQuo, TRUE); - break; - } - } - break; - } - - if (iCurScale < 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - -HaveScale: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - - - sdlTmp.int64 = DivMod64by32(UInt32x32To64(rgulRem[0], ulPwr), rgulDivisor[0]); - rgulRem[0] = sdlTmp.u.Hi; - - if (!Add32To96(rgulQuo, sdlTmp.u.Lo)) { - if (iScale == 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0)); - break; - } - } // for (;;) - } - else { - // Divisor has bits set in the upper 64 bits. - // - // Divisor must be fully normalized (shifted so bit 31 of the most - // significant ULONG is 1). Locate the MSB so we know how much to - // normalize by. The dividend will be shifted by the same amount so - // the quotient is not changed. - // - if (rgulDivisor[2] == 0) - ulTmp = rgulDivisor[1]; - else - ulTmp = rgulDivisor[2]; - - iCurScale = 0; - if (!(ulTmp & 0xFFFF0000)) { - iCurScale += 16; - ulTmp <<= 16; - } - if (!(ulTmp & 0xFF000000)) { - iCurScale += 8; - ulTmp <<= 8; - } - if (!(ulTmp & 0xF0000000)) { - iCurScale += 4; - ulTmp <<= 4; - } - if (!(ulTmp & 0xC0000000)) { - iCurScale += 2; - ulTmp <<= 2; - } - if (!(ulTmp & 0x80000000)) { - iCurScale++; - ulTmp <<= 1; - } - - // Shift both dividend and divisor left by iCurScale. - // - sdlTmp.int64 = DECIMAL_LO64_GET(*pdecL) << iCurScale; - rgulRem[0] = sdlTmp.u.Lo; - rgulRem[1] = sdlTmp.u.Hi; - sdlTmp.u.Lo = DECIMAL_MID32(*pdecL); - sdlTmp.u.Hi = DECIMAL_HI32(*pdecL); - sdlTmp.int64 <<= iCurScale; - rgulRem[2] = sdlTmp.u.Hi; - rgulRem[3] = (DECIMAL_HI32(*pdecL) >> (31 - iCurScale)) >> 1; - - sdlDivisor.u.Lo = rgulDivisor[0]; - sdlDivisor.u.Hi = rgulDivisor[1]; - sdlDivisor.int64 <<= iCurScale; - - if (rgulDivisor[2] == 0) { - // Have a 64-bit divisor in sdlDivisor. The remainder - // (currently 96 bits spread over 4 ULONGs) will be < divisor. - // - sdlTmp.u.Lo = rgulRem[2]; - sdlTmp.u.Hi = rgulRem[3]; - - rgulQuo[2] = 0; - rgulQuo[1] = Div96By64(&rgulRem[1], sdlDivisor); - rgulQuo[0] = Div96By64(rgulRem, sdlDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale64; - } - break; - } - - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - sdlTmp.u.Lo = rgulRem[0]; - sdlTmp.u.Hi = rgulRem[1]; - if (sdlTmp.u.Hi >= 0x80000000 || (sdlTmp.int64 <<= 1) > sdlDivisor.int64 || - (sdlTmp.int64 == sdlDivisor.int64 && (rgulQuo[0] & 1))) - goto RoundUp; - break; - } - - if (iCurScale < 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - -HaveScale64: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - - - rgulRem[2] = 0; // rem is 64 bits, IncreaseScale uses 96 - IncreaseScale(rgulRem, ulPwr); - ulTmp = Div96By64(rgulRem, sdlDivisor); - if (!Add32To96(rgulQuo, ulTmp)) { - if (iScale == 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0 || rgulRem[1] != 0)); - break; - } - - } // for (;;) - } - else { - // Have a 96-bit divisor in rgulDivisor[]. - // - // Start by finishing the shift left by iCurScale. - // - sdlTmp.u.Lo = rgulDivisor[1]; - sdlTmp.u.Hi = rgulDivisor[2]; - sdlTmp.int64 <<= iCurScale; - rgulDivisor[0] = sdlDivisor.u.Lo; - rgulDivisor[1] = sdlDivisor.u.Hi; - rgulDivisor[2] = sdlTmp.u.Hi; - - // The remainder (currently 96 bits spread over 4 ULONGs) - // will be < divisor. - // - rgulQuo[2] = 0; - rgulQuo[1] = 0; - rgulQuo[0] = Div128By96(rgulRem, rgulDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1] | rgulRem[2]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale96; - } - break; - } - - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - if (rgulRem[2] >= 0x80000000) - goto RoundUp; - - ulTmp = rgulRem[0] > 0x80000000; - ulTmp1 = rgulRem[1] > 0x80000000; - rgulRem[0] <<= 1; - rgulRem[1] = (rgulRem[1] << 1) + ulTmp; - rgulRem[2] = (rgulRem[2] << 1) + ulTmp1; - - if (rgulRem[2] > rgulDivisor[2] || (rgulRem[2] == rgulDivisor[2] && - (rgulRem[1] > rgulDivisor[1] || (rgulRem[1] == rgulDivisor[1] && - (rgulRem[0] > rgulDivisor[0] || (rgulRem[0] == rgulDivisor[0] && - (rgulQuo[0] & 1))))))) - goto RoundUp; - break; - } - - if (iCurScale < 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - -HaveScale96: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - - rgulRem[3] = IncreaseScale(rgulRem, ulPwr); - ulTmp = Div128By96(rgulRem, rgulDivisor); - if (!Add32To96(rgulQuo, ulTmp)) { - if (iScale == 0) { - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0 || rgulRem[1] != 0 || rgulRem[2] != 0 || rgulRem[3] != 0)); - break; - } - - } // for (;;) - } - } - - // We need to unscale if and only if we have a non-zero remainder - if (fUnscale) { - // Try extracting any extra powers of 10 we may have - // added. We do this by trying to divide out 10^8, 10^4, 10^2, and 10^1. - // If a division by one of these powers returns a zero remainder, then - // we keep the quotient. If the remainder is not zero, then we restore - // the previous value. - // - // Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 - // we can extract. We use this as a quick test on whether to try a - // given power. - // - while ((rgulQuo[0] & 0xFF) == 0 && iScale >= 8) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100000000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 8; - } - else - break; - } - - if ((rgulQuo[0] & 0xF) == 0 && iScale >= 4) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 4; - } - } - - if ((rgulQuo[0] & 3) == 0 && iScale >= 2) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 2; - } - } - - if ((rgulQuo[0] & 1) == 0 && iScale >= 1) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 1; - } - } - } - - DECIMAL_SIGN(*pdecL) = DECIMAL_SIGN(*pdecL) ^ DECIMAL_SIGN(*pdecR); - DECIMAL_HI32(*pdecL) = rgulQuo[2]; - DECIMAL_MID32(*pdecL) = rgulQuo[1]; - DECIMAL_LO32(*pdecL) = rgulQuo[0]; - DECIMAL_SCALE(*pdecL) = (BYTE)iScale; - - pdecL->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - - -FCIMPL3(void, COMDecimal::DoDivide, DECIMAL * pdecL, DECIMAL * pdecR, CLR_BOOL * overflowed) -{ - FCALL_CONTRACT; - - ULONG rgulQuo[3]; - ULONG rgulQuoSave[3]; - ULONG rgulRem[4]; - ULONG rgulDivisor[3]; - ULONG ulPwr; - ULONG ulTmp; - ULONG ulTmp1; - SPLIT64 sdlTmp; - SPLIT64 sdlDivisor; - int iScale; - int iCurScale; - BOOL fUnscale; - - iScale = DECIMAL_SCALE(*pdecL) - DECIMAL_SCALE(*pdecR); - fUnscale = FALSE; - rgulDivisor[0] = DECIMAL_LO32(*pdecR); - rgulDivisor[1] = DECIMAL_MID32(*pdecR); - rgulDivisor[2] = DECIMAL_HI32(*pdecR); - - if (rgulDivisor[1] == 0 && rgulDivisor[2] == 0) { - // Divisor is only 32 bits. Easy divide. - // - if (rgulDivisor[0] == 0) - FCThrowVoid(kDivideByZeroException); - - rgulQuo[0] = DECIMAL_LO32(*pdecL); - rgulQuo[1] = DECIMAL_MID32(*pdecL); - rgulQuo[2] = DECIMAL_HI32(*pdecL); - rgulRem[0] = Div96By32(rgulQuo, rgulDivisor[0]); - - for (;;) { - if (rgulRem[0] == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale; - } - break; - } - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // We have computed a quotient based on the natural scale - // ( - ). We have a non-zero - // remainder, so now we should increase the scale if possible to - // include more quotient bits. - // - // If it doesn't cause overflow, we'll loop scaling by 10^9 and - // computing more quotient bits as long as the remainder stays - // non-zero. If scaling by that much would cause overflow, we'll - // drop out of the loop and scale by as much as we can. - // - // Scaling by 10^9 will overflow if rgulQuo[2].rgulQuo[1] >= 2^32 / 10^9 - // = 4.294 967 296. So the upper limit is rgulQuo[2] == 4 and - // rgulQuo[1] == 0.294 967 296 * 2^32 = 1,266,874,889.7+. Since - // quotient bits in rgulQuo[0] could be all 1's, then 1,266,874,888 - // is the largest value in rgulQuo[1] (when rgulQuo[2] == 4) that is - // assured not to overflow. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - ulTmp = rgulRem[0] << 1; - if (ulTmp < rgulRem[0] || (ulTmp >= rgulDivisor[0] && - (ulTmp > rgulDivisor[0] || (rgulQuo[0] & 1)))) { -RoundUp: - if (!Add32To96(rgulQuo, 1)) { - if (iScale == 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - iScale--; - OverflowUnscale(rgulQuo, TRUE); - break; - } - } - break; - } - - if (iCurScale < 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - -HaveScale: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - - - sdlTmp.int64 = DivMod64by32(UInt32x32To64(rgulRem[0], ulPwr), rgulDivisor[0]); - rgulRem[0] = sdlTmp.u.Hi; - - if (!Add32To96(rgulQuo, sdlTmp.u.Lo)) { - if (iScale == 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0)); - break; - } - } // for (;;) - } - else { - // Divisor has bits set in the upper 64 bits. - // - // Divisor must be fully normalized (shifted so bit 31 of the most - // significant ULONG is 1). Locate the MSB so we know how much to - // normalize by. The dividend will be shifted by the same amount so - // the quotient is not changed. - // - if (rgulDivisor[2] == 0) - ulTmp = rgulDivisor[1]; - else - ulTmp = rgulDivisor[2]; - - iCurScale = 0; - if (!(ulTmp & 0xFFFF0000)) { - iCurScale += 16; - ulTmp <<= 16; - } - if (!(ulTmp & 0xFF000000)) { - iCurScale += 8; - ulTmp <<= 8; - } - if (!(ulTmp & 0xF0000000)) { - iCurScale += 4; - ulTmp <<= 4; - } - if (!(ulTmp & 0xC0000000)) { - iCurScale += 2; - ulTmp <<= 2; - } - if (!(ulTmp & 0x80000000)) { - iCurScale++; - ulTmp <<= 1; - } - - // Shift both dividend and divisor left by iCurScale. - // - sdlTmp.int64 = DECIMAL_LO64_GET(*pdecL) << iCurScale; - rgulRem[0] = sdlTmp.u.Lo; - rgulRem[1] = sdlTmp.u.Hi; - sdlTmp.u.Lo = DECIMAL_MID32(*pdecL); - sdlTmp.u.Hi = DECIMAL_HI32(*pdecL); - sdlTmp.int64 <<= iCurScale; - rgulRem[2] = sdlTmp.u.Hi; - rgulRem[3] = (DECIMAL_HI32(*pdecL) >> (31 - iCurScale)) >> 1; - - sdlDivisor.u.Lo = rgulDivisor[0]; - sdlDivisor.u.Hi = rgulDivisor[1]; - sdlDivisor.int64 <<= iCurScale; - - if (rgulDivisor[2] == 0) { - // Have a 64-bit divisor in sdlDivisor. The remainder - // (currently 96 bits spread over 4 ULONGs) will be < divisor. - // - sdlTmp.u.Lo = rgulRem[2]; - sdlTmp.u.Hi = rgulRem[3]; - - rgulQuo[2] = 0; - rgulQuo[1] = Div96By64(&rgulRem[1], sdlDivisor); - rgulQuo[0] = Div96By64(rgulRem, sdlDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale64; - } - break; - } - - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - sdlTmp.u.Lo = rgulRem[0]; - sdlTmp.u.Hi = rgulRem[1]; - if (sdlTmp.u.Hi >= 0x80000000 || (sdlTmp.int64 <<= 1) > sdlDivisor.int64 || - (sdlTmp.int64 == sdlDivisor.int64 && (rgulQuo[0] & 1))) - goto RoundUp; - break; - } - - if (iCurScale < 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - -HaveScale64: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - - - rgulRem[2] = 0; // rem is 64 bits, IncreaseScale uses 96 - IncreaseScale(rgulRem, ulPwr); - ulTmp = Div96By64(rgulRem, sdlDivisor); - if (!Add32To96(rgulQuo, ulTmp)) { - if (iScale == 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0 || rgulRem[1] != 0)); - break; - } - - } // for (;;) - } - else { - // Have a 96-bit divisor in rgulDivisor[]. - // - // Start by finishing the shift left by iCurScale. - // - sdlTmp.u.Lo = rgulDivisor[1]; - sdlTmp.u.Hi = rgulDivisor[2]; - sdlTmp.int64 <<= iCurScale; - rgulDivisor[0] = sdlDivisor.u.Lo; - rgulDivisor[1] = sdlDivisor.u.Hi; - rgulDivisor[2] = sdlTmp.u.Hi; - - // The remainder (currently 96 bits spread over 4 ULONGs) - // will be < divisor. - // - rgulQuo[2] = 0; - rgulQuo[1] = 0; - rgulQuo[0] = Div128By96(rgulRem, rgulDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1] | rgulRem[2]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale96; - } - break; - } - - // We need to unscale if and only if we have a non-zero remainder - fUnscale = TRUE; - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], rgulQuo[0], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - if (rgulRem[2] >= 0x80000000) - goto RoundUp; - - ulTmp = rgulRem[0] > 0x80000000; - ulTmp1 = rgulRem[1] > 0x80000000; - rgulRem[0] <<= 1; - rgulRem[1] = (rgulRem[1] << 1) + ulTmp; - rgulRem[2] = (rgulRem[2] << 1) + ulTmp1; - - if (rgulRem[2] > rgulDivisor[2] || (rgulRem[2] == rgulDivisor[2] && - (rgulRem[1] > rgulDivisor[1] || (rgulRem[1] == rgulDivisor[1] && - (rgulRem[0] > rgulDivisor[0] || (rgulRem[0] == rgulDivisor[0] && - (rgulQuo[0] & 1))))))) - goto RoundUp; - break; - } - - if (iCurScale < 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - -HaveScale96: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - - rgulRem[3] = IncreaseScale(rgulRem, ulPwr); - ulTmp = Div128By96(rgulRem, rgulDivisor); - if (!Add32To96(rgulQuo, ulTmp)) { - if (iScale == 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - iScale--; - OverflowUnscale(rgulQuo, (rgulRem[0] != 0 || rgulRem[1] != 0 || rgulRem[2] != 0 || rgulRem[3] != 0)); - break; - } - - } // for (;;) - } - } - - // We need to unscale if and only if we have a non-zero remainder - if (fUnscale) { - // Try extracting any extra powers of 10 we may have - // added. We do this by trying to divide out 10^8, 10^4, 10^2, and 10^1. - // If a division by one of these powers returns a zero remainder, then - // we keep the quotient. If the remainder is not zero, then we restore - // the previous value. - // - // Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 - // we can extract. We use this as a quick test on whether to try a - // given power. - // - while ((rgulQuo[0] & 0xFF) == 0 && iScale >= 8) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100000000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 8; - } - else - break; - } - - if ((rgulQuo[0] & 0xF) == 0 && iScale >= 4) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 4; - } - } - - if ((rgulQuo[0] & 3) == 0 && iScale >= 2) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 2; - } - } - - if ((rgulQuo[0] & 1) == 0 && iScale >= 1) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 1; - } - } - } - - DECIMAL_SIGN(*pdecL) = DECIMAL_SIGN(*pdecL) ^ DECIMAL_SIGN(*pdecR); - DECIMAL_HI32(*pdecL) = rgulQuo[2]; - DECIMAL_MID32(*pdecL) = rgulQuo[1]; - DECIMAL_LO32(*pdecL) = rgulQuo[0]; - DECIMAL_SCALE(*pdecL) = (BYTE)iScale; - - pdecL->wReserved = 0; - *overflowed = false; - FC_GC_POLL(); -} -FCIMPLEND - -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - - -//********************************************************************** -// -// VarDecAdd - Decimal Addition -// VarDecSub - Decimal Subtraction -// -//********************************************************************** - -static const ULONG ulTenToNine = 1000000000; - -/*** -* ScaleResult -* -* Entry: -* rgulRes - Array of ULONGs with value, least-significant first. -* iHiRes - Index of last non-zero value in rgulRes. -* iScale - Scale factor for this value, range 0 - 2 * DEC_SCALE_MAX -* -* Purpose: -* See if we need to scale the result to fit it in 96 bits. -* Perform needed scaling. Adjust scale factor accordingly. -* -* Exit: -* rgulRes updated in place, always 3 ULONGs. -* New scale factor returned, -1 if overflow error. -* -***********************************************************************/ - -int ScaleResult(ULONG *rgulRes, int iHiRes, int iScale) -{ - LIMITED_METHOD_CONTRACT; - - int iNewScale; - int iCur; - ULONG ulPwr; - ULONG ulTmp; - ULONG ulSticky; - SPLIT64 sdlTmp; - - // See if we need to scale the result. The combined scale must - // be <= DEC_SCALE_MAX and the upper 96 bits must be zero. - // - // Start by figuring a lower bound on the scaling needed to make - // the upper 96 bits zero. iHiRes is the index into rgulRes[] - // of the highest non-zero ULONG. - // - iNewScale = iHiRes * 32 - 64 - 1; - if (iNewScale > 0) { - - // Find the MSB. - // - ulTmp = rgulRes[iHiRes]; - if (!(ulTmp & 0xFFFF0000)) { - iNewScale -= 16; - ulTmp <<= 16; - } - if (!(ulTmp & 0xFF000000)) { - iNewScale -= 8; - ulTmp <<= 8; - } - if (!(ulTmp & 0xF0000000)) { - iNewScale -= 4; - ulTmp <<= 4; - } - if (!(ulTmp & 0xC0000000)) { - iNewScale -= 2; - ulTmp <<= 2; - } - if (!(ulTmp & 0x80000000)) { - iNewScale--; - ulTmp <<= 1; - } - - // Multiply bit position by log10(2) to figure it's power of 10. - // We scale the log by 256. log(2) = .30103, * 256 = 77. Doing this - // with a multiply saves a 96-byte lookup table. The power returned - // is <= the power of the number, so we must add one power of 10 - // to make it's integer part zero after dividing by 256. - // - // Note: the result of this multiplication by an approximation of - // log10(2) have been exhaustively checked to verify it gives the - // correct result. (There were only 95 to check...) - // - iNewScale = ((iNewScale * 77) >> 8) + 1; - - // iNewScale = min scale factor to make high 96 bits zero, 0 - 29. - // This reduces the scale factor of the result. If it exceeds the - // current scale of the result, we'll overflow. - // - if (iNewScale > iScale) - return -1; - } - else - iNewScale = 0; - - // Make sure we scale by enough to bring the current scale factor - // into valid range. - // - if (iNewScale < iScale - DEC_SCALE_MAX) - iNewScale = iScale - DEC_SCALE_MAX; - - if (iNewScale != 0) { - // Scale by the power of 10 given by iNewScale. Note that this is - // NOT guaranteed to bring the number within 96 bits -- it could - // be 1 power of 10 short. - // - iScale -= iNewScale; - ulSticky = 0; - sdlTmp.u.Hi = 0; // initialize remainder - - for (;;) { - - ulSticky |= sdlTmp.u.Hi; // record remainder as sticky bit - - if (iNewScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iNewScale]; - - // Compute first quotient. - // DivMod64by32 returns quotient in Lo, remainder in Hi. - // - sdlTmp.int64 = DivMod64by32(rgulRes[iHiRes], ulPwr); - rgulRes[iHiRes] = sdlTmp.u.Lo; - iCur = iHiRes - 1; - - if (iCur >= 0) { - // If first quotient was 0, update iHiRes. - // - if (sdlTmp.u.Lo == 0) - iHiRes--; - - // Compute subsequent quotients. - // - do { - sdlTmp.u.Lo = rgulRes[iCur]; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulPwr); - rgulRes[iCur] = sdlTmp.u.Lo; - iCur--; - } while (iCur >= 0); - - } - - iNewScale -= POWER10_MAX; - if (iNewScale > 0) - continue; // scale some more - - // If we scaled enough, iHiRes would be 2 or less. If not, - // divide by 10 more. - // - if (iHiRes > 2) { - iNewScale = 1; - iScale--; - continue; // scale by 10 - } - - // Round final result. See if remainder >= 1/2 of divisor. - // If remainder == 1/2 divisor, round up if odd or sticky bit set. - // - ulPwr >>= 1; // power of 10 always even - if ( ulPwr <= sdlTmp.u.Hi && (ulPwr < sdlTmp.u.Hi || - ((rgulRes[0] & 1) | ulSticky)) ) { - iCur = -1; - while (++rgulRes[++iCur] == 0); - - if (iCur > 2) { - // The rounding caused us to carry beyond 96 bits. - // Scale by 10 more. - // - iHiRes = iCur; - ulSticky = 0; // no sticky bit - sdlTmp.u.Hi = 0; // or remainder - iNewScale = 1; - iScale--; - continue; // scale by 10 - } - } - - // We may have scaled it more than we planned. Make sure the scale - // factor hasn't gone negative, indicating overflow. - // - if (iScale < 0) - return -1; - - return iScale; - } // for(;;) - } - return iScale; -} - -FCIMPL3(void, COMDecimal::DoAddSubThrow, DECIMAL * pdecL, DECIMAL * pdecR, UINT8 bSign) -{ - FCALL_CONTRACT; - - ULONG rgulNum[6]; - ULONG ulPwr; - int iScale; - int iHiProd; - int iCur; - SPLIT64 sdlTmp; - DECIMAL decRes; - DECIMAL decTmp; - LPDECIMAL pdecTmp; - LPDECIMAL pdecLOriginal; - - _ASSERTE(bSign == 0 || bSign == DECIMAL_NEG); - - pdecLOriginal = pdecL; - - bSign ^= (DECIMAL_SIGN(*pdecR) ^ DECIMAL_SIGN(*pdecL)) & DECIMAL_NEG; - - if (DECIMAL_SCALE(*pdecR) == DECIMAL_SCALE(*pdecL)) { - // Scale factors are equal, no alignment necessary. - // - DECIMAL_SIGNSCALE(decRes) = DECIMAL_SIGNSCALE(*pdecL); - -AlignedAdd: - if (bSign) { - // Signs differ - subtract - // - DECIMAL_LO64_SET(decRes, (DECIMAL_LO64_GET(*pdecL) - DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecL) - DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > DECIMAL_LO64_GET(*pdecL)) { - DECIMAL_HI32(decRes)--; - if (DECIMAL_HI32(decRes) >= DECIMAL_HI32(*pdecL)) - goto SignFlip; - } - else if (DECIMAL_HI32(decRes) > DECIMAL_HI32(*pdecL)) { - // Got negative result. Flip its sign. - // -SignFlip: - DECIMAL_LO64_SET(decRes, -(LONGLONG)DECIMAL_LO64_GET(decRes)); - DECIMAL_HI32(decRes) = ~DECIMAL_HI32(decRes); - if (DECIMAL_LO64_GET(decRes) == 0) - DECIMAL_HI32(decRes)++; - DECIMAL_SIGN(decRes) ^= DECIMAL_NEG; - } - - } - else { - // Signs are the same - add - // - DECIMAL_LO64_SET(decRes, (DECIMAL_LO64_GET(*pdecL) + DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecL) + DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < DECIMAL_LO64_GET(*pdecL)) { - DECIMAL_HI32(decRes)++; - if (DECIMAL_HI32(decRes) <= DECIMAL_HI32(*pdecL)) - goto AlignedScale; - } - else if (DECIMAL_HI32(decRes) < DECIMAL_HI32(*pdecL)) { -AlignedScale: - // The addition carried above 96 bits. Divide the result by 10, - // dropping the scale factor. - // - if (DECIMAL_SCALE(decRes) == 0) - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); // DISP_E_OVERFLOW - DECIMAL_SCALE(decRes)--; - - sdlTmp.u.Lo = DECIMAL_HI32(decRes); - sdlTmp.u.Hi = 1; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_HI32(decRes) = sdlTmp.u.Lo; - - sdlTmp.u.Lo = DECIMAL_MID32(decRes); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_MID32(decRes) = sdlTmp.u.Lo; - - sdlTmp.u.Lo = DECIMAL_LO32(decRes); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_LO32(decRes) = sdlTmp.u.Lo; - - // See if we need to round up. - // - if (sdlTmp.u.Hi >= 5 && (sdlTmp.u.Hi > 5 || (DECIMAL_LO32(decRes) & 1))) { - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(decRes)+1); - if (DECIMAL_LO64_GET(decRes) == 0) - DECIMAL_HI32(decRes)++; - } - } - } - } - else { - // Scale factors are not equal. Assume that a larger scale - // factor (more decimal places) is likely to mean that number - // is smaller. Start by guessing that the right operand has - // the larger scale factor. The result will have the larger - // scale factor. - // - DECIMAL_SCALE(decRes) = DECIMAL_SCALE(*pdecR); // scale factor of "smaller" - DECIMAL_SIGN(decRes) = DECIMAL_SIGN(*pdecL); // but sign of "larger" - iScale = DECIMAL_SCALE(decRes)- DECIMAL_SCALE(*pdecL); - - if (iScale < 0) { - // Guessed scale factor wrong. Swap operands. - // - iScale = -iScale; - DECIMAL_SCALE(decRes) = DECIMAL_SCALE(*pdecL); - DECIMAL_SIGN(decRes) ^= bSign; - pdecTmp = pdecR; - pdecR = pdecL; - pdecL = pdecTmp; - } - - // *pdecL will need to be multiplied by 10^iScale so - // it will have the same scale as *pdecR. We could be - // extending it to up to 192 bits of precision. - // - if (iScale <= POWER10_MAX) { - // Scaling won't make it larger than 4 ULONGs - // - ulPwr = rgulPower10[iScale]; - DECIMAL_LO64_SET(decTmp, UInt32x32To64(DECIMAL_LO32(*pdecL), ulPwr)); - sdlTmp.int64 = UInt32x32To64(DECIMAL_MID32(*pdecL), ulPwr); - sdlTmp.int64 += DECIMAL_MID32(decTmp); - DECIMAL_MID32(decTmp) = sdlTmp.u.Lo; - DECIMAL_HI32(decTmp) = sdlTmp.u.Hi; - sdlTmp.int64 = UInt32x32To64(DECIMAL_HI32(*pdecL), ulPwr); - sdlTmp.int64 += DECIMAL_HI32(decTmp); - if (sdlTmp.u.Hi == 0) { - // Result fits in 96 bits. Use standard aligned add. - // - DECIMAL_HI32(decTmp) = sdlTmp.u.Lo; - pdecL = &decTmp; - goto AlignedAdd; - } - rgulNum[0] = DECIMAL_LO32(decTmp); - rgulNum[1] = DECIMAL_MID32(decTmp); - rgulNum[2] = sdlTmp.u.Lo; - rgulNum[3] = sdlTmp.u.Hi; - iHiProd = 3; - } - else { - // Have to scale by a bunch. Move the number to a buffer - // where it has room to grow as it's scaled. - // - rgulNum[0] = DECIMAL_LO32(*pdecL); - rgulNum[1] = DECIMAL_MID32(*pdecL); - rgulNum[2] = DECIMAL_HI32(*pdecL); - iHiProd = 2; - - // Scan for zeros in the upper words. - // - if (rgulNum[2] == 0) { - iHiProd = 1; - if (rgulNum[1] == 0) { - iHiProd = 0; - if (rgulNum[0] == 0) { - // Left arg is zero, return right. - // - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(*pdecR)); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecR); - DECIMAL_SIGN(decRes) ^= bSign; - goto RetDec; - } - } - } - - // Scaling loop, up to 10^9 at a time. iHiProd stays updated - // with index of highest non-zero ULONG. - // - for (; iScale > 0; iScale -= POWER10_MAX) { - if (iScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iScale]; - - sdlTmp.u.Hi = 0; - for (iCur = 0; iCur <= iHiProd; iCur++) { - sdlTmp.int64 = UInt32x32To64(rgulNum[iCur], ulPwr) + sdlTmp.u.Hi; - rgulNum[iCur] = sdlTmp.u.Lo; - } - - if (sdlTmp.u.Hi != 0) - // We're extending the result by another ULONG. - rgulNum[++iHiProd] = sdlTmp.u.Hi; - } - } - - // Scaling complete, do the add. Could be subtract if signs differ. - // - sdlTmp.u.Lo = rgulNum[0]; - sdlTmp.u.Hi = rgulNum[1]; - - if (bSign) { - // Signs differ, subtract. - // - DECIMAL_LO64_SET(decRes, (sdlTmp.int64 - DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = rgulNum[2] - DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > sdlTmp.int64) { - DECIMAL_HI32(decRes)--; - if (DECIMAL_HI32(decRes) >= rgulNum[2]) - goto LongSub; - } - else if (DECIMAL_HI32(decRes) > rgulNum[2]) { -LongSub: - // If rgulNum has more than 96 bits of precision, then we need to - // carry the subtraction into the higher bits. If it doesn't, - // then we subtracted in the wrong order and have to flip the - // sign of the result. - // - if (iHiProd <= 2) - goto SignFlip; - - iCur = 3; - while(rgulNum[iCur++]-- == 0); - if (rgulNum[iHiProd] == 0) - iHiProd--; - } - } - else { - // Signs the same, add. - // - DECIMAL_LO64_SET(decRes, (sdlTmp.int64 + DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = rgulNum[2] + DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < sdlTmp.int64) { - DECIMAL_HI32(decRes)++; - if (DECIMAL_HI32(decRes) <= rgulNum[2]) - goto LongAdd; - } - else if (DECIMAL_HI32(decRes) < rgulNum[2]) { -LongAdd: - // Had a carry above 96 bits. - // - iCur = 3; - do { - if (iHiProd < iCur) { - rgulNum[iCur] = 1; - iHiProd = iCur; - break; - } - }while (++rgulNum[iCur++] == 0); - } - } - - if (iHiProd > 2) { - rgulNum[0] = DECIMAL_LO32(decRes); - rgulNum[1] = DECIMAL_MID32(decRes); - rgulNum[2] = DECIMAL_HI32(decRes); - DECIMAL_SCALE(decRes) = (BYTE)ScaleResult(rgulNum, iHiProd, DECIMAL_SCALE(decRes)); - if (DECIMAL_SCALE(decRes) == (BYTE)-1) - FCThrowResVoid(kOverflowException, W("Overflow_Decimal")); // DISP_E_OVERFLOW - - DECIMAL_LO32(decRes) = rgulNum[0]; - DECIMAL_MID32(decRes) = rgulNum[1]; - DECIMAL_HI32(decRes) = rgulNum[2]; - } - } - -RetDec: - pdecL = pdecLOriginal; - COPYDEC(*pdecL, decRes) - pdecL->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - -FCIMPL4(void, COMDecimal::DoAddSub, DECIMAL * pdecL, DECIMAL * pdecR, UINT8 bSign, CLR_BOOL * overflowed) -{ - FCALL_CONTRACT; - - ULONG rgulNum[6]; - ULONG ulPwr; - int iScale; - int iHiProd; - int iCur; - SPLIT64 sdlTmp; - DECIMAL decRes; - DECIMAL decTmp; - LPDECIMAL pdecTmp; - LPDECIMAL pdecLOriginal; - - _ASSERTE(bSign == 0 || bSign == DECIMAL_NEG); - - pdecLOriginal = pdecL; - - bSign ^= (DECIMAL_SIGN(*pdecR) ^ DECIMAL_SIGN(*pdecL)) & DECIMAL_NEG; - - if (DECIMAL_SCALE(*pdecR) == DECIMAL_SCALE(*pdecL)) { - // Scale factors are equal, no alignment necessary. - // - DECIMAL_SIGNSCALE(decRes) = DECIMAL_SIGNSCALE(*pdecL); - -AlignedAdd: - if (bSign) { - // Signs differ - subtract - // - DECIMAL_LO64_SET(decRes, (DECIMAL_LO64_GET(*pdecL) - DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecL) - DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > DECIMAL_LO64_GET(*pdecL)) { - DECIMAL_HI32(decRes)--; - if (DECIMAL_HI32(decRes) >= DECIMAL_HI32(*pdecL)) - goto SignFlip; - } - else if (DECIMAL_HI32(decRes) > DECIMAL_HI32(*pdecL)) { - // Got negative result. Flip its sign. - // -SignFlip: - DECIMAL_LO64_SET(decRes, -(LONGLONG)DECIMAL_LO64_GET(decRes)); - DECIMAL_HI32(decRes) = ~DECIMAL_HI32(decRes); - if (DECIMAL_LO64_GET(decRes) == 0) - DECIMAL_HI32(decRes)++; - DECIMAL_SIGN(decRes) ^= DECIMAL_NEG; - } - - } - else { - // Signs are the same - add - // - DECIMAL_LO64_SET(decRes, (DECIMAL_LO64_GET(*pdecL) + DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecL) + DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < DECIMAL_LO64_GET(*pdecL)) { - DECIMAL_HI32(decRes)++; - if (DECIMAL_HI32(decRes) <= DECIMAL_HI32(*pdecL)) - goto AlignedScale; - } - else if (DECIMAL_HI32(decRes) < DECIMAL_HI32(*pdecL)) { -AlignedScale: - // The addition carried above 96 bits. Divide the result by 10, - // dropping the scale factor. - // - if (DECIMAL_SCALE(decRes) == 0) { - *overflowed = true; - FC_GC_POLL(); - return; - } - DECIMAL_SCALE(decRes)--; - - sdlTmp.u.Lo = DECIMAL_HI32(decRes); - sdlTmp.u.Hi = 1; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_HI32(decRes) = sdlTmp.u.Lo; - - sdlTmp.u.Lo = DECIMAL_MID32(decRes); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_MID32(decRes) = sdlTmp.u.Lo; - - sdlTmp.u.Lo = DECIMAL_LO32(decRes); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - DECIMAL_LO32(decRes) = sdlTmp.u.Lo; - - // See if we need to round up. - // - if (sdlTmp.u.Hi >= 5 && (sdlTmp.u.Hi > 5 || (DECIMAL_LO32(decRes) & 1))) { - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(decRes)+1); - if (DECIMAL_LO64_GET(decRes) == 0) - DECIMAL_HI32(decRes)++; - } - } - } - } - else { - // Scale factors are not equal. Assume that a larger scale - // factor (more decimal places) is likely to mean that number - // is smaller. Start by guessing that the right operand has - // the larger scale factor. The result will have the larger - // scale factor. - // - DECIMAL_SCALE(decRes) = DECIMAL_SCALE(*pdecR); // scale factor of "smaller" - DECIMAL_SIGN(decRes) = DECIMAL_SIGN(*pdecL); // but sign of "larger" - iScale = DECIMAL_SCALE(decRes)- DECIMAL_SCALE(*pdecL); - - if (iScale < 0) { - // Guessed scale factor wrong. Swap operands. - // - iScale = -iScale; - DECIMAL_SCALE(decRes) = DECIMAL_SCALE(*pdecL); - DECIMAL_SIGN(decRes) ^= bSign; - pdecTmp = pdecR; - pdecR = pdecL; - pdecL = pdecTmp; - } - - // *pdecL will need to be multiplied by 10^iScale so - // it will have the same scale as *pdecR. We could be - // extending it to up to 192 bits of precision. - // - if (iScale <= POWER10_MAX) { - // Scaling won't make it larger than 4 ULONGs - // - ulPwr = rgulPower10[iScale]; - DECIMAL_LO64_SET(decTmp, UInt32x32To64(DECIMAL_LO32(*pdecL), ulPwr)); - sdlTmp.int64 = UInt32x32To64(DECIMAL_MID32(*pdecL), ulPwr); - sdlTmp.int64 += DECIMAL_MID32(decTmp); - DECIMAL_MID32(decTmp) = sdlTmp.u.Lo; - DECIMAL_HI32(decTmp) = sdlTmp.u.Hi; - sdlTmp.int64 = UInt32x32To64(DECIMAL_HI32(*pdecL), ulPwr); - sdlTmp.int64 += DECIMAL_HI32(decTmp); - if (sdlTmp.u.Hi == 0) { - // Result fits in 96 bits. Use standard aligned add. - // - DECIMAL_HI32(decTmp) = sdlTmp.u.Lo; - pdecL = &decTmp; - goto AlignedAdd; - } - rgulNum[0] = DECIMAL_LO32(decTmp); - rgulNum[1] = DECIMAL_MID32(decTmp); - rgulNum[2] = sdlTmp.u.Lo; - rgulNum[3] = sdlTmp.u.Hi; - iHiProd = 3; - } - else { - // Have to scale by a bunch. Move the number to a buffer - // where it has room to grow as it's scaled. - // - rgulNum[0] = DECIMAL_LO32(*pdecL); - rgulNum[1] = DECIMAL_MID32(*pdecL); - rgulNum[2] = DECIMAL_HI32(*pdecL); - iHiProd = 2; - - // Scan for zeros in the upper words. - // - if (rgulNum[2] == 0) { - iHiProd = 1; - if (rgulNum[1] == 0) { - iHiProd = 0; - if (rgulNum[0] == 0) { - // Left arg is zero, return right. - // - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(*pdecR)); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecR); - DECIMAL_SIGN(decRes) ^= bSign; - goto RetDec; - } - } - } - - // Scaling loop, up to 10^9 at a time. iHiProd stays updated - // with index of highest non-zero ULONG. - // - for (; iScale > 0; iScale -= POWER10_MAX) { - if (iScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iScale]; - - sdlTmp.u.Hi = 0; - for (iCur = 0; iCur <= iHiProd; iCur++) { - sdlTmp.int64 = UInt32x32To64(rgulNum[iCur], ulPwr) + sdlTmp.u.Hi; - rgulNum[iCur] = sdlTmp.u.Lo; - } - - if (sdlTmp.u.Hi != 0) - // We're extending the result by another ULONG. - rgulNum[++iHiProd] = sdlTmp.u.Hi; - } - } - - // Scaling complete, do the add. Could be subtract if signs differ. - // - sdlTmp.u.Lo = rgulNum[0]; - sdlTmp.u.Hi = rgulNum[1]; - - if (bSign) { - // Signs differ, subtract. - // - DECIMAL_LO64_SET(decRes, (sdlTmp.int64 - DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = rgulNum[2] - DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > sdlTmp.int64) { - DECIMAL_HI32(decRes)--; - if (DECIMAL_HI32(decRes) >= rgulNum[2]) - goto LongSub; - } - else if (DECIMAL_HI32(decRes) > rgulNum[2]) { -LongSub: - // If rgulNum has more than 96 bits of precision, then we need to - // carry the subtraction into the higher bits. If it doesn't, - // then we subtracted in the wrong order and have to flip the - // sign of the result. - // - if (iHiProd <= 2) - goto SignFlip; - - iCur = 3; - while(rgulNum[iCur++]-- == 0); - if (rgulNum[iHiProd] == 0) - iHiProd--; - } - } - else { - // Signs the same, add. - // - DECIMAL_LO64_SET(decRes, (sdlTmp.int64 + DECIMAL_LO64_GET(*pdecR))); - DECIMAL_HI32(decRes) = rgulNum[2] + DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < sdlTmp.int64) { - DECIMAL_HI32(decRes)++; - if (DECIMAL_HI32(decRes) <= rgulNum[2]) - goto LongAdd; - } - else if (DECIMAL_HI32(decRes) < rgulNum[2]) { -LongAdd: - // Had a carry above 96 bits. - // - iCur = 3; - do { - if (iHiProd < iCur) { - rgulNum[iCur] = 1; - iHiProd = iCur; - break; - } - }while (++rgulNum[iCur++] == 0); - } - } - - if (iHiProd > 2) { - rgulNum[0] = DECIMAL_LO32(decRes); - rgulNum[1] = DECIMAL_MID32(decRes); - rgulNum[2] = DECIMAL_HI32(decRes); - DECIMAL_SCALE(decRes) = (BYTE)ScaleResult(rgulNum, iHiProd, DECIMAL_SCALE(decRes)); - if (DECIMAL_SCALE(decRes) == (BYTE)-1) { - *overflowed = true; - FC_GC_POLL(); - return; - } - - DECIMAL_LO32(decRes) = rgulNum[0]; - DECIMAL_MID32(decRes) = rgulNum[1]; - DECIMAL_HI32(decRes) = rgulNum[2]; - } - } - -RetDec: - pdecL = pdecLOriginal; - COPYDEC(*pdecL, decRes) - pdecL->wReserved = 0; - FC_GC_POLL(); -} -FCIMPLEND - diff --git a/src/classlibnative/bcltype/decimal.h b/src/classlibnative/bcltype/decimal.h deleted file mode 100644 index f037fd3acb2a..000000000000 --- a/src/classlibnative/bcltype/decimal.h +++ /dev/null @@ -1,52 +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. -// -// File: Decimal.h -// - -// - -#ifndef _DECIMAL_H_ -#define _DECIMAL_H_ - -#include - -#include - -#include "number.h" - -#define DECIMAL_PRECISION 29 - -class COMDecimal { -public: - static FCDECL2_IV(void, InitSingle, DECIMAL *_this, float value); - static FCDECL2_IV(void, InitDouble, DECIMAL *_this, double value); - static FCDECL2(INT32, DoCompare, DECIMAL * d1, DECIMAL * d2); - - static FCDECL3(void, DoAddSubThrow, DECIMAL * d1, DECIMAL * d2, UINT8 bSign); - static FCDECL2(void, DoDivideThrow, DECIMAL * d1, DECIMAL * d2); - static FCDECL2(void, DoMultiplyThrow, DECIMAL * d1, DECIMAL * d2); - - static FCDECL4(void, DoAddSub, DECIMAL * d1, DECIMAL * d2, UINT8 bSign, CLR_BOOL * overflowed); - static FCDECL3(void, DoDivide, DECIMAL * d1, DECIMAL * d2, CLR_BOOL * overflowed); - static FCDECL3(void, DoMultiply, DECIMAL * d1, DECIMAL * d2, CLR_BOOL * overflowed); - - static FCDECL2(void, DoRound, DECIMAL * d1, INT32 decimals); - static FCDECL2_IV(void, DoToCurrency, CY * result, DECIMAL d); - static FCDECL1(void, DoTruncate, DECIMAL * d); - static FCDECL1(void, DoFloor, DECIMAL * d); - - static FCDECL1(double, ToDouble, FC_DECIMAL d); - static FCDECL1(float, ToSingle, FC_DECIMAL d); - static FCDECL1(INT32, ToInt32, FC_DECIMAL d); - static FCDECL1(Object*, ToString, FC_DECIMAL d); - - static int NumberToDecimal(NUMBER* number, DECIMAL* value); - - -}; - -#include - -#endif // _DECIMAL_H_ diff --git a/src/classlibnative/bcltype/number.cpp b/src/classlibnative/bcltype/number.cpp index ac068d6a5410..b20044ec41e0 100644 --- a/src/classlibnative/bcltype/number.cpp +++ b/src/classlibnative/bcltype/number.cpp @@ -8,89 +8,21 @@ // #include "common.h" -#include "excep.h" #include "number.h" -#include "string.h" -#include "decimal.h" #include "bignum.h" #include "grisu3.h" #include "fp.h" -#include typedef wchar_t wchar; -#define INT32_PRECISION 10 -#define UINT32_PRECISION INT32_PRECISION -#define INT64_PRECISION 19 -#define UINT64_PRECISION 20 -#define FLOAT_PRECISION 7 -#define DOUBLE_PRECISION 15 -#define LARGE_BUFFER_SIZE 600 -#define MIN_BUFFER_SIZE 105 - #define SCALE_NAN 0x80000000 #define SCALE_INF 0x7FFFFFFF - -static const char* const posCurrencyFormats[] = { - "$#", "#$", "$ #", "# $"}; - -static const char* const negCurrencyFormats[] = { - "($#)", "-$#", "$-#", "$#-", - "(#$)", "-#$", "#-$", "#$-", - "-# $", "-$ #", "# $-", "$ #-", - "$ -#", "#- $", "($ #)", "(# $)"}; - -static const char* const posPercentFormats[] = { - "# %", "#%", "%#", "% #" // Last one is new in Whidbey -}; - -static const char* const negPercentFormats[] = { - "-# %", "-#%", "-%#", - "%-#", "%#-", // Last 9 are new in WHidbey - "#-%", "#%-", - "-% #", "# %-", "% #-", - "% -#", "#- %" -}; - -static const char* const negNumberFormats[] = { - "(#)", "-#", "- #", "#-", "# -", -}; - -static const char posNumberFormat[] = "#"; - #if defined(_TARGET_X86_) && !defined(FEATURE_PAL) extern "C" void _cdecl /*__stdcall*/ DoubleToNumber(double value, int precision, NUMBER* number); extern "C" void _cdecl /*__stdcall*/ NumberToDouble(NUMBER* number, double* value); -#pragma warning(disable:4035) - -wchar_t* COMNumber::Int32ToDecChars(__in wchar_t* p, unsigned int value, int digits) -{ - LIMITED_METHOD_CONTRACT - - _asm { - mov eax,value - mov ebx,10 - mov ecx,digits - mov edi,p - jmp L2 -L1: xor edx,edx - div ebx - add edx,'0' //promote dl to edx to avoid partial register stall and LCP stall - sub edi,2 - mov [edi],dx -L2: dec ecx - jge L1 - or eax,eax - jne L1 - mov eax,edi - } -} - -#pragma warning(default:4035) - #else // _TARGET_X86_ && !FEATURE_PAL void Dragon4( double value, int count, int* dec, int* sign, wchar_t* digits ) @@ -808,1181 +740,8 @@ void NumberToDouble(NUMBER* number, double* value) if (number->sign) *(UINT64*)value |= I64(0x8000000000000000); } -wchar_t* COMNumber::Int32ToDecChars(__in wchar_t* p, unsigned int value, int digits) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(p != NULL); - - while (--digits >= 0 || value != 0) { - *--p = value % 10 + '0'; - value /= 10; - } - return p; -} #endif // _TARGET_X86_ && !FEATURE_PAL -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("y", on) // Small critical routines, don't put in EBP frame -#endif - -inline void AddStringRef(__in wchar** ppBuffer, STRINGREF strRef) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(ppBuffer != NULL && strRef != NULL); - - wchar* buffer = strRef->GetBuffer(); - _ASSERTE(buffer != NULL); - DWORD length = strRef->GetStringLength(); - for (wchar* str = buffer; str < buffer + length; (*ppBuffer)++, str++) - { - **ppBuffer = *str; - } -} - -inline wchar* GetDigitsBuffer(NUMBER* number) -{ - return (number->allDigits != NULL) ? number->allDigits : number->digits; -} - -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("", on) // Go back to command line default optimizations -#endif - - -void RoundNumber(NUMBER* number, int pos) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(number != NULL); - - wchar_t* digits = GetDigitsBuffer(number); - int i = 0; - while (i < pos && digits[i] != 0) i++; - if (i == pos && digits[i] >= '5') { - while (i > 0 && digits[i - 1] == '9') i--; - if (i > 0) { - digits[i - 1]++; - } - else { - number->scale++; - digits[0] = '1'; - i = 1; - } - } - else { - while (i > 0 && digits[i - 1] == '0') i--; - } - if (i == 0) { - number->scale = 0; - number->sign = 0; - } - digits[i] = 0; - -} - -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("y", on) // Small critical routines, don't put in EBP frame -#endif - -wchar ParseFormatSpecifier(STRINGREF str, int* digits) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(digits != NULL); - - if (str != 0) { - wchar* p = str->GetBuffer(); - _ASSERTE(p != NULL); - wchar ch = *p; - if (ch != 0) { - if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z')) { - p++; - int n = -1; - if (*p >= '0' && *p <= '9') { - n = *p++ - '0'; - while (*p >= '0' && *p <= '9') { - n = n * 10 + *p++ - '0'; - if (n >= 10) break; - } - } - if (*p == 0) { - *digits = n; - return ch; - } - } - return 0; - } - } - *digits = -1; - return 'G'; -} - -wchar* FormatExponent(__in wchar* buffer, int value, wchar expChar, - STRINGREF posSignStr, STRINGREF negSignStr, int minDigits) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(buffer != NULL); - - wchar digits[11]; - *buffer++ = expChar; - if (value < 0) { - _ASSERTE(negSignStr != NULL); - AddStringRef(&buffer, negSignStr); - value = -value; - } - else { - if (posSignStr!= NULL) { - AddStringRef(&buffer, posSignStr); - } - } - wchar* p = COMNumber::Int32ToDecChars(digits + 10, value, minDigits); - _ASSERTE(p != NULL); - int i = (int) (digits + 10 - p); - while (--i >= 0) *buffer++ = *p++; - return buffer; -} - -#if defined(_MSC_VER) && defined(_TARGET_X86_) -#pragma optimize("", on) // Go back to command line default optimizations -#endif - -wchar* FormatGeneral(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits, int nMaxDigits, wchar expChar, - STRINGREF sNumberDecimal, STRINGREF sPositive, STRINGREF sNegative, STRINGREF sZero, BOOL bSuppressScientific = FALSE) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(number != NULL); - _ASSERTE(buffer != NULL); - - int digPos = number->scale; - int scientific = 0; - if (!bSuppressScientific) { // Don't switch to scientific notation - if (digPos > nMaxDigits || digPos < -3) { - digPos = 1; - scientific = 1; - } - } - - wchar* dig = GetDigitsBuffer(number); - _ASSERT(dig != NULL); - if (digPos > 0) { - do { - *buffer++ = *dig != 0? *dig++: '0'; - } while (--digPos > 0); - } - else { - *buffer++ = '0'; - } - if (*dig != 0 || digPos < 0) { - AddStringRef(&buffer, sNumberDecimal); - while (digPos < 0) { - *buffer++ = '0'; - digPos++; - } - while (*dig != 0) { - *buffer++ = *dig++; - } - } - if (scientific) buffer = FormatExponent(buffer, number->scale - 1, expChar, sPositive, sNegative, 2); - return buffer; -} - -wchar* FormatScientific(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits, int nMaxDigits, wchar expChar, - STRINGREF sNumberDecimal, STRINGREF sPositive, STRINGREF sNegative, STRINGREF sZero) -{ - WRAPPER_NO_CONTRACT - _ASSERTE(number != NULL); - _ASSERTE(buffer != NULL); - - wchar* dig = GetDigitsBuffer(number); - _ASSERTE(dig != NULL); - *buffer++ = *dig != 0? *dig++: '0'; - if (nMaxDigits != 1) // For E0 we would like to suppress the decimal point - AddStringRef(&buffer, sNumberDecimal); - while (--nMaxDigits > 0) *buffer++ = *dig != 0? *dig++: '0'; - int e = (GetDigitsBuffer(number))[0] == 0 ? 0 : number->scale - 1; - buffer = FormatExponent(buffer, e, expChar, sPositive, sNegative, 3); - _ASSERTE(buffer != NULL); - return buffer; -} - -wchar* FormatFixed(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits, int nMaxDigits, - I4ARRAYREF groupDigitsRef, STRINGREF sDecimal, STRINGREF sGroup, STRINGREF sNegative,STRINGREF sZero) -{ - CONTRACTL { - THROWS; - INJECT_FAULT(COMPlusThrowOM()); - GC_TRIGGERS; - MODE_COOPERATIVE; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckPointer(number)); - } CONTRACTL_END; - - int digPos = number->scale; - wchar* dig = GetDigitsBuffer(number); - const I4* groupDigits = NULL; - if (groupDigitsRef != NULL) { - groupDigits = groupDigitsRef->GetDirectConstPointerToNonObjectElements(); - } - - if (digPos > 0) { - if (groupDigits != NULL) { - - int groupSizeIndex = 0; // index into the groupDigits array. - int groupSizeCount = groupDigits[groupSizeIndex]; // the current total of group size. - int groupSizeLen = groupDigitsRef->GetNumComponents(); // the length of groupDigits array. - int bufferSize = digPos; // the length of the result buffer string. - int groupSeparatorLen = sGroup->GetStringLength(); // the length of the group separator string. - int groupSize = 0; // the current group size. - - // - // Find out the size of the string buffer for the result. - // - if (groupSizeLen != 0) // You can pass in 0 length arrays - { - while (digPos > groupSizeCount) { - groupSize = groupDigits[groupSizeIndex]; - if (groupSize == 0) { - break; - } - - bufferSize += groupSeparatorLen; - if (groupSizeIndex < groupSizeLen - 1) { - groupSizeIndex++; - } - groupSizeCount += groupDigits[groupSizeIndex]; - if (groupSizeCount < 0 || bufferSize < 0) { - COMPlusThrow(kArgumentOutOfRangeException); // if we overflow - } - } - if (groupSizeCount == 0) // If you passed in an array with one entry as 0, groupSizeCount == 0 - groupSize = 0; - else - groupSize = groupDigits[0]; - } - - groupSizeIndex = 0; - int digitCount = 0; - int digStart; - int digLength = (int)wcslen(dig); - digStart = (digPos=0; i--) { - *(p--) = (i 0) { - digitCount++; - if (digitCount == groupSize && i != 0) { - for (int j = groupSeparatorLen - 1; j >=0; j--) { - *(p--) = sGroup->GetBuffer()[j]; - } - - if (groupSizeIndex < groupSizeLen - 1) { - groupSizeIndex++; - groupSize = groupDigits[groupSizeIndex]; - } - digitCount = 0; - } - } - } - if (p < buffer - 1) { - // This indicates a buffer underflow since we write in backwards. - DoJITFailFast(); - } - buffer += bufferSize; - dig += digStart; - } else { - do { - *buffer++ = *dig != 0? *dig++: '0'; - } while (--digPos > 0); - } - } - else { - *buffer++ = '0'; - } - if (nMaxDigits > 0) { - AddStringRef(&buffer, sDecimal); - while (digPos < 0 && nMaxDigits > 0) { - *buffer++ = '0'; - digPos++; - nMaxDigits--; - } - while (nMaxDigits > 0) { - *buffer++ = *dig != 0? *dig++: '0'; - nMaxDigits--; - } - } - return buffer; -} - -wchar* FormatNumber(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits, int nMaxDigits, int cNegativeNumberFormat, I4ARRAYREF cNumberGroup, STRINGREF sNumberDecimal, STRINGREF sNumberGroup, STRINGREF sNegative, STRINGREF sZero) -{ - CONTRACTL { - MODE_COOPERATIVE; - THROWS; - GC_TRIGGERS; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckPointer(number)); - } CONTRACTL_END; - - char ch; - const char* fmt; - fmt = number->sign? - negNumberFormats[cNegativeNumberFormat]: - posNumberFormat; - - while ((ch = *fmt++) != 0) { - switch (ch) { - case '#': - buffer = FormatFixed(buffer, cchBuffer, number, nMinDigits,nMaxDigits, - cNumberGroup, - sNumberDecimal, sNumberGroup,sNegative,sZero); - break; - case '-': - AddStringRef(&buffer, sNegative); - break; - default: - *buffer++ = ch; - } - } - return buffer; - -} - -wchar* FormatCurrency(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits,int nMaxDigits, int cNegCurrencyFormat, int cPosCurrencyFormat, I4ARRAYREF cCurrencyGroup, - STRINGREF sCurrencyDecimal, STRINGREF sCurrencyGroup, STRINGREF sNegative, STRINGREF sCurrency,STRINGREF sZero) -{ - CONTRACTL { - MODE_COOPERATIVE; - THROWS; - GC_TRIGGERS; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckPointer(number)); - } CONTRACTL_END; - - char ch; - const char* fmt; - fmt = number->sign? - negCurrencyFormats[cNegCurrencyFormat]: - posCurrencyFormats[cPosCurrencyFormat]; - - while ((ch = *fmt++) != 0) { - switch (ch) { - case '#': - buffer = FormatFixed(buffer, cchBuffer, number, nMinDigits,nMaxDigits, - cCurrencyGroup, - sCurrencyDecimal, sCurrencyGroup,sNegative,sZero); - break; - case '-': - AddStringRef(&buffer, sNegative); - break; - case '$': - AddStringRef(&buffer, sCurrency); - break; - default: - *buffer++ = ch; - } - } - return buffer; -} - -wchar* FormatPercent(__in_ecount(cchBuffer) wchar* buffer, SIZE_T cchBuffer, NUMBER* number, int nMinDigits, int nMaxDigits, int cNegativePercentFormat, int cPositivePercentFormat, I4ARRAYREF cPercentGroup, - STRINGREF sPercentDecimal, STRINGREF sPercentGroup, STRINGREF sNegative, STRINGREF sPercent, STRINGREF sZero) -{ - CONTRACTL { - MODE_COOPERATIVE; - THROWS; - GC_TRIGGERS; - PRECONDITION(CheckPointer(buffer)); - PRECONDITION(CheckPointer(number)); - } CONTRACTL_END; - - char ch; - const char* fmt; - fmt = number->sign? - negPercentFormats[cNegativePercentFormat]: - posPercentFormats[cPositivePercentFormat]; - - while ((ch = *fmt++) != 0) { - switch (ch) { - case '#': - buffer = FormatFixed(buffer, cchBuffer, number, nMinDigits,nMaxDigits, - cPercentGroup, - sPercentDecimal, sPercentGroup,sNegative,sZero); - break; - case '-': - AddStringRef(&buffer, sNegative); - break; - case '%': - AddStringRef(&buffer, sPercent); - break; - default: - *buffer++ = ch; - } - } - return buffer; -} - -STRINGREF NumberToString(NUMBER* number, wchar format, int nMaxDigits, NUMFMTREF numfmt, BOOL bDecimal = FALSE ) -{ - CONTRACTL { - THROWS; - INJECT_FAULT(COMPlusThrowOM()); - GC_TRIGGERS; - MODE_COOPERATIVE; - PRECONDITION(CheckPointer(number)); - } CONTRACTL_END; - - int nMinDigits=-1; - STRINGREF sZero=NULL; - - // @TODO what if not sequential? - - // Do the worst case calculation - /* US English - for Double.MinValue.ToString("C99"); we require 514 characters - ---------- - 2 paranthesis - 1 currency character - 308 characters - 103 group seperators - 1 decimal separator - 99 0's - - digPos + 99 + 6(slack) => digPos + 105 - C - sNegative - sCurrencyGroup - sCurrencyDecimal - sCurrency - F - sNegative - sNumberDecimal - N - sNegative - sNumberDecimal - sNumberGroup - E - sNegative - sPositive - sNegative (for exponent) - sPositive - sNumberDecimal - G - sNegative - sPositive - sNegative (for exponent) - sPositive - sNumberDecimal - P (+2 for some spaces) - sNegative - sPercentGroup - sPercentDecimal - sPercent - */ - - _ASSERTE(numfmt != NULL); - UINT64 newBufferLen = MIN_BUFFER_SIZE; - - CQuickBytesSpecifySize buf; - - wchar *buffer = NULL; - wchar* dst = NULL; - wchar ftype = format & 0xFFDF; - int digCount = 0; - - switch (ftype) { - case 'C': - { - nMinDigits = nMaxDigits >= 0 ? nMaxDigits : numfmt->cCurrencyDecimals; - - if (nMaxDigits< 0) - nMaxDigits = numfmt->cCurrencyDecimals; - if (number->scale < 0) - digCount = 0; - else if (!ClrSafeInt::addition(number->scale, nMaxDigits, digCount)) - COMPlusThrowOM(); - - // It is critical to format with the same values that we use to calculate buffer size. - int cNegCurrencyFormat = numfmt->cNegCurrencyFormat; - int cPosCurrencyFormat = numfmt->cPosCurrencyFormat; - I4ARRAYREF cCurrencyGroup = numfmt->cCurrencyGroup; - STRINGREF sCurrencyDecimal = numfmt->sCurrencyDecimal; - STRINGREF sCurrencyGroup = numfmt->sCurrencyGroup; - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sCurrency = numfmt->sCurrency; - // Prefix: bogus warning 22011: newBufferLen+=digCount may be smaller than MIN_BUFFER_SIZE - PREFIX_ASSUME(digCount >=0 && digCount <= INT32_MAX); - newBufferLen += digCount; - newBufferLen += sNegative->GetStringLength(); // For number and exponent - if (!ClrSafeInt::addition((UINT64)sCurrencyGroup->GetStringLength() * digCount, newBufferLen, newBufferLen)) - COMPlusThrowOM(); - newBufferLen += sCurrencyDecimal->GetStringLength(); - newBufferLen += sCurrency->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - RoundNumber(number, number->scale + nMaxDigits); // Don't change this line to use digPos since digCount could have its sign changed. - dst = FormatCurrency(dst, static_cast(newBufferLen/sizeof(WCHAR)), number, nMinDigits,nMaxDigits, cNegCurrencyFormat, cPosCurrencyFormat, cCurrencyGroup, sCurrencyDecimal, sCurrencyGroup, sNegative, sCurrency,sZero); - - break; - } - case 'F': - { - if (nMaxDigits< 0) - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = numfmt->cNumberDecimals; - else - nMinDigits=nMaxDigits; - - if (number->scale < 0) - digCount = 0; - else - digCount = number->scale + nMaxDigits; - - - // It is critical to format with the same values that we use to calculate buffer size. - STRINGREF sNumberDecimal = numfmt->sNumberDecimal; - STRINGREF sNegative = numfmt->sNegative; - - newBufferLen += digCount; - newBufferLen += sNegative->GetStringLength(); // For number and exponent - newBufferLen += sNumberDecimal->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - RoundNumber(number, number->scale + nMaxDigits); - if (number->sign) { - AddStringRef(&dst, sNegative); - } - dst = FormatFixed(dst, static_cast(newBufferLen/sizeof(WCHAR)-(dst-buffer)), number, nMinDigits,nMaxDigits, - NULL, - sNumberDecimal, NULL, sNegative, sZero); - - break; - } - case 'N': - { - if (nMaxDigits < 0) - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = numfmt->cNumberDecimals; // Since we are using digits in our calculation - else - nMinDigits=nMaxDigits; - - if (number->scale < 0) - digCount = 0; - else - digCount = number->scale + nMaxDigits; - - // It is critical to format with the same values that we use to calculate buffer size. - I4ARRAYREF cNumberGroup = numfmt->cNumberGroup; - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sNumberDecimal = numfmt->sNumberDecimal; - STRINGREF sNumberGroup = numfmt->sNumberGroup; - int cNegativeNumberFormat = numfmt->cNegativeNumberFormat; - newBufferLen += digCount; - newBufferLen += sNegative->GetStringLength(); // For number and exponent - if (!ClrSafeInt::addition((UINT64)sNumberGroup->GetStringLength() * digCount, newBufferLen, newBufferLen)) - COMPlusThrowOM(); - newBufferLen += sNumberDecimal->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - RoundNumber(number, number->scale + nMaxDigits); - dst = FormatNumber(dst, static_cast(newBufferLen/sizeof(WCHAR)),number, nMinDigits, nMaxDigits, cNegativeNumberFormat, cNumberGroup, sNumberDecimal, sNumberGroup, sNegative, sZero); - - break; - } - case 'E': - { - // It is critical to format with the same values that we use to calculate buffer size. - STRINGREF sNumberDecimal = numfmt->sNumberDecimal; - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sPositive = numfmt->sPositive; - - if (nMaxDigits < 0) - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = 6; - else - nMinDigits=nMaxDigits; - nMaxDigits++; - - newBufferLen += nMaxDigits; - newBufferLen += (((INT64)sNegative->GetStringLength() + sPositive->GetStringLength()) *2); // For number and exponent - newBufferLen += sNumberDecimal->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - RoundNumber(number, nMaxDigits); - if (number->sign) { - AddStringRef(&dst, sNegative); - } - dst = FormatScientific(dst, static_cast(newBufferLen * sizeof(WCHAR)-(dst-buffer)),number, nMinDigits,nMaxDigits, format, sNumberDecimal, sPositive, sNegative,sZero); - - break; - } - case 'G': - { - bool enableRounding = true; - if (nMaxDigits < 1) { - if (bDecimal && (nMaxDigits == -1)) { // Default to 29 digits precision only for G formatting without a precision specifier - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = DECIMAL_PRECISION; - enableRounding = false; // Turn off rounding for ECMA compliance to output trailing 0's after decimal as significant - } - else { - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = number->precision; - } - } - else - nMinDigits=nMaxDigits; - - // It is critical to format with the same values that we use to calculate buffer size. - STRINGREF sNumberDecimal = numfmt->sNumberDecimal; - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sPositive = numfmt->sPositive; - newBufferLen += nMaxDigits; - newBufferLen += (((INT64)sNegative->GetStringLength() + sPositive->GetStringLength()) *2); // For number and exponent - newBufferLen += sNumberDecimal->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - if (enableRounding) // Don't round for G formatting without precision - RoundNumber(number, nMaxDigits); // This also fixes up the minus zero case - else { - if (bDecimal && ((GetDigitsBuffer(number))[0] == 0)) { // Minus zero should be formatted as 0 - number->sign = 0; - } - } - if (number->sign) { - AddStringRef(&dst, sNegative); - } - - - dst = FormatGeneral(dst, static_cast(newBufferLen/sizeof(WCHAR)), number, nMinDigits,nMaxDigits, format - ('G' - 'E'), sNumberDecimal, sPositive, sNegative, sZero, !enableRounding); - - } - break; - case 'P': - { - if (nMaxDigits< 0) - // This ensures that the PAL code pads out to the correct place even when we use the default precision - nMaxDigits = nMinDigits = numfmt->cPercentDecimals; - else - nMinDigits=nMaxDigits; - number->scale += 2; - - if (number->scale < 0) - digCount = 0; - else - digCount = number->scale + nMaxDigits; - - - - // It is critical to format with the same values that we use to calculate buffer size. - int cNegativePercentFormat = numfmt->cNegativePercentFormat; - int cPositivePercentFormat = numfmt->cPositivePercentFormat; - I4ARRAYREF cPercentGroup = numfmt->cPercentGroup; - STRINGREF sPercentDecimal = numfmt->sPercentDecimal; - STRINGREF sPercentGroup = numfmt->sPercentGroup; - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sPercent = numfmt->sPercent; - - newBufferLen += digCount; - newBufferLen += sNegative->GetStringLength(); // For number and exponent - if (!ClrSafeInt::addition((UINT64)sPercentGroup->GetStringLength() * digCount, newBufferLen, newBufferLen)) - COMPlusThrowOM(); - newBufferLen += sPercentDecimal->GetStringLength(); - newBufferLen += sPercent->GetStringLength(); - - _ASSERTE(newBufferLen >= MIN_BUFFER_SIZE); - if (newBufferLen > INT32_MAX) { - COMPlusThrowOM(); - } - newBufferLen = newBufferLen * sizeof(WCHAR); - dst = buffer = (WCHAR*)buf.AllocThrows(static_cast(newBufferLen)); - - RoundNumber(number, number->scale + nMaxDigits); - dst = FormatPercent(dst, static_cast(newBufferLen/sizeof(WCHAR)),number, nMinDigits,nMaxDigits, cNegativePercentFormat, cPositivePercentFormat, cPercentGroup, sPercentDecimal, sPercentGroup, sNegative, sPercent, sZero); - - break; - } - default: - COMPlusThrow(kFormatException, W("Argument_BadFormatSpecifier")); - } - // check for overflow of the preallocated buffer -// Review signed/unsigned mismatch in '<=' comparison. -#pragma warning(push) -#pragma warning(disable:4018) - if (!((dst - buffer >= 0) && (dst - buffer) <= (newBufferLen / sizeof(WCHAR) ))) { -#pragma warning(pop) - DoJITFailFast(); - } - - return StringObject::NewString(buffer, (int) (dst - buffer)); -} - -LPCWSTR FindSection(LPCWSTR format, int section) -{ - LIMITED_METHOD_CONTRACT - _ASSERTE(format != NULL); - - LPCWSTR src; - wchar ch; - if (section == 0) return format; - src = format; - for (;;) { - switch (ch = *src++) { - case '\'': - case '"': - while (*src != 0 && *src++ != ch); - break; - case '\\': - if (*src != 0) src++; - break; - case ';': - if (--section != 0) break; - if (*src != 0 && *src != ';') return src; - case 0: - return format; - } - } -} - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:21000) // Suppress PREFast warning about overly large function -#endif -STRINGREF NumberToStringFormat(NUMBER* number, STRINGREF str, NUMFMTREF numfmt) -{ - CONTRACTL { - THROWS; - INJECT_FAULT(COMPlusThrowOM()); - GC_TRIGGERS; - MODE_COOPERATIVE; - } CONTRACTL_END; - - int digitCount; - int decimalPos; - int firstDigit; - int lastDigit; - int digPos; - int scientific; - int percent; - int permille; - int thousandPos; - int thousandCount = 0; - int thousandSeps; - int scaleAdjust; - int adjust; - wchar* format=NULL; - LPCWSTR section=NULL; - LPCWSTR src=NULL; - wchar* dst=NULL; - wchar* dig=NULL; - wchar ch; - wchar* buffer=NULL; - CQuickBytes buf; - - _ASSERTE(str != NULL); - _ASSERTE(numfmt != NULL); - - STRINGREF sNegative = numfmt->sNegative; - STRINGREF sPositive = numfmt->sPositive; - STRINGREF sNumberDecimal = numfmt->sNumberDecimal; - STRINGREF sPercent = numfmt->sPercent; - STRINGREF sPerMille = numfmt->sPerMille; - STRINGREF sNumberGroup = numfmt->sNumberGroup; - I4ARRAYREF cNumberGroup = numfmt->cNumberGroup; - - format = str->GetBuffer(); - - section = FindSection(format, (GetDigitsBuffer(number))[0] == 0 ? 2 : number->sign ? 1 : 0); - -ParseSection: - digitCount = 0; - decimalPos = -1; - firstDigit = 0x7FFFFFFF; - lastDigit = 0; - scientific = 0; - percent = 0; - permille = 0; - thousandPos = -1; - thousandSeps = 0; - scaleAdjust = 0; - src = section; - _ASSERTE(src != NULL); - while ((ch = *src++) != 0 && ch != ';') { - switch (ch) { - case '#': - digitCount++; - break; - case '0': - if (firstDigit == 0x7FFFFFFF) firstDigit = digitCount; - digitCount++; - lastDigit = digitCount; - break; - case '.': - if (decimalPos < 0) { - decimalPos = digitCount; - } - break; - case ',': - if (digitCount > 0 && decimalPos < 0) { - if (thousandPos >= 0) { - if (thousandPos == digitCount) { - thousandCount++; - break; - } - thousandSeps = 1; - } - thousandPos = digitCount; - thousandCount = 1; - } - break; - case '%': - percent++; - scaleAdjust += 2; - break; - case 0x2030: - permille++; - scaleAdjust += 3; - break; - case '\'': - case '"': - while (*src != 0 && *src++ != ch); - break; - case '\\': - if (*src != 0) src++; - break; - case 'E': - case 'e': - if (*src=='0' || ((*src == '+' || *src == '-') && src[1] == '0')) { - while (*++src == '0'); - scientific = 1; - } - break; - } - } - - if (decimalPos < 0) decimalPos = digitCount; - if (thousandPos >= 0) { - if (thousandPos == decimalPos) { - scaleAdjust -= thousandCount * 3; - } - else { - thousandSeps = 1; - } - } - if ((GetDigitsBuffer(number))[0] != 0) { - number->scale += scaleAdjust; - int pos = scientific? digitCount: number->scale + digitCount - decimalPos; - RoundNumber(number, pos); - if ((GetDigitsBuffer(number))[0] == 0) { - src = FindSection(format, 2); - if (src != section) { - section = src; - goto ParseSection; - } - } - } else { - number->sign = 0; // We need to format -0 without the sign set. - number->scale = 0; // Decimals with scale ('0.00') should be rounded. - } - - firstDigit = firstDigit < decimalPos? decimalPos - firstDigit: 0; - lastDigit = lastDigit > decimalPos? decimalPos - lastDigit: 0; - if (scientific) { - digPos = decimalPos; - adjust = 0; - } - else { - digPos = number->scale > decimalPos? number->scale: decimalPos; - adjust = number->scale - decimalPos; - } - src = section; - dig = GetDigitsBuffer(number); - - // Find maximum number of characters that the destination string can grow by - // in the following while loop. Use this to avoid buffer overflows. - // Longest strings are potentially +/- signs with 10 digit exponents, - // or decimal numbers, or the while loops copying from a quote or a \ onwards. - // Check for positive and negative - UINT64 maxStrIncLen = 0; // We need this to be UINT64 since the percent computation could go beyond a UINT. - if (number->sign) { - maxStrIncLen = sNegative->GetStringLength(); - } - else { - maxStrIncLen = sPositive->GetStringLength(); - } - - // Add for any big decimal seperator - maxStrIncLen += sNumberDecimal->GetStringLength(); - - // Add for scientific - if (scientific) { - int inc1 = sPositive->GetStringLength(); - int inc2 = sNegative->GetStringLength(); - maxStrIncLen +=(inc1>inc2)?inc1:inc2; - } - - // Add for percent separator - if (percent) { - maxStrIncLen += ((INT64)sPercent->GetStringLength()) * percent; - } - - // Add for permilli separator - if (permille) { - maxStrIncLen += ((INT64)sPerMille->GetStringLength()) * permille; - } - - //adjust can be negative, so we make this an int instead of an unsigned int. - // adjust represents the number of characters over the formatting eg. format string is "0000" and you are trying to - // format 100000 (6 digits). Means adjust will be 2. On the other hand if you are trying to format 10 adjust will be - // -2 and we'll need to fixup these digits with 0 padding if we have 0 formatting as in this example. - INT64 adjustLen=(adjust>0)?adjust:0; // We need to add space for these extra characters anyway. - CQuickBytes thousands; - INT32 bufferLen2 = 125; - INT32 *thousandsSepPos = NULL; - INT32 thousandsSepCtr = -1; - - if (thousandSeps) { // Fixup possible buffer overrun problems - // We need to precompute this outside the number formatting loop - if(cNumberGroup->GetNumComponents() == 0) { - thousandSeps = 0; // Nothing to add - } - else { - thousandsSepPos = (INT32 *)thousands.AllocThrows(bufferLen2 * sizeof(INT32)); - // We need this array to figure out where to insert the thousands separator. We would have to traverse the string - // backwards. PIC formatting always traverses forwards. These indices are precomputed to tell us where to insert - // the thousands separator so we can get away with traversing forwards. Note we only have to compute up to digPos. - // The max is not bound since you can have formatting strings of the form "000,000..", and this - // should handle that case too. - - const I4* groupDigits = cNumberGroup->GetDirectConstPointerToNonObjectElements(); - _ASSERTE(groupDigits != NULL); - - int groupSizeIndex = 0; // index into the groupDigits array. - INT64 groupTotalSizeCount = 0; - int groupSizeLen = cNumberGroup->GetNumComponents(); // the length of groupDigits array. - if (groupSizeLen != 0) - groupTotalSizeCount = groupDigits[groupSizeIndex]; // the current running total of group size. - int groupSize = static_cast(groupTotalSizeCount); // safe cast as long as groupDigits remains I4 - - int totalDigits = digPos + ((adjust < 0)?adjust:0); // actual number of digits in o/p - int numDigits = (firstDigit > totalDigits) ? firstDigit : totalDigits; - while (numDigits > groupTotalSizeCount) { - if (groupSize == 0) - break; - thousandsSepPos[++thousandsSepCtr] = static_cast(groupTotalSizeCount); - if (groupSizeIndex < groupSizeLen - 1) { - groupSizeIndex++; - groupSize = groupDigits[groupSizeIndex]; - } - groupTotalSizeCount += groupSize; - if (bufferLen2 - thousandsSepCtr < 10) { // Slack of 10 - bufferLen2 *= 2; - thousands.ReSizeThrows(bufferLen2*sizeof(INT32)); // memcopied by CQuickBytes automatically - thousandsSepPos = (INT32 *)thousands.Ptr(); - } - } - - // We already have computed the number of separators above. Simply add space for them. - adjustLen += ( (thousandsSepCtr + 1) * ((INT64)sNumberGroup->GetStringLength())); - } - } - - maxStrIncLen += adjustLen; - - // Allocate temp buffer - gotta deal with Schertz' 500 MB strings. - // Some computations like when you specify Int32.MaxValue-2 %'s and each percent is setup to be Int32.MaxValue in length - // will generate a result that will be largest than an unsigned int can hold. This is to protect against overflow. - UINT64 tempLen = str->GetStringLength() + maxStrIncLen + 10; // Include a healthy amount of temp space. - if (tempLen > 0x7FFFFFFF) - COMPlusThrowOM(); // if we overflow - - unsigned int bufferLen = (UINT)tempLen; - if (bufferLen < 250) // Stay under 512 bytes - bufferLen = 250; // This is to prevent unnecessary calls to resize - buffer = (wchar *) buf.AllocThrows(bufferLen* sizeof(WCHAR)); - dst = buffer; - - - if (number->sign && section == format) { - AddStringRef(&dst, sNegative); - } - - BOOL decimalWritten = FALSE; - - while ((ch = *src++) != 0 && ch != ';') { - // Make sure temp buffer is big enough, else resize it. - if (bufferLen - (unsigned int)(dst-buffer) < 10) { - int offset = static_cast(dst - buffer); - bufferLen *= 2; - buf.ReSizeThrows(bufferLen*sizeof(WCHAR)); - buffer = (wchar*)buf.Ptr(); // memcopied by QuickBytes automatically - dst = buffer + offset; - } - - if (adjust > 0) { - switch (ch) { - case '#': - case '0': - case '.': - while (adjust > 0) { // digPos will be one greater than thousandsSepPos[thousandsSepCtr] since we are at - // the character after which the groupSeparator needs to be appended. - *dst++ = *dig != 0? *dig++: '0'; - if (thousandSeps && digPos > 1 && thousandsSepCtr>=0) { - if (digPos == thousandsSepPos[thousandsSepCtr] + 1) { - AddStringRef(&dst, sNumberGroup); - thousandsSepCtr--; - } - } - digPos--; - adjust--; - } - } - } - - switch (ch) { - case '#': - case '0': - { - if (adjust < 0) { - adjust++; - ch = digPos <= firstDigit? '0': 0; - } - else { - ch = *dig != 0? *dig++: digPos > lastDigit? '0': 0; - } - if (ch != 0) { - *dst++ = ch; - if (thousandSeps && digPos > 1 && thousandsSepCtr>=0) { - if (digPos == thousandsSepPos[thousandsSepCtr] + 1) { - AddStringRef(&dst, sNumberGroup); - thousandsSepCtr--; - } - } - } - - digPos--; - break; - } - case '.': - { - if (digPos != 0 || decimalWritten) { - // For compatibility, don't echo repeated decimals - break; - } - // If the format has trailing zeros or the format has a decimal and digits remain - if (lastDigit < 0 - || (decimalPos < digitCount && *dig != 0)) { - AddStringRef(&dst, sNumberDecimal); - decimalWritten = TRUE; - } - break; - } - case 0x2030: - AddStringRef(&dst, sPerMille); - break; - case '%': - AddStringRef(&dst, sPercent); - break; - case ',': - break; - case '\'': - case '"': - // Buffer overflow possibility - while (*src != 0 && *src != ch) { - *dst++ = *src++; - if ((unsigned int)(dst-buffer) == bufferLen-1) { - if (bufferLen - (unsigned int)(dst-buffer) < maxStrIncLen) { - int offset = static_cast(dst - buffer); - bufferLen *= 2; - buf.ReSizeThrows(bufferLen*sizeof(WCHAR)); // memcopied by CQuickBytes automatically - buffer = (wchar *)buf.Ptr(); - dst = buffer + offset; - } - } - } - if (*src != 0) src++; - break; - case '\\': - if (*src != 0) *dst++ = *src++; - break; - case 'E': - case 'e': - { - STRINGREF sign = NULL; - int i = 0; - if (scientific) { - if (*src=='0') { - //Handles E0, which should format the same as E-0 - i++; - } else if (*src == '+' && src[1] == '0') { - //Handles E+0 - sign = sPositive; - } else if (*src == '-' && src[1] == '0') { - //Handles E-0 - //Do nothing, this is just a place holder s.t. we don't break out of the loop. - } else { - *dst++ = ch; - break; - } - while (*++src == '0') i++; - if (i > 10) i = 10; - int exp = (GetDigitsBuffer(number))[0] == 0 ? 0 : number->scale - decimalPos; - dst = FormatExponent(dst, exp, ch, sign, sNegative, i); - scientific = 0; - } - else - { - *dst++ = ch; // Copy E or e to output - if (*src== '+' || *src == '-') { - *dst++ = *src++; - } - while (*src == '0') { - *dst++ = *src++; - } - } - break; - } - default: - *dst++ = ch; - } - } - if (!((dst - buffer >= 0) && (dst - buffer <= (int)bufferLen))) { - DoJITFailFast(); - } - STRINGREF newStr = StringObject::NewString(buffer, (int)(dst - buffer)); - return newStr; -} -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - FCIMPL3_VII(void, COMNumber::DoubleToNumberFC, double value, int precision, NUMBER* number) { FCALL_CONTRACT; @@ -2000,11 +759,3 @@ FCIMPL1(double, COMNumber::NumberToDoubleFC, NUMBER* number) return d; } FCIMPLEND - -FCIMPL2(FC_BOOL_RET, COMNumber::NumberBufferToDecimal, NUMBER* number, DECIMAL* value) -{ - FCALL_CONTRACT; - - FC_RETURN_BOOL(COMDecimal::NumberToDecimal(number, value) != 0); -} -FCIMPLEND diff --git a/src/classlibnative/bcltype/number.h b/src/classlibnative/bcltype/number.h index bf1f328b0200..22c74cacdb7e 100644 --- a/src/classlibnative/bcltype/number.h +++ b/src/classlibnative/bcltype/number.h @@ -33,9 +33,6 @@ class COMNumber public: static FCDECL3_VII(void, DoubleToNumberFC, double value, int precision, NUMBER* number); static FCDECL1(double, NumberToDoubleFC, NUMBER* number); - static FCDECL2(FC_BOOL_RET, NumberBufferToDecimal, NUMBER* number, DECIMAL* value); - - static wchar_t* Int32ToDecChars(__in wchar_t* p, unsigned int value, int digits); }; #include diff --git a/src/classlibnative/bcltype/windowsruntimebufferhelper.cpp b/src/classlibnative/bcltype/windowsruntimebufferhelper.cpp deleted file mode 100644 index c99730e3aadf..000000000000 --- a/src/classlibnative/bcltype/windowsruntimebufferhelper.cpp +++ /dev/null @@ -1,44 +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. - -#ifdef FEATURE_COMINTEROP - -#include "common.h" -#include "ComCallableWrapper.h" -#include "WindowsRuntimeBufferHelper.h" - -void QCALLTYPE WindowsRuntimeBufferHelper::StoreOverlappedPtrInCCW(QCall::ObjectHandleOnStack winRtBuffer, LPOVERLAPPED lpOverlapped) { - - QCALL_CONTRACT; - - BEGIN_QCALL; - - GCX_COOP(); - OBJECTREF buffer = ObjectToOBJECTREF(*winRtBuffer.m_ppObject); - - ComCallWrapper *ccw = ComCallWrapper::GetWrapperForObject(buffer); - SimpleComCallWrapper *simpleCCW = ccw->GetSimpleWrapper(); - - simpleCCW->StoreOverlappedPointer(lpOverlapped); - - END_QCALL; -} - - -void WindowsRuntimeBufferHelper::ReleaseOverlapped(LPOVERLAPPED lpOverlapped) { - - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_ANY; - SO_TOLERANT; - } - CONTRACTL_END; - - GCX_COOP(); - OverlappedDataObject::GetOverlapped(lpOverlapped)->FreeAsyncPinHandles(); -} - -#endif // ifdef FEATURE_COMINTEROP diff --git a/src/classlibnative/bcltype/windowsruntimebufferhelper.h b/src/classlibnative/bcltype/windowsruntimebufferhelper.h deleted file mode 100644 index 42596515a03e..000000000000 --- a/src/classlibnative/bcltype/windowsruntimebufferhelper.h +++ /dev/null @@ -1,27 +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. - -#ifndef _WINDOWSRUNTIMEBUFFERHELPER_H_ -#define _WINDOWSRUNTIMEBUFFERHELPER_H_ - -#ifdef FEATURE_COMINTEROP - -#include "nativeoverlapped.h" -#include "qcall.h" - -class WindowsRuntimeBufferHelper { - -private: - - -public: - - static void QCALLTYPE StoreOverlappedPtrInCCW(QCall::ObjectHandleOnStack winRtBuffer, LPOVERLAPPED lpOverlapped); - static void ReleaseOverlapped(LPOVERLAPPED lpOverlapped); - -}; - -#endif // ifdef FEATURE_COMINTEROP - -#endif // _WINDOWSRUNTIMEBUFFERHELPER_H_ diff --git a/src/coreclr/hosts/corerun/corerun.cpp b/src/coreclr/hosts/corerun/corerun.cpp index 47ec36310529..c1d1fcef492b 100644 --- a/src/coreclr/hosts/corerun/corerun.cpp +++ b/src/coreclr/hosts/corerun/corerun.cpp @@ -110,7 +110,7 @@ class HostEnvironment // Check for %CORE_ROOT% and try to load CoreCLR.dll from it if it is set StackSString coreRoot; - m_coreCLRModule = NULL; // Initialize this here since we don't call TryLoadCoreCLR if CORE_ROOT is unset. + m_coreCLRModule = NULL; // Initialize this here since we don't call TryLoadCoreCLR if CORE_ROOT is unset. if (WszGetEnvironmentVariable(W("CORE_ROOT"), coreRoot) > 0 && coreRoot.GetCount() > 0) { coreRoot.Append(W('\\')); @@ -365,6 +365,64 @@ STARTUP_FLAGS CreateStartupFlags() { return initialFlags; } +// Class used to manage activation context. +// See: https://docs.microsoft.com/en-us/windows/desktop/SbsCs/using-the-activation-context-api +class ActivationContext +{ +public: + // logger - Logger to record errors + // assemblyPath - Assembly containing activation context manifest + ActivationContext(Logger &logger, _In_z_ const WCHAR *assemblyPath) + : _actCookie{} + , _actCxt{ INVALID_HANDLE_VALUE } + , _logger{ logger } + { + ACTCTX cxt{}; + cxt.cbSize = sizeof(cxt); + cxt.dwFlags = (ACTCTX_FLAG_APPLICATION_NAME_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID); + cxt.lpSource = assemblyPath; + cxt.lpResourceName = MAKEINTRESOURCEW(1); // The CreateProcess manifest which contains the context details + + _actCxt = ::CreateActCtxW(&cxt); + if (_actCxt == INVALID_HANDLE_VALUE) + { + DWORD err = ::GetLastError(); + if (err == ERROR_RESOURCE_TYPE_NOT_FOUND) + { + _logger << W("Assembly does not contain a manifest for activation") << Logger::endl; + } + else + { + _logger << W("Activation Context creation failed. Error Code: ") << Logger::hresult << err << Logger::endl; + } + } + else + { + BOOL res = ::ActivateActCtx(_actCxt, &_actCookie); + if (res == FALSE) + _logger << W("Failed to activate Activation Context. Error Code: ") << Logger::hresult << ::GetLastError() << Logger::endl; + } + } + + ~ActivationContext() + { + if (_actCookie != ULONG_PTR{}) + { + BOOL res = ::DeactivateActCtx(0, _actCookie); + if (res == FALSE) + _logger << W("Failed to de-activate Activation Context. Error Code: ") << Logger::hresult << ::GetLastError() << Logger::endl; + } + + if (_actCxt != INVALID_HANDLE_VALUE) + ::ReleaseActCtx(_actCxt); + } + +private: + Logger &_logger; + HANDLE _actCxt; + ULONG_PTR _actCookie; +}; + bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbose, const bool waitForDebugger, DWORD &exitCode) { @@ -578,14 +636,18 @@ bool TryRun(const int argc, const wchar_t* argv[], Logger &log, const bool verbo } } - hr = host->ExecuteAssembly(domainId, managedAssemblyFullName, argc-1, (argc-1)?&(argv[1]):NULL, &exitCode); - if (FAILED(hr)) { - log << W("Failed call to ExecuteAssembly. ERRORCODE: ") << Logger::hresult << hr << Logger::endl; - return false; - } + { + ActivationContext cxt{ log, managedAssemblyFullName.GetUnicode() }; - log << W("App exit value = ") << exitCode << Logger::endl; + hr = host->ExecuteAssembly(domainId, managedAssemblyFullName, argc - 1, (argc - 1) ? &(argv[1]) : NULL, &exitCode); + if (FAILED(hr)) + { + log << W("Failed call to ExecuteAssembly. ERRORCODE: ") << Logger::hresult << hr << Logger::endl; + return false; + } + log << W("App exit value = ") << exitCode << Logger::endl; + } //------------------------------------------------------------- diff --git a/src/debug/createdump/CMakeLists.txt b/src/debug/createdump/CMakeLists.txt index 4272cfcb875c..4e5b7a15f150 100644 --- a/src/debug/createdump/CMakeLists.txt +++ b/src/debug/createdump/CMakeLists.txt @@ -20,7 +20,7 @@ include_directories(BEFORE ${VM_DIR}) add_definitions(-DPAL_STDCPP_COMPAT=1) -add_compile_options(-fPIC) +add_compile_options(-fPIE) set(CREATEDUMP_SOURCES createdump.cpp @@ -36,11 +36,14 @@ _add_library(createdump_lib _add_executable(createdump main.cpp + ${PAL_REDEFINES_FILE} ) +add_dependencies(createdump pal_redefines_file) + target_link_libraries(createdump createdump_lib - # share the PAL in the dac module + # share the PAL/corguids in the dac module mscordaccore ) diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp index e5cc45beb79c..598fb2ff2c7d 100644 --- a/src/debug/daccess/dacdbiimpl.cpp +++ b/src/debug/daccess/dacdbiimpl.cpp @@ -7169,7 +7169,7 @@ HRESULT DacDbiInterfaceImpl::GetActiveRejitILCodeVersionNode(VMPTR_Module vmModu // manager's active IL version hasn't yet asked the profiler for the IL body to use, in which case we want to filter it // out from the return in this method. ILCodeVersion activeILVersion = pCodeVersionManager->GetActiveILCodeVersion(pModule, methodTk); - if (activeILVersion.IsNull() || activeILVersion.GetRejitState() != ILCodeVersion::kStateActive) + if (activeILVersion.IsNull() || activeILVersion.IsDefaultVersion() || activeILVersion.GetRejitState() != ILCodeVersion::kStateActive) { pVmILCodeVersionNode->SetDacTargetPtr(0); } diff --git a/src/debug/daccess/dacimpl.h b/src/debug/daccess/dacimpl.h index 2647c8d30070..6147de3dde1b 100644 --- a/src/debug/daccess/dacimpl.h +++ b/src/debug/daccess/dacimpl.h @@ -2005,7 +2005,7 @@ class DacStackReferenceWalker : public DefaultCOMImpl mCurr = &mHead; // Walk the stack, set mEnumerated to true to ensure we don't do it again. - unsigned int flagsStackWalk = ALLOW_INVALID_OBJECTS|ALLOW_ASYNC_STACK_WALK; + unsigned int flagsStackWalk = ALLOW_INVALID_OBJECTS|ALLOW_ASYNC_STACK_WALK|SKIP_GSCOOKIE_CHECK; #if defined(WIN64EXCEPTIONS) flagsStackWalk |= GC_FUNCLET_REFERENCE_REPORTING; #endif // defined(WIN64EXCEPTIONS) diff --git a/src/debug/daccess/nidump.cpp b/src/debug/daccess/nidump.cpp index 0cd03ae9442c..ca9a60055567 100644 --- a/src/debug/daccess/nidump.cpp +++ b/src/debug/daccess/nidump.cpp @@ -5907,7 +5907,9 @@ void NativeImageDumper::DumpTypes(PTR_Module module) for (COUNT_T i = 0; i < slotChunkCount; ++i) { - DumpMethodTableSlotChunk(m_discoveredSlotChunks[i].addr, m_discoveredSlotChunks[i].nSlots); + DumpMethodTableSlotChunk(m_discoveredSlotChunks[i].addr, + m_discoveredSlotChunks[i].nSlots, + m_discoveredSlotChunks[i].isRelative); } } DisplayEndArray( "Total MethodTableSlotChunks", METHODTABLES ); @@ -7172,8 +7174,9 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, while (itIndirect.Next()) { SlotChunk sc; - sc.addr = itIndirect.GetIndirectionSlot(); + sc.addr = dac_cast(itIndirect.GetIndirectionSlot()); sc.nSlots = (WORD)itIndirect.GetNumSlots(); + sc.isRelative = MethodTable::VTableIndir2_t::isRelative; m_discoveredSlotChunks.AppendEx(sc); } @@ -7185,7 +7188,7 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, DisplayStartElement( "Slot", ALWAYS ); DisplayWriteElementInt( "Index", i, ALWAYS ); TADDR base = dac_cast(&(mt->GetVtableIndirections()[i])); - PTR_PCODE tgt = MethodTable::VTableIndir_t::GetValueMaybeNullAtPtr(base); + DPTR(MethodTable::VTableIndir2_t) tgt = MethodTable::VTableIndir_t::GetValueMaybeNullAtPtr(base); DisplayWriteElementPointer( "Pointer", DataPtrToDisplay(dac_cast(tgt)), ALWAYS ); @@ -7207,8 +7210,9 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, DisplayEndElement( ALWAYS ); //Slot SlotChunk sc; - sc.addr = tgt; + sc.addr = dac_cast(tgt); sc.nSlots = (mt->GetNumVtableSlots() - mt->GetNumVirtuals()); + sc.isRelative = false; m_discoveredSlotChunks.AppendEx(sc); } else if (mt->HasSingleNonVirtualSlot()) @@ -7344,25 +7348,42 @@ NativeImageDumper::DumpMethodTable( PTR_MethodTable mt, const char * name, #endif void -NativeImageDumper::DumpMethodTableSlotChunk( PTR_PCODE slotChunk, COUNT_T numSlots ) +NativeImageDumper::DumpMethodTableSlotChunk( TADDR slotChunk, COUNT_T numSlots, bool isRelative ) { IF_OPT( METHODTABLES ) { - DisplayStartStructure( "MethodTableSlotChunk", DPtrToPreferredAddr(slotChunk), numSlots * sizeof(PCODE), - METHODTABLES ); + COUNT_T slotsSize; + if (isRelative) + { + slotsSize = numSlots * sizeof(RelativePointer); + } + else + { + slotsSize = numSlots * sizeof(PCODE); + } + DisplayStartStructure( "MethodTableSlotChunk", DataPtrToDisplay(slotChunk), slotsSize, METHODTABLES ); IF_OPT(VERBOSE_TYPES) { DisplayStartList( W("[%-4s]: %s (%s)"), ALWAYS ); for( unsigned i = 0; i < numSlots; ++i ) { - DumpSlot(i, slotChunk[i]); + PCODE target; + if (isRelative) + { + target = RelativePointer::GetValueMaybeNullAtPtr(slotChunk + i * sizeof(RelativePointer)); + } + else + { + target = dac_cast(slotChunk)[i]; + } + + DumpSlot(i, target); } DisplayEndList( ALWAYS ); //Slot list } else - CoverageRead( PTR_TO_TADDR(slotChunk), - numSlots * sizeof(PCODE) ); + CoverageRead( slotChunk, slotsSize ); DisplayEndStructure(ALWAYS); //Slot chunk } } @@ -7735,7 +7756,7 @@ void NativeImageDumper::DumpMethodDesc( PTR_MethodDesc md, PTR_Module module ) } if ( md->HasNonVtableSlot() ) { - DisplayWriteElementInt( "Slot", (DWORD)(PTR_TO_TADDR(md->GetAddrOfSlot()) - PTR_TO_TADDR(md)), ALWAYS); + DisplayWriteElementInt( "Slot", (DWORD)(md->GetAddrOfSlot() - PTR_TO_TADDR(md)), ALWAYS); } if (md->HasNativeCodeSlot()) { diff --git a/src/debug/daccess/nidump.h b/src/debug/daccess/nidump.h index fc57e4bf7fd7..ac1c093f6a08 100644 --- a/src/debug/daccess/nidump.h +++ b/src/debug/daccess/nidump.h @@ -194,7 +194,7 @@ class NativeImageDumper PTR_Module module ); #ifndef STUB_DISPATCH_ALL - void DumpMethodTableSlotChunk( PTR_PCODE slotChunk, COUNT_T size ); + void DumpMethodTableSlotChunk( TADDR slotChunk, COUNT_T size, bool ); #endif void DumpSlot( unsigned index, PCODE tgt ); @@ -478,6 +478,8 @@ class NativeImageDumper template TADDR DPtrToPreferredAddr( T ptr ); + TADDR DPtrToPreferredAddr( TADDR tptr ); + void DumpAssemblySignature(CORCOMPILE_ASSEMBLY_SIGNATURE & assemblySignature); SIZE_T CountFields( PTR_MethodTable mt ); @@ -500,12 +502,13 @@ class NativeImageDumper struct SlotChunk { - PTR_PCODE addr; + TADDR addr; WORD nSlots; + bool isRelative; inline bool operator==(const SlotChunk& sc) const { - return (addr == sc.addr) && (nSlots == sc.nSlots); + return (addr == sc.addr) && (nSlots == sc.nSlots) && (isRelative == sc.isRelative); } inline bool operator<(const SlotChunk& sc) const diff --git a/src/debug/daccess/stdafx.h b/src/debug/daccess/stdafx.h index 1c19ebff10a2..93a5d23bf37b 100644 --- a/src/debug/daccess/stdafx.h +++ b/src/debug/daccess/stdafx.h @@ -21,6 +21,7 @@ #define USE_COM_CONTEXT_DEF +#include #include #include diff --git a/src/debug/ee/arm64/arm64walker.cpp b/src/debug/ee/arm64/arm64walker.cpp index 7a51dc9665c9..b38297b3ec9b 100644 --- a/src/debug/ee/arm64/arm64walker.cpp +++ b/src/debug/ee/arm64/arm64walker.cpp @@ -408,7 +408,7 @@ BOOL NativeWalker::DecodePCRelativeBranchInst(PT_CONTEXT context, const PRD_TYP bit_pos = bit_pos + 32; } - PCODE bit_val = 1 << bit_pos; + PCODE bit_val = PCODE{ 1 } << bit_pos; if (opcode & 0x01000000) //TBNZ { result = (RegContent & bit_val) != 0; diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index 7629d17a1e5d..a8d590e25006 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -331,7 +331,7 @@ void Debugger::DoNotCallDirectlyPrivateLock(void) { WRAPPER_NO_CONTRACT; - LOG((LF_CORDB,LL_INFO10000, "D::Lock aquire attempt by 0x%x\n", + LOG((LF_CORDB,LL_INFO10000, "D::Lock acquire attempt by 0x%x\n", GetCurrentThreadId())); // Debugger lock is larger than both Controller & debugger-data locks. @@ -426,7 +426,7 @@ void Debugger::DoNotCallDirectlyPrivateLock(void) if (m_mutexCount == 1) { - LOG((LF_CORDB,LL_INFO10000, "D::Lock aquired by 0x%x\n", m_mutexOwner)); + LOG((LF_CORDB,LL_INFO10000, "D::Lock acquired by 0x%x\n", m_mutexOwner)); } #endif @@ -4990,7 +4990,7 @@ HRESULT Debugger::MapAndBindFunctionPatches(DebuggerJitInfo *djiNew, // The DJI gets deleted as part of the Unbind/Rebind process in MovedCode. // This is to signal that we should not skip here. // under exactly what scenarios (EnC, code pitching etc.) will this apply?... - // can't we be a little clearer about why we don't want to bind the patch in this arcance situation? + // can't we be a little clearer about why we don't want to bind the patch in this arcane situation? if (dcp->HasDJI() && !dcp->IsBreakpointPatch() && !dcp->IsStepperPatch()) { LOG((LF_CORDB, LL_INFO10000, "Neither stepper nor BP but we have valid a DJI (i.e. the DJI hasn't been deleted as part of the Unbind/MovedCode/Rebind mess)! - getting next patch!\n")); @@ -12588,7 +12588,7 @@ bool Debugger::IsThreadAtSafePlaceWorker(Thread *thread) Debugger::AtSafePlaceStackWalkCallback, (VOID*)(&atSafePlace), QUICKUNWIND | HANDLESKIPPEDFRAMES | - DISABLE_MISSING_FRAME_DETECTION); + DISABLE_MISSING_FRAME_DETECTION | SKIP_GSCOOKIE_CHECK); #ifdef LOGGING if (!atSafePlace) diff --git a/src/debug/ee/debugger.h b/src/debug/ee/debugger.h index f3206f1f3563..b443fcfc7b73 100644 --- a/src/debug/ee/debugger.h +++ b/src/debug/ee/debugger.h @@ -1346,7 +1346,7 @@ class CodeRegionInfo { LIMITED_METHOD_CONTRACT; - PCODE address = (PCODE)addr; + PCODE address = PINSTRToPCODE((TADDR)addr); return (((address >= m_addrOfHotCode) && (address < m_addrOfHotCode + m_sizeOfHotCode)) || ((address >= m_addrOfColdCode) && diff --git a/src/debug/ee/frameinfo.cpp b/src/debug/ee/frameinfo.cpp index 0387ca921701..f8f8932cd8f9 100644 --- a/src/debug/ee/frameinfo.cpp +++ b/src/debug/ee/frameinfo.cpp @@ -2141,7 +2141,9 @@ StackWalkAction DebuggerWalkStack(Thread *thread, result = g_pEEInterface->StackWalkFramesEx(thread, &data.regDisplay, DebuggerWalkStackProc, - &data, flags | HANDLESKIPPEDFRAMES | NOTIFY_ON_U2M_TRANSITIONS | ALLOW_ASYNC_STACK_WALK); + &data, + flags | HANDLESKIPPEDFRAMES | NOTIFY_ON_U2M_TRANSITIONS | + ALLOW_ASYNC_STACK_WALK | SKIP_GSCOOKIE_CHECK); } else { diff --git a/src/dlls/mscordac/CMakeLists.txt b/src/dlls/mscordac/CMakeLists.txt index fba524a405ae..ec529037584e 100644 --- a/src/dlls/mscordac/CMakeLists.txt +++ b/src/dlls/mscordac/CMakeLists.txt @@ -20,10 +20,10 @@ if(WIN32) set(CURRENT_BINARY_DIR_FOR_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) - #Preprocess exports definition file + # Preprocess exports definition file preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def) - #create target to add file dependency on mscordac.def + # Create target to add file dependency on mscordac.def add_custom_target(mscordaccore_def DEPENDS ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def) # No library groups for Win32 @@ -32,7 +32,50 @@ if(WIN32) else(WIN32) set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordac_unixexports.src) set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordac.exports) - generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + + # Add dependency on export file + add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) + + if(CLR_CMAKE_PLATFORM_DARWIN) + generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE}) + endif(CLR_CMAKE_PLATFORM_DARWIN) + + if(CLR_CMAKE_PLATFORM_LINUX) + + # Generate DAC export file with the DAC_ prefix + generate_exports_file_prefix(${DEF_SOURCES} ${EXPORTS_FILE} DAC_) + + set(REDEFINES_FILE_AWK_SCRIPT ${CMAKE_SOURCE_DIR}/generateredefinesfile.awk) + + if (CLR_CMAKE_PLATFORM_ARCH_ARM OR CLR_CMAKE_PLATFORM_ARCH_ARM64) + set(JUMP_INSTRUCTION b) + else() + set(JUMP_INSTRUCTION jmp) + endif() + + # Generate the palredefines.inc file to map from the imported prefixed APIs (foo to DAC_foo) + set(PAL_REDEFINES_INC ${GENERATED_INCLUDE_DIR}/palredefines.inc) + add_custom_command( + OUTPUT ${PAL_REDEFINES_INC} + COMMAND ${AWK} -f ${REDEFINES_FILE_AWK_SCRIPT} -v jump=${JUMP_INSTRUCTION} -v prefix2=DAC_ ${DEF_SOURCES} > ${PAL_REDEFINES_INC} + DEPENDS ${DEF_SOURCES} ${REDEFINES_FILE_AWK_SCRIPT} + COMMENT "Generating PAL redefines file -> ${PAL_REDEFINES_INC}" + ) + add_custom_target(pal_redefines_file DEPENDS ${PAL_REDEFINES_INC}) + + # Generate the libredefines.inc file for the DAC to export the prefixed APIs (DAC_foo to foo) + set(LIB_REDEFINES_INC ${GENERATED_INCLUDE_DIR}/libredefines.inc) + add_custom_command( + OUTPUT ${LIB_REDEFINES_INC} + COMMAND ${AWK} -f ${REDEFINES_FILE_AWK_SCRIPT} -v jump=${JUMP_INSTRUCTION} -v prefix1=DAC_ ${DEF_SOURCES} > ${LIB_REDEFINES_INC} + DEPENDS ${DEF_SOURCES} ${REDEFINES_FILE_AWK_SCRIPT} + COMMENT "Generating DAC export redefines file -> ${LIB_REDEFINES_INC}" + ) + add_custom_target(lib_redefines_inc DEPENDS ${LIB_REDEFINES_INC}) + + # Add lib redefines file to DAC + list(APPEND CLR_DAC_SOURCES libredefines.S) + endif(CLR_CMAKE_PLATFORM_LINUX) endif(WIN32) if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD) @@ -64,10 +107,12 @@ _add_library(mscordacobj OBJECT mscordac.cpp) add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $) +if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(mscordaccore lib_redefines_inc) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(CLR_CMAKE_PLATFORM_UNIX) - add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE}) add_dependencies(mscordaccore mscordaccore_exports) - set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION}) set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE}) endif(CLR_CMAKE_PLATFORM_UNIX) diff --git a/src/dlls/mscordac/libredefines.S b/src/dlls/mscordac/libredefines.S new file mode 100644 index 000000000000..2449b9e3b151 --- /dev/null +++ b/src/dlls/mscordac/libredefines.S @@ -0,0 +1,12 @@ +#if defined(_X86_) || defined(_AMD64_) +.intel_syntax noprefix +#endif + +#include "unixasmmacros.inc" + +#if defined(_ARM_) +.syntax unified +.thumb +#endif + +#include "libredefines.inc" diff --git a/src/dlls/mscordac/mscordac_unixexports.src b/src/dlls/mscordac/mscordac_unixexports.src index 77a53d787154..60fae97efdc5 100644 --- a/src/dlls/mscordac/mscordac_unixexports.src +++ b/src/dlls/mscordac/mscordac_unixexports.src @@ -10,179 +10,179 @@ DllMain PAL_RegisterModule PAL_UnregisterModule -PAL_BindResources -PAL_bsearch -PAL_errno -PAL_fflush -PAL__flushall -PAL_free -PAL_fwprintf -PAL_GetPALDirectoryW -PAL_GetResourceString -PAL_get_stdout -PAL_get_stderr -PAL_GetCurrentThread -PAL_GetCpuLimit -PAL_GetSymbolModuleBase -PAL_GetTransportPipeName -PAL_InitializeDLL -PAL_TerminateEx -PAL_IsDebuggerPresent -PAL_ProbeMemory -PAL_Random -PAL_iswspace -PAL_memcpy -PAL_malloc -PAL_realloc -PAL_printf -PAL_qsort -PAL_Reenter -PAL_fprintf -PAL__wcstoui64 -PAL_wcstoul -PAL_iswprint -PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange -PAL_VirtualUnwindOutOfProc -PAL_wcslen -PAL_wcsncmp -PAL_wcsrchr -PAL_wcscmp -PAL_wcschr -PAL_wcscspn -PAL_wcscat -PAL_wcsstr - -_wcsicmp -_stricmp -sprintf_s -swprintf_s -vsprintf_s -_snprintf_s -_snwprintf_s -_vsnprintf_s -_vsnwprintf_s -_itow_s -_i64tow_s -memcpy_s -sscanf_s - -CopyFileW -CreateDirectoryW -CreateFileMappingA -CreateFileMappingW -CreateFileA -CreateFileW -CreateMutexW -CreateMutexExW -CreateEventW -CreateEventExW -CreateProcessW -CreateSemaphoreExW -CreateStreamOnHGlobal -CreateThread -CloseHandle -DebugBreak -DeleteCriticalSection -DeleteFileW -DuplicateHandle -EnterCriticalSection -FindClose -FindFirstFileW -FindNextFileW -FlushFileBuffers -FlushInstructionCache -FormatMessageW -FreeLibrary -FileTimeToSystemTime -GetACP -GetCPInfo -GetCurrentDirectoryW -GetCurrentProcess -GetCurrentProcessId -GetCurrentThreadId -GetEnvironmentVariableA -GetEnvironmentVariableW -GetFileAttributesExW -GetFileAttributesW -GetFileSize -GetFullPathNameW -GetLastError -GetLongPathNameW -GetModuleFileNameW -GetProcAddress -GetProcessAffinityMask -GetProcessHeap -GetShortPathNameW -GetStdHandle -GetSystemInfo -GetSystemTime -GetSystemTimeAsFileTime -GetTempFileNameW -GetTempPathW -HeapAlloc -HeapFree -HeapSetInformation -IIDFromString +; Data exports (not prefixed) +IID_IUnknown IID_IClassFactory IID_ISequentialStream IID_IStream -IID_IUnknown IID_ICLRDataTarget IID_ICorDebugDataTarget4 IID_ICLRDataEnumMemoryRegionsCallback -InitializeCriticalSection -IsDBCSLeadByte -LeaveCriticalSection -LoadLibraryA -LoadLibraryW -LoadLibraryExW -LocalAlloc -LocalReAlloc -LocalFree -MapViewOfFile -MoveFileExW -MultiByteToWideChar -OpenProcess -OutputDebugStringW -OpenEventW -OutputDebugStringA -QueryPerformanceCounter -QueryPerformanceFrequency -RaiseException -ReadFile -ReleaseMutex -ReleaseSemaphore -RemoveDirectoryW -ResetEvent -ResumeThread -SearchPathW -SetEvent -SetFileAttributesW -SetFilePointer -SetLastError -SetErrorMode -Sleep -SleepEx -SwitchToThread -TerminateProcess -TlsAlloc -TlsFree -TlsGetValue -TlsSetValue -VirtualAlloc -VirtualFree -VirtualProtect -VirtualQuery -UnmapViewOfFile -WaitForMultipleObjectsEx -WaitForSingleObject -WaitForSingleObjectEx -WideCharToMultiByte -WriteFile - nativeStringResourceTable_mscorrc_debug -_ZN25NativeExceptionHolderBase4PushEv -_ZN25NativeExceptionHolderBaseC2Ev -_ZN25NativeExceptionHolderBaseD2Ev -_ZN28CatchHardwareExceptionHolderC1Ev -_ZN28CatchHardwareExceptionHolderD1Ev + +; All the # exports are prefixed with DAC_ +#PAL_BindResources +#PAL_CatchHardwareExceptionHolderEnter +#PAL_CatchHardwareExceptionHolderExit +#PAL_bsearch +#PAL_errno +#PAL_fflush +#PAL__flushall +#PAL_free +#PAL_fwprintf +#PAL_GetPALDirectoryW +#PAL_GetResourceString +#PAL_get_stdout +#PAL_get_stderr +#PAL_GetCurrentThread +#PAL_GetCpuLimit +#PAL_GetNativeExceptionHolderHead +#PAL_GetSymbolModuleBase +#PAL_GetTransportPipeName +#PAL_InitializeDLL +#PAL_TerminateEx +#PAL_IsDebuggerPresent +#PAL_ProbeMemory +#PAL_Random +#PAL_iswspace +#PAL_memcpy +#PAL_malloc +#PAL_realloc +#PAL_printf +#PAL_qsort +#PAL_Reenter +#PAL_fprintf +#PAL__wcstoui64 +#PAL_wcstoul +#PAL_iswprint +#PAL_VirtualReserveFromExecutableMemoryAllocatorWithinRange +#PAL_VirtualUnwindOutOfProc +#PAL_wcslen +#PAL_wcsncmp +#PAL_wcsrchr +#PAL_wcscmp +#PAL_wcschr +#PAL_wcscspn +#PAL_wcscat +#PAL_wcsstr + +#_wcsicmp +#_stricmp +#sprintf_s +#swprintf_s +#vsprintf_s +#_snprintf_s +#_snwprintf_s +#_vsnprintf_s +#_vsnwprintf_s +#_itow_s +#_i64tow_s +#memcpy_s +#sscanf_s + +#CopyFileW +#CreateDirectoryW +#CreateFileMappingA +#CreateFileMappingW +#CreateFileA +#CreateFileW +#CreateMutexW +#CreateMutexExW +#CreateEventW +#CreateEventExW +#CreateProcessW +#CreateSemaphoreExW +#CreateThread +#CloseHandle +#DebugBreak +#DeleteCriticalSection +#DeleteFileW +#DuplicateHandle +#EnterCriticalSection +#FindClose +#FindFirstFileW +#FindNextFileW +#FlushFileBuffers +#FlushInstructionCache +#FormatMessageW +#FreeLibrary +#FileTimeToSystemTime +#GetACP +#GetCPInfo +#GetCurrentDirectoryW +#GetCurrentProcess +#GetCurrentProcessId +#GetCurrentThreadId +#GetEnvironmentVariableA +#GetEnvironmentVariableW +#GetFileAttributesExW +#GetFileAttributesW +#GetFileSize +#GetFullPathNameW +#GetLastError +#GetLongPathNameW +#GetModuleFileNameW +#GetProcAddress +#GetProcessAffinityMask +#GetProcessHeap +#GetShortPathNameW +#GetStdHandle +#GetSystemInfo +#GetSystemTime +#GetSystemTimeAsFileTime +#GetTempFileNameW +#GetTempPathW +#HeapAlloc +#HeapFree +#HeapSetInformation +#InitializeCriticalSection +#IsDBCSLeadByte +#LeaveCriticalSection +#LoadLibraryA +#LoadLibraryW +#LoadLibraryExW +#LocalAlloc +#LocalReAlloc +#LocalFree +#MapViewOfFile +#MoveFileExW +#MultiByteToWideChar +#OpenProcess +#OutputDebugStringW +#OpenEventW +#OutputDebugStringA +#QueryPerformanceCounter +#QueryPerformanceFrequency +#RaiseException +#ReadFile +#ReleaseMutex +#ReleaseSemaphore +#RemoveDirectoryW +#ResetEvent +#ResumeThread +#SearchPathW +#SetEvent +#SetFileAttributesW +#SetFilePointer +#SetLastError +#SetErrorMode +#Sleep +#SleepEx +#SwitchToThread +#SysAllocStringLen +#SysFreeString +#TerminateProcess +#TlsAlloc +#TlsFree +#TlsGetValue +#TlsSetValue +#VirtualAlloc +#VirtualFree +#VirtualProtect +#VirtualQuery +#UnmapViewOfFile +#WaitForMultipleObjectsEx +#WaitForSingleObject +#WaitForSingleObjectEx +#WideCharToMultiByte +#WriteFile diff --git a/src/dlls/mscordac/palredefines.S b/src/dlls/mscordac/palredefines.S new file mode 100644 index 000000000000..b0cd6159d357 --- /dev/null +++ b/src/dlls/mscordac/palredefines.S @@ -0,0 +1,12 @@ +#if defined(_X86_) || defined(_AMD64_) +.intel_syntax noprefix +#endif + +#include "unixasmmacros.inc" + +#if defined(_ARM_) +.syntax unified +.thumb +#endif + +#include "palredefines.inc" diff --git a/src/dlls/mscordbi/CMakeLists.txt b/src/dlls/mscordbi/CMakeLists.txt index 5f5ad5139e0d..e979960e074e 100644 --- a/src/dlls/mscordbi/CMakeLists.txt +++ b/src/dlls/mscordbi/CMakeLists.txt @@ -11,9 +11,14 @@ if(CORECLR_SET_RPATH) endif(CORECLR_SET_RPATH) set(MSCORDBI_SOURCES - mscordbi.cpp + mscordbi.cpp ) +# Add the DAC PAL export mapping file +if(CLR_CMAKE_PLATFORM_LINUX) + list(APPEND MSCORDBI_SOURCES ${PAL_REDEFINES_FILE}) +endif(CLR_CMAKE_PLATFORM_LINUX) + if(WIN32) add_precompiled_header(stdafx.h stdafx.cpp MSCORDBI_SOURCES) @@ -24,7 +29,7 @@ if(WIN32) ) set(DEF_SOURCES - mscordbi.src + mscordbi.src ) convert_to_absolute_path(DEF_SOURCES ${DEF_SOURCES}) @@ -63,15 +68,15 @@ if(CLR_CMAKE_PLATFORM_UNIX) endif(CLR_CMAKE_PLATFORM_UNIX) set(COREDBI_LIBRARIES - debug-pal - cordbdi - utilcodestaticnohost - ildbsymlib - mdcompiler-dbi - mdruntime-dbi - mdruntimerw-dbi - mddatasource_dbi - corguids + debug-pal + cordbdi + utilcodestaticnohost + ildbsymlib + mdcompiler-dbi + mdruntime-dbi + mdruntimerw-dbi + mddatasource_dbi + corguids ) if(WIN32) @@ -101,14 +106,18 @@ elseif(CLR_CMAKE_PLATFORM_UNIX) mscordaccore ) - add_dependencies(mscordbi mscordaccore) - # COREDBI_LIBRARIES is mentioned twice because ld is one pass linker and will not find symbols # if they are defined after they are used. Having all libs twice makes sure that ld will actually # find all symbols. target_link_libraries(mscordbi ${COREDBI_LIBRARIES} ${COREDBI_LIBRARIES}) + add_dependencies(mscordbi mscordaccore) + + if(CLR_CMAKE_PLATFORM_LINUX) + add_dependencies(mscordbi pal_redefines_file) + endif(CLR_CMAKE_PLATFORM_LINUX) + endif(WIN32) # add the install targets -install_clr(mscordbi) \ No newline at end of file +install_clr(mscordbi) diff --git a/src/dlls/mscorrc/mscorrc.rc b/src/dlls/mscorrc/mscorrc.rc index 42c0be4f83a7..113391636b89 100644 --- a/src/dlls/mscorrc/mscorrc.rc +++ b/src/dlls/mscorrc/mscorrc.rc @@ -404,62 +404,23 @@ END STRINGTABLE DISCARDABLE BEGIN CLDB_E_FILE_OLDVER "Version %d.%d is not a compatible version." - CLDB_E_NAME_ERROR "'%s' is not a valid name." CLDB_E_SMDUPLICATE "Shared memory '%hs' already exists." CLDB_E_NO_DATA "No metadata was found." - CLDB_E_READONLY "Database is read-only." - + CLDB_E_FILE_CORRUPT "Database file is corrupt and may not be usable." - CLDB_E_SCHEMA_VERNOTFOUND "Version %d of schema '%hs' not found." - - CLDB_E_INDEX_NONULLKEYS "Null value is not allowed in unique index or primary key." - CLDB_E_INDEX_DUPLICATE "Duplicate record violates index %s." - CLDB_E_INDEX_BADTYPE "VARIANT data type is not allowed in an index." + CLDB_E_INDEX_NOTFOUND "Index %s not found." CLDB_E_RECORD_NOTFOUND "No records found." - CLDB_E_RECORD_OVERFLOW "Record capacity has been reached." - CLDB_E_RECORD_DUPLICATE "Record violates the primary key constraint for the table." - CLDB_E_RECORD_PKREQUIRED "Primary key value is required." - CLDB_E_RECORD_DELETED "Access to deleted records is not allowed." - - CLDB_E_COLUMN_READONLY "Attempt to update read-only column failed (column %d, table '%s')." - CLDB_E_COLUMN_SPECIALCOL "Only one column can be the RID or primary key column." - CLDB_E_COLUMN_PKNONULLS "Primary key column '%s' may not allow the null value." - - CLDB_E_OBJECT_NOTFOUND "Object not found." - CLDB_E_OBJECT_COLNOTFOUND "Column '%s' not found." - - CLDB_E_VECTOR_BADINDEX "%d out of range." - + CLDB_E_INTERNALERROR "Internal error 0x%08x." META_E_INVALID_TOKEN_TYPE "A token passed to a metadata function has the wrong type." - META_E_MERGE_COLLISION "Module information inconsistent upon merge." - META_E_METHD_NOT_FOUND "Inconsistent method declarations in duplicated types (types: %s; methods: %s): (0x%08x)." - META_E_FIELD_NOT_FOUND "Inconsistent field declarations in duplicated types (types: %s; fields: %s): (0x%08x)." - META_E_INTFCEIMPL_NOT_FOUND "Inconsistent implemented interfaces in duplicated types (types: %s; interfaces: %s): (0x%08x)." - META_E_EVENT_NOT_FOUND "Inconsistent event declarations in duplicated types (types: %s; events: %s): (0x%08x)." - META_E_PROP_NOT_FOUND "Inconsistent property declarations in duplicated types (types: %s; properties: %s): (0x%08x)." - META_E_PARAM_MISMATCH "Inconsistent parameter information in duplicated methods (methods: %s; type: %s): (0x%08x)." - META_E_METHDIMPL_INCONSISTENT "Inconsistent method implementation flags in duplicated methods (methods: %s; type: %s): (0x%08x)." - META_E_MD_INCONSISTENCY "Custom attributes are not consistent: (0x%08x)." - META_E_CLASS_LAYOUT_INCONSISTENT "Inconsistent layout information in duplicated types (%s): (0x%08x)." - - META_E_METHOD_COUNTS "Differing number of methods in duplicated types (%s): (0x%08x)." - META_E_FIELD_COUNTS "Differing number of fields in duplicated types (%s): (0x%08x)." - META_E_PARAM_COUNTS "Differing number of parameters in duplicated method (types: %s; methods: %s): (0x%08x)." - META_E_GENERICPARAM_INCONSISTENT "Inconsistent Generic information in duplicated types or methods (%s): (0x%08x)." - META_E_EVENT_COUNTS "Differing number of events in duplicated types (%s): (0x%08x)." - META_E_PROPERTY_COUNTS "Differing number of properties in duplicated types (%s): (0x%08x)." - META_E_TYPEDEF_MISSING "A TypeRef exists which should, but does not, have a corresponding TypeDef: (%s): (0x%08x)." META_E_CA_INVALID_TARGET "The custom attribute is not valid for the target object's type." META_E_CA_INVALID_ARGTYPE "Unexpected property found in custom attribute value." META_E_CA_INVALID_BLOB "Unable to process the custom attribute value - it may be corrupt or incorrect." META_E_CA_UNKNOWN_ARGUMENT "Unrecognized custom attribute argument: %*s." META_E_CA_REPEATED_ARG "Custom attribute argument %*s should not be repeated." - META_E_CA_VARIANT_NYI "Custom attribute does not yet support variants." - META_E_CA_ARRAY_NYI "Custom attribute does not yet support arrays." META_E_CA_UNEXPECTED_TYPE "Unexpected argument type." META_E_CA_INVALID_ARG_FOR_TYPE "Argument '%s' cannot be applied to objects of this type." META_E_CA_INVALID_VALUE "Incorrect argument value." @@ -467,118 +428,21 @@ BEGIN META_E_CA_INVALID_MARSHALAS_FIELDS "MarshalAs attribute has fields set that are not valid for the specified unmanaged type." META_E_CA_NT_FIELDONLY "Specified unmanaged type is only valid on fields." META_E_CA_NEGATIVE_PARAMINDEX "Parameter index cannot be negative." - META_E_CA_NEGATIVE_MULTIPLIER "Multiplier cannot be negative." META_E_CA_NEGATIVE_CONSTSIZE "Constant size cannot be negative." META_E_CA_FIXEDSTR_SIZE_REQUIRED "SizeConst is required for a fixed string." META_E_CA_CUSTMARSH_TYPE_REQUIRED "A MarshalType or MarshalTypeRef setting is required for a custom marshaler." - META_E_CA_FILENAME_REQUIRED "A filename is required for DllImport." - META_E_MISMATCHED_VISIBLITY "Duplicate managed types have different visibilities." META_E_CA_BAD_FRIENDS_ARGS "[%1] InternalsVisibleTo declarations cannot have a version, culture, public key token, or processor architecture specified." META_E_CA_FRIENDS_SN_REQUIRED "[%1] Strong-name signed assemblies must specify a public key in their InternalsVisibleTo declarations." // These strings belong to the MetaData validator. VLDTR_E_RID_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has rid out of range." - VLDTR_E_CDTKN_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has coded token type out of range." - VLDTR_E_CDRID_OUTOFRANGE "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has coded rid out of range." VLDTR_E_STRING_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid String offset." VLDTR_E_GUID_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid GUID offset." VLDTR_E_BLOB_INVALID "Error (Structural): Table=0x%08x, Col=0x%08x, Row=0x%08x, has an invalid BLOB offset." - VLDTR_E_MOD_MULTI "Error: Multiple module records found." - VLDTR_E_MOD_NULLMVID "Error: Module has no MVID." - VLDTR_E_MOD_NONAME "Error: Module has no name." - VLDTR_E_MOD_NAMEFULLQLFD "Error: Module name is fully-qualified." - VLDTR_E_TR_NAMENULL "Error: TypeRef has no name." - VLDTR_E_TR_DUP "Error: TypeRef has a duplicate, token=0x%08x." - VLDTR_E_TR_BADSCOPE "Error: TypeRef has invalid resolution scope." - VLDTR_E_TR_HASTYPEDEF "Warning: TypeDef (token=0x%08x) has same name as TypeRef." - VLDTR_E_TD_NAMENULL "Error: TypeDef has no name." - VLDTR_E_TD_DUPNAME "Error: TypeDef has a duplicate based on namespace and name, token=0x%08x." - VLDTR_E_TD_DUPGUID "Warning: TypeDef has a duplicate based on GUID, token=0x%08x." - VLDTR_E_TD_NOTIFACEOBJEXTNULL "Error: TypeDef that is not an Interface and not the Object class extends Nil token." - VLDTR_E_TD_OBJEXTENDSNONNULL "Error: TypeDef for Object class extends token=0x%08x which is not nil." - VLDTR_E_TD_EXTENDSSEALED "Error: TypeDef extends token=0x%08x which is marked Sealed." - VLDTR_E_TD_EXTENDSIFACE "Error: TypeDef extends an Interface (token=0x%08x)." - VLDTR_E_MD_CTORPINVOKE "Error: Type/instance constructor marked PInvokeImpl." - VLDTR_E_TD_DLTNORTSPCL "Error: TypeDef is a Deleted record but not marked RTSpecialName." - VLDTR_E_TD_RTSPCLNOTDLT "Error: TypeDef is marked RTSpecialName but is not a Deleted record." - VLDTR_E_MI_DECLPRIV "Error: MethodImpl overrides private method (token=0x%08x)." - VLDTR_E_AS_BADNAME "Error: Assembly name contains leading spaces or path or extension." - VLDTR_E_FILE_SYSNAME "Error: File has a reserved system name." - VLDTR_E_MI_BODYSTATIC "Error: MethodImpl has static overriding method (token=0x%08x)." - VLDTR_E_TD_IFACENOTABS "Error: TypeDef is marked Interface but not Abstract." - VLDTR_E_TD_IFACEPARNOTNIL "Error: TypeDef is marked Interface but extends non-Nil token=0x%08x." - VLDTR_E_TD_IFACEGUIDNULL "Warning: TypeDef is marked Interface but has no GUID." - VLDTR_E_MAR_BADOFFSET "Error: ManifestResource refers to non-PE file but offset is not 0." - VLDTR_E_MI_DECLFINAL "Error: MethodImpl overrides final method (token=0x%08x)." - VLDTR_E_MI_DECLNOTVIRT "Error: MethodImpl overrides non-virtual method (token=0x%08x)." - VLDTR_E_MI_SIGMISMATCH "Error: MethodImpl's Decl (token=0x%08x) and Body (token=0x%08x) method signatures do not match." - VLDTR_E_TD_VTNOTSEAL "Error: TypeDef is a Value Type, Enum or Delegate, but not marked Sealed." - VLDTR_E_PD_BADFLAGS "Error: Parameter has invalid flags set 0x%08x." - VLDTR_E_TD_NESTEDNOENCL "Error: TypeDef is marked Nested but has no enclosing type." VLDTR_E_TD_ENCLNOTNESTED "Error: TypeDef is not marked Nested but has an enclosing type." - VLDTR_E_TD_ENUMNOVALUE "Warning: [CLS] TypeDef is Enum but has no value__ field." - VLDTR_E_TD_ENUMVALSTATIC "Error: Field value__ (token=0x%08x) in Enum is marked static." - VLDTR_E_TD_ENUMVALNOTSN "Error: Field value__ (token=0x%08x) in Enum is not marked RTSpecialName." - VLDTR_E_TD_ENUMFLDNOTST "Error: Field (token=0x%08x) in Enum is not marked static." - VLDTR_E_TD_ENUMFLDNOTLIT "Error: Field (token=0x%08x) in Enum is not marked literal." - VLDTR_E_TD_ENUMNOLITFLDS "Warning: [CLS] Enum has no literal fields." - VLDTR_E_TD_ENUMFLDSIGMISMATCH "Error: Signature of field (token=0x%08x) in Enum does not match enum type." - VLDTR_E_TD_ENUMVALNOT1ST "Error: Field value__ (token=0x%08x) in Enum is not the first one." - VLDTR_E_TD_ENUMHASMETHODS "Error: Enum has method(s)." - VLDTR_E_TD_ENUMIMPLIFACE "Error: Enum implements interface(s)." - VLDTR_E_TD_ENUMHASPROP "Error: Enum has properties." - VLDTR_E_TD_ENUMHASEVENT "Error: Enum has one or more events." - VLDTR_E_TD_SYSENUMNOTCLASS "Error: System.Enum is not marked Class." - VLDTR_E_TD_SYSENUMNOTEXTVTYPE "Error: System.Enum must extend System.ValueType." - VLDTR_E_TD_MARKEDNOSECUR "Error: TypeDef is marked HasSecurity but has no security information." - VLDTR_E_TD_SECURNOTMARKED "Error: TypeDef has security information but is not marked HasSecurity." - VLDTR_E_TD_NAMETOOLONG "Error: Full name length exceeds maximum allowed (length: %d; max: %d)." - VLDTR_E_TD_RTSPCLNOTSPCL "Error: TypeDef marked as RTSpecialName but not SpecialName." - VLDTR_E_TD_BADMETHODLST "Error: TypeDef has invalid Method List (> Nmethods+1)." - VLDTR_E_TD_BADFIELDLST "Error: TypeDef has invalid Field List (> Nfields+1)." - VLDTR_E_CN_BADTYPE "Error: Constant has illegal type (0x%02x)." - VLDTR_E_TD_ENUMNOINSTFLD "Error: Enum has no instance field." - VLDTR_E_TD_ENUMMULINSTFLD "Error: Enum has multiple instance fields." - VLDTR_E_TD_EXTRAFLAGS "Error: Extraneous bits in Flags (0x%08x)." - VLDTR_E_TD_EXTENDSITSELF "Error: TypeDef extends itself." - VLDTR_E_TD_SYSVTNOTEXTOBJ "Error: System.ValueType must extend System.Object." - VLDTR_E_TD_EXTTYPESPEC "Warning: TypeDef extends TypeSpec (0x%08x), not supported in Version 1." - VLDTR_E_TD_VTNOSIZE "Error: Value class has neither fields nor size parameter." - VLDTR_E_TD_IFACESEALED "Error: Interface is marked Sealed." - VLDTR_E_TD_ENUMFLDBADTYPE "Error: Invalid type of instance field(0x%08x) of an Enum." - VLDTR_E_IFACE_DUP "Error: InterfaceImpl has a duplicate, token=0x%08x." - VLDTR_E_IFACE_BADIMPL "Error: InterfaceImpl has invalid implementing type (0x%08x)." - VLDTR_E_IFACE_BADIFACE "Error: InterfaceImpl has invalid implemented type (0x%08x)." - VLDTR_E_IFACE_NOTIFACE "Error: InterfaceImpl's implemented type (0x%08x) not marked tdInterface." - VLDTR_E_IFACE_METHNOTIMPL "Error: Class implements interface but not method (class:0x%08x; interface:0x%08x; method:0x%08x)." - VLDTR_E_IFACE_METHNOTIMPLTHISMOD "Warning: Class does not implement interface method in this module (class:0x%08x; interface:0x%08x; method:0x%08x)." - VLDTR_E_IFACE_METHMULTIMPL "Error: Multiple implementation of interface method (class:0x%08x; interface:0x%08x; method:0x%08x)." - VLDTR_E_MR_NAMENULL "Error: MemberRef has no name." - VLDTR_E_MR_VTBLNAME "Error: MemberRef name starts with _VtblGap." - VLDTR_E_MR_DELNAME "Error: MemberRef name starts with _Deleted." - VLDTR_E_MR_PARNIL "Error: MemberRef parent is Nil but the module is a PE file." VLDTR_E_MR_BADCALLINGCONV "Error: MemberRef signature has invalid calling convention=0x%08x." - VLDTR_E_MR_NOTVARARG "Error: MemberRef has MethodDef parent, but calling convention is not VARARG (parent:0x%08x; callconv: 0x%08x)." - VLDTR_E_MR_NAMEDIFF "Error: MemberRef has different name than parent MethodDef, token=0x%08x." - VLDTR_E_MR_SIGDIFF "Error: MemberRef has fixed part of signature different from parent MethodDef, token=0x%08x." - VLDTR_E_MR_DUP "Warning: MemberRef has a duplicate, token=0x%08x." - VLDTR_E_MR_VARARGCALLINGCONV "Warning: [CLS] MemberRef has VARARG calling convention." - VLDTR_E_CL_TDAUTO "Error: ClassLayout has parent TypeDef token=0x%08x marked AutoLayout." - VLDTR_E_CL_TDINTF "Error: ClassLayout has parent TypeDef token=0x%08x marked Interface." - VLDTR_E_CL_BADPCKSZ "Error: ClassLayout has invalid PackingSize; valid set of values is {1,2,4,...,128} (parent: 0x%08x; PackingSize: %ld)." - VLDTR_E_CL_DUP "Error: ClassLayout has a duplicate (parent: 0x%08x; duplicate rid: 0x%08x)." - VLDTR_E_FL_BADOFFSET "Error: FieldLayout2 record has invalid offset (field: 0x%08x; offset: 0x%08x)." - VLDTR_E_FL_TDNIL "Error: FieldLayout2 record for Field token=0x%08x has TypeDefNil for parent." - VLDTR_E_FL_NOCL "Error: FieldLayout2 record for field of type that has no ClassLayout record (field: 0x%08x; type: 0x%08x)." - VLDTR_E_FL_TDNOTEXPLCT "Error: Explicit offset specified for field of type marked AutoLayout (field: 0x%08x; type: 0x%08x)." - VLDTR_E_FL_FLDSTATIC "Error: FieldLayout2 record has Field token=0x%08x marked Static." - VLDTR_E_FL_DUP "Error: FieldLayout2 record has a duplicate, rid=0x%08x." - VLDTR_E_MODREF_NAMENULL "Error: ModuleRef has no name." - VLDTR_E_MODREF_DUP "Warning: ModuleRef has a duplicate, token=0x%08x." - VLDTR_E_TD_EXTTRRES "Warning: Type extends TypeRef which resolves to TypeDef in the same module (TypeRef: 0x%08x; TypeDef: 0x%08x)." VLDTR_E_SIGNULL "Error: Signature has zero size." - VLDTR_E_SIGNODATA "Error: Signature does not have enough bytes left at byte=0x%08x as indicated by the compression scheme." VLDTR_E_MD_BADCALLINGCONV "Error: Signature has invalid calling convention=0x%08x." VLDTR_E_MD_THISSTATIC "Error: Method is marked Static but calling convention=0x%08x is marked HASTHIS." VLDTR_E_MD_NOTTHISNOTSTATIC "Error: Method is not marked Static, but calling convention=0x%08x is not marked HASTHIS." @@ -594,223 +458,16 @@ BEGIN VLDTR_E_SIG_MISSNLBND "Error: Signature missing count of lower bounds of array at byte=0x%08x." VLDTR_E_SIG_MISSLBND "Error: Signature missing lower bound of array at byte=0x%08x." VLDTR_E_SIG_BADELTYPE "Error: Signature has invalid ELEMENT_TYPE_* (element type: 0x%08x; offset: 0x%08x)." - VLDTR_E_SIG_MISSVASIZE "Error: Signature missing size for VALUEARRAY at byte=0x%08x." - VLDTR_E_SIG_LONGFORM "Error: Signature contains long form (such as ELEMENT_TYPE_CLASS)." - VLDTR_E_CN_PARENTTYPE "Error: Constant has parent of invalid type (token=0x%08x)." VLDTR_E_SIG_SENTINMETHODDEF "Error: ELEMENT_TYPE_SENTINEL is only allowed in MemberRef signatures." VLDTR_E_SIG_SENTMUSTVARARG "Error: Signature containing ELEMENT_TYPE_SENTINEL must be VARARG." VLDTR_E_SIG_MULTSENTINELS "Error: Multiple ELEMENT_TYPE_SENTINEL in signature." - VLDTR_E_SIG_LASTSENTINEL "Error: Trailing ELEMENT_TYPE_SENTINEL in signature." VLDTR_E_SIG_MISSARG "Error: Signature is missing argument # %d." VLDTR_E_SIG_BYREFINFIELD "Error: Field of ByRef type." - VLDTR_E_SIG_TOKTYPEMISMATCH "Error: Token 0x%08x following ELEMENT_TYPE_CLASS (_VALUETYPE) in signature is a ValueType (Class,respectively)." VLDTR_E_SIG_BADVOID "Error: Illegal use of type 'void' in signature." - VLDTR_E_FD_BADCALLINGCONV "Error: Field signature has invalid calling convention=0x%08x." - VLDTR_E_MD_NAMENULL "Error: Method has no name." - VLDTR_E_MD_PARNIL "Error: Method parent is Nil." - VLDTR_E_MD_DUP "Error: Method has a duplicate, token=0x%08x." - VLDTR_E_MD_ABSTPARNOTABST "Error: Abstract method in non-abstract type (token=0x%08x)." - VLDTR_E_MD_NOTSTATABSTININTF "Error: Neither static nor abstract method in interface (token=0x%08x)." - VLDTR_E_MD_NOTPUBININTF "Error: Non-public method in interface (token=0x%08x)." - VLDTR_E_MD_CTORININTF "Error: Instance constructor in interface (token=0x%08x)." - VLDTR_E_MD_GLOBALCTORCCTOR "Error: Global constructor." - VLDTR_E_MD_CTORSTATIC "Error: Static instance constructor in type (token=0x%08x)." - VLDTR_E_MD_CTORNOTSNRTSN "Error: Constructor/initializer in type (token=0x%08x) is not marked SpecialName and RTSpecialName." - VLDTR_E_MD_CTORVIRT "Error: Virtual constructor/initializer in type (token=0x%08x)." - VLDTR_E_MD_CTORABST "Error: Abstract constructor/initializer in type (token=0x%08x)." - VLDTR_E_MD_CCTORNOTSTATIC "Error: Non-static type initializer in type (token=0x%08x)." - VLDTR_E_MD_ZERORVA "Error: Method marked Abstract, Runtime, InternalCall or Imported must have zero RVA, and vice versa." - VLDTR_E_MD_FINNOTVIRT "Error: Method marked Final or NewSlot or CheckAccessOnOverride but not Virtual." - VLDTR_E_MD_STATANDFINORVIRT "Error: Static method cannot be Final or NewSlot or Virtual." - VLDTR_E_MD_ABSTANDFINAL "Error: Method cannot be both Abstract and Final." - VLDTR_E_MD_ABSTANDIMPL "Error: Abstract method marked ForwardRef." - VLDTR_E_MD_ABSTANDPINVOKE "Error: Abstract method marked PInvokeImpl." - VLDTR_E_MD_ABSTNOTVIRT "Error: Abstract method not marked Virtual." - VLDTR_E_MD_NOTABSTNOTIMPL "Error: Non-abstract method not marked ForwardRef." - VLDTR_E_MD_NOTABSTBADFLAGSRVA "Error: Non-abstract method must have RVA or be PInvokeImpl or Runtime." - VLDTR_E_MD_PRIVSCOPENORVA "Error: PrivateScope method has zero RVA." - VLDTR_E_MD_GLOBALABSTORVIRT "Error: Global method marked Abstract,Virtual." - VLDTR_E_MD_MULTIPLESEMANTICS "Warning: Method has multiple semantics." - VLDTR_E_MD_INVALIDSEMANTICS "Error: Method has invalid semantic association (token=0x%08x)." - VLDTR_E_MD_SEMANTICSNOTEXIST "Error: Method has semantic association (token=0x%08x) that does not exist." - VLDTR_E_MD_MULTSEMANTICFLAGS "Error: Method has multiple semantic flags set for association (token=0x%08x)." - VLDTR_E_MD_NOSEMANTICFLAGS "Error: Method has no semantic flags set for association (token=0x%08x)." - VLDTR_E_MD_PARAMOUTOFSEQ "Warning: Parameter out of sequence (parameter: %d; seq.num: %d)." - VLDTR_E_MD_PARASEQTOOBIG "Error: Parameter has sequence number exceeding number of arguments (parameter: %d; seq.num: %d; num.args: %d)." - VLDTR_E_MD_PARMMARKEDNOMARSHAL "Error: Parameter #%d is marked HasFieldMarshal but has no marshaling information." - VLDTR_E_MD_PARMMARSHALNOTMARKED "Error: Parameter #%d has marshaling information but is not marked HasFieldMarshal." - VLDTR_E_MD_PARMMARKEDNODEFLT "Error: Parameter #%d is marked HasDefault but has no const value." - VLDTR_E_MD_PARMDEFLTNOTMARKED "Error: Parameter #%d has const value but is not marked HasDefault." - VLDTR_E_MD_CTORNOTVOID "Error: Constructor, initializer must return void." - VLDTR_E_MD_SYNCMETHODINVTYPE "Error: Synchronized method in ValueType (token=0x%08x)." - VLDTR_E_MD_RVAANDIMPLMAP "Error: Method has both non-zero RVA and Implementation Map." - VLDTR_E_MD_BADRVA "Error: Method has invalid RVA (0x%x)." - VLDTR_E_MD_BADLOCALSIGTOK "Error: Method has invalid local signature token (0x%08x)." - VLDTR_E_MD_BADHEADER "Error: Method has invalid header." - VLDTR_E_FD_NAMENULL "Error: Field has no name." - VLDTR_E_FD_PARNIL "Error: Field parent is Nil." - VLDTR_E_FD_DUP "Error: Field has a duplicate, token=0x%08x." - VLDTR_E_FD_NOTVALUERTSN "Error: Field (token=0x%08x) is marked RTSpecialName but not named value__." - VLDTR_E_FD_VALUEPARNOTENUM "Error: Field name value__ is reserved for Enums only." - VLDTR_E_FD_INSTINIFACE "Error: Instance field in Interface." - VLDTR_E_FD_NOTPUBINIFACE "Error: Non-public field in Interface." - VLDTR_E_FMD_GLOBALNOTPUBPRIVSC "Error: Global item (field,method) must be Public, Private, or PrivateScope." - VLDTR_E_FMD_GLOBALNOTSTATIC "Error: Global item (field,method) must be Static." - VLDTR_E_FMD_GLOBALITEM "Warning: [CLS] Global item (field,method)." - VLDTR_E_FD_GLOBALNORVA "Error: Global field has no RVA assigned." - VLDTR_E_MD_CTORZERORVA "Error: Type/instance constructor has zero RVA." - VLDTR_E_FD_RVAHASNORVA "Error: Field is marked HasRVA but has no RVA record." - VLDTR_E_FD_RVAHASZERORVA "Error: Field is assigned zero RVA." - VLDTR_E_FD_MARKEDNOMARSHAL "Error: Field is marked marshaled but has no marshaling information." - VLDTR_E_FD_MARSHALNOTMARKED "Error: Field has marshaling information but is not marked marshaled." - VLDTR_E_FD_MARKEDNODEFLT "Error: Field is marked HasDefault but has no const value." - VLDTR_E_FD_DEFLTNOTMARKED "Error: Field has const value but is not marked HasDefault." - VLDTR_E_FD_BADPARENT "Error: Field has invalid parent (token=0x%08x)." - VLDTR_E_FMD_MARKEDNOSECUR "Error: Item (field,method) is marked HasSecurity but has no security information." - VLDTR_E_FMD_SECURNOTMARKED "Error: Item (field,method) has security information but is not marked HasSecurity." - VLDTR_E_FD_INITONLYANDLITERAL "Error: Field marked both InitOnly and Literal." - VLDTR_E_FD_LITERALNOTSTATIC "Error: Literal field must be Static." - VLDTR_E_FD_LITERALNODEFAULT "Error: Literal field has no const value." - VLDTR_E_FD_FLDINIFACE "Warning: [CLS] Field in Interface." VLDTR_E_FMD_PINVOKENOTSTATIC "Error: PInvoke item (field,method) must be Static." - VLDTR_E_FMD_MARKEDNOPINVOKE "Error: PInvoke item (field,method) has no Implementation Map." - VLDTR_E_FMD_PINVOKENOTMARKED "Error: Item (field,method) has Implementation Map but is not marked PInvoke." - VLDTR_E_FMD_BADIMPLMAP "Warning: Item (field,method) has invalid Implementation Map." - VLDTR_E_FMD_BADACCESSFLAG "Error: Item (field,method) has invalid access flag." - VLDTR_E_FMD_RTSNNOTSN "Error: Item (field,method) is marked RTSpecialName but not SpecialName." - VLDTR_E_CT_DUPTDNAME "Error: ExportedType has same namespace and name as TypeDef, token 0x%08x." - VLDTR_E_IMAP_BADMODREF "Error: Implementation Map has invalid Module Ref, token 0x%08x." - VLDTR_E_IMAP_BADMEMBER "Error: Implementation Map has invalid Member Forwarded, token 0x%08x." - VLDTR_E_IMAP_BADIMPORTNAME "Error: Implementation Map has no import name." - VLDTR_E_IMAP_BADCALLCONV "Error: Implementation Map has invalid calling convention 0x%04x." - VLDTR_E_AS_MULTI "Error: Multiple assembly records found." - VLDTR_E_AS_NAMENULL "Error: Assembly has no name." - VLDTR_E_AS_HASHALGID "Warning: Unrecognized Hash Algorithm ID (0x%08x)." - VLDTR_E_AS_PROCID "Error: Unrecognized Processor ID (0x%08x) in Assembly." - VLDTR_E_AS_BADFLAGS "Error: Invalid Assembly flags (0x%04x)." - VLDTR_E_AS_BADLOCALE "Warning: Invalid locale string." - VLDTR_E_AS_PROCDUP "Error: Duplicate Assembly Processor record (0x%08x)." - VLDTR_E_AR_PROCID "Warning: Unrecognized Processor ID (0x%08x) in AssemblyRef (token=0x%08x)." - VLDTR_E_AR_NAMENULL "Error: AssemblyRef has no name." - VLDTR_E_ASOS_OSPLTFRMIDINVAL "Error: AssemblyOS entry has invalid platform ID=0x%08x." - VLDTR_E_ASOS_DUP "Error: Duplicate Assembly OS record (0x%08X)." - VLDTR_E_AROS_OSPLTFRMIDINVAL "Error: AssemblyRefOS entry for AssemblyRef=0x%08x has invalid platform ID=0x%08x." - VLDTR_E_CN_PARENTRANGE "Error: Constant parent token (0x%08x) is out of range." - VLDTR_E_CT_NAMENULL "Error: ExportedType has no name." - VLDTR_E_TD_EXTENDSCHILD "Error: TypeDef extends its own child." - VLDTR_E_MD_CCTORHASARGS "Error: Type constructor must have no arguments." - VLDTR_E_CT_BADIMPL "Error: ExportedType has invalid Implementation (token=0x%08x)." - VLDTR_E_MD_CCTORCALLCONV "Error: Type constructor has invalid calling convention." - VLDTR_E_MI_ALIENBODY "Error: MethodImpl has body from another TypeDef (token=0x%08x)." - VLDTR_E_CT_NOTYPEDEFID "Warning: ExportedType has no TypeDefId." - VLDTR_E_CT_DUP "Error: ExportedType has a duplicate, token=0x%08x." - VLDTR_E_FILE_NAMENULL "Error: File has no name." - VLDTR_E_FILE_DUP "Error: File has a duplicate, token=0x%08x." - VLDTR_E_FILE_NAMEFULLQLFD "Error: File name is fully-qualified, but should not be." - VLDTR_E_FILE_BADFLAGS "Error: File has invalid flags (0x%08x)." - VLDTR_E_FILE_NULLHASH "Error: File has no hash BLOB." - VLDTR_E_MAR_NAMENULL "Error: ManifestResource has no name." - VLDTR_E_MAR_DUP "Error: ManifestResource has a duplicate by name, token=0x%08x." - VLDTR_E_MAR_NOTPUBPRIV "Error: ManifestResource is not marked Public or Private." - VLDTR_E_MAR_BADIMPL "Error: ManifestResource has invalid Implementation (token=0x%08x)." - VLDTR_E_MAR_BADFLAGS "Error: ManifestResource has invalid flags (0x%08x)." - VLDTR_E_MI_BADCLASS "Error: MethodImpl has invalid Type token=0x%08x." - VLDTR_E_MI_BADDECL "Error: MethodImpl has invalid MethodDeclaration token=0x%08x." - VLDTR_E_MI_BADBODY "Error: MethodImpl has invalid MethodBody token=0x%08x." - VLDTR_E_MI_CLASSISINTF "Error: MethodImpl declared in Interface (token=0x%08x)." - VLDTR_E_MI_DUP "Error: MethodImpl has a duplicate (rid=0x%08x)." - VLDTR_E_PR_BADSCOPE "Error: Property has invalid scope (token=0x%08x)." - VLDTR_E_PR_NONAME "Error: Property has no name." - VLDTR_E_PR_NOSIG "Error: Property has no signature." - VLDTR_E_PR_DUP "Error: Property has a duplicate (token=0x%08x)." - VLDTR_E_PR_BADCALLINGCONV "Error: Property has invalid calling convention (0x%x)." - VLDTR_E_PR_MARKEDNODEFLT "Error: Property is marked HasDefault but has no const value." - VLDTR_E_PR_DEFLTNOTMARKED "Error: Property has const value but is not marked HasDefault." - VLDTR_E_PR_BADSEMANTICS "Error: Property has related method with invalid semantics (method: 0x%08x; semantics: 0x%08x)." - VLDTR_E_PR_BADMETHOD "Error: Property has related method with invalid token (0x%08x)." - VLDTR_E_PR_ALIENMETHOD "Error: Property has related method belonging to another type (method: 0x%08x; type: 0x%08x)." - VLDTR_E_CN_BLOBNOTNULL "Error: Constant of type (0x%02x) must have null value." - VLDTR_E_CN_BLOBNULL "Error: Constant of type (0x%02x) must have non-null value." - VLDTR_E_EV_BADSCOPE "Error: Event has invalid scope (token=0x%08x)." - VLDTR_E_EV_NONAME "Error: Event has no name." - VLDTR_E_EV_DUP "Error: Event has a duplicate (token=0x%08x)." - VLDTR_E_EV_BADEVTYPE "Error: Event has invalid EventType (token=0x%08x)." - VLDTR_E_EV_EVTYPENOTCLASS "Error: Event's EventType (token=0x%08x) is not a class (flags=0x%08x)." - VLDTR_E_EV_BADSEMANTICS "Error: Event has related method with invalid semantics (method: 0x%08x; semantics: 0x%08x)." - VLDTR_E_EV_BADMETHOD "Error: Event has related method with invalid token (0x%08x)." - VLDTR_E_EV_ALIENMETHOD "Error: Event has related method belonging to another type (method: 0x%08x; type: 0x%08x)." - VLDTR_E_EV_NOADDON "Error: Event has no AddOn related method." - VLDTR_E_EV_NOREMOVEON "Error: Event has no RemoveOn related method." - VLDTR_E_EV_FIRENOTVOID "Error: Event's Fire method (0x%08x) must return void." - VLDTR_E_DS_BADOWNER "Error: Decl.Security is assigned to invalid item (token=0x%08x)." - VLDTR_E_DS_BADFLAGS "Error: Decl.Security has invalid action flag (0x%08x)." - VLDTR_E_DS_NOBLOB "Error: Decl.Security has no associated permission BLOB." - VLDTR_E_NC_BADNESTED "Error: NestedClass token (0x%08x) in NestedClass record is not a valid TypeDef." - VLDTR_E_NC_BADENCLOSER "Error: EnclosingClass token (0x%08x) in NestedClass record is not a valid TypeDef." - VLDTR_E_NC_DUP "Error: Duplicate NestedClass record (0x%08x)." - VLDTR_E_NC_DUPENCLOSER "Error: Nested type token (0x%08x) has multiple EnclosingClass tokens (0x%08x, 0x%08x)." - VLDTR_E_FRVA_ZERORVA "Error: Zero RVA of field 0x%08x in FieldRVA record." - VLDTR_E_FRVA_BADFIELD "Error: Invalid field token in FieldRVA record (field: 0x%08x; RVA: 0x%x)." - VLDTR_E_FRVA_DUPRVA "Error: Same RVA in another FieldRVA record (RVA: 0x%x; field: 0x%08x)." - VLDTR_E_FRVA_DUPFIELD "Error: Same field in another FieldRVA record(field: 0x%08x; record: 0x%08x)." - VLDTR_E_EP_BADTOKEN "Error: Invalid token specified as EntryPoint in CLR header." - VLDTR_E_EP_INSTANCE "Error: Instance method token specified as EntryPoint in CLR header." - VLDTR_E_EP_TOOMANYARGS "Error: EntryPoint method has invalid number of arguments, expecting %d." - VLDTR_E_EP_BADRET "Error: EntryPoint method has invalid return type." - VLDTR_E_EP_BADARG "Error: EntryPoint method has invalid argument number %d." - VLDTR_E_CA_BADPARENT "Error: CustomAttribute has invalid Parent token (0x%08x)." - VLDTR_E_CA_BADTYPE "Error: CustomAttribute has invalid Type token (0x%08x)." - VLDTR_E_CA_NOTCTOR "Error: CustomAttribute has non-constructor Type (0x%08x)." - VLDTR_E_CA_BADSIG "Error: CustomAttribute's Type (0x%08x) has invalid signature." - VLDTR_E_CA_NOSIG "Error: CustomAttribute's Type (0x%08x) has no signature." - VLDTR_E_CA_BADPROLOG "Error: CustomAttribute's blob has invalid prolog (0x%04x)." -//@GENERICS - VLDTR_E_GP_NAMENULL "Error: GenericParam has no name." - VLDTR_E_GP_OWNERNIL "Warning: GenericParam has nil owner." - VLDTR_E_GP_DUPNAME "Error: GenericParam has a duplicate based on owner and name, token=0x%08x." - VLDTR_E_GP_DUPNUMBER "Error: GenericParam has a duplicate based on owner and number, token=0x%08x." - VLDTR_E_GP_NONSEQ_BY_OWNER "Error: GenericParam is out of sequence by owner." - VLDTR_E_GP_NONSEQ_BY_NUMBER "Error: GenericParam is out of sequence by number." - VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR "Error: GenericParam is co-or-contra variant but its owner, token (0x%08x), is not an interface or delegate." + //@GENERICS VLDTR_E_GP_ILLEGAL_VARIANT_MVAR "Error: GenericParam is a method type parameter and must be non-variant, not co-or-contra variant." - VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS "Error: GenericParam has invalid variance value in flags (0x%08x)." - VLDTR_E_GP_REFANDVALUETYPE "Error: GenericParam has inconsistent special constraints ReferenceTypeConstraint and ValueTypeConstraint in flags (0x%08x)." - VLDTR_E_GPC_OWNERNIL "Error: GenericParamConstraint has nil owner." - VLDTR_E_GPC_DUP "Error: GenericParamConstraint has a duplicate based on owner and constraint, token=0x%08x." - VLDTR_E_GPC_NONCONTIGUOUS "Error: GenericParamConstraint is non-contiguous with preceding constraints for same owner, token=0x%08x." - VLDTR_E_MS_METHODNIL "Error: MethodSpec has nil method." - VLDTR_E_MS_DUP "Error: MethodSpec has a duplicate based on method and instantiation, token=0x%08x." - VLDTR_E_MS_BADCALLINGCONV "Error: MethodSpec signature has invalid calling convention=0x%08x." - VLDTR_E_MS_MISSARITY "Error: MethodSpec signature is missing arity at byte=0x%08x." - VLDTR_E_MS_MISSARG "Error: MethodSpec signature is missing type argument # %d." - VLDTR_E_MS_ARITYMISMATCH "Error: MethodSpec has generic method of arity %d but instantiation of different arity %d." - VLDTR_E_MS_METHODNOTGENERIC "Error: MethodSpec method is not generic." - VLDTR_E_SIG_MISSARITY "Error: Signature missing arity of instantiated generic type at byte=0x%08x." - VLDTR_E_SIG_ARITYMISMATCH "Error: Signature has generic type of arity %d instantiated at different arity %d at byte=0x%08x." - VLDTR_E_MD_GENERIC_CCTOR "Error: Method cannot be both generic and a class constructor." - VLDTR_E_MD_GENERIC_CTOR "Error: Method cannot be both generic and an instance constructor." - VLDTR_E_MD_GENERIC_IMPORT "Error: Method cannot be both generic and defined on an imported type." - VLDTR_E_MD_GENERIC_BADCALLCONV "Error: Method cannot be both generic and have non-default calling convention." - VLDTR_E_EP_GENERIC_METHOD "Error: Entry point in CLR header is the token for a generic method." - VLDTR_E_MD_MISSARITY "Error: Method signature is generic but is missing its arity at byte=0x%08x." - VLDTR_E_MD_ARITYZERO "Error: Method signature is generic but its arity is zero at byte=0x%08x." - VLDTR_E_SIG_ARITYZERO "Error: Signature has generic type instantiated at arity 0 at byte=0x%08x." - VLDTR_E_MS_ARITYZERO "Error: MethodSpec signature has arity 0 at byte=0x%08x." - VLDTR_E_MD_GPMISMATCH "Error: MethodDef signature has arity %d but the token owns %d GenericParams." - VLDTR_E_EP_GENERIC_TYPE "Error: Entry point in CLR header is the token for a method in a generic type." - VLDTR_E_MI_DECLNOTGENERIC "Error: MethodImpl overrides non-generic method (token=0x%08x) with generic method." - VLDTR_E_MI_IMPLNOTGENERIC "Error: MethodImpl overrides generic method (token=0x%08x) with non-generic method." - VLDTR_E_MI_ARITYMISMATCH "Error: MethodImpl overrides generic method (token=0x%08x) of arity %d with generic method of arity %d." - VLDTR_E_TD_EXTBADTYPESPEC "Error: TypeDef extends a TypeSpec (0x%08x) that is not an instantiated type." - VLDTR_E_SIG_BYREFINST "Error: Signature has type instantiated at ByRef at offset 0x%08x." - VLDTR_E_MS_BYREFINST "Error: MethodSpec has type instantiated at ByRef at offset 0x%08x." - VLDTR_E_TS_EMPTY "Error: TypeSpec has empty signature." - VLDTR_E_TS_HASSENTINALS "Error: TypeSpec has signature containing one or more sentinels." - VLDTR_E_TD_GENERICHASEXPLAYOUT "Error: TypeDef is generic but has explicit layout." - VLDTR_E_SIG_BADTOKTYPE "Error: Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef (token: 0x%08x; offset: 0x%08x)." - - MSEE_E_LOADLIBFAILED "Failed to delay load library '%hs' (Win32 error: %d).\n\nThis program can no longer run and will now terminate." - MSEE_E_GETPROCFAILED "Failed to get entry point '%s' in library '%hs'. Win32 error: %d.\n\nThis program can no longer run and will now terminate." + COR_E_APPDOMAINUNLOADED "Error: Attempt to access unloaded AppDomain." COR_E_MISSINGMETHOD "Error: Missing method '%2' from class '%1'." COR_E_FIXUPSINEXE "Cannot load executable '%1' because it contains extra relocations or has relocations stripped." @@ -831,148 +488,41 @@ BEGIN FUSION_E_APP_DOMAIN_LOCKED "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." FUSION_E_CONFIGURATION_ERROR "The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong." FUSION_E_MANIFEST_PARSE_ERROR "Unexpected error while parsing the specified manifest." - FUSION_E_INVALID_ASSEMBLY_REFERENCE "The given assembly name is invalid because a processor architecture is specified." IDS_EE_HASH_VAL_FAILED "Hash validation failed for file or assembly '%1'." CORSEC_E_MISSING_STRONGNAME "Assembly '%1' is missing the required strong name." CORSEC_E_INVALID_PUBLICKEY "The public key for assembly '%1' was invalid." CORSEC_E_INVALID_STRONGNAME "Strong name validation failed for assembly '%1'." CORSEC_E_SIGNATURE_MISMATCH "The allocated signature slot for assembly '%1' does not correspond to the generated signature size." - CORSEC_E_CONTAINER_NOT_FOUND "Strong name key container not found." CORSEC_E_NO_EXEC_PERM "Failed to grant permission to execute '%1'." CORSEC_E_MIN_GRANT_FAIL "Failed to grant required minimum permissions to '%1'." CORSEC_E_POLICY_EXCEPTION "Policy exception occurred while processing '%1'." COR_E_EXECUTIONENGINE "An internal error happened in the Common Language Runtime's Execution Engine." - COR_E_REMOTING "An error relating to remoting occurred during the load of file or assembly '%1'." COR_E_SERIALIZATION "An error relating to serialization occurred during the load of file or assembly '%1'." COR_E_SECURITY "A security violation has occurred." - IDS_EE_INVALID_STRONGNAME "Strong name validation failed for assembly '%s'. The file may have been tampered with or it was delay signed, but not fully signed with the correct private key." - IDS_EE_INVALID_STRONGNAME_TITLE "Strong name validation failed." - IDS_EE_INVALID_DELEGATE_LAYOUT "Invalid delegate layout." IDS_EE_PROC_NOT_FOUND "A procedure imported by '%1' could not be loaded." IDS_EE_SIMD_NGEN_DISALLOWED "Target-dependent SIMD vector types may not be used with ngen." - IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED "SIMD intrinsics may not be used by partial trust applications." IDS_IBC_MISSING_EXTERNAL_TYPE "The generic type specified by the IBC data is not available to this assembly" IDS_IBC_MISSING_EXTERNAL_METHOD "The generic method specified by the IBC data is not available to this assembly" IDS_EE_HWINTRINSIC_NGEN_DISALLOWED "Hardware intrinsics may not be used with ngen." IDS_INET_E_CANNOT_CONNECT "Cannot connect to URL for '%1'." IDS_INET_E_RESOURCE_NOT_FOUND "The server or proxy was not found for '%1'." - IDS_INET_E_OBJECT_NOT_FOUND "The actual object was not found for '%1'." - IDS_INET_E_DATA_NOT_AVAILABLE "Connection was established, but data cannot be retrieved for '%1'." - IDS_INET_E_DOWNLOAD_FAILURE "WinInet download failed for URL '%1'." - IDS_INET_E_UNKNOWN_PROTOCOL "Unknown URL protocol: '%1'." IDS_INET_E_CONNECTION_TIMEOUT "Connection timeout for URL '%1'." IDS_INET_E_SECURITY_PROBLEM "Security problem encountered when connecting to URL for '%1'." CORPROF_E_FUNCTION_NOT_COMPILED "Function 0x%08x had not yet been compiled." CORPROF_E_DATAINCOMPLETE "The ID 0x%08x had not yet been fully loaded or defined." - CORPROF_E_NOT_REJITABLE_METHODS "The Module containing function ID 0x%08x is not configured for updateable methods." - CORPROF_E_CANNOT_UPDATE_METHOD "Method ID 0x%08x could not be updated." CORPROF_E_FUNCTION_NOT_IL "Profiling error: the method has no associated IL." CORPROF_E_NOT_MANAGED_THREAD "Profiling error: the thread is unmanaged and has never run managed code before." CORPROF_E_CALL_ONLY_FROM_INIT "Profiling error: this function may only be called during profiler initialization." - CORPROF_E_INPROC_NOT_ENABLED "Profiling error: in-process debugging must be enabled during profiler initialization." - CORPROF_E_JITMAPS_NOT_ENABLED "Profiling error: cannot get a JIT map because the profiler did not enable JIT map tracking." - CORPROF_E_INPROC_ALREADY_BEGUN "Profiling error: BeginInprocDebugging cannot be called more than once." - CORPROF_E_INPROC_NOT_AVAILABLE "Profiling error: in-process debugging not allowed during this profiler callback." CORPROF_E_NOT_YET_AVAILABLE "Profiling error: the requested information is not yet available." // For these to be moved from the left side to the right side, they must // be less than ENCERRORINFO_MAX_STRING_SIZE in length (currently, 60 characters) - CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE "Error: Cannot increase the maximum nesting level in Edit-and-Continue." CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED "Error: Module must be loaded in Edit-and-Continue mode." - CORDBG_E_ENC_METHOD_SIG_CHANGED "Variable type cannot be changed." - CORDBG_E_ENC_METHOD_NO_LOCAL_SIG "Cannot get the local signature for the method." CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS "Field cannot be added to a value or layout type." - CORDBG_E_ENC_CANT_CHANGE_FIELD "Field properties cannot be changed." - CORDBG_E_ENC_ZAPPED_WITHOUT_ENC "Edit-and-Continue impossible: Zap file was created without Edit-and-Continue flag set." - CORDBG_E_ENC_BAD_METHOD_INFO "Internal data structures missing method information." CORDBG_E_ENC_JIT_CANT_UPDATE "JIT unable to update internal structures." - CORDBG_E_ENC_MISSING_CLASS "Internal type data structures are missing." - CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE "Not allowed to change interface inheritance." -END - -// These strings belong to the type library importer and exporter. -STRINGTABLE DISCARDABLE -BEGIN - TLBX_E_CIRCULAR_EXPORT "CLR assembly '%2' was imported from a type library and cannot be re-exported to a type library. Make sure the type library from which the assembly was imported is registered." - TLBX_E_CIRCULAR_EXPORT2 "CLR assembly '%s' was imported from a type library and cannot be re-exported to a type library. Make sure the type library from which the assembly was imported is registered." - TLBX_E_CIRCULAR_IMPORT "Type library '%s' was exported from a CLR assembly and cannot be re-imported as a CLR assembly." - TLBX_E_BAD_VTABLE "Vtable slot number associated with member '%s' of type '%s' in type library '%s' is invalid." - TLBX_E_CANT_LOAD_CLASS "Type library exporter cannot load type '%hs'." - TLBX_E_CLASS_LOAD_EXCEPTION "Type library exporter cannot load type '%hs' (error: %s)." - TLBX_E_CANT_LOAD_MODULE "Type library exporter cannot load assembly '%2'." - TLBX_E_UNKNOWN_SIGNATURE "Type library exporter encountered an unknown signature element." - TLBX_E_INVALID_NAMESPACE "Type library has an invalid namespace and cannot be imported (library: '%ls'; namespace: '%ls')." - TLBX_E_REFERENCED_TYPELIB "Successful import of type library may require prior import (library: '%ls'; import: '%ls')." - TLBX_E_CRM_NON_STATIC "COM register method is invalid (not static) (method: '%hs'; type: '%hs')." - TLBX_E_CRM_INVALID_SIG "COM register method has an invalid signature (method: '%hs'; type: '%hs'). The COM register method must have a single string argument and a return type of void." - TLBX_E_LAYOUT_ERROR "Type library exporter encountered an error while attempting to lay out the TypeInfo '%2': (%1) %3" - TLBX_E_NOTIUNKNOWN "Type library importer has encountered an interface not derived from IUnknown: '%ls'." - TLBX_W_DUAL_NOT_DISPATCH "Interface '%ls' is marked as [dual], but does not derive from IDispatch. It will be converted as an IUnknown-derived interface." - TLBX_E_NONVISIBLEVALUECLASS "Non COM visible value type '%s' is being referenced either from the type currently being exported or from one of its base types." - TLBX_E_LPTSTR_NOT_ALLOWED "Type '%s' has a method or field with an unmanaged type of LPTStr which cannot be exported to COM." - TLBX_E_AUTO_CS_NOT_ALLOWED "Type '%s' has a char set of auto. Types with a char set of auto cannot be exported to COM." - TLBX_S_NOSTDINTERFACE "Type '%hs' has an IID of IID_IUnknown or IID_IDispatch, which is not allowed." - TLBX_S_DUPLICATE_DISPID "The method '%hs.%hs' has a duplicate dispid, %d, which will be ignored." - TLBX_E_ENUM_VALUE_INVALID "The enum member '%hs.%ls' has a value that cannot be expressed as a 32-bit integer. Type library enum members must be 32-bit integers." - TLBX_W_ENUM_VALUE_TOOBIG "The enum member '%hs.%ls' has a value that cannot be expressed as a 32-bit integer. Type library enum members must be 32-bit integers." - TLBX_E_DUPLICATE_IID "Type '%ls' and type '%ls' both have the same UUID." - TLBX_E_NO_NESTED_ARRAYS "Type '%hs' contains nested arrays, which cannot be exported to a type library." - TLBX_E_PARAM_ERROR_NAMED "Error while importing type: parameter referenced a type library that is not available (type: '%ls'; parameter: '%ls'; method: '%ls')." - TLBX_E_PARAM_ERROR_UNNAMED "Error while importing type: parameter referenced a type library that is not available (type: '%ls'; parameter: '%d'; method: '%ls')." - TLBX_E_INVALID_TYPEINFO "Type '%ls' is invalid and may only be partially converted." - TLBX_E_INVALID_TYPEINFO_UNNAMED "There was an error converting a type. The name of the type cannot be determined. It is index %d in the type library." - TLBX_E_BAD_NATIVETYPE "The method or field has an invalid managed/unmanaged type combination, check the MarshalAs directive." - TLBX_E_CTX_NESTED "%ls, while processing '%ls'." - TLBX_E_ERROR_MESSAGE "Type library exporter encountered an error while processing '%ls'. Error: %ls" - TLBX_W_WARNING_MESSAGE "Type library exporter warning processing '%ls'. Warning: %ls" - TLBX_E_CANT_SAVE "Type library exporter encountered an error while attempting to save the type library '%ls': Error: (%x) %ls." - TLBX_W_LIBNOTREGISTERED "Type library exporter warning: Referenced type is defined in managed component, which is imported from a type library that could not be loaded because it was not registered (type: '%ls'; component: '%ls')." - TLBX_E_CANTLOADLIBRARY "Referenced type is defined in managed component, which is imported from a type library that could not be loaded (type: '%ls'; component: '%ls')." - TLBX_E_AGNOST_SIGNATURE "Type library exporter encountered a size agnostic signature element." - TLBX_E_CONVERT_FAIL "Type library exporter failed." - TLBX_E_BAD_VT_TYPE "Type library importer has encountered an invalid VT type (type: 0x%x; imported member: '%ls.%ls')." - TLBX_E_NO_MSCOREE_TLB "Type library exporter cannot load required library MSCOREE.TLB." - TLBX_E_BAD_MSCOREE_TLB "Type library exporter has encountered an error reading from library MSCOREE.TLB." - TLBX_E_TLB_EXCEPTION "Type library importer has encountered an exception: 0x%x." - TLBX_E_MULTIPLE_LCIDS "Type library importer has encountered a method with multiple [lcid] parameters while importing '%ls.%ls'." - TLBX_I_TYPEINFO_IMPORTED "Type '%ls' imported." - TLBX_I_TYPE_EXPORTED "Type '%hs' exported." - TLBX_E_AMBIGUOUS_RETURN "Type library importer has encountered a method with an unexpected [out, retval] parameter: '%ls.%ls'." - TLBX_E_DUPLICATE_TYPE_NAME "Type library importer has encountered a duplicate type name: '%ls'." - TLBX_I_USEIUNKNOWN "Type library exporter could not find the type library for '%ls'. IUnknown was substituted for the interface." - TLBX_I_UNCONVERTABLE_ARGS "At least one of the arguments for '%ls.%ls' cannot be marshaled by the runtime marshaler. Such arguments will therefore be passed as a pointer and may require unsafe code to manipulate." - TLBX_I_UNCONVERTABLE_FIELD "The type library importer could not convert the signature for the member '%ls.%ls'." - TLBX_I_NONSEQUENTIALSTRUCT "The type has explicit layout, and has been exported as an empty record. Types with explicit layout can only be properly exported if all members have an offset of 0 (a union)." - TLBX_I_RESOLVEREFFAILED "Type library importer has failed to resolve a referenced type library." - TLBX_E_ASANY "Type contains [MarshalAs(AsAny)], which is only valid for PInvoke. The MarshalAs directive was ignored." - TLBX_E_INVALIDLCIDPARAM "The value of the LCID conversion attribute must not exceed the number of parameters." - TLBX_E_LCIDONDISPONLYITF "The LCIDConversionAttribute is not allowed on dispatch only interfaces." - TLBX_E_NONPUBLIC_FIELD "The public struct contains one or more non-public fields that will be exported." - TLBX_I_DUPLICATE_DISPID "The type had one or more duplicate DISPIDs specified. The duplicate DISPIDs were ignored." - TLBX_E_BAD_NAMES "The names list was not valid." - TLBX_I_REF_TYPE_AS_STRUCT "The reference type had sequential or explicit layout, and so was exported as a struct." - TLBX_E_ARRAY_NEEDS_NT_FIXED "Arrays in structs must be SafeArrays or ByValArrays." - TLBX_E_CLASS_NEEDS_NT_INTF "Reference types with layout in structs need [MarshalAs(UnmanagedType.Interface)]." - TLBX_E_GENERICINST_SIGNATURE "Type library exporter encountered a generic type instance in a signature. Generic code may not be exported to COM." - TLBX_E_GENERICPAR_SIGNATURE "Type library exporter encountered a generic type parameter in a signature. Generic code may not be exported to COM." - TLBX_I_GENERIC_TYPE "Type library exporter encountered a generic type. Generic classes may not be exposed to COM." - TLBX_I_GENERIC_BASE_TYPE "Type library exporter encountered a type that derives from a generic class and is not marked as [ClassInterface(ClassInterfaceType.None)]. Class interfaces cannot be exposed for such types. Consider marking the type with [ClassInterface(ClassInterfaceType.None)] and exposing an explicit interface as the default interface to COM using the ComDefaultInterface attribute." - TLBX_W_NON_INTEGRAL_CA_TYPE "Ignoring IDL custom attribute '%ls' on '%ls' because it must be used with an integral value." - TLBX_W_IENUM_CA_ON_IUNK "Ignoring IDL custom attribute '%ls' on '%ls' because it cannot be used on an IUnknown interface." - TLBX_E_NO_SAFEHANDLE_ARRAYS "Type '%hs' contains arrays of SafeHandles, which cannot be exported to a type library." - TLBX_E_NO_CRITICALHANDLE_ARRAYS "Type '%hs' contains arrays of CriticalHandles, which cannot be exported to a type library." - TLBX_W_NO_PROPS_IN_EVENTS "Type library importer has encountered a source interface containing properties: '%ls'." - TLBX_W_EXPORTING_AUTO_LAYOUT "Type '%hs' has auto-layout but is being exported. Consider marking the type [ComVisible(false)] since the exported definition is not guaranteed to work." - TLBX_E_TYPED_REF "Cannot export TypedReference." - TLBX_W_DEFAULT_INTF_NOT_VISIBLE "Default interface is not visible to COM." - TLBX_W_BAD_SAFEARRAYFIELD_NO_ELEMENTVT "System.Array fields without a SafeArraySubType cannot be used from COM. For legacy reasons, they are exported as SAFEARRAYs of VARIANTs. However, at runtime, they are not marshaled as such." - TLBX_W_LAYOUTCLASS_AS_INTERFACE "Type library exporter encountered a reference type with layout marked as [MarshalAs(UnmanagedType.Interface)] in a signature. The reference type was instead treated as if it were marked with [MarshalAs(UnmanagedType.IUnknown)]." - TLBX_E_BITNESS_MISMATCH "Unable to export this assembly with the specified machine type as the assembly is marked machine specific with a different machine type." - TLBX_E_EVENT_WITH_NEWENUM "Type library importer encountered a source interface on coclass '%ls' with a NewEnum member. This is not supported." - TLBX_E_PROPGET_WITHOUT_RETURN "Type library importer encountered a property getter '%ls' on type '%ls' without a valid return type. The importer will attempt to import this property as a method instead." -END + END // These strings are generated from within the EE. STRINGTABLE DISCARDABLE @@ -982,7 +532,6 @@ BEGIN IDS_EE_NDIRECT_UNSUPPORTED_SIG "Method's type signature is not PInvoke compatible." IDS_EE_COM_UNSUPPORTED_SIG "Method's type signature is not Interop compatible." IDS_EE_COM_UNSUPPORTED_TYPE "The method returned a COM Variant type that is not Interop compatible." - IDS_EE_COM_UNSUPPORTED_VT_RECORD "The method returned a VT_RECORD Variant, which is not supported by Interop." IDS_EE_NDIRECT_BADNATL "Invalid PInvoke or UnmanagedFunctionPointer metadata format." IDS_EE_NDIRECT_BADNATL_CALLCONV "Invalid PInvoke or UnmanagedFunctionPointer calling convention." IDS_EE_NDIRECT_BADNATL_VARARGS_CALLCONV "Invalid PInvoke calling convention. Vararg functions must use the cdecl calling convention." @@ -996,44 +545,23 @@ BEGIN IDS_EE_CLASS_CONSTRAINTS_VIOLATION "GenericArguments[%1], '%2', on '%3' violates the constraint of type parameter '%4'." IDS_EE_METHOD_CONSTRAINTS_VIOLATION "Method %1.%2: type argument '%3' violates the constraint of type parameter '%4'." IDS_EE_NOSYNCHRONIZED "Synchronized attribute cannot be used with this method type." - IDS_EE_LOAD_NO_MAIN "Main method not found for type '%1'." IDS_EE_LOAD_BAD_MAIN_SIG "Main method for type '%1' has invalid signature." - IDS_EE_LOAD_CIRCULAR_DEPENDENCY "A circular dependency was detected when loading file or assembly '%1'." - + IDS_EE_FILE_NOT_FOUND "File or assembly name '%1' was not found." - IDS_EE_TOO_MANY_OPEN_FILES "The system cannot open file '%1'. There may be too many open files." - IDS_EE_SHARING_VIOLATION "Cannot access file '%1' because it is being used by another process." - IDS_EE_LOCK_VIOLATION "Cannot access file '%1' because another process has locked a portion of the file." - IDS_EE_OPEN_FAILED "Cannot open file '%1'." - IDS_EE_INVALID_NAME "The filename, directory name, or volume label syntax is incorrect: '%1'." - IDS_EE_UNRECOGNIZED_VOLUME "The volume does not contain a recognized file system." - IDS_EE_FILE_INVALID "'%1' is not a valid file." - IDS_EE_FILE_CORRUPT "The file or directory for '%1' is corrupt and unreadable." - IDS_EE_DISK_CORRUPT "The disk structure is corrupt and unreadable. Unable to load '%1'." - IDS_EE_DISK_FULL "There is not enough space on the disk. Unable to load '%1'." - + E_ACCESSDENIED "Access is denied: '%1'." COR_E_BADIMAGEFORMAT "The format of the file '%1' is invalid." COR_E_NEWER_RUNTIME "The assembly is built by a runtime newer than the currently loaded runtime, and cannot be loaded." IDS_EE_BAD_USER_PROFILE "The specified user does not have a valid profile. Unable to load '%1'." IDS_EE_ALREADY_EXISTS "Cannot create/shadow copy '%1' when that file already exists." - IDS_EE_DLL_INIT_FAILED "The dll initialization routine failed for file '%1'." - IDS_EE_LOAD_UNEXPECTED "Unexpected error occurred loading type '%1'." - IDS_EE_AMBIGUOUSINVOKE "Multiple methods named Invoke." - IDS_EE_CALLBACK_UNSUPPORTED_SIG "Method's type signature contains a type that cannot be automatically converted." - IDS_EE_NOTADELEGATE "Function pointer was not created by a Delegate." IDS_EE_NOTNDIRECT "Not a PInvoke method." - IDS_EE_METADATA_ERROR "Error loading file '%s'.\n%s." IDS_EE_ERRORTITLE "Error" IDS_EE_ERRORMESSAGETEMPLATE "Error 0x%08x.\n\n%s." - IDS_EE_ERRORMESSAGETEXTTEMPLATE "Error: %s." IDS_EE_TWO_LOADED_MSCOREE_TITLE "MSCOREE.DLL load error." IDS_EE_TWO_LOADED_MSCOREE_MSG "Two different copies of MSCORWKS.DLL have been loaded.\n\nFirst copy:\n%s\n\nSecond copy:\n%s\n\nThis is typically caused by having a registered MSCOREE.DLL that is different\nfrom the one that is statically linked with the application." - IDS_EE_CUST_MARSHALER_ON_INVALID_TYPE "Custom marshalers can only be specified for classes." IDS_EE_RETHROW_NOT_ALLOWED "No exception available to rethrow." IDS_EE_INVALID_OLE_VARIANT "Specified OLE variant is invalid." - IDS_EE_FAILED_TO_LOAD "Exception from HRESULT: 0x%1. Failed to load '%2'." IDS_EE_TO_MANY_ARGUMENTS_IN_MAIN "Signature for the entry point has too many arguments." IDS_EE_FAILED_TO_FIND_MAIN "Entry point not found in assembly '%1'." IDS_EE_ILLEGAL_TOKEN_FOR_MAIN "Specified entry point in assembly '%1' is not a legal method." @@ -1061,7 +589,6 @@ BEGIN IDS_EE_BADMARSHAL_WINRT_MARSHAL_AS "Invalid managed/unmanaged type combination (Windows Runtime parameters and fields must not have a MarshalAs attribute set)." IDS_EE_BADMARSHAL_WINRT_MISSING_GUID "Invalid managed/unmanaged type combination (Windows Runtime interfaces, classes and delegates must have a Guid or a default interface)." IDS_EE_BADMARSHAL_WINRT_DELEGATE "Invalid managed/unmanaged type combination (Delegates must be Windows Runtime delegates)." - IDS_EE_BADMARSHAL_WINRT_COPYCTOR "Windows Runtime marshaler does not support types with copy constructor." IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_WINRT_IFACE "The default interface must refer to a Windows Runtime interface with a GUID." IDS_EE_BADMARSHAL_DEFAULTIFACE_NOT_SUBTYPE "The default interface must refer to an interface that is implemented by the type." IDS_EE_BADMARSHAL_DATETIMEOFFSET "Invalid managed/unmanaged type combination (the DateTimeOffset structure must be paired with Struct)." @@ -1112,13 +639,9 @@ BEGIN IDS_EE_BADMARSHAL_PTRSUBTYPE "Pointers cannot reference managed objects. Use ByRef instead." IDS_EE_BADMARSHAL_PTRNONBLITTABLE "Pointers cannot reference marshaled structures. Use ByRef instead." IDS_EE_BADMARSHAL_RESTRICTION "This type can only be marshaled in restricted ways." - IDS_EE_BADMARSHAL_CHARARRAYRESTRICTION "Ansi char arrays cannot be marshaled as ByRef or as unmanaged-to-managed parameters." IDS_EE_BADMARSHAL_ASANYRESTRICTION "AsAny cannot be used on return types, ByRef parameters, ArrayWithOffset, or parameters passed from unmanaged to managed." IDS_EE_BADMARSHAL_VBBYVALSTRRESTRICTION "VBByRefStr can only be used in combination with in/out, ByRef managed-to-unmanaged strings." IDS_EE_BADMARSHAL_AWORESTRICTION "ArrayWithOffsets can only be marshaled as inout, non-ByRef, managed-to-unmanaged parameters." - IDS_EE_BADMARSHAL_BVCRESTRICTION "Internal error." - IDS_EE_BADMARSHAL_COPYCTORRESTRICTION "Classes with copy-ctors can only be marshaled non-ByRef." - IDS_EE_BADMARSHAL_VCRESTRICTION "Internal error." IDS_EE_BADMARSHAL_ARGITERATORRESTRICTION "ArgIterators cannot be marshaled ByRef." IDS_EE_BADMARSHAL_HANDLEREFRESTRICTION "HandleRefs cannot be marshaled ByRef or from unmanaged to managed." IDS_EE_BADMARSHAL_SAFEHANDLENATIVETOCOM "SafeHandles cannot be marshaled from unmanaged to managed." @@ -1131,7 +654,6 @@ BEGIN IDS_EE_BADMARSHAL_NOTMARSHALABLE "The type definition of this field has layout information but has an invalid managed/unmanaged type combination or is unmarshalable." IDS_EE_BADMARSHAL_BADMETADATA "Invalid marshaling metadata." IDS_EE_BADMARSHAL_CUSTOMMARSHALER "Custom marshalers are only allowed on classes, strings, arrays, and boxed value types." - IDS_EE_BADMARSHAL_BADSAFEARRAYSUBTYPE "Invalid SafeArraySubType/managed element type combination." IDS_EE_BADMARSHAL_GENERICS_RESTRICTION "Generic types cannot be marshaled." IDS_EE_BADMARSHALPARAM_STRINGBUILDER "Invalid managed/unmanaged type combination (StringBuilders must be paired with LPStr, LPWStr, or LPTStr)." @@ -1169,7 +691,6 @@ BEGIN IDS_EE_WINRT_IID_ILLEGALTYPE "Unable to compute GUID for type '%1' because the instantiation contains types that are not supported by Windows Runtime." IDS_EE_WINRT_IID_NODEFAULTINTERFACE "Unable to compute GUID because type '%1' does not have a default Windows Runtime interface." IDS_EE_WINRT_ATTRIBUTES_NOT_INVOKABLE "Cannot construct type '%1'. Windows Runtime attribute types are not constructable." - IDS_EE_WINRT_TYPE_IN_ORDINARY_ASSEMBLY "Windows Runtime types can only be declared in Windows Runtime assemblies." IDS_EE_WINRT_TYPE_NOT_REGISTERED "Requested Windows Runtime type '%1' is not registered." IDS_EE_WINRT_NOT_FACTORY_FOR_TYPE "Windows Runtime factory '%1' is not a factory for Windows Runtime type '%2'." IDS_EE_WINRT_INVALID_FACTORY_FOR_TYPE "Windows Runtime type '%1' has a invalid Windows Runtime factory" @@ -1180,10 +701,8 @@ BEGIN IDS_EE_ADUNLOAD_IN_FINALIZER "AppDomain cannot be unloaded during object finalization." IDS_EE_ADUNLOAD_DEFAULT "The default domain cannot be unloaded." IDS_EE_ADUNLOAD_CANT_UNWIND_THREAD "AppDomain cannot be unloaded because the thread '%1' cannot be unwound out of it." - IDS_EE_ADUNLOAD_NOT_LOCAL "AppDomain cannot be unloaded because it is not local to the current process." - + IDS_CLASSLOAD_TYPEWRONGNUMGENERICARGS "The generic type '%1' was used with the wrong number of generic arguments in assembly '%2'." - IDS_CLASSLOAD_METHODWRONGNUMGENERICARGS "A method in the type '%1' from assembly '%2' was used with the wrong number of generic arguments." IDS_CLASSLOAD_INVALIDINSTANTIATION "The generic type '%1' was used with an invalid instantiation in assembly '%2'." IDS_CLASSLOAD_VARIANCE_IN_METHOD_ARG "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in the signature for an argument in method '%3'." IDS_CLASSLOAD_VARIANCE_IN_METHOD_RESULT "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in the signature for the result type in method '%3'." @@ -1191,8 +710,6 @@ BEGIN IDS_CLASSLOAD_VARIANCE_IN_CONSTRAINT "Could not load type '%1' from assembly '%2' because a covariant or contravariant type parameter was used illegally in a type parameter constraint in method '%3'." IDS_CLASSLOAD_VARIANCE_CLASS "Could not load type '%1' from assembly '%2' because it declares a covariant or contravariant type parameter and is not an interface or delegate." IDS_CLASSLOAD_BADVARIANCE "Could not load type '%1' from assembly '%2' because it uses an illegal variance annotation on a type parameter." - IDS_CLASSLOAD_GENERIC_CONTEXT_BOUND_OBJECT "Generic context-bound objects are not supported." - IDS_CLASSLOAD_COLLECTIBLE_CONTEXT_BOUND_OBJECT "Collectible context-bound objects are not supported." IDS_CLASSLOAD_CONTEXT_BOUND_GENERIC_METHOD "Context-bound objects with generic methods are not supported." IDS_CLASSLOAD_ENUM_EXTRA_GENERIC_TYPE_PARAM "Enumerated types cannot have any generic type parameters, beyond any inherited from their enclosing type (for nested enums)." IDS_CLASSLOAD_GENERICTYPE_RECURSIVE "Could not load type '%1' from assembly '%2' because it has recursive generic definition." @@ -1200,12 +717,9 @@ BEGIN IDS_CLASSLOAD_GENERAL "Could not load type '%1' from assembly '%2'." IDS_CLASSLOAD_TYPESPEC "Could not load TypeSpec from assembly '%2'." - IDS_CLASSLOAD_MODULELOAD "Could not load type '%1' because the module containing it from assembly '%2' failed to load." - IDS_CLASSLOAD_ASSEMBLYLOAD "Could not load type '%1' because the assembly containing it failed to load." IDS_CLASSLOAD_SEALEDPARENT "Could not load type '%1' from assembly '%2' because the parent type is sealed." IDS_CLASSLOAD_BADFORMAT "Could not load type '%1' from assembly '%2' because the format is invalid." IDS_CLASSLOAD_CANTCREATEARRAYCLASS "Could not create array type '%1' from assembly '%2'." - IDS_CLASSLOAD_NOCLSIDREG "No server registered or could not load class for CLSID %1." IDS_CLASSLOAD_MISSINGMETHOD "Could not load type '%1' from assembly '%2' because the method '%3' could not be loaded." IDS_CLASSLOAD_FIELDTOOLARGE "Size of field of type '%1' from assembly '%2' is too large." IDS_CLASSLOAD_CANTEXTEND "Type '%1' from assembly '%2' cannot extend from any other type." @@ -1229,25 +743,18 @@ BEGIN IDS_CLASSLOAD_BYREFLIKE_STATICFIELD "A value type containing a by-ref instance field, such as Span, cannot be used as the type for a static field." IDS_CLASSLOAD_BYREFLIKE_NOTVALUECLASSFIELD "A value type containing a by-ref instance field, such as Span, cannot be used as the type for a class instance field." - IDS_CLASSLOAD_BAD_NAME "Type name '%1' from assembly '%2' is invalid." IDS_CLASSLOAD_RANK_TOOLARGE "'%1' from assembly '%2' has too many dimensions." - IDS_CLASSLOAD_BAD_MANAGED_RVA "Managed method '%3' on type '%1' from assembly '%2' is not supported." IDS_CLASSLOAD_BAD_UNMANAGED_RVA "Native method '%3' on type '%1' from assembly '%2' is not supported." - IDS_CLASSLOAD_INHERITANCECHECK "Type '%1' from assembly '%2' does not have sufficient permission to override super type methods." IDS_CLASSLOAD_NOMETHOD_NAME "Type '%1' from assembly '%2' has a method with no name." IDS_CLASSLOAD_ZEROSIZE "Type '%1' from assembly '%2' has zero size." IDS_CLASSLOAD_EXPLICIT_LAYOUT "Could not load type '%1' from assembly '%2' because it contains an object field at offset %3 that is incorrectly aligned or overlapped by a non-object field." - IDS_CLASSLOAD_UNVERIFIABLE_FIELD_LAYOUT "Could not load type '%1' from assembly '%2' because objects overlapped at offset %3 and the assembly must be verifiable." - IDS_CLASSLOAD_PRIVATEVIRTUAL "Private method '%3' on type '%1' from assembly '%2' cannot be virtual." IDS_CLASSLOAD_BADSPECIALMETHOD "Constructor '%3' on type '%1' from assembly '%2' does not have the correct name or signature." IDS_CLASSLOAD_MI_DECLARATIONNOTFOUND "Method override '%3' on type '%1' from assembly '%2' cannot find a method to replace." IDS_CLASSLOAD_MI_MULTIPLEOVERRIDES "Method '%3' on type '%1' from assembly '%2' is overriding a method that has been overridden." - IDS_CLASSLOAD_MI_OVERRIDEIMPL "Method '%3' on type '%1' from assembly '%2' is overriding a method impl." IDS_CLASSLOAD_MI_ACCESS_FAILURE "Method '%3' on type '%1' from assembly '%2' is overriding a method that is not visible from that assembly." IDS_CLASSLOAD_MI_BADSIGNATURE "Method '%3' on type '%1' from assembly '%2' tried to override a method with a different signature." IDS_CLASSLOAD_MI_NOTIMPLEMENTED "Type '%1' from assembly '%2' tried to override method '%3' but does not implement or inherit that method." - IDS_CLASSLOAD_MI_VIRTUALMISMATCH "Method '%3' on type '%1' from assembly '%2' tried to implement a method declaration with a different virtual state." IDS_CLASSLOAD_MI_MUSTBEVIRTUAL "Method '%3' on type '%1' from assembly '%2' must be virtual to implement a method on an interface or super type." IDS_CLASSLOAD_MI_BAD_SIG "Type '%1' from assembly '%2' contains an invalid method implementation signature." IDS_CLASSLOAD_MI_FINAL_IMPL "Method implementation on an interface '%1' from assembly '%2' must be a final method." @@ -1259,12 +766,10 @@ BEGIN SECURITY_E_UNVERIFIABLE "Unverifiable assembly '%1' failed policy check." IDS_CLASSLOAD_BAD_FIELD "Type '%1' from assembly '%2' has a field of an illegal type." IDS_CLASSLOAD_MI_ILLEGAL_BODY "Body referenced in a method implementation must be defined in the same type. Type: '%1'. Assembly: '%2'." - IDS_CLASSLOAD_MI_ILLEGAL_STATIC "Body referenced in a method implementation cannot be static. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_BODY "Body token used in a method implementation is out of range. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_DECL "Declaration token used in a method implementation is out of range. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_SEALED_DECL "Declaration referenced in a method implementation cannot be on a sealed type. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_FINAL_DECL "Declaration referenced in a method implementation cannot be a final method. Type: '%1'. Assembly: '%2'." - IDS_CLASSLOAD_MI_PRIVATE_DECL "The declaration referenced in a method implementation is inaccessible. Type: '%1' Assembly: '%2'" IDS_CLASSLOAD_MI_NONVIRTUAL_DECL "Declaration referenced in a method implementation must be a virtual method. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_BODY_DECL_MISMATCH "Signature of the body and declaration in a method implementation do not match. Type: '%1'. Assembly: '%2'." IDS_CLASSLOAD_MI_MISSING_SIG_BODY "Signature for the body in a method implementation cannot be found. Type: '%1'. Assembly: '%2'." @@ -1273,29 +778,20 @@ BEGIN IDS_CLASSLOAD_EQUIVALENTSTRUCTMETHODS "Could not load the structure '%1' from assembly '%2'. The structure is marked as eligible for type equivalence, but it has a method." IDS_CLASSLOAD_EQUIVALENTSTRUCTFIELDS "Could not load the structure '%1' from assembly '%2'. The structure is marked as eligible for type equivalence, but it has a static or non-public field." IDS_CLASSLOAD_EQUIVALENTBADTYPE "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but either it has generic parameters, or it is not a structure, COM imported interface, enumeration, or delegate." - IDS_CLASSLOAD_EQUIVALENTNOTTRUSTED "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but the containing assembly is not loaded as fully trusted." - IDS_CLASSLOAD_EQUIVALENTNOTPUBLIC "Could not load type '%1' from assembly '%2'. The type is marked as eligible for type equivalence, but it is not marked as public." IDS_EE_CODEEXECUTION_CONTAINSGENERICVAR "Could not execute the method because either the method itself or the containing type is not fully instantiated." IDS_CLASSLOAD_WRONGCPU "Could not load file or assembly '%1'. This assembly was compiled for a different processor." IDS_CANNOT_MARSHAL "Type '%1' cannot be marshaled as an unmanaged structure; no meaningful size or offset can be computed." - IDS_PINVOKE_STRINGBUILDEROVERFLOW "Warning: A StringBuilder buffer has been overflowed by unmanaged code. The process may become unstable. Insufficient capacity allocated to the StringBuilder before marshaling it." - + IDS_INVALID_REDIM "Illegal attempt to replace or redimension a fixed or locked SafeArray." IDS_INVALID_PINVOKE_CALLCONV "Invalid unmanaged calling convention: must be one of stdcall, cdecl, or thiscall." IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS "Type could not be marshaled because an embedded valuetype has no layout information." IDS_CLASSLOAD_NSTRUCT_EXPLICIT_OFFSET "Could not load type '%1' from assembly '%2' because field '%3' was not given an explicit offset." - IDS_UNI2ANSI_FAILURE_IN_NSTRUCT "Type could not be marshaled because an embedded string could not be converted from Unicode to ANSI." IDS_WRONGSIZEARRAY_IN_NSTRUCT "Type could not be marshaled because the length of an embedded array instance does not match the declared length in the layout." - IDS_UNI2ANSI_FAILURE "Failure converting Unicode string to ANSI." - IDS_ANSI2UNI_FAILURE "Failure converting ANSI string to Unicode." - + IDS_EE_INVALIDLCIDPARAM "The value of the LCID conversion attribute must not exceed the number of parameters." - IDS_ENCODEDPERMSET_DECODEFAILURE "Failure decoding embedded permission set object." - IDS_ENCODEDPERMSETCOLLECTION_DECODEFAILURE "Failure decoding embedded permission set collection object." - IDS_BAD_MSCORLIB "Mscorlib.dll is missing types required by security." IDS_EE_INVALIDCOMSOURCEITF "The list of COM source interfaces for type '%1' contains non interface or generic type '%2'." IDS_EE_CANNOT_COERCE_BYREF_VARIANT "Object cannot be coerced to the original type of the ByRef VARIANT it was obtained from." IDS_EE_WRAPPER_MUST_HAVE_DEF_CONS "The new wrapper type must have an empty constructor." @@ -1308,8 +804,7 @@ BEGIN IDS_EE_CALLBACK_NOT_CALLED_FROM_CCTOR "Function can only be called from inside the class constructor of a class derived from a COM imported class." IDS_EE_CALLBACK_ALREADY_REGISTERED "Base type has already registered a type creation callback." IDS_EE_CANNOTCAST "Unable to cast object of type '%1' to type '%2'." - IDS_EE_CANNOTCASTPROXY "Unable to cast transparent proxy to type '%1'." - + IDS_EE_CANNOTCASTSAME "[A]%1 cannot be cast to [B]%2. %3. %4." IDS_EE_CANNOTCAST_HELPER_PATH "Type %s originates from '%s' in the context '%s' at location '%s'" IDS_EE_CANNOTCAST_HELPER_BYTE "Type %s originates from '%s' in the context '%s' in a byte array" @@ -1318,37 +813,12 @@ BEGIN IDS_EE_BAD_COMEXTENDS_CLASS "Types extending from COM objects should override all methods of an interface implemented by the base COM class." IDS_EE_INTERFACE_NOT_DISPATCH_BASED "The interface does not support late bound calls since it does not derive from IDispatch." IDS_EE_MARSHAL_UNMAPPABLE_CHAR "Cannot marshal: Encountered unmappable character." - IDS_EE_VTRECORD_SECURITY "Structures defined in untrusted code cannot be marshaled to and from native code as either parameters or return values." // Errors associated with parsing security custom attributes at compile time. - CORSECATTR_E_BAD_ATTRIBUTE "Invalid custom attribute." - CORSECATTR_E_MISSING_CONSTRUCTOR "The permission associated with this attribute is missing a required constructor." - CORSECATTR_E_FAILED_TO_CREATE_PERM "Unable to create an instance of the permission for this attribute." - CORSECATTR_E_BAD_ACTION_ASM "SecurityAction type invalid on assembly." - CORSECATTR_E_BAD_ACTION_OTHER "SecurityAction type invalid on types and methods." - CORSECATTR_E_BAD_PARENT "Security custom attribute attached to invalid parent." - CORSECATTR_E_TRUNCATED "Serialized security custom attribute is truncated or incorrectly formed." - CORSECATTR_E_BAD_VERSION "Serialized security custom attribute has unrecognized version." CORSECATTR_E_BAD_ACTION "Security custom attribute has invalid SecurityAction." - CORSECATTR_E_NO_SELF_REF "Security custom attributes cannot be referenced from defining assembly." - CORSECATTR_E_BAD_NONCAS "Invalid SecurityAction for non-Code Access Security permission." - CORSECATTR_E_ASSEMBLY_LOAD_FAILED "Failed to load assembly '%s'." - CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX "Failed to load assembly '%s' - %s." - CORSECATTR_E_TYPE_LOAD_FAILED "Failed to load type '%s'." - CORSECATTR_E_TYPE_LOAD_FAILED_EX "Failed to load type '%s' - %s." - CORSECATTR_E_ABSTRACT "Security custom attribute cannot be abstract." - CORSECATTR_E_UNSUPPORTED_TYPE "Security custom attributes do not support array or Type fields and properties." - CORSECATTR_E_UNSUPPORTED_ENUM_TYPE "Unsupported enumeration base type." - CORSECATTR_E_NO_FIELD "Failed to locate field '%s'." - CORSECATTR_E_NO_PROPERTY "Failed to locate property '%s'." - CORSECATTR_E_EXCEPTION "Unexpected exception processing attribute - '%s'." - CORSECATTR_E_EXCEPTION_HR "Unexpected exception processing attribute - HRESULT 0x%08X." - - IDS_EE_OFFSETOF_NOFIELDFOUND "Field passed in is not a marshaled member of the type '%1'." + IDS_EE_COPY_OUTOFRANGE "Requested range extends past the end of the array." - IDS_EE_CANNOTPIN "Object type cannot be pinned." IDS_EE_ARRAYWITHOFFSETOVERFLOW "ArrayWithOffset: offset exceeds array size." - IDS_EE_OUTOFLOCALS "Ran out of internal resource while executing marshaling operation. Possible cause: overly complex method signature." IDS_EE_NOCUSTOMMARSHALER "A call to GetInstance() for custom marshaler '%1' returned null, which is not allowed." IDS_EE_SIZECONTROLOUTOFRANGE "Array size control parameter index is out of range." IDS_EE_SIZECONTROLBADTYPE "Array size control parameter type not supported." @@ -1356,24 +826,16 @@ BEGIN IDS_EE_SAFEARRAYSZARRAYMISMATCH "SafeArray cannot be marshaled to this array type because it has either nonzero lower bounds or more than one dimension." IDS_EE_REFLECTIONONLYGETTYPE_NOASSEMBLY "Explicit assembly name must be specified when loading a type as ReflectionOnly" - IDS_EE_REFLECTIONONLY_LOADFROM "API restriction: The assembly '%1' has already loaded from a different location. It cannot be loaded from a new location within the same appdomain." IDS_EE_REFLECTIONONLY_LOADFAILURE "Cannot resolve dependency to assembly '%1' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event." - IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE "Cannot resolve dependency to Windows Runtime type '%1'. When using the ReflectionOnly APIs, dependent Windows Runtime assemblies must be resolved on demand through the ReflectionOnlyNamespaceResolve event." - IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE_THIRDPARTY "To resolve a namespace from a custom Windows Runtime component, you must supply the packageGraphFilePaths argument to ResolveNamespace." - IDS_EE_REFLECTIONONLY_WINRT_INVALIDASSEMBLY "Returning a .NET Framework assembly to resolve a Windows Runtime reference is not supported." IDS_EE_WINRT_LOADFAILURE "Could not find Windows Runtime type '%1'." IDS_EE_WINRT_THIRDPARTY_NOTSUPPORTED "Types from custom Windows Runtime components are not supported in desktop applications." IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC "Type names passed to Assembly.GetType() must not specify an assembly." - IDS_EE_IJWLOAD_CROSSVERSION_DISALLOWED "Mixed mode assembly is built against version '%1' of the runtime and cannot be loaded in the %2 runtime without additional configuration information." - IDS_EE_IJWLOAD_MULTIRUNTIME_DISALLOWED "Mixed mode assembly cannot be loaded into version '%1' of the runtime because it is already loaded into version '%2'." IDS_EE_CANNOT_HAVE_ASSEMBLY_SPEC "Unexpected assembly-qualifier in a typename." IDS_EE_NEEDS_ASSEMBLY_SPEC "Typename needs an assembly qualifier." IDS_EE_FILELOAD_ERROR_GENERIC "Could not load file or assembly '%1'. %2" - IDS_EE_CRYPTO_UNKNOWN_OPERATION "Unknown import key operation specified." - IDS_EE_LOCAL_COGETCLASSOBJECT_FAILED "Retrieving the COM class factory for component with CLSID %2 failed due to the following error: %1 %3." IDS_EE_REMOTE_COGETCLASSOBJECT_FAILED "Retrieving the COM class factory for remote component with CLSID %2 from machine %3 failed due to the following error: %1 %3." @@ -1393,17 +855,13 @@ BEGIN IDS_EE_MISSING_FIELD "Field not found: '%1'." IDS_EE_MISSING_METHOD "Method not found: '%1'." - IDS_EE_MSCOREE_MISSING "MSCOREE is not loaded." - IDS_EE_MSCOREE_MISSING_ENTRYPOINT "Missing entrypoint in MSCOREE: '%1'." - - IDS_EE_PINVOKE_NOREFFORSIZEIS "Cannot use SizeParamIndex for ByRef array parameters." + IDS_EE_NO_IDISPATCH "This object cannot be marshaled as an IDispatch." IDS_EE_NO_BACKING_CLASS_FACTORY "An instance of the __ComObject type cannot be created unless the type has been obtained using GetTypeFromProgID or GetTypeFromCLSID." IDS_EE_SIGTOOCOMPLEX "Internal limitation: method signature is too complex or too large." IDS_EE_STRUCTTOOCOMPLEX "Internal limitation: structure is too complex or too large." IDS_EE_STRUCTARRAYTOOLARGE "Array size exceeds addressing limitations." - IDS_EE_TOOMANYASSOCIATES "Internal limitation: too many property methods associated with this method." IDS_EE_TOOMANYFIELDS "Internal limitation: too many fields." IDS_EE_UNHANDLED_EXCEPTION "Unhandled Exception:" @@ -1417,7 +875,6 @@ BEGIN IDS_EE_ARRAY_DIMENSIONS_EXCEEDED "Array dimensions exceeded supported range." - IDS_EE_CANNOT_LOAD_JIT "Unable to load Jit Compiler: (%s): file may be missing or corrupt. Please check or rerun setup." IDS_EE_PROFILING_FAILURE "Profiling failure" @@ -1431,9 +888,6 @@ BEGIN IDS_EE_THREADSTART_STATE "Thread is running or terminated; it cannot restart." IDS_EE_THREAD_CANNOT_GET "Unable to retrieve thread information." - IDS_EE_THREAD_SUSPEND_NON_RUNNING "Thread is not running; it cannot be suspended." - IDS_EE_THREAD_RESUME_NON_RUNNING "Thread is not running; it cannot be resumed." - IDS_EE_THREAD_RESUME_NON_USER_SUSPEND "Thread is not user-suspended; it cannot be resumed." IDS_EE_THREAD_DEAD_PRIORITY "Thread is dead; priority cannot be accessed." IDS_EE_THREAD_PRIORITY_FAIL "Unable to set thread priority." IDS_EE_THREAD_DEAD_STATE "Thread is dead; state cannot be accessed." @@ -1443,23 +897,12 @@ BEGIN IDS_EE_THREAD_DEADLOCK_VICTIM "The current thread has been chosen as a deadlock victim." IDS_EE_PATH_TOO_LONG "The path is too long after being fully qualified. Make sure the full path is less than 260 characters and the directory name is less than 248 characters." - IDS_EE_PATH_HAS_IMPROPER_CHAR "The path contains illegal characters." - IDS_EE_PATH_ILLEGAL "The path is not of a legal form." - IDS_EE_PATH_INVALID_UNCPATH "The UNC path should be of the form \\\\server\\share." - IDS_EE_PATH_GLOBALROOT "Paths starting with \\\\?\\GlobalRoot are internal to the kernel and should not be opened by managed applications." - - IDS_CLASSLOAD_BADOVERLAP "Illegal layout for type '%1' from assembly '%2': valuetypes with non-public fields may not overlap with other fields." - - IDS_EE_SID_TIMEOUT "Lookup of token information timed out." - + IDS_EE_INVALID_SAFEARRAY "Specified SAFEARRAY is invalid." IDS_EE_METHOD_NOT_FOUND_ON_EV_PROV "Method '%1' of COM event interface '%2' is not present on event provider '%3'." IDS_EE_BAD_COMEVENTITF_CLASS "Methods on COM event interfaces must take a single delegate derived class as a parameter and have a void return type." - IDS_EE_COREXEMAIN_FAILED_TEXT "Could not run the given program. _CorExeMain failed." - IDS_EE_COREXEMAIN_FAILED_TITLE "The Common Language Runtime could not run the given program." - IDS_EE_ICUSTOMMARSHALERNOTIMPL "Custom marshaler '%1' does not implement the ICustomMarshaler interface." IDS_EE_GETINSTANCENOTIMPL "Custom marshaler '%1' does not implement a static GetInstance method that takes a single string parameter and returns an ICustomMarshaler." @@ -1476,15 +919,10 @@ BEGIN IDS_EE_SH_FIELD_INVALID_OPERATION "Structures containing SafeHandle fields are not allowed in this operation." IDS_EE_CANNOT_CREATE_SAFEHANDLE_FIELD "SafeHandle fields cannot be created from an unmanaged handle." IDS_EE_SH_IN_VARIANT_NOT_SUPPORTED "SafeHandle derived types cannot be stored in Variants." - IDS_CLASSLOAD_SH_SUBCLASS_FINALIZER "SafeHandle subclasses may not override the finalizer. Put logic in ReleaseHandle instead." - - IDS_EE_CRITICALHANDLECLOSED "Critical handle has been closed" - - IDS_EE_CH_FIELD_INVALID_OPERATION "Structures containing CriticalHandle fields are not allowed in this operation." + IDS_EE_CANNOT_CREATE_CRITICALHANDLE_FIELD "CriticalHandle fields cannot be created from an unmanaged handle." IDS_EE_CH_IN_VARIANT_NOT_SUPPORTED "CriticalHandle derived types cannot be stored in Variants." - IDS_CLASSLOAD_CH_SUBCLASS_FINALIZER "CriticalHandle subclasses may not override the finalizer. Put logic in ReleaseHandle instead." - + IDS_EE_VAR_WRAP_IN_VAR_NOT_SUPPORTED "VariantWrappers cannot be stored in Variants." IDS_EE_RECORD_NON_SUPPORTED_FIELDS "The structure contains fields that are not supported in unmanaged records." @@ -1495,8 +933,6 @@ BEGIN IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_INTROSPECTION "AssemblyResolveEvent handlers cannot return Assemblies loaded for reflection only." IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_EXECUTION "ReflectionOnlyAssemblyResolve handlers must return Assemblies loaded for reflection only." - IDS_CLASSLOAD_MODULE_RESOLVE_INTROSPECTION_MISMATCH "ModuleResolveEvent returned an incompatible Module. ReflectionOnly assemblies cannot bind to normal Modules, nor vice-versa." - IDS_CLASSLOAD_OVERLAPPING_INTERFACES "The type '%1' in assembly '%2' has a contracting interface set for some instantiations" IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY "Attempted to load a 64-bit assembly on a 32-bit platform." @@ -1507,9 +943,7 @@ BEGIN IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_PARENT_METHOD_IMPL "Method '%3' on type '%1' from assembly '%2' tried to explicitly implement a parent method with weaker type parameter constraints." IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_INTERFACE_METHOD_IMPL "Method '%3' on type '%1' from assembly '%2' tried to explicitly implement an interface method with weaker type parameter constraints." IDS_CLASSLOAD_EXPLICIT_GENERIC "Could not load type '%1' from assembly '%2' because generic types cannot have explicit layout." - IDS_EE_CONFIGPARSER_ERROR_CAPTION "Configuration parser error" - IDS_EE_CONFIGPARSER_ERROR "Error parsing %s\nParser returned error 0x%08X." - + IDS_EE_COM_INVISIBLE_PARENT "This type has a ComVisible(false) parent in its hierarchy, therefore QueryInterface calls for IDispatch or class interfaces are disallowed." IDS_EE_COMIMPORT_METHOD_NO_INTERFACE "Method '%1' in ComImport class '%2' must implement an interface method." @@ -1521,14 +955,11 @@ BEGIN IDS_CLASSLOAD_BAD_VARIANCE_SIG "Type contains improperly formed type variance signature." IDS_CLASSLOAD_VARIANCE_IN_DELEGATE "Could not load type '%1' from assembly '%2' because it declares a field in a covariant type." IDS_CLASSLOAD_TOO_MANY_METHODS "Type '%1' from assembly '%2' contains more methods than the current implementation allows." - IDS_LOADINTROSPECTION_DISALLOWED "Illegal to load assemblies for ReflectionOnly in a verification domain." IDS_EE_CODEEXECUTION_ASSEMBLY_FOR_PASSIVE_DOMAIN_ONLY "File '%1' was loaded in a passive domain in a manner that makes it unable to run." IDS_CLASSLOAD_MI_CANNOT_OVERRIDE "Cannot override runtime implemented method '%3' on type '%1' from assembly '%2'." - IDS_EE_WRONG_METADATA_VERSION "'%1' has an incompatible metadata format. The assembly must be compiled using metadata format '%2'." IDS_CLASSLOAD_COLLECTIBLEFIXEDVTATTR "Collectible type '%1' has unsupported FixedAddressValueTypeAttribute applied to a field." - IDS_EE_JIT_COMPILER_ERROR "JIT Compiler encountered an internal limitation." - IDS_UNMARSHALABLE_DEMAND_OBJECT "The security object (Permission or PermissionSet) used for performing a Demand caused an error relating to serialization/deserialization." + IDS_EE_JIT_COMPILER_ERROR "The JIT compiler encountered invalid IL code or an internal limitation." IDS_EE_OBJECT_TO_VARIANT_NOT_SUPPORTED "Invalid managed/unmanaged type combination (Marshaling to and from COM VARIANTs isn't supported)." IDS_EE_OBJECT_TO_ITF_NOT_SUPPORTED "Invalid managed/unmanaged type combination (Marshaling to and from COM interface pointers isn't supported)." @@ -1536,21 +967,9 @@ BEGIN IDS_E_METHODACCESS "Attempt by method '%1' to access method '%2' failed.%3" IDS_E_TYPEACCESS "Attempt by method '%1' to access type '%2' failed.%3" - IDS_EE_TORNSTATE "Unexpected change made to file '%1'." - IDS_INVOKE_NULLREF_RETURNED "The target method returned a null reference." END -// These strings are generated from within the EE for streams -STRINGTABLE DISCARDABLE -BEGIN - IDS_STREAMS_FILE_EOF "Reached the end of the file." - IDS_STREAMS_FILE_OPEN "File has not been opened." - IDS_STREAMS_FILE_BUFFER "Buffer is shorter than requested bytes." - IDS_STREAMS_FILE_NAME "File name was not supplied." - IDS_STREAMS_SEEK_MODIFIER "Undefined seek modifier." -END - // These strings are used for Event Log Entry STRINGTABLE DISCARDABLE BEGIN @@ -1574,348 +993,42 @@ END STRINGTABLE DISCARDABLE BEGIN - IDS_FAIL_CAPTION "Configuration error." IDS_COMPLUS_ERROR "CLR error: %lx.\n The program will now terminate." IDS_FATAL_ERROR "Fatal error" IDS_ERROR "Error" - IDS_INVALID_VARIANT_MSG "An invalid VARIANT has been passed as argument %i of method '%s' of type '%s'. If this argument is meant to be an interface pointer, add [MarshalAs(UnmanagedType.Interface)] to the managed definition of the argument.\n\nClick CANCEL to break into the debugger and OK to continue." - IDS_INVALID_VARIANT_CAPTION "Invalid VARIANT." - - IDS_DEBUG_DIFF_BUILDS_ERR "Warning: Components of the Common Language Runtime debugging services are from different builds.\nContinuing to run will cause unpredictable results.\n\nIn-process component (mscoree.dll) is version %d.%d (%s)\nOut-of-process component (mscordbi.dll) is version %d.%d (%s).\n." - IDS_DEBUG_NO_DEBUGGER_FOUND "No debugger found." + IDS_DEBUG_UNHANDLEDEXCEPTION_IPC "INTERNAL ERROR:\n\nUnhandled exception in Debugger::HandleIPCEvent.\n\nEvent ID=0x%x.\n\nException code=0x%08x, Eip=0x%08x.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\n" IDS_DEBUG_UNHANDLED_EXCEPTION_MSG "Application has generated an exception that could not be handled.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick OK to terminate the application.\nClick CANCEL to debug the application." IDS_DEBUG_USER_BREAKPOINT_MSG "Application has encountered a user-defined breakpoint.\n\nProcess ID=0x%x (%d), Thread ID=0x%x (%d).\n\nClick ABORT to terminate the application.\nClick RETRY to debug the application.\nClick IGNORE to ignore the breakpoint." - IDS_DBI_ERRLOG_CATAGORY "DebuggerError" - IDS_DBI_EXCEPTION_ON_UNKNOWN_THREAD_MSG "Ignoring managed exception from unknown thread." - - IDS_EE_NOTSUPPORTED_CATCHBEFORETRY "Catch handler cannot precede try block." - - IDS_PERFORMANCEMON_WINNT_ERR "Performance Monitor Extension DLL for CLR. This can only be used on Windows NT." - IDS_PERFORMANCEMON_WINNT_TITLE "Could not load on non-Windows NT system." - - IDS_WATSON_DEBUG_BREAK_INTRO_BOLD "%General_AppName% has encountered a user-defined breakpoint." - IDS_WATSON_DEBUG_BREAK_INTRO_REG "A breakpoint in an application indicates a program error. After this dialog is dismissed, the application will continue running, but it may be in an unstable state." END -// IsolatedStore error messages -STRINGTABLE DISCARDABLE -BEGIN - ISS_E_ISOSTORE "IsolatedStorage operation failed." - - ISS_E_OPEN_STORE_FILE "Unable to open the store." - ISS_E_OPEN_FILE_MAPPING "Unable to create store file mapping." - ISS_E_MAP_VIEW_OF_FILE "Unable to map the store file." - ISS_E_GET_FILE_SIZE "Unable to determine store file size." - ISS_E_CREATE_MUTEX "Unable to create mutex." - ISS_E_LOCK_FAILED "Unable to lock the store." - ISS_E_FILE_WRITE "File Write failed." - ISS_E_SET_FILE_POINTER "Cannot set file pointer." - ISS_E_CREATE_DIR "Unable to create the store directory." - ISS_E_STORE_NOT_OPEN "Store must be open for this operation." - - ISS_E_CORRUPTED_STORE_FILE "Store file is corrupt." - ISS_E_STORE_VERSION "Store version is not supported." - ISS_E_FILE_NOT_MAPPED "Store file is not mapped." - ISS_E_BLOCK_SIZE_TOO_SMALL "Block size is too small." - ISS_E_ALLOC_TOO_LARGE "Allocation size is too large." - ISS_E_USAGE_WILL_EXCEED_QUOTA "Allowed quota is fully used." - ISS_E_TABLE_ROW_NOT_FOUND "Row not found." - - ISS_E_DEPRECATE "Unable to deprecate old store." - ISS_E_CALLER "Unable to determine the caller." - ISS_E_PATH_LENGTH "Path length is too long." - ISS_E_MACHINE "Machine Store is not supported." - ISS_E_MACHINE_DACL "The DACL for the machine store is incorrect or could not be created." -END - // Verifier error messages STRINGTABLE DISCARDABLE BEGIN - VER_E_HRESULT "[HRESULT 0x%08X]" - VER_E_OFFSET "[offset 0x%08X]" - VER_E_OPCODE "[opcode %s]" - VER_E_OPERAND "[operand 0x%08X]" - VER_E_TOKEN "[token 0x%08X]" - VER_E_EXCEPT "[exception #0x%08X]" - VER_E_STACK_SLOT "[stack slot 0x%08X]" - VER_E_LOC "[local variable #0x%08X]" - VER_E_LOC_BYNAME "[local variable '%s']" - VER_E_ARG "[argument #0x%08x]" - VER_E_FOUND "[found %s]" - VER_E_EXPECTED "[expected %s]" - - VER_E_UNKNOWN_OPCODE "Unknown opcode [0x%08X]." - VER_E_SIG_CALLCONV "Unknown calling convention [0x%08X]." - VER_E_SIG_ELEMTYPE "Unknown ELEMENT_TYPE [0x%08x]." - - VER_E_RET_SIG "[return sig]" VER_E_FIELD_SIG "[field sig]" - VER_E_INTERNAL "Internal error." - VER_E_STACK_TOO_LARGE "Stack is too large." - VER_E_ARRAY_NAME_LONG "Array name is too long." - - VER_E_FALLTHRU "fall through end of the method without returning." - VER_E_TRY_GTEQ_END "try start >= try end." - VER_E_TRYEND_GT_CS "try end > code size." - VER_E_HND_GTEQ_END "handler start >= handler end." - VER_E_HNDEND_GT_CS "handler end > code size." - VER_E_TRY_START "Try starts in the middle of an instruction." - VER_E_HND_START "Handler starts in the middle of an instruction." - VER_E_TRY_OVERLAP "Try block overlap with another block." - VER_E_TRY_EQ_HND_FIL "Try and filter/handler blocks are equivalent." - VER_E_TRY_SHARE_FIN_FAL "Shared try has finally or fault handler." - VER_E_HND_OVERLAP "Handler block overlaps with another block." - VER_E_HND_EQ "Handler block is the same as another block." - VER_E_FIL_OVERLAP "Filter block overlaps with another block." - VER_E_FIL_EQ "Filter block is the same as another block." - VER_E_FIL_CONT_TRY "Filter contains try." - VER_E_FIL_CONT_HND "Filter contains handler." - VER_E_FIL_CONT_FIL "Nested filters." - VER_E_FIL_GTEQ_CS "filter >= code size." - VER_E_FIL_START "Filter starts in the middle of an instruction." - VER_E_FALLTHRU_EXCEP "fallthru the end of an exception block." - VER_E_FALLTHRU_INTO_HND "fallthru into an exception handler." - VER_E_FALLTHRU_INTO_FIL "fallthru into an exception filter." - VER_E_LEAVE "Leave from outside a try or catch block." - VER_E_RETHROW "Rethrow from outside a catch handler." - VER_E_ENDFINALLY "Endfinally from outside a finally handler." - VER_E_ENDFILTER "Endfilter from outside an exception filter block." - VER_E_ENDFILTER_MISSING "Missing Endfilter." - VER_E_BR_INTO_TRY "Branch into try block." - VER_E_BR_INTO_HND "Branch into exception handler block." - VER_E_BR_INTO_FIL "Branch into exception filter block." - VER_E_BR_OUTOF_TRY "Branch out of try block." - VER_E_BR_OUTOF_HND "Branch out of exception handler block." - VER_E_BR_OUTOF_FIL "Branch out of exception filter block." - VER_E_BR_OUTOF_FIN "Branch out of finally block." - VER_E_RET_FROM_TRY "Return out of try block." - VER_E_RET_FROM_HND "Return out of exception handler block." - VER_E_RET_FROM_FIL "Return out of exception filter block." - VER_E_BAD_JMP_TARGET "jmp / exception into the middle of an instruction." - VER_E_PATH_LOC "Non-compatible types depending on path." - VER_E_PATH_THIS "Init state for this differs depending on path." - VER_E_PATH_STACK "Non-compatible types on stack depending on path." - VER_E_PATH_STACK_DEPTH "Stack depth differs depending on path." - VER_E_THIS "Instance variable (this) missing." - VER_E_THIS_UNINIT_EXCEP "Uninitialized this on entering a try block." - VER_E_THIS_UNINIT_STORE "Store into this when it is uninitialized." - VER_E_THIS_UNINIT_RET "Return from .ctor when this is uninitialized." - VER_E_THIS_UNINIT_V_RET "Return from .ctor before all fields are initialized." - VER_E_THIS_UNINIT_BR "Branch back when this is uninitialized." - VER_E_LDFTN_CTOR "ldftn/ldvirtftn not allowed on .ctor." - VER_E_STACK_NOT_EQ "Non-compatible types on the stack." - VER_E_STACK_UNEXPECTED "Unexpected type on the stack." - VER_E_STACK_EXCEPTION "Missing stack slot for exception." - VER_E_STACK_OVERFLOW "Stack overflow." - VER_E_STACK_UNDERFLOW "Stack underflow." - VER_E_STACK_EMPTY "Stack empty." - VER_E_STACK_UNINIT "Uninitialized item on stack." - VER_E_STACK_I_I4_I8 "Expected I, I4, or I8 on the stack." - VER_E_STACK_R_R4_R8 "Expected R, R4, or R8 on the stack." - VER_E_STACK_NO_R_I8 "unexpected R, R4, R8, or I8 on the stack." - VER_E_STACK_NUMERIC "Expected numeric type on the stack." - VER_E_STACK_OBJREF "Expected an ObjRef on the stack." - VER_E_STACK_P_OBJREF "Expected address of an ObjRef on the stack." - VER_E_STACK_BYREF "Expected ByRef on the stack." - VER_E_STACK_METHOD "Expected pointer to function on the stack." - VER_E_STACK_ARRAY_SD "Expected single dimension array on the stack." - VER_E_STACK_VALCLASS "Expected value type instance on the stack." - VER_E_STACK_P_VALCLASS "Expected address of value type on the stack." - VER_E_STACK_NO_VALCLASS "Unexpected value type instance on the stack." - VER_E_LOC_DEAD "Local variable is unusable at this point." - VER_E_LOC_NUM "Unrecognized local variable number." - VER_E_ARG_NUM "Unrecognized argument number." - VER_E_TOKEN_RESOLVE "Unable to resolve token." - VER_E_TOKEN_TYPE "Unable to resolve type of the token." - VER_E_TOKEN_TYPE_MEMBER "Expected memberRef, memberDef or methodSpec token." - VER_E_TOKEN_TYPE_FIELD "Expected memberRef or fieldDef token." - VER_E_TOKEN_TYPE_SIG "Expected signature token." - VER_E_UNVERIFIABLE "Instruction cannot be verified." - VER_E_LDSTR_OPERAND "Operand does not point to a valid string ref." - VER_E_RET_PTR_TO_STACK "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator." - VER_E_RET_VOID "Stack must be empty on return from a void function." - VER_E_RET_MISSING "Return value missing on the stack." - VER_E_RET_EMPTY "Stack must contain only the return value." - VER_E_RET_UNINIT "Return uninitialized data." - VER_E_ARRAY_ACCESS "Illegal array access." - VER_E_ARRAY_V_STORE "Store non Object type into Object array." - VER_E_ARRAY_SD "Expected single-dimension zero-based array." - VER_E_ARRAY_SD_PTR "Expected single dimension array of pointer types." - VER_E_ARRAY_FIELD "Array field access is denied." - VER_E_ARGLIST "Allowed only in vararg methods." - VER_E_VALCLASS "Value type expected." - VER_E_OPEN_DLGT_PROT_ACC "Protected method access through an open instance delegate is not verifiable." - VER_E_METHOD_ACCESS "Method is not visible." - VER_E_FIELD_ACCESS "Field is not visible." - VER_E_DEAD "Item is unusable at this point." - VER_E_FIELD_STATIC "Expected static field." - VER_E_FIELD_NO_STATIC "Expected non-static field." - VER_E_ADDR "Address of not allowed for this item." - VER_E_ADDR_BYREF "Address of not allowed for ByRef." - VER_E_ADDR_LITERAL "Address of not allowed for literal field." - VER_E_INITONLY "Cannot change initonly field outside its .ctor." - VER_E_WRITE_RVA_STATIC "Cannot modify an imaged based (RVA) static" - VER_E_THROW "Cannot throw this object." - VER_E_CALLVIRT_VALCLASS "Callvirt on a value type method." - VER_E_CALL_SIG "Call signature mismatch." - VER_E_CALL_STATIC "Static function expected." - VER_E_CTOR ".ctor expected." - VER_E_CTOR_VIRT "Cannot use callvirt on .ctor." - VER_E_CTOR_OR_SUPER "Only super::ctor or typeof(this)::ctor allowed here." - VER_E_CTOR_MUL_INIT "Possible call to .ctor more than once." - VER_E_SIG "Unrecognized signature." - VER_E_SIG_ARRAY "Cannot resolve Array type." - VER_E_SIG_ARRAY_PTR "Array of ELEMENT_TYPE_PTR." - VER_E_SIG_ARRAY_BYREF "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF." - VER_E_SIG_ELEM_PTR "ELEMENT_TYPE_PTR cannot be verified." - VER_E_SIG_VARARG "Unexpected vararg." - VER_E_SIG_VOID "Unexpected Void." - VER_E_SIG_BYREF_BYREF "ByRef of ByRef" - VER_E_CODE_SIZE_ZERO "Code size is zero." - VER_E_BAD_VARARG "Unrecognized use of vararg." - VER_E_TAIL_CALL "Missing call/callvirt/calli." - VER_E_TAIL_BYREF "Cannot pass ByRef to a tail call." - VER_E_TAIL_RET "Missing ret." - VER_E_TAIL_RET_VOID "Void ret type expected for tail call." - VER_E_TAIL_RET_TYPE "Tail call return type not compatible." - VER_E_TAIL_STACK_EMPTY "Stack not empty after tail call." - VER_E_METHOD_END "Method ends in the middle of an instruction." - VER_E_BAD_BRANCH "Branch out of the method." - VER_E_FIN_OVERLAP "Finally handler blocks overlap." - VER_E_LEXICAL_NESTING "Lexical nesting." - VER_E_VOLATILE "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk, or cpblk." - VER_E_UNALIGNED "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk, cpblk." - VER_E_INNERMOST_FIRST "Innermost exception blocks should be declared first." - VER_E_CALLI_VIRTUAL "Calli not allowed on virtual methods." - VER_E_CALL_ABSTRACT "Call not allowed on abstract methods." - VER_E_STACK_UNEXP_ARRAY "Unexpected array type on the stack." - VER_E_NOT_IN_GC_HEAP "Value type with NotInGCHeap attribute being created on the GC heap." - VER_E_TRY_N_EMPTY_STACK "Attempt to enter a try block with nonempty stack." - VER_E_DLGT_CTOR "Unrecognized arguments for delegate .ctor." - VER_E_DLGT_BB "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method." - VER_E_DLGT_PATTERN "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)." - VER_E_DLGT_LDFTN "Ldftn or ldvirtftn instruction required before call to a delegate .ctor." - VER_E_FTN_ABSTRACT "Attempt to load address of an abstract method." - VER_E_SIG_C_VC "ELEMENT_TYPE_CLASS ValueClass in signature." - VER_E_SIG_VC_C "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature." - VER_E_BOX_PTR_TO_STACK "Box operation on TypedReference, ArgHandle, or ArgIterator." - VER_E_SIG_BYREF_TB_AH "ByRef of TypedReference, ArgHandle, or ArgIterator." - VER_E_SIG_ARRAY_TB_AH "Array of TypedReference, ArgHandle, or ArgIterator." - VER_E_ENDFILTER_STACK "Stack not empty when leaving an exception filter." - VER_E_DLGT_SIG_I "Unrecognized delegate .ctor signature; expected I." - VER_E_DLGT_SIG_O "Unrecognized delegate .ctor signature; expected Object." - VER_E_RA_PTR_TO_STACK "Mkrefany on TypedReference, ArgHandle, or ArgIterator." - VER_E_CATCH_VALUE_TYPE "Value type not allowed as catch type." - VER_E_CATCH_BYREF "ByRef not allowed as catch type." - VER_E_FIL_PRECEED_HND "filter block should immediately precede handler block" - VER_E_LDVIRTFTN_STATIC "ldvirtftn on static" - VER_E_CALLVIRT_STATIC "callvirt on static" - VER_E_INITLOCALS "initlocals must be set for verifiable methods with one or more local variables." - VER_E_BR_TO_EXCEPTION "branch/leave to the beginning of a catch/filter handler" - VER_E_CALL_CTOR "call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj." - //@GENERICSVER: new generics related error messages - VER_E_VALCLASS_OBJREF_VAR "Value type, ObjRef type or variable type expected." - VER_E_STACK_P_VALCLASS_OBJREF_VAR "Expected address of value type, ObjRef type or variable type on the stack." - VER_E_SIG_VAR_PARAM "Unrecognized type parameter of enclosing class." - VER_E_SIG_MVAR_PARAM "Unrecognized type parameter of enclosing method." - VER_E_SIG_VAR_ARG "Unrecognized type argument of referenced class instantiation." - VER_E_SIG_MVAR_ARG "Unrecognized type argument of referenced method instantiation." - VER_E_SIG_GENERICINST "Cannot resolve generic type." - VER_E_SIG_METHOD_INST "Method instantiation contains non boxable type arguments." - VER_E_SIG_METHOD_PARENT_INST "Method parent instantiation contains non boxable type arguments." - VER_E_SIG_FIELD_PARENT_INST "Field parent instantiation contains non boxable type arguments." - VER_E_CALLCONV_NOT_GENERICINST "Unrecognized calling convention for an instantiated generic method." - VER_E_TOKEN_BAD_METHOD_SPEC "Unrecognized generic method in method instantiation." - VER_E_BAD_READONLY_PREFIX "Missing ldelema or call following readonly prefix." - VER_E_BAD_CONSTRAINED_PREFIX "Missing callvirt following constrained prefix." - VER_E_CIRCULAR_VAR_CONSTRAINTS "Method parent has circular class type parameter constraints." VER_E_CIRCULAR_MVAR_CONSTRAINTS "Method has circular method type parameter constraints." - VER_E_UNSATISFIED_METHOD_INST "Method instantiation has unsatisfied method type parameter constraints." - VER_E_UNSATISFIED_METHOD_PARENT_INST "Method parent instantiation has unsatisfied class type parameter constraints." - VER_E_UNSATISFIED_FIELD_PARENT_INST "Field parent instantiation has unsatisfied class type parameter constraints." - VER_E_UNSATISFIED_BOX_OPERAND "Type operand of box instruction has unsatisfied class type parameter constraints." - VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS "The 'this' argument to a constrained call must have ByRef type." - VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE "The operand to a constrained prefix instruction must be a type parameter." - VER_E_READONLY_UNEXPECTED_CALLEE "The readonly prefix may only be applied to calls to array methods returning ByRefs." - VER_E_READONLY_ILLEGAL_WRITE "Illegal write to readonly ByRef." - VER_E_READONLY_IN_MKREFANY "A readonly ByRef cannot be used with mkrefany." - VER_E_UNALIGNED_ALIGNMENT "Alignment specified for 'unaligned' prefix must be 1, 2, or 4." - VER_E_TAILCALL_INSIDE_EH "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block." - VER_E_BACKWARD_BRANCH "Stack height at all points must be determinable in a single forward scan of IL." - VER_E_CALL_TO_VTYPE_BASE "Call to base type of valuetype." - VER_E_NEWOBJ_OF_ABSTRACT_CLASS "Cannot construct an instance of abstract class." - VER_E_UNMANAGED_POINTER "Unmanaged pointers are not a verifiable type." - VER_E_LDFTN_NON_FINAL_VIRTUAL "Cannot LDFTN a non-final virtual method for delegate creation if target object is potentially not the same type as the method class." - VER_E_FIELD_OVERLAP "Accessing type with overlapping fields." - VER_E_THIS_MISMATCH "The 'this' parameter to the call must be the calling method's 'this' parameter." - VER_E_STACK_I_I4 "Expected I4 on the stack." - - VER_E_BAD_PE "Unverifiable PE Header/native stub." - VER_E_BAD_MD "Unrecognized metadata, unable to verify IL." - VER_E_BAD_APPDOMAIN "Unrecognized appdomain pointer." - - VER_E_TYPELOAD "Type load failed." - VER_E_PE_LOAD "Module load failed." - - IDS_VER_E_FORMATTING "Error formatting message." - IDS_VER_E_ILERROR "[IL]: Error: " - IDS_VER_E_GLOBAL "" - IDS_VER_E_MDTOKEN "[mdToken=0x%x]" -END - -// Security error messages -STRINGTABLE DISCARDABLE -BEGIN - SN_CRYPTOAPI_CALL_FAILED "StrongName APIs not supported on system." - SN_NO_SUITABLE_CSP "StrongName APIs could not locate a matching CSP." - SN_NO_SUITABLE_CSP_NAME "StrongName APIs could not locate a matching CSP for assembly '%1'." - SN_E_PUBLICKEY_MISMATCH "Key pair does not match public key from assembly '%1'." -END - -// Object clone error messages. Most of these have corresponding resources in mscorlib (see mscorlib.txt) -STRINGTABLE DISCARDABLE -BEGIN - IDS_SERIALIZATION_NONSERTYPE "Type '%1' in assembly '%2' is not marked as serializable." - IDS_SERIALIZATION_CTOR_NOT_FOUND "The constructor to deserialize an object of type '%1' was not found." - IDS_SERIALIZATION_WRONGFIELDTYPE "Possible version mismatch. Field '%1' in class '%2' has mismatched types." - IDS_SERIALIZATION_UNRESOLVED_SPECIAL_OBJECT "Not all delayed fixup objects could be resolved. Such objects could be cyclic IObjectReferences, IObjectReferences that return other IObjectReferences too many times (i.e. objects with too long an IObjectReference chain) or nested valuetypes." - IDS_SERIALIZATION_UNRESOLVED_TYPE "Type is not resolved for member '%1,%2'." - IDS_SERIALIZATION_NONFREEZABLE_TYPE "Type '%1' in assembly '%2' cannot be persisted into the native image." - IDS_SERIALIZATION_BAD_ISER_TYPE "ISerializable type '%1' tried to deserialize itself as type '%2' which is an invalid type." - IDS_REMOTING_SERVER_DISCONNECTED "Object '%1' has been disconnected or does not exist at the server." - IDS_REMOTING_METHODMISSING "The method '%1' was not found on type '%2'." - IDS_CLASSLOAD_TOO_MANY_VTS_METHODS "Type '%1' in assembly '%2' has more than one method with the following custom attribute '%3'." - IDS_CLASSLOAD_INVALID_VTS_SIG "Type '%1' in assembly '%2' has method '%3' with an incorrect signature for the serialization attribute that it is decorated with." - IDS_CLASSLOAD_INVALID_VTS_METHOD "Type '%1' in assembly '%2' has method '%3' which is either static, virtual, abstract or generic, but is marked as being a serialization callback method." - IDS_SERIALIZATION_MISSING_FIELD "Member '%1' in class '%2' is not present in the serialized stream and is not marked with System.Runtime.Serialization.OptionalFieldAttribute." END // General prompt strings. STRINGTABLE DISCARDABLE BEGIN - IDS_GENERAL_SVC_DESCRIPTION "Notifies a subscribing client when a specified process is initializing the CLR. If this service is stopped, the client will not receive such notification. If this service is disabled, any services that explicitly depend on it will fail to start." IDS_RTL "RTL_False" // change this to RTL_True on Arabic/Hebrew system END // BAD_FORMAT_ASSERT error messages STRINGTABLE DISCARDABLE BEGIN - BFA_INVALID_FILE_TOKEN "Invalid file token." BFA_INVALID_TOKEN_TYPE "Invalid token type." - BFA_INVALID_ENTRYPOINT_TOKEN "Invalid entry point token." BFA_INVALID_TOKEN "Invalid token." - BFA_INVALID_TOKEN_VTABLE "Invalid token in v-table fix-up table; use ildasm to find code generation error." BFA_UNABLE_TO_GET_NESTED_PROPS "Unable to get nested type properties." BFA_METHOD_TOKEN_OUT_OF_RANGE "Method token out of range." BFA_METHOD_NAME_TOO_LONG "Method name too long." - BFA_METHOD_NAME_NOT_TERMINATED "Method name is not null terminated." BFA_METHOD_IN_A_ENUM "Method in an Enum." BFA_METHOD_WITH_NONZERO_RVA "Method with non-zero RVA in an Import." BFA_ABSTRACT_METHOD_WITH_RVA "Abstract method with non-zero RVA." @@ -1945,7 +1058,6 @@ BEGIN BFA_INSTANCE_FIELD_IN_INT "Instance Field in an Interface." BFA_INSTANCE_FIELD_IN_ENUM "No Instance Field in an Enum." BFA_NONVIRT_NO_SEARCH "Non-virtual methods should not be searched." - BFA_CANT_BE_INIT_METHOD "This method cannot be an Init Method." BFA_MANAGED_NATIVE_NYI "Managed native not presently supported." BFA_BAD_IMPL_FLAGS "Bad implementation flags." BFA_BAD_UNMANAGED_ENTRY_POINT "Bad unmanaged code entry point." @@ -1957,7 +1069,6 @@ BEGIN BFA_MISSING_DELEGATE_METHOD "Missing definition for required runtime implemented delegate method." BFA_MULT_TYPE_SAME_NAME "Duplicate type with name '%1' in assembly '%2'." BFA_INVALID_METHOD_TOKEN "Bad method token." - BFA_CANT_GET_LINKREF "Cannot get LinkRef." BFA_ECALLS_MUST_BE_IN_SYS_MOD "ECall methods must be packaged into a system module." BFA_CANT_GET_CLASSLAYOUT "Could not get classlayout." BFA_CALLCONV_NOT_LOCAL_SIG "Signature is not IMAGE_CEE_CS_CALLCONV_LOCAL_SIG." @@ -1965,7 +1076,6 @@ BEGIN BFA_BAD_IL_RANGE "Bad IL range." BFA_METHODDEF_WO_TYPEDEF_PARENT "MethodDef without TypeDef as Parent." BFA_METHODDEF_PARENT_NO_MEMBERS "MethodSpec or MemberRef has parent with no members." - BFA_MUST_USE_MEMBERREF_W_FIELD_GEN "Fields inside generic classes must be referenced using MemberRefs, even in the same module as the class." BFA_INVALID_TOKEN_IN_MANIFESTRES "Invalid token saved in ManifestResource." BFA_EMPTY_ASSEMDEF_NAME "Empty assembly simple name." BFA_BAD_IL "Bad IL format." @@ -1980,13 +1090,10 @@ BEGIN BFA_BAD_CLASS_INT_CA "The ClassInterface custom attribute is invalid." BFA_BAD_CLASS_INT_CA_FORMAT "ClassInterface custom attribute does not have the right format." BFA_BAD_COMPLUS_SIG "Illegal or unimplemented ELEM_TYPE in signature." - BFA_TYPE_FWD_CHAIN_TOO_LONG "Type forwarding chain is too long or is recursive." BFA_BAD_ELEM_IN_SIZEOF "Bad element type in SizeOf." BFA_BAD_CA_HEADER "Malformed custom attribute header." - BFA_BAD_CA_STRING "Malformed custom attribute string." BFA_BAD_STRING_TOKEN "Bad string token." BFA_BAD_STRING_TOKEN_RANGE "No string associated with token." - BFA_FIXUP_WRONG_PLATFORM "Image has a platform-specific fixup type that is not compatible with this platform." BFA_UNEXPECTED_GENERIC_TOKENTYPE "Token specifying generic type must be either a typeref or typedef." BFA_MDARRAY_BADRANK "Array rank may not be zero." BFA_SDARRAY_BADRANK "Single-dimensional array rank must be one." @@ -1997,14 +1104,11 @@ BEGIN BFA_NOFIND_EXPORTED_TYPE "Could not find exported type in metadata." BFA_NOT_AN_ARRAY "Expected array type." BFA_EXPECTED_METHODDEF_OR_MEMBERREF "Generic member ref must be of type MethodDef or MemberRef." - BFA_EXPECTED_INTERFACE "Expected interface." - BFA_INVALID_CA_TYPESPEC "Custom attributes that are TypeSpecs must be of type ELEMENT_TYPE_VALUETYPE or ELEMENT_TYPE_CLASS." BFA_UNEXPECTED_FIELD_SIGNATURE "An unexpected field signature was found." BFA_UNEXPECTED_TOKEN_AFTER_CLASSVALTYPE "A valid typedef or typeref token is expected to follow a ELEMENT_TYPE_CLASS or ELEMENT_TYPE_VALUETYPE." BFA_FNPTR_CANNOT_BE_A_FIELD "A ELEMENT_TYPE_FNPTR cannot have a field signature." BFA_FNPTR_CANNOT_BE_GENERIC "A ELEMENT_TYPE_FNPTR cannot be generic." BFA_UNEXPECTED_TOKEN_AFTER_GENINST "A valid typedef or typeref token is expected to follow a ELEMENT_TYPE_GENERICINST." - BFA_ONLY_VOID_PTR_IN_ARGS "Only pointer to void allowed in function arguments." BFA_TYPEDBYREFCANNOTHAVEBYREF "An ELEMENT_TYPE_TYPEDBYREF cannot have a ELEMENT_TYPE_BYREF modifier." BFA_REFERENCE_ASSEMBLY "Cannot load a reference assembly for execution." @@ -2048,13 +1152,7 @@ BEGIN IDS_E_PROF_TIMEOUT_WAITING_FOR_CONCURRENT_GC "Profiler timed out on waiting for concurrent GC to finish after '%d' milliseconds. Please configure your profiler to increase its attaching time out value or consult the documentation for the COMPlus_ProfAPI_AttachProfilerMinTimeoutInMs environment variable and try again. Profiler CLSID: '%s'." END -// Dialog box buttons -STRINGTABLE DISCARDABLE -BEGIN - IDS_DIALOG_BOX_ABORT_BUTTON "&Abort" - IDS_DIALOG_BOX_DEBUG_BUTTON "&Debug" - IDS_DIALOG_BOX_IGNORE_BUTTON "&Ignore" -END + STRINGTABLE DISCARDABLE diff --git a/src/dlls/mscorrc/resource.h b/src/dlls/mscorrc/resource.h index 49f1d0e69d19..3fc71bf6f10d 100644 --- a/src/dlls/mscorrc/resource.h +++ b/src/dlls/mscorrc/resource.h @@ -81,7 +81,6 @@ #define MDARC_LOADER_LOCK_DLL 0x193A #define MDARC_JIT_ATTACH 0x193B -#define IDS_GENERAL_SVC_DESCRIPTION 0x01F4 #define IDS_RTL 0x01F5 #define IDS_DS_ACTIVESESSIONS 0x1701 @@ -101,50 +100,27 @@ #define IDS_EE_NOSYNCHRONIZED 0x170f #define IDS_EE_NDIRECT_BADNATL_THISCALL 0x1710 -#define IDS_EE_LOAD_NO_MAIN 0x1711 #define IDS_EE_LOAD_BAD_MAIN_SIG 0x1712 #define IDS_EE_COM_UNSUPPORTED_TYPE 0x1713 -#define IDS_EE_COM_UNSUPPORTED_VT_RECORD 0x1714 -#define IDS_EE_LOAD_UNEXPECTED 0x1715 -#define IDS_EE_AMBIGUOUSINVOKE 0x1716 -#define IDS_EE_CALLBACK_UNSUPPORTED_SIG 0x1717 -#define IDS_EE_NOTADELEGATE 0x1718 #define IDS_EE_NOTNDIRECT 0x1719 #define IDS_EE_TWO_LOADED_MSCOREE_TITLE 0x171a #define IDS_EE_TWO_LOADED_MSCOREE_MSG 0x171b -#define IDS_EE_CUST_MARSHALER_ON_INVALID_TYPE 0x171c #define IDS_EE_RETHROW_NOT_ALLOWED 0x171d #define IDS_EE_INVALID_OLE_VARIANT 0x171e #define IDS_EE_ADUNLOAD_DEFAULT 0x171f #define IDS_EE_FILE_NOT_FOUND 0x80070002 -#define IDS_EE_TOO_MANY_OPEN_FILES 0x80070004 -#define IDS_EE_SHARING_VIOLATION 0x80070020 -#define IDS_EE_LOCK_VIOLATION 0x80070021 -#define IDS_EE_OPEN_FAILED 0x8007006D #define IDS_EE_PATH_TOO_LONG 0x8007006F -#define IDS_EE_DISK_FULL 0x80070070 -#define IDS_EE_INVALID_NAME 0x8007007B #define IDS_EE_PROC_NOT_FOUND 0x8007007F #define IDS_EE_ALREADY_EXISTS 0x800700B7 -#define IDS_EE_UNRECOGNIZED_VOLUME 0x800703ED -#define IDS_EE_FILE_INVALID 0x800703EE -#define IDS_EE_DLL_INIT_FAILED 0x8007045A #define IDS_EE_BAD_USER_PROFILE 0x800704E5 -#define IDS_EE_FILE_CORRUPT 0x80070570 -#define IDS_EE_DISK_CORRUPT 0x80070571 #define IDS_INET_E_CANNOT_CONNECT 0x1799 // 0x800C0004 #define IDS_INET_E_RESOURCE_NOT_FOUND 0x1a60 // 0x800C0005 -#define IDS_INET_E_OBJECT_NOT_FOUND 0x800C0006 -#define IDS_INET_E_DATA_NOT_AVAILABLE 0x800C0007 -#define IDS_INET_E_DOWNLOAD_FAILURE 0x800C0008 #define IDS_INET_E_CONNECTION_TIMEOUT 0x1a1e // 0x800C000B -#define IDS_INET_E_UNKNOWN_PROTOCOL 0x800C000D #define IDS_INET_E_SECURITY_PROBLEM 0x800C000E -#define IDS_EE_FAILED_TO_LOAD 0x1720 #define IDS_EE_TO_MANY_ARGUMENTS_IN_MAIN 0x1721 #define IDS_EE_FAILED_TO_FIND_MAIN 0x1722 #define IDS_EE_ILLEGAL_TOKEN_FOR_MAIN 0x1723 @@ -197,13 +173,9 @@ #define IDS_EE_BADMARSHAL_PTRNONBLITTABLE 0x175c #define IDS_EE_BADMARSHAL_RESTRICTION 0x175d -#define IDS_EE_BADMARSHAL_CHARARRAYRESTRICTION 0x175e #define IDS_EE_BADMARSHAL_ASANYRESTRICTION 0x175f #define IDS_EE_BADMARSHAL_VBBYVALSTRRESTRICTION 0x1760 #define IDS_EE_BADMARSHAL_AWORESTRICTION 0x1761 -#define IDS_EE_BADMARSHAL_BVCRESTRICTION 0x1762 -#define IDS_EE_BADMARSHAL_COPYCTORRESTRICTION 0x1763 -#define IDS_EE_BADMARSHAL_VCRESTRICTION 0x1764 #define IDS_EE_BADMARSHAL_ARGITERATORRESTRICTION 0x1765 #define IDS_EE_BADMARSHAL_HANDLEREFRESTRICTION 0x1766 @@ -211,23 +183,13 @@ #define IDS_EE_ADUNLOAD_IN_FINALIZER 0x1768 #define IDS_EE_ADUNLOAD_CANT_UNWIND_THREAD 0x1769 -#define IDS_STREAMS_FILE_EOF 0x176a -#define IDS_STREAMS_FILE_OPEN 0x176b -#define IDS_STREAMS_FILE_BUFFER 0x176c -#define IDS_STREAMS_FILE_NAME 0x176d -#define IDS_STREAMS_SEEK_MODIFIER 0x176e - - #define IDS_CANNOT_MARSHAL 0x1770 -#define IDS_PINVOKE_STRINGBUILDEROVERFLOW 0x1771 #define IDS_EE_HASH_VAL_FAILED 0x1772 #define IDS_CLASSLOAD_GENERAL 0x80131522 -#define IDS_CLASSLOAD_MODULELOAD 0x1773 #define IDS_CLASSLOAD_BADFORMAT 0x1774 #define IDS_CLASSLOAD_CANTCREATEARRAYCLASS 0x1775 -#define IDS_CLASSLOAD_NOCLSIDREG 0x1776 #define IDS_CLASSLOAD_MISSINGMETHOD 0x1777 #define IDS_CLASSLOAD_STATICVIRTUAL 0x1778 #define IDS_CLASSLOAD_REDUCEACCESS 0x1779 @@ -241,24 +203,18 @@ #define IDS_CLASSLOAD_NOTINTERFACE 0x1781 #define IDS_CLASSLOAD_VALUEINSTANCEFIELD 0x1782 #define IDS_CLASSLOAD_EXPLICIT_GENERIC 0x1783 -#define IDS_CLASSLOAD_BAD_NAME 0x1784 #define IDS_CLASSLOAD_RANK_TOOLARGE 0x1785 -#define IDS_CLASSLOAD_BAD_MANAGED_RVA 0x1786 #define IDS_CLASSLOAD_BAD_UNMANAGED_RVA 0x1787 -#define IDS_CLASSLOAD_INHERITANCECHECK 0x1788 #define IDS_CLASSLOAD_ENCLOSING 0x1789 #define IDS_CLASSLOAD_EXPLICIT_LAYOUT 0x178a #define IDS_CLASSLOAD_SEALEDPARENT 0x178b #define IDS_CLASSLOAD_NOMETHOD_NAME 0x178c -#define IDS_CLASSLOAD_PRIVATEVIRTUAL 0x178d #define IDS_CLASSLOAD_BADSPECIALMETHOD 0x178e #define IDS_CLASSLOAD_MI_DECLARATIONNOTFOUND 0x178f #define IDS_CLASSLOAD_MI_MULTIPLEOVERRIDES 0x1790 #define IDS_CLASSLOAD_MI_ACCESS_FAILURE 0x1791 -#define IDS_CLASSLOAD_MI_OVERRIDEIMPL 0x1792 #define IDS_CLASSLOAD_MI_BADSIGNATURE 0x1793 #define IDS_CLASSLOAD_MI_NOTIMPLEMENTED 0x1794 -#define IDS_CLASSLOAD_MI_VIRTUALMISMATCH 0x1795 #define IDS_CLASSLOAD_MI_MUSTBEVIRTUAL 0x1796 #define IDS_CLASSLOAD_MISSINGMETHODRVA 0x1797 #define IDS_CLASSLOAD_FIELDTOOLARGE 0x1798 @@ -267,7 +223,6 @@ #define IDS_CLASSLOAD_TYPESPEC 0x179c #define IDS_CLASSLOAD_BAD_FIELD 0x179d #define IDS_CLASSLOAD_MI_ILLEGAL_BODY 0x179e -#define IDS_CLASSLOAD_MI_ILLEGAL_STATIC 0x179f #define IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_BODY 0x17a0 #define IDS_CLASSLOAD_MI_ILLEGAL_TOKEN_DECL 0x17a1 #define IDS_CLASSLOAD_MI_SEALED_DECL 0x17a2 @@ -276,26 +231,17 @@ #define IDS_CLASSLOAD_MI_BODY_DECL_MISMATCH 0x17a5 #define IDS_CLASSLOAD_MI_MISSING_SIG_BODY 0x17a6 #define IDS_CLASSLOAD_MI_MISSING_SIG_DECL 0x17a7 -#define IDS_CLASSLOAD_ASSEMBLYLOAD 0x17a8 -#define IDS_CLASSLOAD_UNVERIFIABLE_FIELD_LAYOUT 0x17a9 -#define IDS_FAIL_CAPTION 0x17aa #define IDS_CLASSLOAD_TOOMANYGENERICARGS 0x17ab #define IDS_CLASSLOAD_COLLECTIBLEPINVOKE 0x17ac #define IDS_CLASSLOAD_COLLECTIBLESPECIALSTATICS 0x17ad #define IDS_COMPLUS_ERROR 0x17ae #define IDS_FATAL_ERROR 0x17af #define IDS_ERROR 0x17b0 -#define IDS_INVALID_VARIANT_MSG 0x17b1 -#define IDS_INVALID_VARIANT_CAPTION 0x17b2 -#define IDS_DEBUG_DIFF_BUILDS_ERR 0x17b3 #define IDS_DEBUG_SERVICE_CAPTION 0x17b4 -#define IDS_DEBUG_NO_DEBUGGER_FOUND 0x17b5 #define IDS_DEBUG_USERBREAKPOINT 0x17b6 #define IDS_DEBUG_UNHANDLEDEXCEPTION 0x17b7 #define IDS_DEBUG_UNHANDLEDEXCEPTION_IPC 0x17b8 -#define IDS_PERFORMANCEMON_WINNT_ERR 0x17b9 -#define IDS_PERFORMANCEMON_WINNT_TITLE 0x17ba #define IDS_PERFORMANCEMON_FUNCNOTFOUND 0x17bb #define IDS_PERFORMANCEMON_FUNCNOTFOUND_TITLE 0x17bc #define IDS_PERFORMANCEMON_PSAPINOTFOUND 0x17bd @@ -304,22 +250,15 @@ #define IDS_DEBUG_UNHANDLED_EXCEPTION_MSG 0x17c0 #define IDS_DEBUG_USER_BREAKPOINT_MSG 0x17c1 -#define IDS_EE_ADUNLOAD_NOT_LOCAL 0x17c2 - #define IDS_INVALID_REDIM 0x17c3 #define IDS_INVALID_PINVOKE_CALLCONV 0x17c4 #define IDS_NOLAYOUT_IN_EMBEDDED_VALUECLASS 0x17c5 #define IDS_CLASSLOAD_NSTRUCT_EXPLICIT_OFFSET 0x17c7 -#define IDS_UNI2ANSI_FAILURE_IN_NSTRUCT 0x17c8 #define IDS_EE_BADPINVOKEFIELD_NOTMARSHALABLE 0x17c9 #define IDS_WRONGSIZEARRAY_IN_NSTRUCT 0x17ca -#define IDS_UNI2ANSI_FAILURE 0x17cb -#define IDS_ANSI2UNI_FAILURE 0x17cc #define IDS_EE_INVALIDLCIDPARAM 0x17cd #define IDS_EE_BADMARSHAL_NESTEDARRAY 0x17ce -#define IDS_ENCODEDPERMSET_DECODEFAILURE 0x17cf -#define IDS_BAD_MSCORLIB 0x17d0 #define IDS_EE_INVALIDCOMSOURCEITF 0x17d1 #define IDS_EE_CANNOT_COERCE_BYREF_VARIANT 0x17d2 #define IDS_EE_WRAPPER_MUST_HAVE_DEF_CONS 0x17d3 @@ -335,11 +274,8 @@ #define IDS_EE_CANNOTCAST 0x17e0 #define IDS_EE_NOTISOMORPHIC 0x17e1 -#define IDS_EE_OFFSETOF_NOFIELDFOUND 0x17e2 #define IDS_EE_COPY_OUTOFRANGE 0x17e3 -#define IDS_EE_CANNOTPIN 0x17e4 #define IDS_EE_ARRAYWITHOFFSETOVERFLOW 0x17e5 -#define IDS_EE_OUTOFLOCALS 0x17e6 #define IDS_EE_NOCUSTOMMARSHALER 0x17e7 #define IDS_EE_SIZECONTROLOUTOFRANGE 0x17e8 #define IDS_EE_SIZECONTROLBADTYPE 0x17e9 @@ -348,31 +284,22 @@ #define IDS_EE_INVALID_VT_FOR_CUSTOM_MARHALER 0x17ec #define IDS_EE_BAD_COMEXTENDS_CLASS 0x17ed -#define IDS_EE_METADATA_ERROR 0x17ee #define IDS_EE_ERRORTITLE 0x17f0 #define IDS_EE_ERRORMESSAGETEMPLATE 0x17f1 -#define IDS_EE_ERRORMESSAGETEXTTEMPLATE 0x17f2 - -#define IDS_EE_CRYPTO_UNKNOWN_OPERATION 0x17f4 #define IDS_EE_LOCAL_COGETCLASSOBJECT_FAILED 0x17f5 -#define SN_NO_SUITABLE_CSP_NAME 0x17f6 #define IDS_EE_MISSING_FIELD 0x17f7 #define IDS_EE_MISSING_METHOD 0x17f8 #define IDS_EE_INTERFACE_NOT_DISPATCH_BASED 0x17f9 -#define IDS_EE_MSCOREE_MISSING 0x17fa -#define IDS_EE_MSCOREE_MISSING_ENTRYPOINT 0x17fb - #define IDS_EE_UNHANDLED_EXCEPTION 0x17fc #define IDS_EE_EXCEPTION_TOSTRING_FAILED 0x17fd #define IDS_CLASSLOAD_EQUIVALENTSTRUCTMETHODS 0x17fe #define IDS_CLASSLOAD_EQUIVALENTSTRUCTFIELDS 0x17ff -#define IDS_EE_PINVOKE_NOREFFORSIZEIS 0x1a01 #define IDS_EE_NO_IDISPATCH 0x1a02 @@ -386,7 +313,6 @@ #define IDS_EE_NO_BACKING_CLASS_FACTORY 0x1a0b #define IDS_EE_NAME_UNKNOWN_UNQ 0x1a0c #define IDS_EE_STRING_TOOLONG 0x1a0d -#define IDS_CLASSLOAD_MI_PRIVATE_DECL 0x1a0e #define IDS_EE_VARARG_NOT_SUPPORTED 0x1a0f #define IDS_EE_INVALID_CA 0x1a10 @@ -394,12 +320,8 @@ #define IDS_EE_THREADSTART_STATE 0x1a12 -#define IDS_EE_CANNOTCASTPROXY 0x1a13 #define IDS_EE_THREAD_DEADLOCK_VICTIM 0x1a14 #define IDS_EE_THREAD_CANNOT_GET 0x1a15 -#define IDS_EE_THREAD_SUSPEND_NON_RUNNING 0x1a16 -#define IDS_EE_THREAD_RESUME_NON_RUNNING 0x1a17 -#define IDS_EE_THREAD_RESUME_NON_USER_SUSPEND 0x1a18 #define IDS_EE_THREAD_DEAD_PRIORITY 0x1a19 #define IDS_EE_THREAD_DEAD_STATE 0x1a1a #define IDS_EE_THREAD_BAD_STATE 0x1a1b @@ -407,30 +329,14 @@ #define IDS_EE_NOVARIANTRETURN 0x1a1d -#define IDS_EE_PATH_HAS_IMPROPER_CHAR 0x1a1f -#define IDS_EE_PATH_ILLEGAL 0x1a20 - -#define IDS_CLASSLOAD_BADOVERLAP 0x1a21 - -#define IDS_EE_SID_TIMEOUT 0x1a22 - #define IDS_EE_INVALID_SAFEARRAY 0x1a23 #define IDS_EE_METHOD_NOT_FOUND_ON_EV_PROV 0x1a24 #define IDS_EE_BAD_COMEVENTITF_CLASS 0x1a25 -#define IDS_EE_INVALID_STRONGNAME 0x1a26 -#define IDS_EE_INVALID_STRONGNAME_TITLE 0x1a27 - -#define IDS_EE_INVALID_DELEGATE_LAYOUT 0x1a28 - -#define IDS_EE_COREXEMAIN_FAILED_TITLE 0x1a29 -#define IDS_EE_COREXEMAIN_FAILED_TEXT 0x1a2a #define IDS_EE_COREXEMAIN2_FAILED_TITLE 0x1a2b #define IDS_EE_COREXEMAIN2_FAILED_TEXT 0x1a2c -#define IDS_EE_PATH_INVALID_UNCPATH 0x1a2d - #define IDS_EE_ICUSTOMMARSHALERNOTIMPL 0x1a2e #define IDS_EE_GETINSTANCENOTIMPL 0x1a2f @@ -456,43 +362,23 @@ #define IDS_EE_SH_FIELD_INVALID_OPERATION 0x1a41 #define IDS_EE_CANNOT_CREATE_SAFEHANDLE_FIELD 0x1a42 -#define IDS_ENCODEDPERMSETCOLLECTION_DECODEFAILURE 0x1a43 - #define IDS_EE_BADMARSHAL_ABSTRACTRETSAFEHANDLE 0x1a44 #define IDS_EE_SH_IN_VARIANT_NOT_SUPPORTED 0x1a47 -#define IDS_CLASSLOAD_SH_SUBCLASS_FINALIZER 0x1a45 #define IDS_EE_BADMARSHAL_SYSARRAY 0x1a48 #define IDS_EE_VAR_WRAP_IN_VAR_NOT_SUPPORTED 0x1a49 #define IDS_EE_RECORD_NON_SUPPORTED_FIELDS 0x1a4a #define IDS_CLASSLOAD_TYPEWRONGNUMGENERICARGS 0x1a4b -#define IDS_CLASSLOAD_METHODWRONGNUMGENERICARGS 0x1a4c #define IDS_CLASSLOAD_NSTRUCT_NEGATIVE_OFFSET 0x1a4d #define IDS_EE_THREAD_PRIORITY_FAIL 0x1a4e -#define IDS_SERIALIZATION_NONSERTYPE 0x1a4f -#define IDS_SERIALIZATION_CTOR_NOT_FOUND 0x1a50 -#define IDS_SERIALIZATION_MISSING_FIELD 0x1a51 -#define IDS_SERIALIZATION_WRONGFIELDTYPE 0x1a52 -#define IDS_SERIALIZATION_UNRESOLVED_SPECIAL_OBJECT 0x1a53 -#define IDS_SERIALIZATION_UNRESOLVED_TYPE 0x1a54 - -#define IDS_REMOTING_SERVER_DISCONNECTED 0x1a55 -#define IDS_REMOTING_METHODMISSING 0x1a56 - -#define IDS_EE_PATH_GLOBALROOT 0x1a58 #define IDS_CLASSLOAD_INVALIDINSTANTIATION 0x1a59 #define IDS_EE_CLASSLOAD_INVALIDINSTANTIATION 0x1a59 #define IDS_EE_BADMARSHALFIELD_ZEROLENGTHFIXEDSTRING 0x1a5a -#define IDS_VER_E_FORMATTING 0x1a5b -#define IDS_VER_E_ILERROR 0x1a5c -#define IDS_VER_E_GLOBAL 0x1a5d -#define IDS_VER_E_MDTOKEN 0x1a5e - #define IDS_EE_CODEEXECUTION_IN_INTROSPECTIVE_ASSEMBLY 0x1a61 #define IDS_EE_BADMARSHAL_CRITICALHANDLENATIVETOCOM 0x1a62 @@ -500,13 +386,10 @@ #define IDS_EE_BADMARSHAL_RETURNCHCOMTONATIVE 0x1a64 #define IDS_EE_BADMARSHAL_CRITICALHANDLE 0x1a65 -#define IDS_EE_CRITICALHANDLECLOSED 0x1a67 -#define IDS_EE_CH_FIELD_INVALID_OPERATION 0x1a68 #define IDS_EE_CANNOT_CREATE_CRITICALHANDLE_FIELD 0x1a69 #define IDS_EE_BADMARSHAL_ABSTRACTRETCRITICALHANDLE 0x1a6a #define IDS_EE_CH_IN_VARIANT_NOT_SUPPORTED 0x1a6b -#define IDS_CLASSLOAD_CH_SUBCLASS_FINALIZER 0x1a6c #define IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_INTROSPECTION 0x1a6d #define IDS_CLASSLOAD_ASSEMBLY_RESOLVE_RETURNED_EXECUTION 0x1a6e @@ -517,14 +400,9 @@ #define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_PARENT_METHOD_IMPL 0x1a72 #define IDS_CLASSLOAD_CONSTRAINT_MISMATCH_ON_INTERFACE_METHOD_IMPL 0x1a73 -#define IDS_EE_LOAD_CIRCULAR_DEPENDENCY 0x1a74 - #define IDS_EE_NDIRECT_BADNATL_VARARGS_CALLCONV 0x1a75 -#define IDS_SERIALIZATION_NONFREEZABLE_TYPE 0x1a76 #define IDS_EE_REFLECTIONONLYGETTYPE_NOASSEMBLY 0x1a77 -#define IDS_CLASSLOAD_MODULE_RESOLVE_INTROSPECTION_MISMATCH 0x1a78 - #define IDS_CLASSLOAD_VARIANCE_IN_METHOD_ARG 0x1a79 #define IDS_CLASSLOAD_VARIANCE_IN_METHOD_RESULT 0x1a7a #define IDS_CLASSLOAD_VARIANCE_IN_BASE 0x1a7b @@ -535,12 +413,8 @@ #define IDS_CLASSLOAD_OVERLAPPING_INTERFACES 0x1a80 #define IDS_CLASSLOAD_32BITCLRLOADING64BITASSEMBLY 0x1a81 -#define IDS_EE_CONFIGPARSER_ERROR_CAPTION 0x1a82 -#define IDS_EE_CONFIGPARSER_ERROR 0x1a83 #define IDS_EE_ASSEMBLY_GETTYPE_CANNONT_HAVE_ASSEMBLY_SPEC 0x1a84 -#define IDS_EE_IJWLOAD_CROSSVERSION_DISALLOWED 0x1a85 - #define IDS_EE_CANNOT_HAVE_ASSEMBLY_SPEC 0x1a86 #define IDS_EE_NEEDS_ASSEMBLY_SPEC 0x1a87 @@ -553,11 +427,8 @@ #define IDS_EE_BADMARSHAL_DECIMALARRAY 0x1a8d #define IDS_EE_BADMARSHAL_SAFEHANDLEARRAY 0x1a8f #define IDS_EE_BADMARSHAL_CRITICALHANDLEARRAY 0x1a90 -#define IDS_EE_BADMARSHAL_BADSAFEARRAYSUBTYPE 0x1a91 #define IDS_EE_BADMARSHALFIELD_ERROR_MSG 0x1a92 #define IDS_EE_BADMARSHAL_ERROR_MSG 0x1a93 -#define IDS_SERIALIZATION_BAD_ISER_TYPE 0x1a94 -#define IDS_EE_REFLECTIONONLY_LOADFROM 0x1a95 #define IDS_EE_REFLECTIONONLY_LOADFAILURE 0x1a96 #define IDS_EE_COM_INVISIBLE_PARENT 0x1a97 @@ -580,50 +451,35 @@ #define IDS_EE_THREAD_INTERRUPTED 0x1aa5 #define IDS_EE_OUT_OF_MEMORY 0x1aa6 -#define IDS_EE_CANNOT_LOAD_JIT 0x1aa7 #define IDS_EE_PROFILING_FAILURE 0x1aa8 #define IDS_EE_ATTEMPT_TO_CREATE_GENERIC_CCW 0x1aa9 -#define IDS_EE_IJWLOAD_MULTIRUNTIME_DISALLOWED 0x1aaa #define IDS_EE_COMIMPORT_METHOD_NO_INTERFACE 0x1aab #define IDS_EE_OUT_OF_MEMORY_WITHIN_RANGE 0x1aac #define IDS_EE_ARRAY_DIMENSIONS_EXCEEDED 0x1aad -#define IDS_WATSON_DEBUG_BREAK_INTRO_BOLD 0x1ab0 -#define IDS_WATSON_DEBUG_BREAK_INTRO_REG 0x1ab1 #define IDS_EE_CODEEXECUTION_ASSEMBLY_FOR_PASSIVE_DOMAIN_ONLY 0x1ab2 #define IDS_CLASSLOAD_MI_CANNOT_OVERRIDE 0x1ab3 -#define IDS_EE_WRONG_METADATA_VERSION 0x1ab4 #define IDS_CLASSLOAD_COLLECTIBLEFIXEDVTATTR 0x1ab6 #define IDS_CLASSLOAD_EQUIVALENTBADTYPE 0x1ab7 -#define IDS_CLASSLOAD_EQUIVALENTNOTTRUSTED 0x1ab8 -#define IDS_CLASSLOAD_EQUIVALENTNOTPUBLIC 0x1aba #define IDS_EE_CODEEXECUTION_CONTAINSGENERICVAR 0x1abb #define IDS_CLASSLOAD_WRONGCPU 0x1abc #define IDS_EE_CREATEINSTANCEFROMAPP_FAILED 0x1abd -#define IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE 0x1abe #define IDS_EE_WINRT_LOADFAILURE 0x1abf -#define IDS_EE_REFLECTIONONLY_WINRT_LOADFAILURE_THIRDPARTY 0x1ac0 -#define IDS_EE_REFLECTIONONLY_WINRT_INVALIDASSEMBLY 0x1ac1 #define IDS_EE_WINRT_THIRDPARTY_NOTSUPPORTED 0x1ac2 #define IDS_EE_SIMD_NGEN_DISALLOWED 0x1ac3 -#define IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED 0x1ac4 #define IDS_IBC_MISSING_EXTERNAL_TYPE 0x1ac5 #define IDS_IBC_MISSING_EXTERNAL_METHOD 0x1ac6 #define IDS_EE_HWINTRINSIC_NGEN_DISALLOWED 0x1ac7 #define IDS_CLASSLOAD_MI_FINAL_IMPL 0x1ac8 #define IDS_CLASSLOAD_AMBIGUOUS_OVERRIDE 0x1ac9 -#define BFA_INVALID_FILE_TOKEN 0x2000 #define BFA_INVALID_TOKEN_TYPE 0x2001 -#define BFA_INVALID_ENTRYPOINT_TOKEN 0x2002 #define BFA_INVALID_TOKEN 0x2003 -#define BFA_INVALID_TOKEN_VTABLE 0x2004 #define BFA_UNABLE_TO_GET_NESTED_PROPS 0x2005 #define BFA_METHOD_TOKEN_OUT_OF_RANGE 0x2006 #define BFA_METHOD_NAME_TOO_LONG 0x2007 -#define BFA_METHOD_NAME_NOT_TERMINATED 0x2008 #define BFA_METHOD_IN_A_ENUM 0x2009 #define BFA_METHOD_WITH_NONZERO_RVA 0x200a #define BFA_ABSTRACT_METHOD_WITH_RVA 0x200b @@ -653,7 +509,6 @@ #define BFA_INSTANCE_FIELD_IN_INT 0x2023 #define BFA_INSTANCE_FIELD_IN_ENUM 0x2024 #define BFA_NONVIRT_NO_SEARCH 0x2025 -#define BFA_CANT_BE_INIT_METHOD 0x2026 #define BFA_MANAGED_NATIVE_NYI 0x2027 #define BFA_BAD_IMPL_FLAGS 0x2028 #define BFA_BAD_UNMANAGED_ENTRY_POINT 0x2029 @@ -665,7 +520,6 @@ #define BFA_MISSING_DELEGATE_METHOD 0x2030 #define BFA_MULT_TYPE_SAME_NAME 0x2031 #define BFA_INVALID_METHOD_TOKEN 0x2032 -#define BFA_CANT_GET_LINKREF 0x2033 #define BFA_ECALLS_MUST_BE_IN_SYS_MOD 0x2034 #define BFA_CANT_GET_CLASSLAYOUT 0x2035 #define BFA_CALLCONV_NOT_LOCAL_SIG 0x2036 @@ -673,7 +527,6 @@ #define BFA_BAD_IL_RANGE 0x2038 #define BFA_METHODDEF_WO_TYPEDEF_PARENT 0x2039 #define BFA_METHODDEF_PARENT_NO_MEMBERS 0x203a -#define BFA_MUST_USE_MEMBERREF_W_FIELD_GEN 0x203b #define BFA_INVALID_TOKEN_IN_MANIFESTRES 0x203c #define BFA_EMPTY_ASSEMDEF_NAME 0x203d #define BFA_BAD_IL 0x203e @@ -690,16 +543,11 @@ #define BFA_BAD_COMPLUS_SIG 0x2049 #define BFA_BAD_ELEM_IN_SIZEOF 0x204b -#define IDS_CLASSLOAD_TOO_MANY_VTS_METHODS 0x204c -#define IDS_CLASSLOAD_INVALID_VTS_SIG 0x204d -#define IDS_EE_VTRECORD_SECURITY 0x204e #define IDS_CLASSLOAD_INTERFACE_NO_ACCESS 0x204f #define BFA_BAD_CA_HEADER 0x2050 -#define BFA_BAD_CA_STRING 0x2051 #define BFA_BAD_STRING_TOKEN 0x2052 #define BFA_BAD_STRING_TOKEN_RANGE 0x2053 -#define BFA_FIXUP_WRONG_PLATFORM 0x2054 #define BFA_UNEXPECTED_GENERIC_TOKENTYPE 0x2055 #define BFA_MDARRAY_BADRANK 0x2056 #define BFA_SDARRAY_BADRANK 0x2057 @@ -710,7 +558,6 @@ #define BFA_NOFIND_EXPORTED_TYPE 0x205c #define BFA_NOT_AN_ARRAY 0x205d #define BFA_EXPECTED_METHODDEF_OR_MEMBERREF 0x205e -#define BFA_EXPECTED_INTERFACE 0x205f #define IDS_CLASSLOAD_BAD_METHOD_COUNT 0x2062 #define IDS_CLASSLOAD_BAD_FIELD_COUNT 0x2063 @@ -718,38 +565,26 @@ #define IDS_CLASSLOAD_BAD_VARIANCE_SIG 0x2065 #define IDS_CLASSLOAD_VARIANCE_IN_DELEGATE 0x2066 -#define BFA_INVALID_CA_TYPESPEC 0x2067 #define BFA_UNEXPECTED_FIELD_SIGNATURE 0x2068 #define BFA_UNEXPECTED_TOKEN_AFTER_CLASSVALTYPE 0x2069 #define BFA_FNPTR_CANNOT_BE_A_FIELD 0x206a #define BFA_FNPTR_CANNOT_BE_GENERIC 0x206b #define BFA_UNEXPECTED_TOKEN_AFTER_GENINST 0x206c -#define BFA_ONLY_VOID_PTR_IN_ARGS 0x206d #define BFA_TYPEDBYREFCANNOTHAVEBYREF 0x206e -#define IDS_CLASSLOAD_INVALID_VTS_METHOD 0x206f #define IDS_CLASSLOAD_MI_BAD_SIG 0x2070 -#define IDS_EE_TOOMANYASSOCIATES 0x2071 #define IDS_EE_TOOMANYFIELDS 0x2072 #define IDS_EE_NDIRECT_GETPROCADDRESS_NONAME 0x2073 -#define IDS_CLASSLOAD_GENERIC_CONTEXT_BOUND_OBJECT 0x2074 #define IDS_CLASSLOAD_CONTEXT_BOUND_GENERIC_METHOD 0x2075 #define IDS_EE_CLASS_CONSTRAINTS_VIOLATION 0x2076 #define IDS_EE_METHOD_CONSTRAINTS_VIOLATION 0x2077 #define IDS_CLASSLOAD_TOO_MANY_METHODS 0x2078 #define IDS_CLASSLOAD_ENUM_EXTRA_GENERIC_TYPE_PARAM 0x2079 -#define IDS_DBI_ERRLOG_CATAGORY 0x207A -#define IDS_DBI_EXCEPTION_ON_UNKNOWN_THREAD_MSG 0x207B - -#define IDS_EE_NOTSUPPORTED_CATCHBEFORETRY 0x207c #define IDS_CLASSLOAD_GENERICTYPE_RECURSIVE 0x207D -#define IDS_LOADINTROSPECTION_DISALLOWED 0x207E #define IDS_EE_JIT_COMPILER_ERROR 0x207F -#define IDS_UNMARSHALABLE_DEMAND_OBJECT 0x2080 -#define BFA_TYPE_FWD_CHAIN_TOO_LONG 0x2081 #define IDS_ER_APPLICATION 0x2082 #define IDS_ER_UNKNOWN 0x2083 @@ -775,8 +610,6 @@ #define IDS_EE_CANNOTCAST_HELPER_BYTE 0x209b #define IDS_EE_CANNOTCAST_HELPER_PATH 0x209c -#define IDS_CLASSLOAD_COLLECTIBLE_CONTEXT_BOUND_OBJECT 0x209d - // For ForwardInteropStubAttribute #ifdef FEATURE_COMINTEROP #define IDS_EE_INTEROP_STUB_CA_MUST_BE_WITHIN_SAME_ASSEMBLY 0x2107 @@ -830,10 +663,6 @@ #define IDS_EE_LINK_FOR_ERROR_MESSAGES 0x2600 #define IDS_EE_LINK_FOR_DEBUGGING_MESSAGES 0x2601 -#define IDS_DIALOG_BOX_ABORT_BUTTON 0x2602 -#define IDS_DIALOG_BOX_DEBUG_BUTTON 0x2603 -#define IDS_DIALOG_BOX_IGNORE_BUTTON 0x2604 - #ifdef FEATURE_COMINTEROP #define IDS_EE_BADMARSHALFIELD_NULL_HSTRING 0x2605 #define IDS_EE_BADMARSHAL_WINRT_MARSHAL_AS 0x2606 @@ -854,12 +683,10 @@ #define IDS_EE_WINRT_IID_ILLEGALTYPE 0x2619 #define IDS_EE_WINRT_IID_NODEFAULTINTERFACE 0x261A #define IDS_EE_WINRT_ATTRIBUTES_NOT_INVOKABLE 0x261B -#define IDS_EE_WINRT_TYPE_IN_ORDINARY_ASSEMBLY 0x261C #define IDS_EE_WINRT_TYPE_NOT_REGISTERED 0x261F #define IDS_EE_WINRT_NOT_FACTORY_FOR_TYPE 0x2620 #define IDS_EE_INVALIDARG_WINRT_INVALIDURI 0x2624 -#define IDS_EE_BADMARSHAL_WINRT_COPYCTOR 0x2625 #define IDS_EE_WINRT_INVALID_FACTORY_FOR_TYPE 0x2628 #define IDS_EE_CANNOTCAST_NOMARSHAL 0x2629 @@ -869,9 +696,6 @@ #endif // FEATURE_COMINTEROP -#define IDS_EE_TORNSTATE 0x2613 - - #ifdef FEATURE_COMINTEROP #define IDS_EE_WINRT_WEAKREF_BAD_TYPE 0x262e #endif // FEATURE_COMINTEROP diff --git a/src/gc/env/volatile.h b/src/gc/env/volatile.h index 782b6eff4177..311e12663f54 100644 --- a/src/gc/env/volatile.h +++ b/src/gc/env/volatile.h @@ -448,32 +448,6 @@ class VolatilePtr : public Volatile

} }; - -// -// Warning: workaround -// -// At the bottom of this file, we are going to #define the "volatile" keyword such that it is illegal -// to use it. Unfortunately, VC++ uses the volatile keyword in stddef.h, in the definition of "offsetof". -// GCC does not use volatile in its definition. -// -// To get around this, we include stddef.h here (even if we're on GCC, for consistency). We then need -// to redefine offsetof such that it does not use volatile, if we're building with VC++. -// -#include -#ifdef _MSC_VER -#undef offsetof -#ifdef _WIN64 -#define offsetof(s,m) (size_t)( (ptrdiff_t)&reinterpret_cast((((s *)0)->m)) ) -#else -#define offsetof(s,m) (size_t)&reinterpret_cast((((s *)0)->m)) -#endif //_WIN64 - -// These also use volatile, so we'll include them here. -//#include -//#include - -#endif //_MSC_VER - #define VOLATILE(T) Volatile #endif //_VOLATILE_H_ diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h index 40812d586078..58482b8c8922 100644 --- a/src/gc/gcinterface.h +++ b/src/gc/gcinterface.h @@ -7,7 +7,7 @@ // The major version of the GC/EE interface. Breaking changes to this interface // require bumps in the major version number. -#define GC_INTERFACE_MAJOR_VERSION 1 +#define GC_INTERFACE_MAJOR_VERSION 2 // The minor version of the GC/EE interface. Non-breaking changes are required // to bump the minor version number. GCs and EEs with minor version number diff --git a/src/gc/objecthandle.cpp b/src/gc/objecthandle.cpp index ab3958921f3f..2e26476e9957 100644 --- a/src/gc/objecthandle.cpp +++ b/src/gc/objecthandle.cpp @@ -285,7 +285,7 @@ void CALLBACK AsyncPinObject(_UNCHECKED_OBJECTREF *pObjRef, uintptr_t *pExtraInf Object **pRef = (Object **)pObjRef; _ASSERTE(lp2); promote_func* callback = (promote_func*)lp2; - callback(pRef, (ScanContext *)lp1, GC_CALL_PINNED); + callback(pRef, (ScanContext *)lp1, 0); Object* pPinnedObj = *pRef; if (!HndIsNullOrDestroyedHandle(pPinnedObj)) { diff --git a/src/gcinfo/gcinfoencoder.cpp b/src/gcinfo/gcinfoencoder.cpp index 8b75166fd712..01a3a745395e 100644 --- a/src/gcinfo/gcinfoencoder.cpp +++ b/src/gcinfo/gcinfoencoder.cpp @@ -2661,7 +2661,7 @@ int BitStreamWriter::SizeofVarLengthUnsigned( size_t n, UINT32 base) // If a value gets so big we are probably doing something wrong _ASSERTE(((INT32)(UINT32)n) >= 0); _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; + size_t numEncodings = size_t{ 1 } << base; int bitsUsed; for(bitsUsed = base+1; ; bitsUsed += base+1) { @@ -2682,7 +2682,7 @@ int BitStreamWriter::EncodeVarLengthUnsigned( size_t n, UINT32 base) // If a value gets so big we are probably doing something wrong _ASSERTE(((INT32)(UINT32)n) >= 0); _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; + size_t numEncodings = size_t{ 1 } << base; int bitsUsed; for(bitsUsed = base+1; ; bitsUsed += base+1) { @@ -2704,7 +2704,7 @@ int BitStreamWriter::EncodeVarLengthUnsigned( size_t n, UINT32 base) int BitStreamWriter::EncodeVarLengthSigned( SSIZE_T n, UINT32 base ) { _ASSERTE((base > 0) && (base < BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; + size_t numEncodings = size_t{ 1 } << base; for(int bitsUsed = base+1; ; bitsUsed += base+1) { size_t currentChunk = ((size_t) n) & (numEncodings-1); diff --git a/src/inc/CrstTypes.def b/src/inc/CrstTypes.def index 65810599914f..be4a0c47ac2b 100644 --- a/src/inc/CrstTypes.def +++ b/src/inc/CrstTypes.def @@ -791,3 +791,7 @@ End Crst ReadyToRunEntryPointToMethodDescMap AcquiredBefore ExecuteManRangeLock UniqueStack End + +Crst TieredCompilation + AcquiredBefore ThreadpoolTimerQueue +End diff --git a/src/inc/clrconfigvalues.h b/src/inc/clrconfigvalues.h index 12a2c0f37502..503d29dc5280 100644 --- a/src/inc/clrconfigvalues.h +++ b/src/inc/clrconfigvalues.h @@ -653,7 +653,8 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_GainExponent, RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredCompilation, W("TieredCompilation"), 0, "Enables tiered compilation") RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_LEGACY_TieredCompilation, W("EXPERIMENTAL_TieredCompilation"), 0, "Deprecated - Use COMPLUS_TieredCompilation") RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountThreshold, W("TieredCompilation_Tier1CallCountThreshold"), 30, "Number of times a method must be called after which it is promoted to tier 1.") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountingDelayMs, W("TieredCompilation_Tier1CallCountingDelayMs"), 100, "Delay in milliseconds since process startup or the last tier 0 JIT before call counting begins for tier 1 promotion.") +RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountingDelayMs, W("TieredCompilation_Tier1CallCountingDelayMs"), 100, "A perpetual delay in milliseconds that is applied to tier 1 call counting and jitting, while there is tier 0 activity.") +RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1DelaySingleProcMultiplier, W("TieredCompilation_Tier1DelaySingleProcMultiplier"), 10, "Multiplier for TieredCompilation_Tier1CallCountingDelayMs that is applied on a single-processor machine or when the process is affinitized to a single processor.") RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_CallCounting, W("TieredCompilation_Test_CallCounting"), 1, "Enabled by default (only activates when TieredCompilation is also enabled). If disabled immediately backpatches prestub, and likely prevents any tier1 promotion") RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_OptimizeTier0, W("TieredCompilation_Test_OptimizeTier0"), 0, "Use optimized codegen (normally used by tier1) in tier0") diff --git a/src/inc/corcompile.h b/src/inc/corcompile.h index 6de9c8e3402d..bc78c33787ad 100644 --- a/src/inc/corcompile.h +++ b/src/inc/corcompile.h @@ -1331,7 +1331,8 @@ class ICorCompilePreloader CORCOMPILE_SECTION(READONLY_HOT) \ CORCOMPILE_SECTION(READONLY_WARM) \ CORCOMPILE_SECTION(READONLY_COLD) \ - CORCOMPILE_SECTION(READONLY_VCHUNKS_AND_DICTIONARY) \ + CORCOMPILE_SECTION(READONLY_VCHUNKS) \ + CORCOMPILE_SECTION(READONLY_DICTIONARY) \ CORCOMPILE_SECTION(CLASS_COLD) \ CORCOMPILE_SECTION(CROSS_DOMAIN_INFO) \ CORCOMPILE_SECTION(METHOD_PRECODE_COLD) \ @@ -1745,6 +1746,8 @@ class ICorCompileInfo IN CORINFO_METHOD_HANDLE hMethod, OUT CORJIT_FLAGS *pFlags) = 0; + virtual ICorJitHost* GetJitHost() = 0; + // needed for stubs to obtain the number of bytes to copy into the native image // return the beginning of the stub and the size to copy (in bytes) virtual void* GetStubSize(void *pStubAddress, DWORD *pSizeToCopy) = 0; diff --git a/src/inc/cordebuginfo.h b/src/inc/cordebuginfo.h index b065c5fc06b5..8c076e8b68fa 100644 --- a/src/inc/cordebuginfo.h +++ b/src/inc/cordebuginfo.h @@ -2,6 +2,10 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// +// Keep in sync with https://github.com/dotnet/corert/blob/master/src/Native/ObjWriter/cordebuginfo.h +// + /**********************************************************************************/ // DebugInfo types shared by JIT-EE interface and EE-Debugger interface @@ -191,104 +195,114 @@ class ICorDebugInfo VLT_INVALID, }; + // VLT_REG/VLT_REG_FP -- Any pointer-sized enregistered value (TYP_INT, TYP_REF, etc) + // eg. EAX + // VLT_REG_BYREF -- the specified register contains the address of the variable + // eg. [EAX] + + struct vlReg + { + RegNum vlrReg; + }; + + // VLT_STK -- Any 32 bit value which is on the stack + // eg. [ESP+0x20], or [EBP-0x28] + // VLT_STK_BYREF -- the specified stack location contains the address of the variable + // eg. mov EAX, [ESP+0x20]; [EAX] + + struct vlStk + { + RegNum vlsBaseReg; + signed vlsOffset; + }; + + // VLT_REG_REG -- TYP_LONG with both DWords enregistred + // eg. RBM_EAXEDX + + struct vlRegReg + { + RegNum vlrrReg1; + RegNum vlrrReg2; + }; + + // VLT_REG_STK -- Partly enregistered TYP_LONG + // eg { LowerDWord=EAX UpperDWord=[ESP+0x8] } + + struct vlRegStk + { + RegNum vlrsReg; + struct + { + RegNum vlrssBaseReg; + signed vlrssOffset; + } vlrsStk; + }; + + // VLT_STK_REG -- Partly enregistered TYP_LONG + // eg { LowerDWord=[ESP+0x8] UpperDWord=EAX } + + struct vlStkReg + { + struct + { + RegNum vlsrsBaseReg; + signed vlsrsOffset; + } vlsrStk; + RegNum vlsrReg; + }; + + // VLT_STK2 -- Any 64 bit value which is on the stack, + // in 2 successsive DWords. + // eg 2 DWords at [ESP+0x10] + + struct vlStk2 + { + RegNum vls2BaseReg; + signed vls2Offset; + }; + + // VLT_FPSTK -- enregisterd TYP_DOUBLE (on the FP stack) + // eg. ST(3). Actually it is ST("FPstkHeigth - vpFpStk") + + struct vlFPstk + { + unsigned vlfReg; + }; + + // VLT_FIXED_VA -- fixed argument of a varargs function. + // The argument location depends on the size of the variable + // arguments (...). Inspecting the VARARGS_HANDLE indicates the + // location of the first arg. This argument can then be accessed + // relative to the position of the first arg + + struct vlFixedVarArg + { + unsigned vlfvOffset; + }; + + // VLT_MEMORY + + struct vlMemory + { + void *rpValue; // pointer to the in-process + // location of the value. + }; + struct VarLoc { VarLocType vlType; union { - // VLT_REG/VLT_REG_FP -- Any pointer-sized enregistered value (TYP_INT, TYP_REF, etc) - // eg. EAX - // VLT_REG_BYREF -- the specified register contains the address of the variable - // eg. [EAX] - - struct - { - RegNum vlrReg; - } vlReg; - - // VLT_STK -- Any 32 bit value which is on the stack - // eg. [ESP+0x20], or [EBP-0x28] - // VLT_STK_BYREF -- the specified stack location contains the address of the variable - // eg. mov EAX, [ESP+0x20]; [EAX] - - struct - { - RegNum vlsBaseReg; - signed vlsOffset; - } vlStk; - - // VLT_REG_REG -- TYP_LONG with both DWords enregistred - // eg. RBM_EAXEDX - - struct - { - RegNum vlrrReg1; - RegNum vlrrReg2; - } vlRegReg; - - // VLT_REG_STK -- Partly enregistered TYP_LONG - // eg { LowerDWord=EAX UpperDWord=[ESP+0x8] } - - struct - { - RegNum vlrsReg; - struct - { - RegNum vlrssBaseReg; - signed vlrssOffset; - } vlrsStk; - } vlRegStk; - - // VLT_STK_REG -- Partly enregistered TYP_LONG - // eg { LowerDWord=[ESP+0x8] UpperDWord=EAX } - - struct - { - struct - { - RegNum vlsrsBaseReg; - signed vlsrsOffset; - } vlsrStk; - RegNum vlsrReg; - } vlStkReg; - - // VLT_STK2 -- Any 64 bit value which is on the stack, - // in 2 successsive DWords. - // eg 2 DWords at [ESP+0x10] - - struct - { - RegNum vls2BaseReg; - signed vls2Offset; - } vlStk2; - - // VLT_FPSTK -- enregisterd TYP_DOUBLE (on the FP stack) - // eg. ST(3). Actually it is ST("FPstkHeigth - vpFpStk") - - struct - { - unsigned vlfReg; - } vlFPstk; - - // VLT_FIXED_VA -- fixed argument of a varargs function. - // The argument location depends on the size of the variable - // arguments (...). Inspecting the VARARGS_HANDLE indicates the - // location of the first arg. This argument can then be accessed - // relative to the position of the first arg - - struct - { - unsigned vlfvOffset; - } vlFixedVarArg; - - // VLT_MEMORY - - struct - { - void *rpValue; // pointer to the in-process - // location of the value. - } vlMemory; + vlReg vlReg; + vlStk vlStk; + vlRegReg vlRegReg; + vlRegStk vlRegStk; + vlStkReg vlStkReg; + vlStk2 vlStk2; + vlFPstk vlFPstk; + vlFixedVarArg vlFixedVarArg; + vlMemory vlMemory; }; }; diff --git a/src/inc/corerror.xml b/src/inc/corerror.xml index a859cfac5d40..713fce20fcc2 100644 --- a/src/inc/corerror.xml +++ b/src/inc/corerror.xml @@ -71,166 +71,11 @@ STATUS: Data value was truncated. - - CLDB_S_NULL - NULL data value. - - - - CLDB_S_INDEX_TABLESCANREQUIRED - Table scan required to run query. - - - - TLBX_I_TYPEINFO_IMPORTED - Typelib import: progress report. - - - - TLBX_I_PIA_REGISTERED_FOR_TLB - Primary interop assembly '{0}' is already registered for type library '{1}'. - - - - TLBX_I_AGNOSTIC_ASSEMBLY - Importing a type library into a platform agnostic assembly. This can cause errors if the type library is not truly platform agnostic. - - - - TLBX_I_USEIUNKNOWN - Typelib export: substituted IUnknown for type. - - - - TLBX_I_UNCONVERTABLE_ARGS - Typelib import: signature can't be converted (eg, struct**) - - - - TLBX_I_UNCONVERTABLE_FIELD - Typelib import: signature can't be converted (eg, struct**) - - - - TLBX_W_WARNING_MESSAGE - Typelib export: Warning message wrapper. - - - - TLBX_W_ASSEMBLY_HAS_EMBEDDED_TLB - Type library is being exported for assembly '{0}' which already contains an embedded type library - - - - TLBX_W_CROSS_COMPILE_NO_REFS - When cross-compiling, all type library references should be included on the command line to ensure the correct bit-specific type libraries are loaded. - - - - TLBX_W_PURE_CROSS_COMPILE - Performing cross-compile of 32-bit non-agnostic assembly to 64-bit type library or 64-bit non-agnostic assembly to 32-bit type library. This is dangerous as pointer sizes and processor dependence will likely cause incompatibility between the assembly and resultant type library. - - - - TLBX_I_TYPE_EXPORTED - Typelib export: type exported - - - - TLBX_I_DUPLICATE_DISPID - Typelib export: duplicate dispid -- auto corrected. - - - - TLBX_I_REF_TYPE_AS_STRUCT - Typelib export: reference type had layout, exported as struct. - - - - TLBX_I_GENERIC_TYPE - TypeLib export: generic type definition - - - - TLBX_W_NON_INTEGRAL_CA_TYPE - TypeLib import: Ignoring IDL custom attribute -- does not have an integral value. - - - - TLBX_W_IENUM_CA_ON_IUNK - TypeLib import: Ignoring IDL custom attribute -- using IEnum CA on an IUnknown derived interface. - - - - META_S_PARAM_MISMATCH - Merge: Parameter information mismatched. - - META_S_DUPLICATE Attempt to define an object that already exists in valid scenerios. - - TLBX_S_REFERENCED_TYPELIB - TypeLib import: reference to an external typelib. - - - - TLBX_S_NOSTDINTERFACE - Typelib export: Found an interface marked as IID_IDispatch or IID_IUnknown. - - - - TLBX_S_DUPLICATE_DISPID - Typelib export: duplicate dispid found; ignored. - - - - TLBX_W_ENUM_VALUE_TOOBIG - Typelib export: The enum value is not legal for a typelib. - - - - TLBX_W_EXPORTING_AUTO_LAYOUT - TypeLib export: Exporting an auto-layout type. - - - - TLBX_W_DEFAULT_INTF_NOT_VISIBLE - TypeLib export: ComDefaultInterface is not COMVisible. - - - - TLBX_W_BAD_SAFEARRAYFIELD_NO_ELEMENTVT - TypeLib export: System.Array SAFEARRAY field without a SafeArraySubType. - - - - TLBX_W_LAYOUTCLASS_AS_INTERFACE - TypeLib export: Class with layout parameter of field marked with UnmanagedType.Interface - - - - TLBX_I_GENERIC_BASE_TYPE - TypeLib export: type deriving from a generic type. - - - - VLDTR_S_WRN - Warnings found in the validator. - - - - VLDTR_S_ERR - Errors found in the validator. - - - - VLDTR_S_WRNERR - Warnings and errors found in the validator. - - CORDBG_S_BAD_START_SEQUENCE_POINT Attempt to SetIP not at a sequence point sequence point. @@ -241,11 +86,6 @@ Attempt to SetIP when not going to a sequence point. If both this and CORDBG_E_BAD_START_SEQUENCE_POINT are true, only CORDBG_E_BAD_START_SEQUENCE_POINT will be reported. - - CORDBG_S_INSUFFICIENT_INFO_FOR_SET_IP - SetIP is possible, but the debugger doesn't have enough info to fix variable locations, GC refs, or anything else. Use at your own risk. - - CORDBG_S_FUNC_EVAL_HAS_NO_RESULT Some Func evals will lack a return value, @@ -272,36 +112,12 @@ Not all bits specified were successfully applied - - CEE_E_ENTRYPOINT - "Invalid entrypoint information." - The entry point info is invalid. - - CEE_E_CVTRES_NOT_FOUND "cvtres.exe not found." cannot find cvtres.exe - - MSEE_E_LOADLIBFAILED - "Failed to delayload a library." - Failed to delay load library %s (Win32 error: %d). - - - - MSEE_E_GETPROCFAILED - "Failed to get dll entrypoint." - Failed to get entry point %s (Win32 error: %d). - - - - MSEE_E_MULTCOPIESLOADED - "Multiple copies of mscoree.dll have been loaded into the same process." - Multiple copies of MSCOREE.dll have been loaded by the same process. - - COR_E_TYPEUNLOADED "Type has been unloaded." @@ -326,12 +142,6 @@ Assembly is being currently being loaded - - MSEE_E_CANNOTCREATEAPPDOMAIN - "Attempt to create appdomain failed." - Attempt to create appdomain failed - - COR_E_ASSEMBLYEXPECTED "The module was expected to contain an assembly manifest." @@ -344,30 +154,12 @@ Attempt to load an unverifiable exe with fixups (IAT with more than 2 sections or a TLS section) - - COR_E_NO_LOADLIBRARY_ALLOWED - "Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT area allowed)." - Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT's area allowed.) - - COR_E_NEWER_RUNTIME "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." The assembly is built by a runtime newer than the currently loaded runtime, and cannot be loaded. - - COR_E_CANNOT_SET_POLICY - "Cannot set security policy under MultiDomain after non-GAC assemblies have been loaded in appdomain." - Unable to set app domain security policy after non-GAC domain neutral assemblies are loaded - - - - COR_E_CANNOT_SPECIFY_EVIDENCE - "Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain." - Unable to use assembly evidence after non-GAC domain neutral assemblies are loaded - - COR_E_MULTIMODULEASSEMBLIESDIALLOWED "The module cannot be loaded because only single file assemblies are supported." @@ -380,12 +172,6 @@ Host detects deadlock on a blocking operation - - HOST_E_INTERRUPTED - "Host interrupted a wait." - Host interrupts a wait, similar to APC - - HOST_E_INVALIDOPERATION "Invalid operation." @@ -398,24 +184,6 @@ CLR has been disabled due to unrecoverable error - - HOST_E_TIMEOUT - "A wait has timed out." - A wait times out - - - - HOST_E_NOT_OWNER - "The leave operation has been attempted on a synchronization primitive that is not owned by the current thread." - - - - - HOST_E_ABANDONED - "An event has been abandoned." - An event is abandoned - - HOST_E_EXITPROCESS_THREADABORT "Process exited due to ThreadAbort escalation." @@ -440,12 +208,6 @@ ExitProcess due to OutOfMemory escalation - - HOST_E_EXITPROCESS_STACKOVERFLOW - "Process exited due to StackOverflow escalation." - ExitProcess due to StackOverflow escalation - - COR_E_MODULE_HASH_CHECK_FAILED "The check of the module's hash failed." @@ -470,12 +232,6 @@ A module specified in the manifest was not found. - - FUSION_E_UNEXPECTED_MODULE_FOUND - "Modules which are not in the manifest were streamed in." - Modules which are not in the manifest were streamed in. - - FUSION_E_PRIVATE_ASM_DISALLOWED "A strongly-named assembly is required." @@ -488,12 +244,6 @@ The check of the signature failed. - - FUSION_E_DATABASE_ERROR - "An unexpected error was encountered in the Assembly Cache database." - An unexpected error was encountered in the Assembly Cache database. - - FUSION_E_INVALID_NAME "The given assembly name or codebase was invalid." @@ -506,18 +256,6 @@ HTTP download of assemblies has been disabled for this appdomain. - - FUSION_E_UNINSTALL_DISALLOWED - "Uninstall of given assembly is not allowed." - Uninstall of given assembly is not allowed. - - - - CLR_E_APP_CONFIG_NOT_ALLOWED_IN_APPX_PROCESS - "Application configuration file not allowed in AppX process." - Application configuration file not allowed in AppX process. - - FUSION_E_HOST_GAC_ASM_MISMATCH "Assembly in host store has a different signature than assembly in GAC." @@ -554,18 +292,6 @@ Unexpected error while parsing the specified manifest - - FUSION_E_INVALID_ASSEMBLY_REFERENCE - "The given assembly name is invalid because a processor architecture is specified." - The given assembly name is invalid because a processor architecture is specified - - - - COR_E_ASSEMBLY_NOT_EXPECTED - "The module was expected to not contain an assembly manifest." - The module was expected to not contain an assembly manifest. - - COR_E_LOADING_REFERENCE_ASSEMBLY "Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context." @@ -596,36 +322,12 @@ Error occurred during a write. - - CLDB_E_FILE_READONLY - "File is read only." - File is read only. - - - - CLDB_E_NAME_ERROR - "Ill-formed name." - An ill-formed name was given. - - - - CLDB_E_TRUNCATION - "Data value was truncated." - ERROR: Data value was truncated. - - CLDB_E_FILE_OLDVER "Old version error." Old version error. - - CLDB_E_RELOCATED - "A shared memory open failed to open at the originally assigned memory address." - A shared mem open failed to open at the originally - - CLDB_E_SMDUPLICATE "Create of shared memory failed. A memory mapping of the same name already exists." @@ -638,12 +340,6 @@ There isn't .CLB data in the memory or stream. - - CLDB_E_READONLY - "Database is read only." - Database is read only. - - CLDB_E_INCOMPATIBLE "Importing scope is not compatible with the emitting scope." @@ -656,36 +352,12 @@ File is corrupt. - - CLDB_E_SCHEMA_VERNOTFOUND - "Required version of schema not found." - Version %d of schema '%s' not found. - - CLDB_E_BADUPDATEMODE "Cannot open a incrementally build scope for full update." cannot open a incrementally build scope for full update - - CLDB_E_INDEX_NONULLKEYS - "Null value not allowed in unique index or primary key." - Null value not allowed in unique index or primary key. - - - - CLDB_E_INDEX_DUPLICATE - "Index has been duplicated." - Unique index %s has been violated. - - - - CLDB_E_INDEX_BADTYPE - "The columns data type is not allowed in an index." - The columns data type is not allowed in an index. - - CLDB_E_INDEX_NOTFOUND "Index not found." @@ -698,84 +370,12 @@ Record wasn't found on lookup. - - CLDB_E_RECORD_OVERFLOW - "Too many records were returned for criteria." - Too many records were returned for criteria. - - - - CLDB_E_RECORD_DUPLICATE - "Record is a duplicate." - Record is a duplicate. - - - - CLDB_E_RECORD_PKREQUIRED - "Primary key value is required." - Primary key value is required. - - - - CLDB_E_RECORD_DELETED - "Record is valid but deleted." - Record is valid but deleted. - - CLDB_E_RECORD_OUTOFORDER "Record is emitted out of order." Record is emitted out of order. - - CLDB_E_COLUMN_OVERFLOW - "Data too large." - Data too large. - - - - CLDB_E_COLUMN_READONLY - "Column cannot be changed." - Column cannot be changed. - - - - CLDB_E_COLUMN_SPECIALCOL - "Too many RID or primary key columns, 1 is max." - Too many RID or primary key columns, 1 is max. - - - - CLDB_E_COLUMN_PKNONULLS - "Primary key column may not allow the null value." - Primary key column %s may not allow the null value. - - - - CLDB_E_TABLE_CANTDROP - "Attempted auto-drop of table while open." - Can't auto-drop table while open. - - - - CLDB_E_OBJECT_NOTFOUND - "Object not found in the database." - Object was not found in the database. - - - - CLDB_E_OBJECT_COLNOTFOUND - "Column not found." - The column was not found. - - - - CLDB_E_VECTOR_BADINDEX - "Invalid index." - The index given was invalid. - - CLDB_E_TOO_BIG "A blob or string was too big." @@ -788,239 +388,12 @@ A token of the wrong type passed to a metadata function. - - TLBX_E_INVALID_TYPEINFO - "Typelib import: Invalid type, not converted." - Typelib import: invalid type, not converted. - - - - TLBX_E_INVALID_TYPEINFO_UNNAMED - "Typelib import: Invalid type, not converted - name unknown." - Typelib import: invalid type, not converted -- name unknown. - - - - TLBX_E_CTX_NESTED - "Typelib export: TLBX_E_CTX_NESTED" - Typelib export: Format string for nested contexts. - - - - TLBX_E_ERROR_MESSAGE - "Typelib export: General error. See IError info for more information." - Typelib export: Error message wrapper. - - - - TLBX_E_CANT_SAVE - "Typelib export: SaveAllChanges() failed." - Typelib export: cant "SaveAllChanges()" - - - - TLBX_W_LIBNOTREGISTERED - "Typelib export: Type library is not registered." - Typelib export: type library is not registered. - - - - TLBX_E_CANTLOADLIBRARY - "Typelib export: Type library could not be loaded." - Typelib export: type library cannot be loaded. - - - - TLBX_E_BAD_VT_TYPE - "Typelib import: Invalid vartype, not converted." - Typelib import: invalid VT_*, not converted. - - - - TLBX_E_NO_MSCOREE_TLB - "Typelib export: Could not load mscoree.tlb." - Typelib export: can't load mscoree.tlb - - - - TLBX_E_BAD_MSCOREE_TLB - "Typelib export: Could not get a required typeinfo from mscoree.tlb." - Typelib export: can't get a required typeinfo from mscoree.tlb. - - - - TLBX_E_TLB_EXCEPTION - "Typelib import: Fault reading a typelib." - Typelib import: fault reading a typelib. - - - - TLBX_E_MULTIPLE_LCIDS - "Typelib import: Multiple [lcid] parameters on a method." - Typelib import: Multiple LCID's parameters on a method. - - - - TLBX_E_AMBIGUOUS_RETURN - "Typelib import: Duplicate or ambiguous return types." - Typelib import: duplicate or ambiguous return types. - - - - TLBX_E_DUPLICATE_TYPE_NAME - "Typelib import: Duplicate name (due to user-defined name)." - Typelib import: duplicate name (due to user-defined name). - - - - TLBX_I_NONSEQUENTIALSTRUCT - "Typelib export: Cannot convert non-sequential structs." - Typelib export: Can't convert non-sequential structs. - - - - TLBX_I_RESOLVEREFFAILED - "Typelib import: The resolve ref call failed." - Typelib import: The resolve ref call failed. - - - - TLBX_E_ASANY - "Typelib export: Encountered AsAny - ignored." - Typelib export: Encounterd "AsAny" -- ignored. - - - - TLBX_E_INVALIDLCIDPARAM - "Typelib export: Encountered an [lcid] attribute set to an invalid parameter." - Typelib export: Encounterd an LCID attribute set to an invalid param. - - - - TLBX_E_LCIDONDISPONLYITF - "Typelib export: Encountered an [lcid] attribute on a pure dispatch interface." - Typelib export: Encounterd an LCID attribute on a disp only interface. - - - - TLBX_E_NONPUBLIC_FIELD - "Typelib export: Non-public field in public struct." - Typelib export: Non-public field in public struct. - - - - TLBX_E_BAD_NAMES - "Typelib export: Bad names list." - Typelib export: bad names list. - - - - TLBX_E_GENERICINST_SIGNATURE - "TypeLib export: generic type instance in signature." - TypeLib export: generic type instance in signature. - - - - TLBX_E_GENERICPAR_SIGNATURE - "TypeLib export: generic type parameter in signature." - TypeLib export: generic type parameter in signature. - - - - META_E_DUPLICATE - "Attempted to define an object that already exists." - Attempt to define an object that already exists. - - - - META_E_GUID_REQUIRED - "A guid was not provided where one was required." - A guid was not provided where one was required. - - - - META_E_TYPEDEF_MISMATCH - "Merge: an import typedef matched ns.name, but not version and guid." - Merge: an import typedef matched ns.name, but not version and guid. - - - - META_E_MERGE_COLLISION - "Merge: conflict between import and emit." - Merge: conflict between import and emit - - - - TLBX_E_NO_SAFEHANDLE_ARRAYS - "TypeLib export: Detected array of SafeHandles." - TypeLib export: detected array of SafeHandles - - - - META_E_METHD_NOT_FOUND - "Merge: Class already in emit scope, but member not found." - Merge: Class already in emit scope, but member not found - - - - META_E_FIELD_NOT_FOUND - "Merge: Class already in emit scope, but member not found." - Merge: Class already in emit scope, but member not found - - - - META_E_PARAM_MISMATCH - "Merge: Parameter information mismatched." - Merge: Parameter information mismatched. - - META_E_BADMETADATA "Merge: Inconsistency in meta data import scope." Merge: Inconsistency in meta data import scope - - META_E_INTFCEIMPL_NOT_FOUND - "Merge: Class already in emit scope, but interfaceimpl not found." - Merge: Class already in emit scope, but interfaceimpl not found - - - - TLBX_E_NO_CRITICALHANDLE_ARRAYS - "TypeLib export: Detected array of CriticalHandles." - TypeLib export: detected array of CriticalHandles - - - - META_E_CLASS_LAYOUT_INCONSISTENT - "Merge: Duplicate classes have inconsistent class layout information." - Merge: Class is duplicated but class layout information is not consistent - - - - META_E_FIELD_MARSHAL_NOT_FOUND - "Merge: Field is duplicated but no matching FieldMarshal information." - Merge: Field is duplicated but we cannot find the matching FieldMarshal information - - - - META_E_METHODSEM_NOT_FOUND - Merge: - - - - META_E_EVENT_NOT_FOUND - "Merge: Method is duplicated but no matching event info." - Merge: Method is duplicated but we cannot find the matching event info. - - - - META_E_PROP_NOT_FOUND - "Merge: Method is duplicated but no matching property info." - Merge: Method is duplicated but we cannot find the maching property info. - - META_E_BAD_SIGNATURE "Bad binary signature." @@ -1033,18 +406,6 @@ Bad input parameters - - META_E_METHDIMPL_INCONSISTENT - "Merge: duplicated methods have inconsistent ImplFlags." - Merge: duplicated methods have inconsistent ImplFlags - - - - META_E_MD_INCONSISTENCY - "Merge: Inconsistency in meta data." - Merge: Inconsistency in meta data - - META_E_CANNOTRESOLVETYPEREF "Cannot resolve typeref." @@ -1057,12 +418,6 @@ No logical space left to create more user strings. - - META_E_UNEXPECTED_REMAP - "Unexpected TokenRemap." - A TokenRemap occurred which we weren't prepared to handle. - - META_E_HAS_UNMARKALL "Unmark all has been called already." @@ -1075,262 +430,46 @@ Must call UnmarkAll first before marking. - - META_E_GENERICPARAM_INCONSISTENT - "Merge: duplicated types or methods have inconsistent GenericParams." - Merge: duplicated types/methods have inconsistent GenericParams - - - - META_E_EVENT_COUNTS - "Merge: different event counts in import and emit scopes." - Merge: different event counts in import and emit scopes. + + META_E_CA_INVALID_TARGET + "Known custom attribute on invalid target." + Known custom attribute on invalid target. - - META_E_PROPERTY_COUNTS - "Merge: different property counts in import and emit scopes." - Merge: different property counts in import and emit scopes. + + META_E_CA_INVALID_VALUE + "Known custom attribute had invalid value." + Known custom attribute had invalid value. - - META_E_TYPEDEF_MISSING - "Merge: An input scope has a TypeRef which does not have a matching TypeDef." - Merge: An input scope has a TypeRef which should but doesn't have a matching TypeDef. + + META_E_CA_INVALID_BLOB + "Known custom attribute blob has bad format." + Known custom attribute blob is bad format. - - TLBX_E_CANT_LOAD_MODULE - "TypeLib export: cannot open the module to export." - TypeLib export: can't open the module to export. + + META_E_CA_REPEATED_ARG + "Known custom attribute blob has repeated named argument." + Known custom attribute blob has repeated named argument. - - TLBX_E_CANT_LOAD_CLASS - "TypeLib export: cannot load a class." - TypeLib export: can't load a class. + + META_E_CA_UNKNOWN_ARGUMENT + "Known custom attribute named argument not recognized." + Known custom attrubte named arg not recognized. - - TLBX_E_NULL_MODULE - "TypeLib export: the hModule of a loaded class is 0; cannot export it." - TypeLib export: the hMod of a loaded class is 0; can't export it. + + META_E_CA_UNEXPECTED_TYPE + "Known attribute parser found unexpected type." + Known attribute parser found unexpected type. - - TLBX_E_NO_CLSID_KEY - "TypeLib export: no CLSID or Interface subkey to HKCR." - TypeLib export: no CLSID or Interface subkey to HKCR. - - - - TLBX_E_CIRCULAR_EXPORT - "TypeLib export: attempted to export an Assembly imported from a TLB." - TypeLib export: attempt to export a CLB imported from a TLB. - - - - TLBX_E_CIRCULAR_IMPORT - "TypeLib import: attempted to import a TLB exported from an Assembly." - TypeLib import: attempt to import a TLB exported from a CLB. - - - - TLBX_E_BAD_NATIVETYPE - "TypeLib export: bad Native type in method signature." - TypeLib export: bad Native type in method signature. - - - - TLBX_E_BAD_VTABLE - "TypeLib import: non-increasing vtable (duplicate slots)." - TypeLib import: non-increasing vtable (duplicate slots). - - - - TLBX_E_CRM_NON_STATIC - "TypeLib export: the COM register method is non static." - TypeLib export: the COM register method is non static. - - - - TLBX_E_CRM_INVALID_SIG - "TypeLib export: the specified COM register method does not have the correct signature." - TypeLib export: the specified COM register method does not have the correct signature. - - - - TLBX_E_CLASS_LOAD_EXCEPTION - "TypeLib export: cannot load CLR type." - TypeLib export: can't load, have the class load exception. - - - - TLBX_E_UNKNOWN_SIGNATURE - "TypeLib export: unknown element in signature." - TypeLib export: unknown element in signature. - - - - TLBX_E_REFERENCED_TYPELIB - "TypeLib import: reference to an external typelib." - TypeLib import: reference to an external typelib. - - - - TLBX_E_INVALID_NAMESPACE - "TypeLib import: an imported typelib has an invalid namespace name." - TypeLib import: an imported typelib has an invalid namespace name. - - - - TLBX_E_LAYOUT_ERROR - "Typelib export: an error on Layout()" - Typelib export: an error on Layout() - - - - TLBX_E_NOTIUNKNOWN - "Typelib import: Interface not derived from IUnknown." - Typelib import: Interface not derived from IUnknown. - - - - TLBX_E_NONVISIBLEVALUECLASS - "Typelib export: Non COM visible value type in method signature." - Typelib export: Non COM visible value type in method signature. - - - - TLBX_E_LPTSTR_NOT_ALLOWED - "Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM." - Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM. - - - - TLBX_E_AUTO_CS_NOT_ALLOWED - "Typelib export: Types with a charset of auto are not allowed to be exported to COM." - Typelib export: Types with a char set of auto are not allowed to be exported to COM. - - - - TLBX_E_ENUM_VALUE_INVALID - "Typelib export: The enum value is not legal for a typelib." - Typelib export: The enum value is not legal for a typelib. - - - - TLBX_E_DUPLICATE_IID - "Typelib export: Duplicate IID." - Typelib export: Duplicate IID - - - - TLBX_E_NO_NESTED_ARRAYS - "Typelib export: detected nested arrays." - Tyeplib export: detected nested arrays. - - - - TLBX_E_PARAM_ERROR_NAMED - "Typelib import: parameter type could not be converted." - Typelib import: param type couldn't be converted. - - - - TLBX_E_PARAM_ERROR_UNNAMED - "Typelib import: parameter type could not be converted - parameter name unknown." - Typelib import: param type couldn't be converted -- param name unknown. - - - - TLBX_E_AGNOST_SIGNATURE - "TypeLib export: size agnostic element in signature." - TypeLib export: size agnostic element in signature. - - - - TLBX_E_CONVERT_FAIL - "TypeLib export: exporter failed." - TypeLib export: exporter failed. - - - - TLBX_W_DUAL_NOT_DISPATCH - "Typelib import: [dual] interface not derived from IDispatch." - Typelib import: [dual] interface not derived from IDispatch. - - - - TLBX_E_BAD_SIGNATURE - "Typelib export: bad signature." - Typelib export: unconvertable signature (use specific error for reporting!) - - - - TLBX_E_ARRAY_NEEDS_NT_FIXED - "Typelib export: non-fixed or non-safearray array in struct." - Typelib export: non-fixed/non-safearray array in struct - - - - TLBX_E_CLASS_NEEDS_NT_INTF - "Typelib export: non-interface class in struct." - Typelib export: non-interface class in struct - - - - META_E_CA_INVALID_TARGET - "Known custom attribute on invalid target." - Known custom attribute on invalid target. - - - - META_E_CA_INVALID_VALUE - "Known custom attribute had invalid value." - Known custom attribute had invalid value. - - - - META_E_CA_INVALID_BLOB - "Known custom attribute blob has bad format." - Known custom attribute blob is bad format. - - - - META_E_CA_REPEATED_ARG - "Known custom attribute blob has repeated named argument." - Known custom attribute blob has repeated named argument. - - - - META_E_CA_UNKNOWN_ARGUMENT - "Known custom attribute named argument not recognized." - Known custom attrubte named arg not recognized. - - - - META_E_CA_VARIANT_NYI - "Known attribute named argument does not support variant." - Known attribute named argument doesn't support variant. - - - - META_E_CA_ARRAY_NYI - "Known attribute named argument does not support array." - Known attribute named argument doesn't support array. - - - - META_E_CA_UNEXPECTED_TYPE - "Known attribute parser found unexpected type." - Known attribute parser found unexpected type. - - - - META_E_CA_INVALID_ARGTYPE - "Known attribute parser only handles fields, not properties." - Known attribute parser only handles fields -- no properties. + + META_E_CA_INVALID_ARGTYPE + "Known attribute parser only handles fields, not properties." + Known attribute parser only handles fields -- no properties. @@ -1363,12 +502,6 @@ The parameter index cannot be negative. - - META_E_CA_NEGATIVE_MULTIPLIER - "The multiplier cannot be negative." - The multiplier cannot be negative. - - META_E_CA_NEGATIVE_CONSTSIZE "The constant size cannot be negative." @@ -1387,69 +520,12 @@ A custom marshaler requires the custom marshaler type. - - META_E_CA_FILENAME_REQUIRED - "A DllImport attribute requires a filename." - A DllImport attribute requires a filename. - - - - TLBX_W_NO_PROPS_IN_EVENTS - "TypeLib import: Detected properties in a source dispinterface." - TypeLib import: Detected properties in a source dispinterface. - - META_E_NOT_IN_ENC_MODE "SaveDelta was called without being in EnC mode." SaveDelta was called without being in EnC mode - - META_E_METHOD_COUNTS - "Merge: different method counts in import and emit scopes." - Merge: different method counts in import and emit scopes. - - - - META_E_FIELD_COUNTS - "Merge: different field counts in import and emit scopes." - Merge: different field counts in import and emit scopes. - - - - META_E_PARAM_COUNTS - "Merge: different parameter counts in import and emit scopes." - Merge: different param counts in import and emit scopes. - - - - TLBX_E_TYPED_REF - "TypeLib export: Exporting a TypedReference." - TypeLib export: Exporting a TypedReference. - - - - TLBX_E_BITNESS_MISMATCH - "TypeLib export: bitness of assembly does not match bitness of output type library." - TypeLib export: bitness of assembly doesn't match bitness of output type library - - - - TLBX_E_EVENT_WITH_NEWENUM - TypeLib import: source interface with NewEnum member. - - - - TLBX_E_PROPGET_WITHOUT_RETURN - TypeLib import: propget without return type - - - - META_E_MISMATCHED_VISIBLITY - Merge - Match found for type/method/etc but differs in visiblity - - META_E_CA_BAD_FRIENDS_ARGS "InternalsVisibleTo can't have a version, culture, or processor architecture." @@ -1467,18 +543,6 @@ Rid is out of range. - - VLDTR_E_CDTKN_OUTOFRANGE - "Coded token type is out of range." - Coded token type is out of range. - - - - VLDTR_E_CDRID_OUTOFRANGE - "Coded rid is out of range." - Coded rid is out of range. - - VLDTR_E_STRING_INVALID "String offset is invalid." @@ -1497,294 +561,18 @@ Blob offset if invalid. - - VLDTR_E_MOD_MULTI - "Multiple module records found." - Multiple module records found. - - - - VLDTR_E_MOD_NULLMVID - "Module has null MVID." - Module has null MVID. - - - - VLDTR_E_TR_NAMENULL - "TypeRef name is NULL." - TypeRef name is NULL. - - - - VLDTR_E_TR_DUP - "TypeRef has a duplicate." - TypeRef has a dup. - - - - VLDTR_E_TD_NAMENULL - "TypeDef name is NULL." - TypeDef name is NULL. - - - - VLDTR_E_TD_DUPNAME - "TypeDef has a duplicate based on name+namespace." - TypeDef has a dup based on name+namespace. - - - - VLDTR_E_TD_DUPGUID - "TypeDef has a duplicate based on GUID." - TypeDef has a dup based on GUID. - - - - VLDTR_E_TD_NOTIFACEOBJEXTNULL - "TypeDef that is not an Interface and not System.Object extends nil parent." - TypeDef that's not an Interface and not System.Object extends nil parent. - - - - VLDTR_E_TD_OBJEXTENDSNONNULL - "System.Object extends a non-nil parent." - System.Object extends a non-nil parent. - - - - VLDTR_E_TD_EXTENDSSEALED - "TypeDef extends sealed class." - TypeDef extends sealed class. - - - - VLDTR_E_TD_DLTNORTSPCL - "TypeDef is Deleted but not marked with RTSpecialName." - TypeDef is Deleted but not marked with RTSpecialName. - - - - VLDTR_E_TD_RTSPCLNOTDLT - "TypeDef is marked RTSpecialName, but is not a Deleted record." - TypeDef is marked RTSpecialName, but is not a Deleted record. - - - - VLDTR_E_MI_DECLPRIV - "MethodImpl's Decl is private." - MethodImpl's Decl is private - - - - VLDTR_E_AS_BADNAME - "Assembly [Ref] name has path and/or extension." - Assembly [Ref] name has path and/or extension. - - - - VLDTR_E_FILE_SYSNAME - "File has a system name (con, com, aux, etc.)." - File has a system name (con, com, aux, etc.). - - - - VLDTR_E_MI_BODYSTATIC - "MethodImpl's body is static." - MethodImpl's body is static. - - - - VLDTR_E_TD_IFACENOTABS - "TypeDef is marked Interface but not Abstract." - TypeDef is marked Interface but not Abstract. - - - - VLDTR_E_TD_IFACEPARNOTNIL - "TypeDef is marked Interface but parent is not Nil." - TypeDef is marked Interface but parent is not Nil. - - - - VLDTR_E_TD_IFACEGUIDNULL - "TypeDef is marked Interface but GUID is NULL." - TypeDef is marked Interface but GUID is NULL. - - - - VLDTR_E_MI_DECLFINAL - "TMethodImpl's Decl is final." - TMethodImpl's Decl is final. - - - - VLDTR_E_TD_VTNOTSEAL - "TypeDef is marked ValueType but not marked Sealed." - TypeDef is marked ValueType but not marked Sealed. - - - - VLDTR_E_PD_BADFLAGS - "Parameter has extra bits in flags." - Param has extra bits in flags. - - - - VLDTR_E_IFACE_DUP - "InterfaceImpl has a duplicate." - InterfaceImpl has a dup. - - - - VLDTR_E_MR_NAMENULL - "MemberRef name is NULL." - MemberRef name is NULL. - - - - VLDTR_E_MR_VTBLNAME - "MemberRef has an invalid name, _VtblGap*." - MemberRef has an invalid name, _VtblGap*. - - - - VLDTR_E_MR_DELNAME - "MemberRef has an invalid name, _Deleted*." - MemberRef has an invalid name, _Deleted*. - - - - VLDTR_E_MR_PARNIL - "MemberRef parent Nil in a PE file." - MemberRef parent Nil in a PE file. - - VLDTR_E_MR_BADCALLINGCONV "MemberRef has invalid calling convention." MemberRef has invalid calling convention. - - VLDTR_E_MR_NOTVARARG - "MemberRef has Method parent but calling convention is not VARARG." - MemberRef has Method parent but calling convention is not VARARG. - - - - VLDTR_E_MR_NAMEDIFF - "MemberRef name different from parent MethodDef." - MemberRef name different from parent MethodDef. - - - - VLDTR_E_MR_SIGDIFF - "MemberRef signature different from parent MethodDef." - MemberRef signature different from parent MethodDef. - - - - VLDTR_E_MR_DUP - "MemberRef has a duplicate." - MemberRef has a dup. - - - - VLDTR_E_CL_TDAUTO - "ClassLayout parent TypeDef is marked AutoLayout." - ClassLayout parent TypeDef is marked AutoLayout. - - - - VLDTR_E_CL_BADPCKSZ - "ClassLayout has bad PackingSize." - ClassLayout has bad PackingSize. - - - - VLDTR_E_CL_DUP - "ClassLayout has a duplicate." - ClassLayout has dup. - - - - VLDTR_E_FL_BADOFFSET - "FieldLayout2 has bad offset." - FieldLayout2 has bad offset. - - - - VLDTR_E_FL_TDNIL - "FieldLayout2 has field with nil parent." - FieldLayout2 has field with nil parent. - - - - VLDTR_E_FL_NOCL - "FieldLayout2 has no ClassLayout record." - FieldLayout2 has no ClassLayout record. - - - - VLDTR_E_FL_TDNOTEXPLCT - "FieldLayout2 parent TypeDef is not marked with ExplicitLayout." - FieldLayout2 parent TypeDef is not marked with ExplicitLayout. - - - - VLDTR_E_FL_FLDSTATIC - "FieldLayout2 has field marked Static." - FieldLayout2 has field marked Static. - - - - VLDTR_E_FL_DUP - "FieldLayout2 has a duplicate." - FieldLayout2 has a dup. - - - - VLDTR_E_MODREF_NAMENULL - "ModuleRef name is NULL." - ModuleRef name is NULL. - - - - VLDTR_E_MODREF_DUP - "ModuleRef has a duplicate." - ModuleRef has a dup. - - - - VLDTR_E_TR_BADSCOPE - "TypeRef has a bad resolution scope." - TypeRef has a bad resolution scope. - - - - VLDTR_E_TD_NESTEDNOENCL - "TypeDef marked nested has no encloser." - TypeDef marked nested has no encloser. - - - - VLDTR_E_TD_EXTTRRES - "TypeDef extends a TypeRef which resolves to a TypeDef in the same module." - TypeDef extends a TypeRef which resolves to a TypeDef in the same module. - - VLDTR_E_SIGNULL "Signature specified is zero-sized." Signature specified is zero-sized. - - VLDTR_E_SIGNODATA - "Signature does not have enough data at specified byte." - Signature does not have enough data at specified byte. - - VLDTR_E_MD_BADCALLINGCONV "Method signature has invalid calling convention." @@ -1875,4372 +663,1127 @@ Signature has bad element type. - - VLDTR_E_SIG_MISSVASIZE - "Signature has value array missing size." - Signature has value array missing size. + + VLDTR_E_TD_ENCLNOTNESTED + "TypeDef not nested has encloser." + TypeDef not nested has encloser. - - VLDTR_E_FD_BADCALLINGCONV - "Field signature has invalid calling convention." - Field signature has invalid calling convention. + + VLDTR_E_FMD_PINVOKENOTSTATIC + "Field or method is PInvoke but is not marked Static." + Field/method is PInvoke but is not marked Static. - - VLDTR_E_MD_NAMENULL - "Method name is NULL." - Method name is NULL. + + VLDTR_E_SIG_SENTINMETHODDEF + "E_T_SENTINEL in MethodDef signature." + E_T_SENTINEL in MethodDef signature - - VLDTR_E_MD_PARNIL - "Method has parent NIL." - Method has parent NIL. + + VLDTR_E_SIG_SENTMUSTVARARG + "E_T_SENTINEL <=> VARARG." + E_T_SENTINEL <=> VARARG - - VLDTR_E_MD_DUP - "Method has a duplicate." - Method has dup. + + VLDTR_E_SIG_MULTSENTINELS + "Multiple E_T_SENTINELs." + Multiple E_T_SENTINELs - - VLDTR_E_FD_NAMENULL - "Field name is NULL." - Field name is NULL. + + VLDTR_E_SIG_MISSARG + "Signature missing argument." + Signature missing argument - - VLDTR_E_FD_PARNIL - "Field parent is Nil." - Field parent is Nil. + + VLDTR_E_SIG_BYREFINFIELD + "Field of ByRef type." + Field of ByRef type - - VLDTR_E_FD_DUP - "Field has a duplicate." - Field has dup. + + CORDBG_E_UNRECOVERABLE_ERROR + "Unrecoverable API error." + Unrecoverable API error. - - VLDTR_E_AS_MULTI - "Multiple Assembly records found." - Multiple Assembly records found. + + CORDBG_E_PROCESS_TERMINATED + "Process was terminated." + Process was terminated. - - VLDTR_E_AS_NAMENULL - "Assembly name is NULL." - Assembly name is NULL. + + CORDBG_E_PROCESS_NOT_SYNCHRONIZED + "Process not synchronized." + Process not synchronized. - - VLDTR_E_SIG_TOKTYPEMISMATCH - "E_T_VALUETYPE<class token> or E_T_CLASS<vtype token>." - E_T_VALUETYPE<class token> or E_T_CLASS<vtype token>. - - - - VLDTR_E_CL_TDINTF - "Class layout on an Interface." - Class layout on an Interface. - - - - VLDTR_E_ASOS_OSPLTFRMIDINVAL - "AssemblyOS platform ID invalid." - AssemblyOS platform ID invalid. - - - - VLDTR_E_AR_NAMENULL - "AssemblyRef name is NULL." - AssemblyRef name is NULL. - - - - VLDTR_E_TD_ENCLNOTNESTED - "TypeDef not nested has encloser." - TypeDef not nested has encloser. - - - - VLDTR_E_AROS_OSPLTFRMIDINVAL - "AssemblyRefOS has invalid platform ID." - AssemblyRefOS has invalid platform ID. - - - - VLDTR_E_FILE_NAMENULL - "File name is NULL." - File name is NULL. - - - - VLDTR_E_CT_NAMENULL - "ExportedType name is NULL." - ExportedType name is NULL. - - - - VLDTR_E_TD_EXTENDSCHILD - "TypeDef extends its own child." - TypeDef extends its own child. - - - - VLDTR_E_MAR_NAMENULL - "ManifestResource name is NULL." - ManifestResource name is NULL. - - - - VLDTR_E_FILE_DUP - "File has a duplicate." - File has dup. - - - - VLDTR_E_FILE_NAMEFULLQLFD - "File name is fully qualified." - File name is fully qualified. - - - - VLDTR_E_CT_DUP - "ExportedType has a duplicate." - ExportedType has dup. - - - - VLDTR_E_MAR_DUP - "ManifestResource has a duplicate." - ManifestResource has dup. - - - - VLDTR_E_MAR_NOTPUBPRIV - "ManifestResource is neither Public nor Private." - ManifestResource is neither Public not Private. - - - - VLDTR_E_TD_ENUMNOVALUE - "Enum has no value__ field." - Enum has no "value__" field. - - - - VLDTR_E_TD_ENUMVALSTATIC - "Enum's value__ field is static." - Enum's "value__" field is static. - - - - VLDTR_E_TD_ENUMVALNOTSN - "Enum's value__ field is not SpecialName." - Enum's "value__" field is not SpecialName. - - - - VLDTR_E_TD_ENUMFLDNOTST - "Enum's field is not static." - Enum's field is not static. - - - - VLDTR_E_TD_ENUMFLDNOTLIT - "Enum's field is not literal." - Enum's field is not literal. - - - - VLDTR_E_TD_ENUMNOLITFLDS - "Enum has no literal fields." - Enum has no literal fields. - - - - VLDTR_E_TD_ENUMFLDSIGMISMATCH - "Enum's field signature does not match value__ signature." - Enum's field sig does not match value__ sig. - - - - VLDTR_E_TD_ENUMVALNOT1ST - "Enum's value__ field is not first." - Enum's "value__" field is not first. - - - - VLDTR_E_FD_NOTVALUERTSN - "Field is RTSpecialName but name is not value__." - Field is RTSpecialName but name is not "value__". - - - - VLDTR_E_FD_VALUEPARNOTENUM - "Field value__ in not Enum class." - Field "value__" in not Enum class. - - - - VLDTR_E_FD_INSTINIFACE - "Instance field in interface." - Instance field in interface. - - - - VLDTR_E_FD_NOTPUBINIFACE - "Non-public field in interface." - Non-public field in interface. - - - - VLDTR_E_FMD_GLOBALNOTPUBPRIVSC - "Global field or method is neither Public nor PrivateScope." - Global field/method neither Public nor PrivateScope. - - - - VLDTR_E_FMD_GLOBALNOTSTATIC - "Global field or method is not static." - Global field/method not static. - - - - VLDTR_E_FD_GLOBALNORVA - "Global field has no RVA." - Global field has no RVA. - - - - VLDTR_E_MD_CTORZERORVA - ".ctor or .cctor has zero RVA." - .ctor,.cctor has zero RVA. - - - - VLDTR_E_FD_MARKEDNOMARSHAL - "Field is marked marshaled but has no marshaling record." - Field is marked marshaled but has no marshaling rec. - - - - VLDTR_E_FD_MARSHALNOTMARKED - "Field has marshaling record but is not marked marshaled." - Field has marshaling rec but is not marked marshaled. - - - - VLDTR_E_FD_MARKEDNODEFLT - "Field is marked HasDefault but has no const value." - Field is marked HasDefault but has no const value. - - - - VLDTR_E_FD_DEFLTNOTMARKED - "Field has const value record but is not marked HasDefault." - Field has const value rec but is not marked HasDefault. - - - - VLDTR_E_FMD_MARKEDNOSECUR - "Field or method is marked HasSecurity but has no security record." - Field/method is marked HasSecurity but has no security rec. - - - - VLDTR_E_FMD_SECURNOTMARKED - "Field or method has security record but is not marked HasSecurity." - Field/method has security rec but is not marked HasSecurity. - - - - VLDTR_E_FMD_PINVOKENOTSTATIC - "Field or method is PInvoke but is not marked Static." - Field/method is PInvoke but is not marked Static. - - - - VLDTR_E_FMD_MARKEDNOPINVOKE - "Field or method is marked PInvoke but has no ImplMap." - Field/method is marked PInvoke but has no ImplMap. - - - - VLDTR_E_FMD_PINVOKENOTMARKED - "Field or method has ImplMap but is not marked PInvoke." - Field/method has ImplMap but is not marked PInvoke. - - - - VLDTR_E_FMD_BADIMPLMAP - "Field or method has invalid ImplMap." - Field/method has invalid ImplMap - - - - VLDTR_E_IMAP_BADMODREF - "ImplMap has invalid ModuleRef." - ImplMap has invalid ModuleRef - - - - VLDTR_E_IMAP_BADMEMBER - "ImplMap has invalid MemberForwarded." - ImplMap has invalid MemberForwarded - - - - VLDTR_E_IMAP_BADIMPORTNAME - "ImplMap has invalid ImportName." - ImplMap has invalid ImportName - - - - VLDTR_E_IMAP_BADCALLCONV - "ImplMap has invalid call conv." - ImplMap has invalid call conv - - - - VLDTR_E_FMD_BADACCESSFLAG - "Field or method has invalid access flag." - Field/method has invalid access flag - - - - VLDTR_E_FD_INITONLYANDLITERAL - "Field is InitOnly and Literal." - Field is InitOnly and Literal - - - - VLDTR_E_FD_LITERALNOTSTATIC - "Field is Literal but not Static." - Field is Literal but not Static - - - - VLDTR_E_FMD_RTSNNOTSN - "Field or method is RTSpec.Name but not Spec.Name." - Field/method is RTSpec.Name but not Spec.Name - - - - VLDTR_E_MD_ABSTPARNOTABST - "Method is abstract, parent is not." - Method is abstract, parent is not - - - - VLDTR_E_MD_NOTSTATABSTININTF - "Method not static or abstract in interface." - Method not static or abstract in interface - - - - VLDTR_E_MD_NOTPUBININTF - "Method not public in interface." - Method not public in interface - - - - VLDTR_E_MD_CTORININTF - ".ctor in interface." - ctor in interface - - - - VLDTR_E_MD_GLOBALCTORCCTOR - "global .ctor or .cctor." - global ctor or cctor - - - - VLDTR_E_MD_CTORSTATIC - "static .ctor." - static ctor - - - - VLDTR_E_MD_CTORNOTSNRTSN - ".ctor or .cctor not marked SpecialName or RTSpecialName." - ctor,cctor not marked SpecialName,RTSpecialName - - - - VLDTR_E_MD_CTORVIRT - "virtual .ctor or .cctor." - virtual ctor,cctor - - - - VLDTR_E_MD_CTORABST - "abstract .ctor or .cctor." - abstract ctor,cctor - - - - VLDTR_E_MD_CCTORNOTSTATIC - "instance .cctor." - instance cctor - - - - VLDTR_E_MD_ZERORVA - "RVA set to zero, but method not abstract or pinvoke or runtime, or reverse." - RVA=0, method not abstract or pinvoke or runtime, or reverse - - - - VLDTR_E_MD_FINNOTVIRT - "Method is final and not virtual." - Method is final and not virtual - - - - VLDTR_E_MD_STATANDFINORVIRT - "Method is static and final or virtual." - Method is static and final or virtual - - - - VLDTR_E_MD_ABSTANDFINAL - "Method is abstract and final." - Method is abstract and final - - - - VLDTR_E_MD_ABSTANDIMPL - "Method is abstract and implemented." - Method is abstract and implemented - - - - VLDTR_E_MD_ABSTANDPINVOKE - "Method is abstract and pinvoke." - Method is abstract and pinvoke - - - - VLDTR_E_MD_ABSTNOTVIRT - "Method is abstract and not virtual." - Method is abstract and not virtual - - - - VLDTR_E_MD_NOTABSTNOTIMPL - "Method is not abstract and not implemented." - Method is not abstract and not implemented - - - - VLDTR_E_MD_NOTABSTBADFLAGSRVA - "Method is not abstract and not (non-zero RVA or PInvoke or runtime)." - Method is not abstract and not (RVA!=0 or pinvoke or runtime) - - - - VLDTR_E_MD_PRIVSCOPENORVA - "Method is PrivateScope and has RVA set to zero." - Method is PrivateScope and has RVA==0 - - - - VLDTR_E_MD_GLOBALABSTORVIRT - "Global method is abstract or virtual." - Global method is abstract or virtual - - - - VLDTR_E_SIG_LONGFORM - "Signature uses long form." - Signature uses long form - - - - VLDTR_E_MD_MULTIPLESEMANTICS - "Method has multiple semantics (warning)." - Method has multiple semantics (warning) - - - - VLDTR_E_MD_INVALIDSEMANTICS - "Method has invalid semantics (not event or property.)" - Method has invalid semantics (not event or prop) - - - - VLDTR_E_MD_SEMANTICSNOTEXIST - "Method has semantics association that does not exist." - Method has semantics assoc that does not exist - - - - VLDTR_E_MI_DECLNOTVIRT - "MethodImpl's Decl is not virtual." - MethodImpl's Decl is not virtual - - - - VLDTR_E_FMD_GLOBALITEM - "Global field or method (warning, CLS)." - Global field/method (warning,CLS) - - - - VLDTR_E_MD_MULTSEMANTICFLAGS - "Method has multiple semantic flags set." - Method has multiple semantic flags set - - - - VLDTR_E_MD_NOSEMANTICFLAGS - "Method has no semantic flags set." - Method has no semantic flags set - - - - VLDTR_E_FD_FLDINIFACE - "Field in Interface (warning, CLS)." - Field in Interface (warning, CLS) - - - - VLDTR_E_AS_HASHALGID - "Unrecognized Hash Alg ID (warning)." - Unrecognized Hash Alg ID (warning) - - - - VLDTR_E_AS_PROCID - "Unrecognized Processor ID in Assembly(warning)." - Unrecognized Processor ID in Assembly(warning) - - - - VLDTR_E_AR_PROCID - "Unrecognized Processor ID in AssemblyRef(warning)." - Unrecognized Processor ID in AssemblyRef(warning) - - - - VLDTR_E_CN_PARENTRANGE - "Constant: parent token out of range." - Constant: parent token out of range - - - - VLDTR_E_AS_BADFLAGS - "Invalid flags in Assembly." - Invalid flags in Assembly - - - - VLDTR_E_TR_HASTYPEDEF - "There is TypeDef with same name as TypeRef (warning)." - There is TypeDef with same name as TypeRef (warning) - - - - VLDTR_E_IFACE_BADIMPL - "In InterfaceImpl, the implementing token is not TypeDef." - In InterfaceImpl, the implementing token is not TypeDef - - - - VLDTR_E_IFACE_BADIFACE - "In InterfaceImpl, the implemented token is not TypeDef or TypeRef." - In InterfaceImpl, the implemented token is not TypeDef or TypeRef - - - - VLDTR_E_TD_SECURNOTMARKED - "TypeDef has security record but it is not marked HasSecurity." - TypeDef has security rec but not marked HasSecurity - - - - VLDTR_E_TD_MARKEDNOSECUR - "TypeDef marked HasSecurity but has no security record." - TypeDef marked HasSecurity but has no security rec - - - - VLDTR_E_MD_CCTORHASARGS - ".cctor has arguments." - .cctor has arguments - - - - VLDTR_E_CT_BADIMPL - "ExportedType has invalid Implementation." - ExportedType has invalid Implementation - - - - VLDTR_E_MI_ALIENBODY - "MethodImpl has body from other class." - MethodImpl has body from other class - - - - VLDTR_E_MD_CCTORCALLCONV - ".cctor has invalid calling convention." - .cctor has invalid calling convention - - - - VLDTR_E_MI_BADCLASS - "MethodImpl has invalid Class token." - MethodImpl has invalid Class token - - - - VLDTR_E_MI_CLASSISINTF - "MethodImpl declared in Interface." - MethodImpl declared in Interface - - - - VLDTR_E_MI_BADDECL - "MethodImpl has invalid MethodDeclaration token." - MethodImpl has invalid MethodDeclaration token - - - - VLDTR_E_MI_BADBODY - "MethodImpl has invalid MethodBody token." - MethodImpl has invalid MethodBody token - - - - VLDTR_E_MI_DUP - "MethodImpl has duplicate." - MethodImpl has duplicate - - - - VLDTR_E_FD_BADPARENT - "Bad field parent." - Bad field parent - - - - VLDTR_E_MD_PARAMOUTOFSEQ - "Parameter out of sequence (warning)." - Param out of sequence (warning) - - - - VLDTR_E_MD_PARASEQTOOBIG - "Parameter's sequence number exceeds number of arguments." - Param's sequence num exceeds num of args - - - - VLDTR_E_MD_PARMMARKEDNOMARSHAL - "Parameter marked HasMarshal, has no marshaling info." - Param marked HasMarshal, has no marshaling info - - - - VLDTR_E_MD_PARMMARSHALNOTMARKED - "Parameter has marshaling info, not marked HasMarshal." - Param has marshaling info, not marked HasMarshal - - - - VLDTR_E_MD_PARMMARKEDNODEFLT - "Parameter marked HasDefault, has no const value." - Param marked HasDefault, has no const value - - - - VLDTR_E_MD_PARMDEFLTNOTMARKED - "Parameter has const value, not marked HasDefault." - Param has const value, not marked HasDefault - - - - VLDTR_E_PR_BADSCOPE - "Property has invalid scope." - Prop has invalid scope - - - - VLDTR_E_PR_NONAME - "Property has no name." - Prop has no name - - - - VLDTR_E_PR_NOSIG - "Property has no signature." - Prop has no signature - - - - VLDTR_E_PR_DUP - "Property has a duplicate." - Prop has a duplicate - - - - VLDTR_E_PR_BADCALLINGCONV - "Property has bad calling convention." - Prop has bad calling convention - - - - VLDTR_E_PR_MARKEDNODEFLT - "Property marked HasDefault, has no const value." - Prop marked HasDefault, has no const value - - - - VLDTR_E_PR_DEFLTNOTMARKED - "Property has const value, not marked HasDefault." - Prop has const value, not marked HasDefault - - - - VLDTR_E_PR_BADSEMANTICS - "Property has method that is neither a Setter nor a Getter." - Prop has method not (Setter,Getter, or Other) - - - - VLDTR_E_PR_BADMETHOD - "Property has method with invalid token." - Prop has method with invalid token - - - - VLDTR_E_PR_ALIENMETHOD - "Property has method from another class." - Prop has method from another class - - - - VLDTR_E_CN_BLOBNOTNULL - "Const has non-null blob when it should not." - Const has non-null blob when it should not - - - - VLDTR_E_CN_BLOBNULL - "Const has null value blob." - Const has null value blob - - - - VLDTR_E_EV_BADSCOPE - "Event has invalid scope." - Event has invalid scope - - - - VLDTR_E_EV_NONAME - "Event has no name." - Event has no name - - - - VLDTR_E_EV_DUP - "Event has a duplicate." - Event has a duplicate - - - - VLDTR_E_EV_BADEVTYPE - "Event has invalid EventType." - Event has invalid EventType - - - - VLDTR_E_EV_EVTYPENOTCLASS - "Event's EventType is not a class." - Event's EventType is not a class - - - - VLDTR_E_EV_BADSEMANTICS - "Event has method not (AddOn,RemoveOn,Fire,Other)." - Event has method not (AddOn,RemoveOn,Fire,Other) - - - - VLDTR_E_EV_BADMETHOD - "Event has method with invalid token." - Event has method with invalid token - - - - VLDTR_E_EV_ALIENMETHOD - "Event has method from another class." - Event has method from another class - - - - VLDTR_E_EV_NOADDON - "Event has no AddOn method." - Event has no AddOn method - - - - VLDTR_E_EV_NOREMOVEON - "Event has no RemoveOn method." - Event has no RemoveOn method - - - - VLDTR_E_CT_DUPTDNAME - "ExportedType has same name as TypeDef." - ExportedType has same name as TypeDef - - - - VLDTR_E_MAR_BADOFFSET - "MRes refers to non-PE file with non-zero offset." - MRes refers to non-PE file with offset !=0 - - - - VLDTR_E_DS_BADOWNER - "Declarative security has invalid owner token." - Decl.security has invalid owner token - - - - VLDTR_E_DS_BADFLAGS - "Declarative security has invalid action flags." - Decl.security has invalid action flags - - - - VLDTR_E_DS_NOBLOB - "Declarative security has no permission blob." - Decl.security has no permission blob - - - - VLDTR_E_MAR_BADIMPL - "Manifest resource has invalid Implementation." - Manifest resource has invalid Implementation - - - - VLDTR_E_MR_VARARGCALLINGCONV - "MemberRef has VARARG calling conv. (CLS warning)." - MemberRef has VARARG calling conv. (CLS warning) - - - - VLDTR_E_MD_CTORNOTVOID - ".ctor or .cctor returns something other than void." - .ctor,.cctor returning not void - - - - VLDTR_E_EV_FIRENOTVOID - "Fire method returns something other than void." - Fire method returning not void - - - - VLDTR_E_AS_BADLOCALE - "Invalid locale." - Invalid locale - - - - VLDTR_E_CN_PARENTTYPE - "Constant has parent of invalid type." - Constant has parent of invalid type - - - - VLDTR_E_SIG_SENTINMETHODDEF - "E_T_SENTINEL in MethodDef signature." - E_T_SENTINEL in MethodDef signature - - - - VLDTR_E_SIG_SENTMUSTVARARG - "E_T_SENTINEL <=> VARARG." - E_T_SENTINEL <=> VARARG - - - - VLDTR_E_SIG_MULTSENTINELS - "Multiple E_T_SENTINELs." - Multiple E_T_SENTINELs - - - - VLDTR_E_SIG_LASTSENTINEL - "E_T_SENTINEL not followed by type." - E_T_SENTINEL not followed by type - - - - VLDTR_E_SIG_MISSARG - "Signature missing argument." - Signature missing argument - - - - VLDTR_E_SIG_BYREFINFIELD - "Field of ByRef type." - Field of ByRef type - - - - VLDTR_E_MD_SYNCMETHODINVTYPE - "Synchronized method in value class." - Synchronized method in value class - - - - VLDTR_E_TD_NAMETOOLONG - "TypeDef name too long." - TypeDef name too long - - - - VLDTR_E_AS_PROCDUP - "Duplicate Assembly Processor." - Duplicate Assembly Processor - - - - VLDTR_E_ASOS_DUP - "Duplicate Assembly OS (ID+ver.major+ver.minor)." - Duplicate Assembly OS (ID+ver.major+ver.minor) - - - - VLDTR_E_MAR_BADFLAGS - "Manifest Resource has bad flags." - Manifest Resource has bad flags - - - - VLDTR_E_CT_NOTYPEDEFID - "ExportedType has nil TypeDefId." - ExportedType has nil TypeDefId - - - - VLDTR_E_FILE_BADFLAGS - "File has bad flags." - File has bad flags - - - - VLDTR_E_FILE_NULLHASH - "File has no hash blob." - File has no hash blob - - - - VLDTR_E_MOD_NONAME - "Module has no name." - Module has no name - - - - VLDTR_E_MOD_NAMEFULLQLFD - "Module has fully-qualified name." - Module has fully-qualified name - - - - VLDTR_E_TD_RTSPCLNOTSPCL - "TypeDef is tdRTSpecialName but not tdSpecialName." - TypeDef is tdRTSpecialName but not tdSpecialName - - - - VLDTR_E_TD_EXTENDSIFACE - "TypeDef extends interface." - TypeDef extends interface - - - - VLDTR_E_MD_CTORPINVOKE - ".ctor or .cctor is PInvokeImpl." - .ctor,.cctor is PInvokeImpl - - - - VLDTR_E_TD_SYSENUMNOTCLASS - "System.Enum is not a class." - System.Enum is not a class - - - - VLDTR_E_TD_SYSENUMNOTEXTVTYPE - "System.Enum extends not System.ValueType." - System.Enum extends not System.ValueType - - - - VLDTR_E_MI_SIGMISMATCH - "MethodImpl's Decl and Body signatures mismatch." - MethodImpl's Decl and Body signatures mismatch - - - - VLDTR_E_TD_ENUMHASMETHODS - "TypeDef extends System.Enum but has methods." - TypeDef extends System.Enum but has methods - - - - VLDTR_E_TD_ENUMIMPLIFACE - "TypeDef extends System.Enum but implements an interface." - TypeDef extends System.Enum but impls interface(s) - - - - VLDTR_E_TD_ENUMHASPROP - "TypeDef extends System.Enum but has a property." - TypeDef extends System.Enum but has prop(s) - - - - VLDTR_E_TD_ENUMHASEVENT - "TypeDef extends System.Enum but has an event." - TypeDef extends System.Enum but has event(s) - - - - VLDTR_E_TD_BADMETHODLST - "TypeDef has MethodList > Nmethods+1." - TypeDef has MethodList > Nmethods+1 - - - - VLDTR_E_TD_BADFIELDLST - "TypeDef has FieldList > Nfields+1." - TypeDef has FieldList > Nfields+1 - - - - VLDTR_E_CN_BADTYPE - "Constant has wrong type." - Constant has wrong type - - - - VLDTR_E_TD_ENUMNOINSTFLD - "Enum has no instance fields." - Enum has no instance fields - - - - VLDTR_E_TD_ENUMMULINSTFLD - "Enum has multiple instance fields." - Enum has multiple instance fields - - - - VLDTR_E_INTERRUPTED - "Validator has been interrupted by the VEHandler." - Validator has been interrupted by the VEHandler. - - - - VLDTR_E_NOTINIT - "Validator failed to initialize correctly." - Validator failed to initialize correctly. - - - - CORDBG_E_UNRECOVERABLE_ERROR - "Unrecoverable API error." - Unrecoverable API error. - - - - CORDBG_E_PROCESS_TERMINATED - "Process was terminated." - Process was terminated. - - - - CORDBG_E_PROCESS_NOT_SYNCHRONIZED - "Process not synchronized." - Process not synchronized. - - - - CORDBG_E_CLASS_NOT_LOADED - "A class is not loaded." - A class is not loaded. - - - - CORDBG_E_IL_VAR_NOT_AVAILABLE - "An IL variable is not available at the current native IP." - An IL variable is not available at the - - - - CORDBG_E_BAD_REFERENCE_VALUE - "A reference value was found to be bad during dereferencing." - A reference value was found to be bad - - - - CORDBG_E_FIELD_NOT_AVAILABLE - "A field in a class is not available, because the runtime optimized it away." - A field in a class is not available, - - - - CORDBG_E_NON_NATIVE_FRAME - "'Native-frame-only' operation on non-native frame." - "Native frame only" operation on - - - - CORDBG_E_NONCONTINUABLE_EXCEPTION - "Cannot Continue on non-continuable exception." - Continue on non-continuable exception - - - - CORDBG_E_CODE_NOT_AVAILABLE - "The code is currently unavailable." - The code is currently unavailable - - - - CORDBG_E_FUNCTION_NOT_IL - "Attempt to get a ICorDebugFunction for a function that is not IL." - Attempt to get a ICorDebugFunction for - - - - CORDBG_E_CANT_SET_IP_INTO_FINALLY - "SetIP is not possible because SetIP would move EIP from outside of an exception handling finally clause to a point inside of one." - SetIP isn't possible, because SetIP would - - - - CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY - "SetIP is not possible because it would move EIP from within an exception handling finally clause to a point outside of one." - SetIP isn't possible because it would move - - - - CORDBG_E_CANT_SET_IP_INTO_CATCH - "SetIP is not possible, because SetIP would move EIP from outside of an exception handling catch clause to a point inside of one." - SetIP isn't possible, because SetIP would - - - - CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME - "SetIP cannot be done on any frame except the leaf frame." - Setip cannot be done on any frame except - - - - CORDBG_E_SET_IP_IMPOSSIBLE - "SetIP is not allowed." - SetIP isn't allowed. For example, there is - - - - CORDBG_E_FUNC_EVAL_BAD_START_POINT - "Func eval cannot work. Bad starting point." - Func eval can't work if we're, for example, - - - - CORDBG_E_INVALID_OBJECT - "This object value is no longer valid." - This object value is no longer valid. - - - - CORDBG_E_FUNC_EVAL_NOT_COMPLETE - "CordbEval::GetResult called before func eval has finished." - If you call CordbEval::GetResult before the - - - - CORDBG_E_INPROC_NOT_IMPL - "The in-process version of the debugging API does not support this function." - The inproc version of the debugging API - - - - CORDBG_E_STATIC_VAR_NOT_AVAILABLE - "A static variable is not available because it has not been initialized yet." - A static variable isn't available because - - - - CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS - "Cannot copy a VC with object refs in it." - Can't copy a VC with object refs in it. - - - - CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER - "SetIP cannot leave or enter a filter." - SetIP can't leave or enter a filter - - - - CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE - "JIT settings for ZAP modules cannot be changed." - You can't change JIT settings for ZAP - - - - CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64 - "SetIP is not possible because it would move EIP from within a finally clause to a point outside of one on WIN64 platforms." - SetIP isn't possible because it would move - - - - CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64 - "SetIP is not possible because it would move EIP from within a catch clause to a point outside of one on WIN64 platforms." - SetIP isn't possible because it would move - - - - CORDBG_E_REMOTE_CONNECTION_CONN_RESET - "The remote device closed the connection." - The remote device closed the connection. - - - - CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE - "The connection was closed due to a keep-alive failure." - The connection was closed due to akeep alive failure. - - - - CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR - "Generic error that the device connection has been broken with no chance for recovery." - Generic error that the device connection has been broken with no chance for recovery. - - - - CORDBG_E_CANT_SET_TO_JMC - "Cannot use JMC on this code (likely wrong JIT settings)." - Can't use JMC on this code (likely wrong jit settings). - - - - CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME - "Internal frame markers have no associated context." - Internal frame markers have no associated context. - - - - CORDBG_E_NOT_CHILD_FRAME - "The current frame is not a child frame." - The current frame is not a child frame. - - - - CORDBG_E_NON_MATCHING_CONTEXT - "The provided CONTEXT does not match the specified thread." - The provided CONTEXT does not match the specified thread. - The stack pointer in the provided CONTEXT must match the cached stack base and stack limit of the thread. - - - - - CORDBG_E_PAST_END_OF_STACK - "The stackwalker is now past the end of stack. No information is available." - The stackwalker is now past the end of stack. No information is available. - - - - CORDBG_E_FUNC_EVAL_CANNOT_UPDATE_REGISTER_IN_NONLEAF_FRAME - "Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument." - Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument. - - - - CORDBG_E_BAD_THREAD_STATE - "The state of the thread is invalid." - The state of the thread is invalid. - - - - CORDBG_E_DEBUGGER_ALREADY_ATTACHED - "This process has already been attached." - This process has already been attached to - - - - CORDBG_E_SUPERFLOUS_CONTINUE - "Returned from a call to Continue that was not matched with a stopping event." - Returned from a call to Continue that was - - - - CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME - "Cannot perfrom SetValue on non-leaf frames." - Can't perfrom SetValue on non-leaf frames. - - - - CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE - "When doing Edit and Continue, some JITs do not allow increasing the maximum level to which exception handling can be nested." - When doing EnC, some JITters don't let you - - - - CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED - "Tried to do Edit and Continue on a module that was not started in Edit and Continue mode." - Tried to do EnC on a module that wasn't - - - - CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION - "SetIP cannot be done on any exception." - Setip cannot be done on any exception - - - - CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL - "The 'variable' does not exist because it is a literal optimized away by the compiler." - The 'variable' doesn't exist because it is a - - - - CORDBG_E_PROCESS_DETACHED - "Process has been detached." - Process has been detached from - - - - CORDBG_E_ENC_METHOD_SIG_CHANGED - "Not allowed to change the signature of an existing method." - Not allowed to change the signature of an - - - - CORDBG_E_ENC_METHOD_NO_LOCAL_SIG - "Cannot get the local signature for the method." - Can't get the local signature for the method - - - - CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS - "Adding a field to a value or layout class is prohibited." - Adding a field to a value or layout class is prohibitted, - - - - CORDBG_E_ENC_CANT_CHANGE_FIELD - "Cannot change field after adding." - Once you've got a field, you're not allowed to change - - - - CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER - "Only support addition of private members." - Only support addition of private members. - - - - CORDBG_E_FIELD_NOT_STATIC - "GetStaticFieldValue called on a non-static field." - Returned if someone tries to call GetStaticFieldValue - - - - CORDBG_E_FIELD_NOT_INSTANCE - "Returned if someone tries to call GetStaticFieldValue on a non-instance field." - Returned if someone tries to call GetStaticFieldValue - - - - CORDBG_E_ENC_ZAPPED_WITHOUT_ENC - "If a zap file was created without the Edit and Continue flag set, then we cannot do Edit and Continue on it, no matter what." - If a zap file was created without the EnC flag set, then - - - - CORDBG_E_ENC_BAD_METHOD_INFO - "Lacking information about method." - Lacking information about method. - - - - CORDBG_E_ENC_JIT_CANT_UPDATE - "The JIT is unable to update the method." - The JIT is unable to update the method. - - - - CORDBG_E_ENC_MISSING_CLASS - "An internal structure about the class is missing." - An internal structure about the class is missing - - - - CORDBG_E_ENC_INTERNAL_ERROR - "Internal Runtime Error while doing Edit-and-Continue." - Generic message for "Something user doesn't control went wrong" message. - - - - CORDBG_E_ENC_HANGING_FIELD - "The field was added via Edit and Continue after the class was loaded." - The field was added via EnC after the class was loaded, and so instead of the the field being contiguous with the other fields, it's 'hanging' off the instance or type. This error is used to indicate that either the storage for this field is not yet available and so the field value cannot be read, or the debugger needs to use an EnC specific code path to get the value. - - - - CORDBG_E_MODULE_NOT_LOADED - "Module not loaded." - If the module isn't loaded, including if it's been unloaded. - - - - CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS - "Not allowed to change base class." - Not allowed to change which class something inherits from - - - - CORDBG_E_UNABLE_TO_SET_BREAKPOINT - "Cannot set a breakpoint here." - Can't set a breakpoint here. - - - - CORDBG_E_DEBUGGING_NOT_POSSIBLE - "Debugging is not possible due to an incompatibility within the CLR implementation." - Debugging isn't possible due to an incompatibility within the CLR implementation. - - - - CORDBG_E_KERNEL_DEBUGGER_ENABLED - "A kernel debugger is enabled on the system. User-mode debugging will trap to the kernel debugger." - Debugging isn't possible because a kernel debugger is enabled on the system. - - - - CORDBG_E_KERNEL_DEBUGGER_PRESENT - "A kernel debugger is present on the system. User-mode debugging will trap to the kernel debugger." - Debugging isn't possible because a kernel debugger is present on the system. - - - - CORDBG_E_HELPER_THREAD_DEAD - "The debugger's internal helper thread is dead." - The debugger's internal helper thread is dead. - - - - CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE - "Not allowed to change interface inheritance." - Not allowed to change interface inheritance. - - - - CORDBG_E_INCOMPATIBLE_PROTOCOL - "The debugger's protocol is incompatible with the debuggee." - The debugger's protocol is incompatible with the debuggee. - - - - CORDBG_E_TOO_MANY_PROCESSES - "The debugger can only handle a finite number of debuggees." - The debugger can only handle a finite number of debuggees. - - - - CORDBG_E_INTEROP_NOT_SUPPORTED - "Interop debugging is not supported." - Interop debugging is not supported - - - - CORDBG_E_NO_REMAP_BREAKPIONT - "Cannot call RemapFunction until have received RemapBreakpoint." - Cannot call RemapFunction until have received RemapBreakpoint - - - - CORDBG_E_OBJECT_NEUTERED - "Object is in a zombie state." - Object has been neutered (it's in a zombie state). - - - - CORPROF_E_FUNCTION_NOT_COMPILED - "Function not yet compiled." - Function not yet compiled. - - - - CORPROF_E_DATAINCOMPLETE - "The ID is not fully loaded/defined yet." - The ID is not fully loaded/defined yet. - - - - CORPROF_E_NOT_REJITABLE_METHODS - "The Module is not configured for updateable methods." - The Module is not configured for updateable methods. - - - - CORPROF_E_CANNOT_UPDATE_METHOD - "The Method could not be updated for re-JIT." - The Method could not be updated for re-jit. - - - - CORPROF_E_FUNCTION_NOT_IL - "The Method has no associated IL." - The Method has no associated IL - - - - CORPROF_E_NOT_MANAGED_THREAD - "The thread has never run managed code before." - The thread has never run managed code before - - - - CORPROF_E_CALL_ONLY_FROM_INIT - "The function may only be called during profiler initialization." - The function may only be called during profiler init - - - - CORPROF_E_INPROC_NOT_ENABLED - "In-process debugging must be enabled during initialization." - Inprocess debugging must be enabled during init - - - - CORPROF_E_JITMAPS_NOT_ENABLED - "Cannot get a JIT map becuase they are not enabled." - Can't get a JIT map becuase they are not enabled - - - - CORPROF_E_INPROC_ALREADY_BEGUN - "BeginInprocDebugging already called." - If a profiler tries to call BeginInprocDebugging more than - - - - CORPROF_E_INPROC_NOT_AVAILABLE - "In-process debugging not allowed at this point." - States that inprocess debugging not allowed at this point - - - - CORPROF_E_NOT_YET_AVAILABLE - "Requested information is not yet available." - This is a general error used to indicated that the information - - - - CORPROF_E_TYPE_IS_PARAMETERIZED - "The given type is a generic and cannot be used with this method." - The given type is a generic and cannot be used with this method. - - - - CORPROF_E_FUNCTION_IS_PARAMETERIZED - "The given function is a generic and cannot be used with this method." - The given function is a generic and cannot be used with this method. - - - - CORPROF_E_STACKSNAPSHOT_INVALID_TGT_THREAD - A profiler tried to walk the stack of an invalid thread - - - - CORPROF_E_STACKSNAPSHOT_UNMANAGED_CTX - A profiler can not walk a thread that is currently executing unmanaged code - - - - CORPROF_E_STACKSNAPSHOT_UNSAFE - A stackwalk at this point may cause dead locks or data corruption - - - - CORPROF_E_STACKSNAPSHOT_ABORTED - Stackwalking callback requested the walk to abort - - - - CORPROF_E_LITERALS_HAVE_NO_ADDRESS - Returned when asked for the address of a static that is a literal. - - - - CORPROF_E_UNSUPPORTED_CALL_SEQUENCE - A call was made at an unsupported time. Examples include illegally calling a profiling API method asynchronously, calling a method that might trigger a GC at an unsafe time, and calling a method at a time that could cause locks to be taken out of order. - - - - CORPROF_E_ASYNCHRONOUS_UNSAFE - A legal asynchronous call was made at an unsafe time (e.g., CLR locks are held) - - - - CORPROF_E_CLASSID_IS_ARRAY - The specified ClassID cannot be inspected by this function because it is an array - - - - CORPROF_E_CLASSID_IS_COMPOSITE - The specified ClassID is a non-array composite type (e.g., ref) and cannot be inspected - - - - CORPROF_E_PROFILER_DETACHING - The profiler's call into the CLR is disallowed because the profiler is attempting to detach. - - - - CORPROF_E_PROFILER_NOT_ATTACHABLE - The profiler does not support attaching to a live process. - - - - CORPROF_E_UNRECOGNIZED_PIPE_MSG_FORMAT - The message sent on the profiling API attach pipe is in an unrecognized format. - - - - CORPROF_E_PROFILER_ALREADY_ACTIVE - The request to attach a profiler was denied because a profiler is already loaded. - - - - CORPROF_E_PROFILEE_INCOMPATIBLE_WITH_TRIGGER - Unable to request a profiler attach because the target profilee's runtime is of a version incompatible with the current process calling AttachProfiler(). - - - - CORPROF_E_IPC_FAILED - AttachProfiler() encountered an error while communicating on the pipe to the target profilee. This is often caused by a target profilee that is shutting down or killed while AttachProfiler() is reading or writing the pipe. - - - - CORPROF_E_PROFILEE_PROCESS_NOT_FOUND - AttachProfiler() was unable to find a profilee with the specified process ID. - - - - CORPROF_E_CALLBACK3_REQUIRED - Profiler must implement ICorProfilerCallback3 interface for this call to be supported. - - - - CORPROF_E_UNSUPPORTED_FOR_ATTACHING_PROFILER - This call was attempted by a profiler that attached to the process after startup, but this call is only supported by profilers that are loaded into the process on startup. - - - - CORPROF_E_IRREVERSIBLE_INSTRUMENTATION_PRESENT - Detach is impossible because the profiler has either instrumented IL or inserted enter/leave hooks. Detach was not attempted; the profiler is still fully attached. - - - - CORPROF_E_RUNTIME_UNINITIALIZED - The profiler called a function that cannot complete because the CLR is not yet fully initialized. The profiler may try again once the CLR has fully started. - - - - CORPROF_E_IMMUTABLE_FLAGS_SET - Detach is impossible because immutable flags were set by the profiler at startup. Detach was not attempted; the profiler is still fully attached. - - - - CORPROF_E_PROFILER_NOT_YET_INITIALIZED - The profiler called a function that cannot complete because the profiler is not yet fully initialized. - - - - CORPROF_E_INCONSISTENT_WITH_FLAGS - The profiler called a function that first requires additional flags to be set in the event mask. This HRESULT may also indicate that the profiler called a function that first requires that some of the flags currently set in the event mask be reset. - - - - CORPROF_E_PROFILER_CANCEL_ACTIVATION - The profiler has requested that the CLR instance not load the profiler into this process. - - - - CORPROF_E_CONCURRENT_GC_NOT_PROFILABLE - Concurrent GC mode is enabled, which prevents use of COR_PRF_MONITOR_GC - - - - CORPROF_E_INCONSISTENT_FLAGS_WITH_HOST_PROTECTION_SETTING - Host enforces host protection attributes, which prevents use of COR_PRF_USE_PROFILE_IMAGES, COR_PRF_MONITOR_CODE_TRANSITIONS, and COR_PRF_MONITOR_ENTERLEAVE - - - - CORPROF_E_DEBUGGING_DISABLED - This functionality requires CoreCLR debugging to be enabled. - - - - CORPROF_E_TIMEOUT_WAITING_FOR_CONCURRENT_GC - Timed out on waiting for concurrent GC to finish during attach. - - - - CORPROF_E_MODULE_IS_DYNAMIC - The specified module was dynamically generated (e.g., via Reflection.Emit API), and is thus not supported by this API method. - - - - CORPROF_E_CALLBACK4_REQUIRED - Profiler must implement ICorProfilerCallback4 interface for this call to be supported. - - - - CORPROF_E_REJIT_NOT_ENABLED - This call is not supported unless ReJIT is first enabled during initialization by setting COR_PRF_ENABLE_REJIT via SetEventMask. - - - - CORPROF_E_ACTIVE_REJIT_REQUEST_NOT_FOUND - Could not revert the specified method, because a corresponding active ReJIT request was not found. Either the method was never requested to be reJITted OR the method was already reverted. - - - - CORPROF_E_FUNCTION_IS_COLLECTIBLE - The specified function is instantiated into a collectible assembly, and is thus not supported by this API method. - - - - CORPROF_E_REJIT_REQUIRES_DISABLE_NGEN - If the profiler specifies COR_PRF_ENABLE_REJIT to SetEventMask, it must also specify COR_PRF_DISABLE_ALL_NGEN_IMAGES. - - - - CORPROF_E_CALLBACK6_REQUIRED - Profiler must implement ICorProfilerCallback6 interface for this call to be supported. - - - - - - CORPROF_E_CALLBACK7_REQUIRED - Profiler must implement ICorProfilerCallback7 interface for this call to be supported. - - - - SECURITY_E_XML_TO_ASN_ENCODING - "Failed to convert XML to ASN." - Failed to convert XML to ASN - - - - SECURITY_E_INCOMPATIBLE_SHARE - "Loading this assembly would produce a different grant set from other instances." - Loading this assembly would produce a different grant set from other instances - - - - SECURITY_E_UNVERIFIABLE - "Unverifiable code failed policy check." - Unverifable code failed policy check - - - - SECURITY_E_INCOMPATIBLE_EVIDENCE - "Assembly already loaded without additional security evidence." - Assembly already loaded without additional security evidence. - - - - CORSEC_E_DECODE_SET - "Failure decoding permission set." - Failure decoding permission set - - - - CORSEC_E_ENCODE_SET - "Failure encoding permission set." - Failure encoding permission set - - - - CORSEC_E_UNSUPPORTED_FORMAT - "Unrecognized encoding format." - Unrecognized encoding format - - - - SN_CRYPTOAPI_CALL_FAILED - StrongName APIs not supported on system - - - - CORSEC_E_CRYPTOAPI_CALL_FAILED - "StrongName APIs not supported on system." - StrongName APIs not supported on system - - - - SN_NO_SUITABLE_CSP - StrongName APIs couldn't locate a matching CSP - - - - CORSEC_E_NO_SUITABLE_CSP - "StrongName APIs could not locate a matching CSP." - StrongName APIs couldn't locate a matching CSP - - - - CORSEC_E_INVALID_ATTR - "Invalid security custom attribute." - Invalid security custom attribute - - - - CORSEC_E_POLICY_EXCEPTION - "PolicyException thrown." - PolicyException thrown - - - - CORSEC_E_MIN_GRANT_FAIL - "Failed to grant minimum permission requests." - Failed to grant minimum permission requests - - - - CORSEC_E_NO_EXEC_PERM - "Failed to grant permission to execute." - Failed to grant permission to execute - - - - CORSEC_E_XMLSYNTAX - "XML Syntax error." - XML Syntax error - - - - CORSEC_E_INVALID_STRONGNAME - "Strong name validation failed." - Strong name validation failed - - - - CORSEC_E_MISSING_STRONGNAME - "Assembly is not strong named." - Assembly is not strong named - - - - CORSEC_E_CONTAINER_NOT_FOUND - "Strong name key container not found." - Strong name key container not found - - - - CORSEC_E_INVALID_IMAGE_FORMAT - "Invalid assembly file format." - Invalid assembly file format - - - - CORSEC_E_INVALID_PUBLICKEY - "Invalid assembly public key." - Invalid assembly public key - - - - CORSEC_E_SIGNATURE_MISMATCH - "Signature size mismatch." - Signature size mismatch - - - - SN_E_PUBLICKEY_MISMATCH - "Public key of assembly did not match signing public key." - Public key of assembly did not match signing public key - - - - CORSEC_E_INVALID_SIGNATUREKEY - "Invalid signature public key specified in AssemblySignatureKeyAttribute." - Invalid signature key (or invalid key format) specified in the assembly's attribute - - - - CORSEC_E_INVALID_COUNTERSIGNATURE - "Invalid countersignature specified in AssemblySignatureKeyAttribute." - Invalid signature (or invalid signature format) specified in the assembly's attribute - - - - CORSEC_E_CRYPTO - "Failure during Cryptographic operation." - generic CryptographicException - - - - CORSEC_E_CRYPTO_UNEX_OPER - "Unexpected Cryptographic operation." - generic CryptographicUnexpectedOperationException - - - - CORSECATTR_E_BAD_ATTRIBUTE - "Generic problem with a custom attribute." - Generic problem with a custom attribute - - - - CORSECATTR_E_MISSING_CONSTRUCTOR - "Missing a required constructor." - Missing a required constructor - - - - CORSECATTR_E_FAILED_TO_CREATE_PERM - "Unable to create a permission for this attribute." - Unable to create a permission for this attribute - - - - CORSECATTR_E_BAD_ACTION_ASM - "SecurityAction type invalid on assembly." - SecurityAction type invalid on assembly - - - - CORSECATTR_E_BAD_ACTION_OTHER - "SecurityAction type invalid on types and methods." - SecurityAction type invalid on types and methods - - - - CORSECATTR_E_BAD_PARENT - "Security custom attribute attached to invalid parent." - Security custom attribute attached to invalid parent - - - - CORSECATTR_E_TRUNCATED - "Bad custom attribute serialized blob." - Bad custom attribute serialized blob - - - - CORSECATTR_E_BAD_VERSION - "Bad custom attribute serialized blob version." - Bad custom attribute serialized blob version - - - - CORSECATTR_E_BAD_ACTION - "Invalid security action code." - Invalid security action code - - - - CORSECATTR_E_NO_SELF_REF - "CA reference to CA definition in same assembly." - CA ref to CA def'd in same assembly - - - - CORSECATTR_E_BAD_NONCAS - "Use of non-CAS permission with invalid action." - Use of non-CAS perm with invalid action - - - - CORSECATTR_E_ASSEMBLY_LOAD_FAILED - "Failed to load assembly containing CA (or required CA type)." - Failed to load assembly containing CA (or req'd CA type) - - - - CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX - "Failed to load assembly containing CA (or required CA type)." - Failed to load assembly containing CA (or req'd CA type) - - - - CORSECATTR_E_TYPE_LOAD_FAILED - "Failed to load CA type (or required CA type)." - Failed to load CA type (or reqd CA type) - - - - CORSECATTR_E_TYPE_LOAD_FAILED_EX - "Failed to load CA type (or required CA type)." - Failed to load CA type (or reqd CA type) - - - - CORSECATTR_E_ABSTRACT - "CA type is abstract." - CA type is abstract - - - - CORSECATTR_E_UNSUPPORTED_TYPE - "Security custom attributes do not support array or Type fields and properties." - Security custom attributes do not support array or Type fields and properties - - - - CORSECATTR_E_UNSUPPORTED_ENUM_TYPE - "Unsupported base type for enum field or property." - Unsupported base type for enum field/property - - - - CORSECATTR_E_NO_FIELD - "Could not find a CA field." - Couldn't find a CA field - - - - CORSECATTR_E_NO_PROPERTY - "Could not find a CA property." - Couldn't find a CA property - - - - CORSECATTR_E_EXCEPTION - "Unexpected exception." - Unexpected exception - - - - CORSECATTR_E_EXCEPTION_HR - "Unexpected exception." - Unexpected exception - - - - ISS_E_ISOSTORE_START - - - - ISS_E_ISOSTORE - "IsolatedStorage operation failed." - - - - ISS_E_OPEN_STORE_FILE - "Unable to open the store." - - - - ISS_E_OPEN_FILE_MAPPING - "Unable to create store file mapping." - - - - ISS_E_MAP_VIEW_OF_FILE - "Unable to map the store file." - - - - ISS_E_GET_FILE_SIZE - "Unable to determine store file size." - - - - ISS_E_CREATE_MUTEX - "Unable to create mutex." - - - - ISS_E_LOCK_FAILED - "Unable to lock the store." - - - - ISS_E_FILE_WRITE - "File Write failed." - - - - ISS_E_SET_FILE_POINTER - "Cannot set file pointer." - - - - ISS_E_CREATE_DIR - "Unable to create the store directory." - - - - ISS_E_STORE_NOT_OPEN - "Store must be open for this operation." - - - - ISS_E_CORRUPTED_STORE_FILE - "Store file is corrupt." - - - - ISS_E_STORE_VERSION - "Store version is not supported." - - - - ISS_E_FILE_NOT_MAPPED - "Store file is not mapped." - - - - ISS_E_BLOCK_SIZE_TOO_SMALL - "Block size is too small." - - - - ISS_E_ALLOC_TOO_LARGE - "Allocation size is too large." - - - - ISS_E_USAGE_WILL_EXCEED_QUOTA - "Allowed quota is fully used." - - - - ISS_E_TABLE_ROW_NOT_FOUND - "Row not found." - - - - ISS_E_DEPRECATE - "Unable to deprecate old store." - - - - ISS_E_CALLER - "Unable to determine the caller." - - - - ISS_E_PATH_LENGTH - "Path length is too long." - - - - ISS_E_MACHINE - "Machine Store is not supported." - - - - ISS_E_MACHINE_DACL - "The DACL for the machine store is incorrect or could not be created." - - - - ISS_E_ISOSTORE_END - - - - COR_E_EXCEPTION - "General Exception" - Base class for all exceptions in the runtime - - - - COR_E_SYSTEM - "System.Exception" - The base class for the runtime's "less serious" exceptions - - - - COR_E_ARGUMENTOUTOFRANGE - "An argument was out of its legal range." - An argument was out of its legal range. - - - - COR_E_ARRAYTYPEMISMATCH - "Attempted to store an object of the wrong type in an array." - Attempted to store an object of the wrong type in an array - - - - COR_E_CONTEXTMARSHAL - "Attempted to marshal an object across a context boundary." - - - - - COR_E_TIMEOUT - "Operation timed out." - - - - - COR_E_EXECUTIONENGINE - "Internal CLR error." - An internal error happened in the Common Language Runtime's Execution Engine - - - - COR_E_FIELDACCESS - "Access to this field is denied." - Access to this field is denied. - - - - COR_E_INDEXOUTOFRANGE - "Array subscript out of range." - Attempted to access an element within an array by using an index that is - - - - COR_E_INVALIDOPERATION - "An operation is not legal in the current state." - An operation is not legal in the current state. - - - - COR_E_SECURITY - "An error relating to security occurred." - An error relating to security occurred. - - - - COR_E_REMOTING - "An error relating to remoting occurred." - An error relating to remoting occurred. - - - - COR_E_SERIALIZATION - "An error relating to serialization occurred." - An error relating to serialization has occurred. - - - - COR_E_VERIFICATION - "A verification failure has occurred." - A verification failure occurred - - - - COR_E_SERVER - "An error relating to remoting occurred." - - - - COR_E_SERVICEDCOMPONENT - "An error relating to ServicedComponent occurred." - An error relating to ServicedComponent occurred. - - - - COR_E_METHODACCESS - "Access to this method is denied." - Access to this method is denied. - - - - COR_E_MISSINGFIELD - "Field does not exist." - An attempt was made to dynamically access a field that does not exist. - - - - COR_E_MISSINGMEMBER - "Member does not exist." - An attempt was made to dynamically invoke or access a field or method - - - - COR_E_MISSINGMETHOD - "Method does not exist." - An attempt was made to dynamically invoke a method that does not exist - - - - COR_E_MULTICASTNOTSUPPORTED - "Attempt to combine delegates that are not multicast." - Attempted to combine delegates that are not multicast - - - - COR_E_NOTSUPPORTED - "Operation is not supported." - The operation is not supported - - - - COR_E_OVERFLOW - "Arithmetic, casting or conversion operation overflowed or underflowed." - An arithmetic, casting, or conversion operation overflowed or underflowed. - - - - COR_E_RANK - "An array has the wrong number of dimensions for a particular operation." - An array has the wrong number of dimensions for a particular operation. - - - - COR_E_SYNCHRONIZATIONLOCK - "This operation must be called from a synchronized block." - Wait(), Notify() or NotifyAll() was called from an unsynchronized ** block of c - - - - COR_E_THREADINTERRUPTED - "Thread was interrupted from a waiting state." - Indicates that the thread was interrupted from a waiting state - - - - COR_E_MEMBERACCESS - "Access to this member is denied." - Access to this member is denied. - - - - COR_E_THREADSTATE - "Thread is in an invalid state for this operation." - Indicate that the Thread class is in an invalid state for the method call - - - - COR_E_THREADSTOP - "Thread is stopping." - Thrown into a thread to cause it to stop. This exception is typically not caught - - - - COR_E_TYPELOAD - "Could not find or load a type." - Could not find or load a specific type (class, enum, etc). - - - - COR_E_ENTRYPOINTNOTFOUND - "Could not find the specified DllImport entrypoint." - Could not find the specified DllImport entry point - - - - COR_E_DLLNOTFOUND - "Could not find the specified DllImport Dll." - Could not find the specified DllImport DLL. - - - - COR_E_THREADSTART - Indicate that a user thread fails to start. - - - - COR_E_INVALIDCOMOBJECT - "An invalid __ComObject has been used." - An invalid __ComObject has been used. - - - - COR_E_NOTFINITENUMBER - "Not a Number." - Thrown if value (a floating point number) is either the not a number value (NaN) or +- infinity value - - - - COR_E_DUPLICATEWAITOBJECT - "An object appears more than once in the wait objects array." - An object appears more than once in the wait objects array. - - - - COR_E_SEMAPHOREFULL - "Reached maximum count for semaphore." - Adding the given count to the semaphore would cause it to exceed its maximum count. - - - - COR_E_WAITHANDLECANNOTBEOPENED - "No semaphore of the given name exists." - No Semaphore of the given name exists. - - - - COR_E_ABANDONEDMUTEX - "The wait completed due to an abandoned mutex." - The wait completed due to an abandoned mutex. - - - - COR_E_THREADABORTED - "Thread has aborted." - Thrown into a thread to cause it to abort. Not catchable. - - - - COR_E_INVALIDOLEVARIANTTYPE - "OLE Variant has an invalid type." - The type of an OLE variant that was passed into the runtime is invalid. - - - - COR_E_MISSINGMANIFESTRESOURCE - "An expected resource in the assembly manifest was missing." - An expected resource in the assembly manifest was missing. - - - - COR_E_SAFEARRAYTYPEMISMATCH - "A mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata." - A mismatch has occurred between the runtime type of the array and the subtype recorded in the metadata - - - - COR_E_TYPEINITIALIZATION - "Uncaught exception during type initialization." - An exception was thrown by a type's initializer (.cctor). - - - - COR_E_MARSHALDIRECTIVE - "Invalid marshaling directives." - The marshaling directives are invalid. - - - - COR_E_MISSINGSATELLITEASSEMBLY - "An expected satellite assembly containing the ultimate fallback resources for a given culture was not found or could not be loaded." - An expected satellite assembly containing the ultimate fallback resources - - - - COR_E_FORMAT - "The format of one argument does not meet the contract of the method." - The format of one argument does not meet the contract of the method. - - - - COR_E_SAFEARRAYRANKMISMATCH - "A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata." - A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata - - - - COR_E_PLATFORMNOTSUPPORTED - "Operation is not supported on this platform." - The method is not supported on this platform - - - - COR_E_INVALIDPROGRAM - "Invalid IL or CLR metadata." - A program contained invalid IL or bad metadata. Usually this is a compiler bug. - - - - COR_E_OPERATIONCANCELED - "The operation was cancelled." - The operation was cancelled. - - - - COR_E_INSUFFICIENTMEMORY - Not enough memory was available for an operation. - - - - COR_E_RUNTIMEWRAPPED - An object that does not derive from System.Exception has been wrapped in a RuntimeWrappedException. - - - - COR_E_DEVICESNOTSUPPORTED - "Devices not supported." - - - - - COR_E_DATAMISALIGNED - "A datatype misalignment was detected in a load or store instruction." - A datatype misalignment was detected in a load or store instruction. - - - - COR_E_CODECONTRACTFAILED - "A managed code contract (ie, precondition, postcondition, invariant, or assert) failed." - A managed code contract (ie, precondition, postcondition, invariant, or assert) failed. - - - - COR_E_TYPEACCESS - "Access to this type is denied." - Access to this type is denied. - - - - COR_E_ACCESSING_CCW - "Fail to access a CCW because the corresponding managed object is already collected." - Fail to access a CCW because the corresponding managed object is already collected. - - - - COR_E_MAXMETHODSIZE - "A method in this assembly is greater than the maximum allowed method size." - This is Apollo only. - - - - - COR_E_KEYNOTFOUND - "The given key was not present in the dictionary." - - - - - COR_E_INSUFFICIENTEXECUTIONSTACK - "Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space." - Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. - - - - COR_E_APPLICATION - "Application exception" - The base class for all "less serious" exceptions. - - - - COR_E_INVALIDFILTERCRITERIA - "The given filter criteria does not match the filter content." - The given filter criteria does not match the filter contract. - - - - COR_E_REFLECTIONTYPELOAD - "Could not find or load a specific class that was requested through Reflection." - Could not find or load a specific class that was requested through Reflection - - - - COR_E_TARGET - "Attempt to invoke non-static method with a null Object." - - If you attempt to invoke a non-static method with a null Object - If you atte - - - - COR_E_TARGETINVOCATION - "Uncaught exception thrown by method called through Reflection." - If the method called throws an exception - - - - COR_E_CUSTOMATTRIBUTEFORMAT - "Custom attribute has invalid format." - If the binary format of a custom attribute is invalid. - - - - COR_E_IO - "Error during managed I/O." - Some sort of I/O error. - - - - COR_E_FILELOAD - "Could not find or load a specific file." - - - - - COR_E_OBJECTDISPOSED - "The object has already been disposed." - The object has already been disposed. - - - - COR_E_FAILFAST - "Runtime operation halted by call to System.Environment.FailFast()." - Runtime operation halted by call to System.Environment.FailFast(). - - - - COR_E_HOSTPROTECTION - "The host has forbidden this operation." - Attempted to perform an operation that was forbidden by the host. - - - - COR_E_ILLEGAL_REENTRANCY - "Attempted to call into managed code when executing inside a low level extensibility point." - Attempted to call into managed code when executing inside a low level extensibility point. - - - - CLR_E_SHIM_RUNTIMELOAD - "Failed to load the runtime." - Failed to load the runtime - - - - CLR_E_SHIM_RUNTIMEEXPORT - "Failed to find a required export in the runtime." - Failed to find a required export in the runtime - - - - CLR_E_SHIM_INSTALLROOT - "Install root is not defined." - Install root is not defined - - - - CLR_E_SHIM_INSTALLCOMP - "Expected component of the runtime is not available." - Expected component of the runtime is not available - - - - CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND - "A runtime has already been bound for legacy activation policy use." - - - - CLR_E_SHIM_SHUTDOWNINPROGRESS - "The operation is invalid because the process may be shutting down." - - - - VER_E_HRESULT - - - - VER_E_OFFSET - - - - VER_E_OPCODE - - - - VER_E_OPERAND - - - - VER_E_TOKEN - - - - VER_E_EXCEPT - - - - VER_E_STACK_SLOT - - - - VER_E_LOC - - - - VER_E_ARG - - - - VER_E_FOUND - - - - VER_E_EXPECTED - - - - VER_E_LOC_BYNAME - - - - VER_E_UNKNOWN_OPCODE - "Unknown opcode." - - - - VER_E_SIG_CALLCONV - "Unknown calling convention." - - - - VER_E_SIG_ELEMTYPE - "Unknown ELEMENT_TYPE." - - - - VER_E_RET_SIG - "[return sig]" - - - - VER_E_FIELD_SIG - "[field sig]" - - - - VER_E_OPEN_DLGT_PROT_ACC - "Protected method access through an open instance delegate is not verifiable." - - - - VER_E_INTERNAL - "Internal error." - - - - VER_E_STACK_TOO_LARGE - "Stack is too large." - - - - VER_E_ARRAY_NAME_LONG - "Array name is too long." - - - - VER_E_FALLTHRU - "fall through end of the method without returning" - - - - VER_E_TRY_GTEQ_END - "try start >= try end" - - - - VER_E_TRYEND_GT_CS - "try end > code size" - - - - VER_E_HND_GTEQ_END - "handler start >= handler end" - - - - VER_E_HNDEND_GT_CS - "handler end > code size" - - - - VER_E_FLT_GTEQ_CS - - - - VER_E_TRY_START - "Try starts in the middle of an instruction." - - - - VER_E_HND_START - "Handler starts in the middle of an instruction." - - - - VER_E_FLT_START - - - - VER_E_TRY_OVERLAP - "Try block overlap with another block." - - - - VER_E_TRY_EQ_HND_FIL - "Try and filter/handler blocks are equivalent." - - - - VER_E_TRY_SHARE_FIN_FAL - "Shared try has finally or fault handler." - - - - VER_E_HND_OVERLAP - "Handler block overlaps with another block." - - - - VER_E_HND_EQ - "Handler block is the same as another block." - - - - VER_E_FIL_OVERLAP - "Filter block overlaps with another block." - - - - VER_E_FIL_EQ - "Filter block is the same as another block." - - - - VER_E_FIL_CONT_TRY - "Filter contains try." - - - - VER_E_FIL_CONT_HND - "Filter contains handler." - - - - VER_E_FIL_CONT_FIL - "Nested filters." - - - - VER_E_FIL_GTEQ_CS - "filter >= code size" - - - - VER_E_FIL_START - "Filter starts in the middle of an instruction." - - - - VER_E_FALLTHRU_EXCEP - "fallthru the end of an exception block" - - - - VER_E_FALLTHRU_INTO_HND - "fallthru into an exception handler" - - - - VER_E_FALLTHRU_INTO_FIL - "fallthru into an exception filter" - - - - VER_E_LEAVE - "Leave from outside a try or catch block." - - - - VER_E_RETHROW - "Rethrow from outside a catch handler." - - - - VER_E_ENDFINALLY - "Endfinally from outside a finally handler" - - - - VER_E_ENDFILTER - "Endfilter from outside an exception filter block" - - - - VER_E_ENDFILTER_MISSING - "Missing Endfilter." - - - - VER_E_BR_INTO_TRY - "Branch into try block." - - - - VER_E_BR_INTO_HND - "Branch into exception handler block." - - - - VER_E_BR_INTO_FIL - "Branch into exception filter block." - - - - VER_E_BR_OUTOF_TRY - "Branch out of try block." - - - - VER_E_BR_OUTOF_HND - "Branch out of exception handler block." - - - - VER_E_BR_OUTOF_FIL - "Branch out of exception filter block." - - - - VER_E_BR_OUTOF_FIN - "Branch out of finally block." - - - - VER_E_RET_FROM_TRY - "Return out of try block." - - - - VER_E_RET_FROM_HND - "Return out of exception handler block." - - - - VER_E_RET_FROM_FIL - "Return out of exception filter block." - - - - VER_E_BAD_JMP_TARGET - "jmp / exception into the middle of an instruction." - - - - VER_E_PATH_LOC - "Non-compatible types depending on path." - - - - VER_E_PATH_THIS - "Init state for this differs depending on path." - - - - VER_E_PATH_STACK - "Non-compatible types on stack depending on path." - - - - VER_E_PATH_STACK_DEPTH - "Stack depth differs depending on path." - - - - VER_E_THIS - "Instance variable (this) missing." - - - - VER_E_THIS_UNINIT_EXCEP - "Uninitialized this on entering a try block." - - - - VER_E_THIS_UNINIT_STORE - "Store into this when it is uninitialized." - - - - VER_E_THIS_UNINIT_RET - "Return from .ctor when this is uninitialized." - - - - VER_E_THIS_UNINIT_V_RET - "Return from .ctor before all fields are initialized." - - - - VER_E_THIS_UNINIT_BR - "Branch back when this is uninitialized." - - - - VER_E_LDFTN_CTOR - "ldftn and ldvirtftn not allowed on .ctor." - - - - VER_E_STACK_NOT_EQ - "Non-compatible types on the stack." - - - - VER_E_STACK_UNEXPECTED - "Unexpected type on the stack." - - - - VER_E_STACK_EXCEPTION - "Missing stack slot for exception." - - - - VER_E_STACK_OVERFLOW - "Stack overflow." - - - - VER_E_STACK_UNDERFLOW - "Stack underflow." - - - - VER_E_STACK_EMPTY - "Stack empty." - - - - VER_E_STACK_UNINIT - "Uninitialized item on stack." - - - - VER_E_STACK_I_I4_I8 - "Expected I, I4, or I8 on the stack." - - - - VER_E_STACK_R_R4_R8 - "Expected R, R4, or R8 on the stack." - - - - VER_E_STACK_NO_R_I8 - "unexpected R, R4, R8, or I8 on the stack." - - - - VER_E_STACK_NUMERIC - "Expected numeric type on the stack." - - - - VER_E_STACK_OBJREF - "Expected an ObjRef on the stack." - - - - VER_E_STACK_P_OBJREF - "Expected address of an ObjRef on the stack." - - - - VER_E_STACK_BYREF - "Expected ByRef on the stack." - - - - VER_E_STACK_METHOD - "Expected pointer to function on the stack." - - - - VER_E_STACK_ARRAY_SD - "Expected single dimension array on the stack." - - - - VER_E_STACK_VALCLASS - "Expected value type instance on the stack." - - - - VER_E_STACK_P_VALCLASS - "Expected address of value type on the stack." - - - - VER_E_STACK_NO_VALCLASS - "Unexpected value type instance on the stack." - - - - VER_E_LOC_DEAD - "Local variable is unusable at this point." - - - - VER_E_LOC_NUM - "Unrecognized local variable number." - - - - VER_E_ARG_NUM - "Unrecognized argument number." - - - - VER_E_TOKEN_RESOLVE - "Unable to resolve token." - - - - VER_E_TOKEN_TYPE - "Unable to resolve type of the token." - - - - VER_E_TOKEN_TYPE_MEMBER - "Expected memberRef, memberDef or methodSpec token." - - - - VER_E_TOKEN_TYPE_FIELD - "Expected memberRef or fieldDef token." - - - - VER_E_TOKEN_TYPE_SIG - "Expected signature token." - - - - VER_E_UNVERIFIABLE - "Instruction cannot be verified." - - - - VER_E_LDSTR_OPERAND - "Operand does not point to a valid string ref." - - - - VER_E_RET_PTR_TO_STACK - "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator." - - - - VER_E_RET_VOID - "Stack must be empty on return from a void function." - - - - VER_E_RET_MISSING - "Return value missing on the stack." - - - - VER_E_RET_EMPTY - "Stack must contain only the return value." - - - - VER_E_RET_UNINIT - "Return uninitialized data." - - - - VER_E_ARRAY_ACCESS - "Illegal array access." - - - - VER_E_ARRAY_V_STORE - "Store non Object type into Object array." - - - - VER_E_ARRAY_SD - "Expected single dimension array." - - - - VER_E_ARRAY_SD_PTR - "Expected single dimension array of pointer types." - - - - VER_E_ARRAY_FIELD - "Array field access is denied." - - - - VER_E_ARGLIST - "Allowed only in vararg methods." - - - - VER_E_VALCLASS - "Value type expected." - - - - VER_E_METHOD_ACCESS - "Method is not visible." - - - - VER_E_FIELD_ACCESS - "Field is not visible." - - - - VER_E_DEAD - "Item is unusable at this point." - - - - VER_E_FIELD_STATIC - "Expected static field." - - - - VER_E_FIELD_NO_STATIC - "Expected non-static field." - - - - VER_E_ADDR - "Address of not allowed for this item." - - - - VER_E_ADDR_BYREF - "Address of not allowed for ByRef." - - - - VER_E_ADDR_LITERAL - "Address of not allowed for literal field." - - - - VER_E_INITONLY - "Cannot change initonly field outside its .ctor." - - - - VER_E_THROW - "Cannot throw this object." - - - - VER_E_CALLVIRT_VALCLASS - "Callvirt on a value type method." - - - - VER_E_CALL_SIG - "Call signature mismatch." - - - - VER_E_CALL_STATIC - "Static function expected." - - - - VER_E_CTOR - ".ctor expected." - - - - VER_E_CTOR_VIRT - "Cannot use callvirt on .ctor." - - - - VER_E_CTOR_OR_SUPER - "Only super::ctor or typeof(this)::ctor allowed here." - - - - VER_E_CTOR_MUL_INIT - "Possible call to .ctor more than once." - - - - VER_E_SIG - "Unrecognized signature." - - - - VER_E_SIG_ARRAY - "Cannot resolve Array type." - - - - VER_E_SIG_ARRAY_PTR - "Array of ELEMENT_TYPE_PTR." - - - - VER_E_SIG_ARRAY_BYREF - "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF." - - - - VER_E_SIG_ELEM_PTR - "ELEMENT_TYPE_PTR cannot be verified." - - - - VER_E_SIG_VARARG - "Unexpected vararg." - - - - VER_E_SIG_VOID - "Unexpected Void." - - - - VER_E_SIG_BYREF_BYREF - "ByRef of ByRef" - - - - VER_E_CODE_SIZE_ZERO - "Code size is zero." - - - - VER_E_BAD_VARARG - "Unrecognized use of vararg." - - - - VER_E_TAIL_CALL - "Missing call, callvirt or calli." - - - - VER_E_TAIL_BYREF - "Cannot pass ByRef to a tail call." - - - - VER_E_TAIL_RET - "Missing ret." - - - - VER_E_TAIL_RET_VOID - "Void ret type expected for tail call." - - - - VER_E_TAIL_RET_TYPE - "Tail call return type not compatible." - - - - VER_E_TAIL_STACK_EMPTY - "Stack not empty after tail call." - - - - VER_E_METHOD_END - "Method ends in the middle of an instruction." - - - - VER_E_BAD_BRANCH - "Branch out of the method." + + CORDBG_E_CLASS_NOT_LOADED + "A class is not loaded." + A class is not loaded. - - VER_E_FIN_OVERLAP - "Finally handler blocks overlap." + + CORDBG_E_IL_VAR_NOT_AVAILABLE + "An IL variable is not available at the current native IP." + An IL variable is not available at the - - VER_E_LEXICAL_NESTING - "Lexical nesting." + + CORDBG_E_BAD_REFERENCE_VALUE + "A reference value was found to be bad during dereferencing." + A reference value was found to be bad - - VER_E_VOLATILE - "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." + + CORDBG_E_FIELD_NOT_AVAILABLE + "A field in a class is not available, because the runtime optimized it away." + A field in a class is not available, - - VER_E_UNALIGNED - "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." + + CORDBG_E_NON_NATIVE_FRAME + "'Native-frame-only' operation on non-native frame." + "Native frame only" operation on - - VER_E_INNERMOST_FIRST - "Innermost exception blocks should be declared first." + + CORDBG_E_CODE_NOT_AVAILABLE + "The code is currently unavailable." + The code is currently unavailable - - VER_E_CALLI_VIRTUAL - "Calli not allowed on virtual methods." + + CORDBG_E_FUNCTION_NOT_IL + "Attempt to get a ICorDebugFunction for a function that is not IL." + Attempt to get a ICorDebugFunction for - - VER_E_CALL_ABSTRACT - "Call not allowed on abstract methods." + + CORDBG_E_CANT_SET_IP_INTO_FINALLY + "SetIP is not possible because SetIP would move EIP from outside of an exception handling finally clause to a point inside of one." + SetIP isn't possible, because SetIP would - - VER_E_STACK_UNEXP_ARRAY - "Unexpected array type on the stack." + + CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY + "SetIP is not possible because it would move EIP from within an exception handling finally clause to a point outside of one." + SetIP isn't possible because it would move - - VER_E_NOT_IN_GC_HEAP - "Value type with NotInGCHeap attribute being created on the GC heap." + + CORDBG_E_CANT_SET_IP_INTO_CATCH + "SetIP is not possible, because SetIP would move EIP from outside of an exception handling catch clause to a point inside of one." + SetIP isn't possible, because SetIP would - - VER_E_TRY_N_EMPTY_STACK - "Attempt to enter a try block with nonempty stack." + + CORDBG_E_SET_IP_NOT_ALLOWED_ON_NONLEAF_FRAME + "SetIP cannot be done on any frame except the leaf frame." + Setip cannot be done on any frame except - - VER_E_DLGT_CTOR - "Unrecognized arguments for delegate .ctor." + + CORDBG_E_SET_IP_IMPOSSIBLE + "SetIP is not allowed." + SetIP isn't allowed. For example, there is - - VER_E_DLGT_BB - "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method." + + CORDBG_E_FUNC_EVAL_BAD_START_POINT + "Func eval cannot work. Bad starting point." + Func eval can't work if we're, for example, - - VER_E_DLGT_PATTERN - "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)." + + CORDBG_E_INVALID_OBJECT + "This object value is no longer valid." + This object value is no longer valid. - - VER_E_DLGT_LDFTN - "Ldftn or ldvirtftn instruction required before call to a delegate .ctor." + + CORDBG_E_FUNC_EVAL_NOT_COMPLETE + "CordbEval::GetResult called before func eval has finished." + If you call CordbEval::GetResult before the - - VER_E_FTN_ABSTRACT - "Attempt to load address of an abstract method." + + CORDBG_E_STATIC_VAR_NOT_AVAILABLE + "A static variable is not available because it has not been initialized yet." + A static variable isn't available because - - VER_E_SIG_C_VC - "ELEMENT_TYPE_CLASS ValueClass in signature." + + CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER + "SetIP cannot leave or enter a filter." + SetIP can't leave or enter a filter - - VER_E_SIG_VC_C - "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature." + + CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE + "JIT settings for ZAP modules cannot be changed." + You can't change JIT settings for ZAP - - VER_E_BOX_PTR_TO_STACK - "Box operation on TypedReference, ArgHandle, or ArgIterator." + + CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64 + "SetIP is not possible because it would move EIP from within a finally clause to a point outside of one on WIN64 platforms." + SetIP isn't possible because it would move - - VER_E_SIG_BYREF_TB_AH - "ByRef of TypedReference, ArgHandle, or ArgIterator." + + CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64 + "SetIP is not possible because it would move EIP from within a catch clause to a point outside of one on WIN64 platforms." + SetIP isn't possible because it would move - - VER_E_SIG_ARRAY_TB_AH - "Array of TypedReference, ArgHandle, or ArgIterator." + + CORDBG_E_CANT_SET_TO_JMC + "Cannot use JMC on this code (likely wrong JIT settings)." + Can't use JMC on this code (likely wrong jit settings). - - VER_E_ENDFILTER_STACK - "Stack not empty when leaving an exception filter." + + CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME + "Internal frame markers have no associated context." + Internal frame markers have no associated context. - - VER_E_DLGT_SIG_I - "Unrecognized delegate .ctor signature; expected I." + + CORDBG_E_NOT_CHILD_FRAME + "The current frame is not a child frame." + The current frame is not a child frame. - - VER_E_DLGT_SIG_O - "Unrecognized delegate .ctor signature; expected Object." + + CORDBG_E_NON_MATCHING_CONTEXT + "The provided CONTEXT does not match the specified thread." + The provided CONTEXT does not match the specified thread. + The stack pointer in the provided CONTEXT must match the cached stack base and stack limit of the thread. + - - - VER_E_RA_PTR_TO_STACK - "Mkrefany on TypedReference, ArgHandle, or ArgIterator." + + + CORDBG_E_PAST_END_OF_STACK + "The stackwalker is now past the end of stack. No information is available." + The stackwalker is now past the end of stack. No information is available. - - VER_E_CATCH_VALUE_TYPE - "Value type not allowed as catch type." + + CORDBG_E_FUNC_EVAL_CANNOT_UPDATE_REGISTER_IN_NONLEAF_FRAME + "Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument." + Func eval cannot update a variable stored in a register on a non-leaf frame. The most likely cause is that such a variable is passed as a ref/out argument. - - VER_E_CATCH_BYREF - "ByRef not allowed as catch type." + + CORDBG_E_BAD_THREAD_STATE + "The state of the thread is invalid." + The state of the thread is invalid. - - VER_E_FIL_PRECEED_HND - "filter block should immediately precede handler block" + + CORDBG_E_DEBUGGER_ALREADY_ATTACHED + "This process has already been attached." + This process has already been attached to - - VER_E_LDVIRTFTN_STATIC - "ldvirtftn on static" + + CORDBG_E_SUPERFLOUS_CONTINUE + "Returned from a call to Continue that was not matched with a stopping event." + Returned from a call to Continue that was - - VER_E_CALLVIRT_STATIC - "callvirt on static" + + CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME + "Cannot perfrom SetValue on non-leaf frames." + Can't perfrom SetValue on non-leaf frames. - - VER_E_INITLOCALS - "initlocals must be set for verifiable methods with one or more local variables." + + CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED + "Tried to do Edit and Continue on a module that was not started in Edit and Continue mode." + Tried to do EnC on a module that wasn't - - VER_E_BR_TO_EXCEPTION - "branch or leave to the beginning of a catch/filter handler" + + CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION + "SetIP cannot be done on any exception." + Setip cannot be done on any exception - - VER_E_CALL_CTOR - "Call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj." + + CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL + "The 'variable' does not exist because it is a literal optimized away by the compiler." + The 'variable' doesn't exist because it is a - - VER_E_VALCLASS_OBJREF_VAR - "Value type, ObjRef type or variable type expected." + + CORDBG_E_PROCESS_DETACHED + "Process has been detached." + Process has been detached from - - VER_E_STACK_P_VALCLASS_OBJREF_VAR - "Expected address of value type, ObjRef type or variable type on the stack." + + CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS + "Adding a field to a value or layout class is prohibited." + Adding a field to a value or layout class is prohibitted, - - VER_E_SIG_VAR_PARAM - "Unrecognized type parameter of enclosing class." + + CORDBG_E_FIELD_NOT_STATIC + "GetStaticFieldValue called on a non-static field." + Returned if someone tries to call GetStaticFieldValue - - VER_E_SIG_MVAR_PARAM - "Unrecognized type parameter of enclosing method." + + CORDBG_E_FIELD_NOT_INSTANCE + "Returned if someone tries to call GetStaticFieldValue on a non-instance field." + Returned if someone tries to call GetStaticFieldValue - - VER_E_SIG_VAR_ARG - "Unrecognized type argument of referenced class instantiation." + + CORDBG_E_ENC_JIT_CANT_UPDATE + "The JIT is unable to update the method." + The JIT is unable to update the method. - - VER_E_SIG_MVAR_ARG - "Unrecognized type argument of referenced method instantiation." + + CORDBG_E_ENC_INTERNAL_ERROR + "Internal Runtime Error while doing Edit-and-Continue." + Generic message for "Something user doesn't control went wrong" message. - - VER_E_SIG_GENERICINST - "Cannot resolve generic type." + + CORDBG_E_ENC_HANGING_FIELD + "The field was added via Edit and Continue after the class was loaded." + The field was added via EnC after the class was loaded, and so instead of the the field being contiguous with the other fields, it's 'hanging' off the instance or type. This error is used to indicate that either the storage for this field is not yet available and so the field value cannot be read, or the debugger needs to use an EnC specific code path to get the value. - - VER_E_SIG_METHOD_INST - "Method instantiation contains non boxable type arguments." + + CORDBG_E_MODULE_NOT_LOADED + "Module not loaded." + If the module isn't loaded, including if it's been unloaded. - - VER_E_SIG_METHOD_PARENT_INST - "Method parent instantiation contains non boxable type arguments." + + CORDBG_E_UNABLE_TO_SET_BREAKPOINT + "Cannot set a breakpoint here." + Can't set a breakpoint here. - - VER_E_SIG_FIELD_PARENT_INST - "Field parent instantiation contains non boxable type arguments." + + CORDBG_E_DEBUGGING_NOT_POSSIBLE + "Debugging is not possible due to an incompatibility within the CLR implementation." + Debugging isn't possible due to an incompatibility within the CLR implementation. - - VER_E_CALLCONV_NOT_GENERICINST - "Unrecognized calling convention for an instantiated generic method." + + CORDBG_E_KERNEL_DEBUGGER_ENABLED + "A kernel debugger is enabled on the system. User-mode debugging will trap to the kernel debugger." + Debugging isn't possible because a kernel debugger is enabled on the system. - - VER_E_TOKEN_BAD_METHOD_SPEC - "Unrecognized generic method in method instantiation." + + CORDBG_E_KERNEL_DEBUGGER_PRESENT + "A kernel debugger is present on the system. User-mode debugging will trap to the kernel debugger." + Debugging isn't possible because a kernel debugger is present on the system. - - VER_E_BAD_READONLY_PREFIX - "Missing ldelema or call following readonly. prefix." + + CORDBG_E_INCOMPATIBLE_PROTOCOL + "The debugger's protocol is incompatible with the debuggee." + The debugger's protocol is incompatible with the debuggee. - - VER_E_BAD_CONSTRAINED_PREFIX - "Missing callvirt following constrained. prefix." + + CORDBG_E_TOO_MANY_PROCESSES + "The debugger can only handle a finite number of debuggees." + The debugger can only handle a finite number of debuggees. - - - VER_E_CIRCULAR_VAR_CONSTRAINTS - "Method parent has circular class type parameter constraints." + + + CORDBG_E_INTEROP_NOT_SUPPORTED + "Interop debugging is not supported." + Interop debugging is not supported - - VER_E_CIRCULAR_MVAR_CONSTRAINTS - "Method has circular method type parameter constraints." + + CORDBG_E_NO_REMAP_BREAKPIONT + "Cannot call RemapFunction until have received RemapBreakpoint." + Cannot call RemapFunction until have received RemapBreakpoint - - VER_E_UNSATISFIED_METHOD_INST - "Method instantiation has unsatisfied method type parameter constraints." + + CORDBG_E_OBJECT_NEUTERED + "Object is in a zombie state." + Object has been neutered (it's in a zombie state). - - VER_E_UNSATISFIED_METHOD_PARENT_INST - "Method parent instantiation has unsatisfied class type parameter constraints." + + CORPROF_E_FUNCTION_NOT_COMPILED + "Function not yet compiled." + Function not yet compiled. - - VER_E_UNSATISFIED_FIELD_PARENT_INST - "Field parent instantiation has unsatisfied class type parameter constraints." + + CORPROF_E_DATAINCOMPLETE + "The ID is not fully loaded/defined yet." + The ID is not fully loaded/defined yet. - - VER_E_UNSATISFIED_BOX_OPERAND - "Type operand of box instruction has unsatisfied class type parameter constraints." + + CORPROF_E_FUNCTION_NOT_IL + "The Method has no associated IL." + The Method has no associated IL - - VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS - "The 'this' argument to a constrained call must have ByRef type." + + CORPROF_E_NOT_MANAGED_THREAD + "The thread has never run managed code before." + The thread has never run managed code before - - VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE - "The operand to a constrained prefix instruction must be a type parameter." + + CORPROF_E_CALL_ONLY_FROM_INIT + "The function may only be called during profiler initialization." + The function may only be called during profiler init - - VER_E_READONLY_UNEXPECTED_CALLEE - "The readonly prefix may only be applied to calls to array methods returning ByRefs." - - - VER_E_READONLY_ILLEGAL_WRITE - "Illegal write to readonly ByRef." + + CORPROF_E_NOT_YET_AVAILABLE + "Requested information is not yet available." + This is a general error used to indicated that the information - - VER_E_READONLY_IN_MKREFANY - "A readonly ByRef cannot be used with mkrefany." + + CORPROF_E_TYPE_IS_PARAMETERIZED + "The given type is a generic and cannot be used with this method." + The given type is a generic and cannot be used with this method. - - VER_E_UNALIGNED_ALIGNMENT - "Alignment specified for 'unaligned' prefix must be 1, 2, or 4." + + CORPROF_E_FUNCTION_IS_PARAMETERIZED + "The given function is a generic and cannot be used with this method." + The given function is a generic and cannot be used with this method. - - VER_E_TAILCALL_INSIDE_EH - "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block." + + CORPROF_E_STACKSNAPSHOT_INVALID_TGT_THREAD + A profiler tried to walk the stack of an invalid thread - - VER_E_BACKWARD_BRANCH - "Stack height at all points must be determinable in a single forward scan of IL." + + CORPROF_E_STACKSNAPSHOT_UNMANAGED_CTX + A profiler can not walk a thread that is currently executing unmanaged code - - VER_E_CALL_TO_VTYPE_BASE - "Call to base type of valuetype." + + CORPROF_E_STACKSNAPSHOT_UNSAFE + A stackwalk at this point may cause dead locks or data corruption - - VER_E_NEWOBJ_OF_ABSTRACT_CLASS - "Cannot construct an instance of abstract class." + + CORPROF_E_STACKSNAPSHOT_ABORTED + Stackwalking callback requested the walk to abort - - VER_E_UNMANAGED_POINTER - "Unmanaged pointers are not a verifiable type." + + CORPROF_E_LITERALS_HAVE_NO_ADDRESS + Returned when asked for the address of a static that is a literal. - - VER_E_LDFTN_NON_FINAL_VIRTUAL - "Cannot LDFTN a non-final virtual method." + + CORPROF_E_UNSUPPORTED_CALL_SEQUENCE + A call was made at an unsupported time. Examples include illegally calling a profiling API method asynchronously, calling a method that might trigger a GC at an unsafe time, and calling a method at a time that could cause locks to be taken out of order. - - VER_E_FIELD_OVERLAP - "Accessing type with overlapping fields." + + CORPROF_E_ASYNCHRONOUS_UNSAFE + A legal asynchronous call was made at an unsafe time (e.g., CLR locks are held) - - VER_E_THIS_MISMATCH - "The 'this' parameter to the call must be the calling method's 'this' parameter." + + CORPROF_E_CLASSID_IS_ARRAY + The specified ClassID cannot be inspected by this function because it is an array - - VER_E_STACK_I_I4 - "Expected I4 on the stack." + + CORPROF_E_CLASSID_IS_COMPOSITE + The specified ClassID is a non-array composite type (e.g., ref) and cannot be inspected - - VER_E_BAD_PE - "Unverifiable PE Header/native stub." + + CORPROF_E_PROFILER_DETACHING + The profiler's call into the CLR is disallowed because the profiler is attempting to detach. - - VER_E_BAD_MD - "Unrecognized metadata, unable to verify IL." + + CORPROF_E_PROFILER_NOT_ATTACHABLE + The profiler does not support attaching to a live process. - - VER_E_BAD_APPDOMAIN - "Unrecognized appdomain pointer." + + CORPROF_E_UNRECOGNIZED_PIPE_MSG_FORMAT + The message sent on the profiling API attach pipe is in an unrecognized format. - - VER_E_TYPELOAD - "Type load failed." + + CORPROF_E_PROFILER_ALREADY_ACTIVE + The request to attach a profiler was denied because a profiler is already loaded. - - VER_E_PE_LOAD - "Module load failed." + + CORPROF_E_PROFILEE_INCOMPATIBLE_WITH_TRIGGER + Unable to request a profiler attach because the target profilee's runtime is of a version incompatible with the current process calling AttachProfiler(). - - VER_E_WRITE_RVA_STATIC - "Cannot modify an imaged based (RVA) static" + + CORPROF_E_IPC_FAILED + AttachProfiler() encountered an error while communicating on the pipe to the target profilee. This is often caused by a target profilee that is shutting down or killed while AttachProfiler() is reading or writing the pipe. - - VER_E_INITIALIZE_ARRAY_MISSING_TOKEN - "Ldtoken instruction required before call to System.Runtime.CompilerServices.InitializeArray." + + CORPROF_E_PROFILEE_PROCESS_NOT_FOUND + AttachProfiler() was unable to find a profilee with the specified process ID. - - COR_E_SqlException - System.Data.SqlClient.SqlClientException + + CORPROF_E_CALLBACK3_REQUIRED + Profiler must implement ICorProfilerCallback3 interface for this call to be supported. - - COR_E_Data + + CORPROF_E_UNSUPPORTED_FOR_ATTACHING_PROFILER + This call was attempted by a profiler that attached to the process after startup, but this call is only supported by profilers that are loaded into the process on startup. - - - COR_E_DataDeletedRowInaccessible + + + CORPROF_E_IRREVERSIBLE_INSTRUMENTATION_PRESENT + Detach is impossible because the profiler has either instrumented IL or inserted enter/leave hooks. Detach was not attempted; the profiler is still fully attached. - - COR_E_DataDuplicateName + + CORPROF_E_RUNTIME_UNINITIALIZED + The profiler called a function that cannot complete because the CLR is not yet fully initialized. The profiler may try again once the CLR has fully started. - - COR_E_DataInRowChangingEvent + + CORPROF_E_IMMUTABLE_FLAGS_SET + Detach is impossible because immutable flags were set by the profiler at startup. Detach was not attempted; the profiler is still fully attached. - - COR_E_DataInvalidConstraint + + CORPROF_E_PROFILER_NOT_YET_INITIALIZED + The profiler called a function that cannot complete because the profiler is not yet fully initialized. - - COR_E_DataMissingPrimaryKey + + CORPROF_E_INCONSISTENT_WITH_FLAGS + The profiler called a function that first requires additional flags to be set in the event mask. This HRESULT may also indicate that the profiler called a function that first requires that some of the flags currently set in the event mask be reset. - - COR_E_DataNoNullAllowed + + CORPROF_E_PROFILER_CANCEL_ACTIVATION + The profiler has requested that the CLR instance not load the profiler into this process. - - COR_E_DataReadOnly + + CORPROF_E_CONCURRENT_GC_NOT_PROFILABLE + Concurrent GC mode is enabled, which prevents use of COR_PRF_MONITOR_GC - - COR_E_DataRowNotInTable + + CORPROF_E_DEBUGGING_DISABLED + This functionality requires CoreCLR debugging to be enabled. - - COR_E_DataVersionNotFound + + CORPROF_E_TIMEOUT_WAITING_FOR_CONCURRENT_GC + Timed out on waiting for concurrent GC to finish during attach. - - COR_E_DataConstraint + + CORPROF_E_MODULE_IS_DYNAMIC + The specified module was dynamically generated (e.g., via Reflection.Emit API), and is thus not supported by this API method. - - COR_E_StrongTyping + + CORPROF_E_CALLBACK4_REQUIRED + Profiler must implement ICorProfilerCallback4 interface for this call to be supported. - - COR_E_SqlType + + CORPROF_E_REJIT_NOT_ENABLED + This call is not supported unless ReJIT is first enabled during initialization by setting COR_PRF_ENABLE_REJIT via SetEventMask. - - COR_E_SqlNullValue + + CORPROF_E_FUNCTION_IS_COLLECTIBLE + The specified function is instantiated into a collectible assembly, and is thus not supported by this API method. - - COR_E_SqlTruncate + + CORPROF_E_CALLBACK6_REQUIRED + Profiler must implement ICorProfilerCallback6 interface for this call to be supported. - - - COR_E_AdapterMapping + + + + + CORPROF_E_CALLBACK7_REQUIRED + Profiler must implement ICorProfilerCallback7 interface for this call to be supported. - - COR_E_DBConcurrency + + SECURITY_E_INCOMPATIBLE_SHARE + "Loading this assembly would produce a different grant set from other instances." + Loading this assembly would produce a different grant set from other instances - - COR_E_OperationAborted + + SECURITY_E_UNVERIFIABLE + "Unverifiable code failed policy check." + Unverifable code failed policy check - - COR_E_InvalidUdt + + SECURITY_E_INCOMPATIBLE_EVIDENCE + "Assembly already loaded without additional security evidence." + Assembly already loaded without additional security evidence. - - COR_E_OdbcException - System.Data.Odbc.OdbcException + + CORSEC_E_POLICY_EXCEPTION + "PolicyException thrown." + PolicyException thrown - - COR_E_OracleException - System.Data.OracleClient.OracleException + + CORSEC_E_MIN_GRANT_FAIL + "Failed to grant minimum permission requests." + Failed to grant minimum permission requests - - COR_E_Xml + + CORSEC_E_NO_EXEC_PERM + "Failed to grant permission to execute." + Failed to grant permission to execute - - COR_E_XmlSchema + + CORSEC_E_XMLSYNTAX + "XML Syntax error." + XML Syntax error - - COR_E_XmlXslt + + CORSEC_E_INVALID_STRONGNAME + "Strong name validation failed." + Strong name validation failed - - COR_E_XmlXPath + + CORSEC_E_MISSING_STRONGNAME + "Assembly is not strong named." + Assembly is not strong named - - COR_E_XmlQuery + + CORSEC_E_INVALID_IMAGE_FORMAT + "Invalid assembly file format." + Invalid assembly file format - - VLDTR_E_IFACE_NOTIFACE - "Interface in InterfaceImpl is not marked tdInterface." - Interface in InterfaceImpl is not marked tdInterface + + CORSEC_E_INVALID_PUBLICKEY + "Invalid assembly public key." + Invalid assembly public key - - VLDTR_E_FD_RVAHASNORVA - "Field marked fdHasFieldRVA but has no RVA record." - Field marked fdHasFieldRVA but has no RVA rec + + CORSEC_E_SIGNATURE_MISMATCH + "Signature size mismatch." + Signature size mismatch - - VLDTR_E_FD_RVAHASZERORVA - "Field marked fdHasFieldRVA has RVA set to zero." - Field marked fdHasFieldRVA has RVA =0 + + CORSEC_E_CRYPTO + "Failure during Cryptographic operation." + generic CryptographicException - - VLDTR_E_MD_RVAANDIMPLMAP - "Method has both non-zero RVA and ImplMap." - Method has both RVA !=0 and ImplMap + + CORSEC_E_CRYPTO_UNEX_OPER + "Unexpected Cryptographic operation." + generic CryptographicUnexpectedOperationException - - VLDTR_E_TD_EXTRAFLAGS - "TypeDef has extraneous bits in flags." - TypeDef has extraneous bits in flags + + CORSECATTR_E_BAD_ACTION + "Invalid security action code." + Invalid security action code - - VLDTR_E_TD_EXTENDSITSELF - "TypeDef extends itself." - TypeDef extends itself + + COR_E_EXCEPTION + "General Exception" + Base class for all exceptions in the runtime - - VLDTR_E_TD_SYSVTNOTEXTOBJ - "System.ValueType does not extend System.Object." - System.ValueType does not extend System.Object + + COR_E_SYSTEM + "System.Exception" + The base class for the runtime's "less serious" exceptions - - VLDTR_E_TD_EXTTYPESPEC - "Class extends TypeSpec (warning)." - Class extends TypeSpec (warning) + + COR_E_ARGUMENTOUTOFRANGE + "An argument was out of its legal range." + An argument was out of its legal range. - - VLDTR_E_TD_VTNOSIZE - "Value Class has zero size." - Value Class has zero size + + COR_E_ARRAYTYPEMISMATCH + "Attempted to store an object of the wrong type in an array." + Attempted to store an object of the wrong type in an array - - VLDTR_E_TD_IFACESEALED - "Interface is sealed." - Interface is sealed + + COR_E_CONTEXTMARSHAL + "Attempted to marshal an object across a context boundary." + - - VLDTR_E_NC_BADNESTED - "Bad 'nested' token in NestedClass." - Bad "nested" token in NestedClass + + COR_E_TIMEOUT + "Operation timed out." + - - VLDTR_E_NC_BADENCLOSER - "Bad 'enclosing' token in NestedClass." - Bad "enclosing" token in NestedClass + + COR_E_EXECUTIONENGINE + "Internal CLR error." + An internal error happened in the Common Language Runtime's Execution Engine - - VLDTR_E_NC_DUP - "Duplicate NestedClass record." - Duplicate NestedClass record + + COR_E_FIELDACCESS + "Access to this field is denied." + Access to this field is denied. - - VLDTR_E_NC_DUPENCLOSER - "Duplicate NestedClass with different encloser." - Duplicate NestedClass with different encloser + + COR_E_INDEXOUTOFRANGE + "Array subscript out of range." + Attempted to access an element within an array by using an index that is - - VLDTR_E_FRVA_ZERORVA - "RVA set to zero in FieldRVA record." - RVA=0 in FieldRVA record + + COR_E_INVALIDOPERATION + "An operation is not legal in the current state." + An operation is not legal in the current state. - - VLDTR_E_FRVA_BADFIELD - "Invalid field token in FieldRVA record." - Invalid field token in FieldRVA record + + COR_E_SECURITY + "An error relating to security occurred." + An error relating to security occurred. - - VLDTR_E_FRVA_DUPRVA - "Duplicate RVA in FieldRVA record." - Duplicate RVA in FieldRVA record - - - VLDTR_E_FRVA_DUPFIELD - "Duplicate field in FieldRVA record." - Duplicate field in FieldRVA record + + COR_E_SERIALIZATION + "An error relating to serialization occurred." + An error relating to serialization has occurred. - - VLDTR_E_EP_BADTOKEN - "Bad token as entry point in CLR header." - Bad token as entry point in CLR header + + COR_E_VERIFICATION + "A verification failure has occurred." + A verification failure occurred - - VLDTR_E_EP_INSTANCE - "Entry point in CLR header is a token of instance method." - Entry point in CLR header is a token of instance method + + COR_E_METHODACCESS + "Access to this method is denied." + Access to this method is denied. - - VLDTR_E_TD_ENUMFLDBADTYPE - "Enum has non-integral underlying type." - Enum has non-integral underlying type + + COR_E_MISSINGFIELD + "Field does not exist." + An attempt was made to dynamically access a field that does not exist. - - VLDTR_E_MD_BADRVA - "Method has bogus RVA." - Method has bogus RVA + + COR_E_MISSINGMEMBER + "Member does not exist." + An attempt was made to dynamically invoke or access a field or method - - VLDTR_E_FD_LITERALNODEFAULT - "Literal field has no const value." - Literal field has no const value + + COR_E_MISSINGMETHOD + "Method does not exist." + An attempt was made to dynamically invoke a method that does not exist - - VLDTR_E_IFACE_METHNOTIMPL - "Class implementing an interface does not implement one of methods." - Class implementing an interface doesn't impl.one of methods + + COR_E_MULTICASTNOTSUPPORTED + "Attempt to combine delegates that are not multicast." + Attempted to combine delegates that are not multicast - - VLDTR_E_CA_BADPARENT - "CA has invalid owner." - CA has invalid owner + + COR_E_NOTSUPPORTED + "Operation is not supported." + The operation is not supported - - VLDTR_E_CA_BADTYPE - "CA has invalid type." - CA has invalid type + + COR_E_OVERFLOW + "Arithmetic, casting or conversion operation overflowed or underflowed." + An arithmetic, casting, or conversion operation overflowed or underflowed. - - VLDTR_E_CA_NOTCTOR - "CA type is not .ctor." - CA type is not .ctor + + COR_E_RANK + "An array has the wrong number of dimensions for a particular operation." + An array has the wrong number of dimensions for a particular operation. - - VLDTR_E_CA_BADSIG - "CA type has bad signature." - CA type has bad signature + + COR_E_SYNCHRONIZATIONLOCK + "This operation must be called from a synchronized block." + Wait(), Notify() or NotifyAll() was called from an unsynchronized ** block of c - - VLDTR_E_CA_NOSIG - "CA type has no signature." - CA type has no signature + + COR_E_THREADINTERRUPTED + "Thread was interrupted from a waiting state." + Indicates that the thread was interrupted from a waiting state - - VLDTR_E_CA_BADPROLOG - "CA blob has bad prolog (not 0x01 0x00)." - CA blob has bad prolog (not 0x01 0x00) + + COR_E_MEMBERACCESS + "Access to this member is denied." + Access to this member is denied. - - VLDTR_E_MD_BADLOCALSIGTOK - "Method has invalid LocalSig token." - Method has invalid LocalSig token + + COR_E_THREADSTATE + "Thread is in an invalid state for this operation." + Indicate that the Thread class is in an invalid state for the method call - - VLDTR_E_MD_BADHEADER - "Method has invalid header." - Method has invalid header + + COR_E_THREADSTOP + "Thread is stopping." + Thrown into a thread to cause it to stop. This exception is typically not caught - - VLDTR_E_EP_TOOMANYARGS - "Entry point has more than one argument." - Entry point has more than one arg + + COR_E_TYPELOAD + "Could not find or load a type." + Could not find or load a specific type (class, enum, etc). - - VLDTR_E_EP_BADRET - "Entry point has bad return type." - Entry point has bad return type + + COR_E_ENTRYPOINTNOTFOUND + "Could not find the specified DllImport entrypoint." + Could not find the specified DllImport entry point - - VLDTR_E_EP_BADARG - "Entry point has bad argument." - Entry point has bad argument + + COR_E_DLLNOTFOUND + "Could not find the specified DllImport Dll." + Could not find the specified DllImport DLL. - - VLDTR_E_SIG_BADVOID - "Illegal 'void' in signature." - Illegal "void" in signature + + COR_E_THREADSTART + Indicate that a user thread fails to start. - - VLDTR_E_IFACE_METHMULTIMPL - "Multiple implementation of method." - Multiple implementation of method + + COR_E_INVALIDCOMOBJECT + "An invalid __ComObject has been used." + An invalid __ComObject has been used. - - VLDTR_E_GP_NAMENULL - "GenericParam name is NULL." - GenericParam name is NULL + + COR_E_NOTFINITENUMBER + "Not a Number." + Thrown if value (a floating point number) is either the not a number value (NaN) or +- infinity value - - VLDTR_E_GP_OWNERNIL - "GenericParam has nil owner." - GenericParam has nil owner. + + COR_E_DUPLICATEWAITOBJECT + "An object appears more than once in the wait objects array." + An object appears more than once in the wait objects array. - - VLDTR_E_GP_DUPNAME - "GenericParam has duplicate by owner and name." - GenericParam has duplicate by owner and name. + + COR_E_SEMAPHOREFULL + "Reached maximum count for semaphore." + Adding the given count to the semaphore would cause it to exceed its maximum count. - - VLDTR_E_GP_DUPNUMBER - "GenericParam has duplicate by owner and number." - GenericParam has duplicate by owner and number. + + COR_E_WAITHANDLECANNOTBEOPENED + "No semaphore of the given name exists." + No Semaphore of the given name exists. - - VLDTR_E_GP_NONSEQ_BY_OWNER - "GenericParam is non sequential by owner." - GenericParam is non sequential by owner + + COR_E_ABANDONEDMUTEX + "The wait completed due to an abandoned mutex." + The wait completed due to an abandoned mutex. - - VLDTR_E_GP_NONSEQ_BY_NUMBER - "GenericParam is non sequential by number." - GenericParam is non sequential by number + + COR_E_THREADABORTED + "Thread has aborted." + Thrown into a thread to cause it to abort. Not catchable. - - VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR - "GenericParam has variance but its owner is not an interface or delegate." - GenericParam has variance but its owner is not an interface or delegate + + COR_E_INVALIDOLEVARIANTTYPE + "OLE Variant has an invalid type." + The type of an OLE variant that was passed into the runtime is invalid. - - VLDTR_E_GP_ILLEGAL_VARIANT_MVAR - "GenericParam is a method type parameter and must be non-variant." - GenericParam is a method type parameter and must be non-variant + + COR_E_MISSINGMANIFESTRESOURCE + "An expected resource in the assembly manifest was missing." + An expected resource in the assembly manifest was missing. - - VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS - "GenericParam has illegal value for variance flags." - GenericParam has illegal value for variance flags + + COR_E_SAFEARRAYTYPEMISMATCH + "A mismatch has occurred between the runtime type of the array and the sub type recorded in the metadata." + A mismatch has occurred between the runtime type of the array and the subtype recorded in the metadata - - VLDTR_E_GP_REFANDVALUETYPE - "GenericParam has incompatible special constraints reference type and valuetype." - GenericParam has incompatible special constraints reference type and valuetype + + COR_E_TYPEINITIALIZATION + "Uncaught exception during type initialization." + An exception was thrown by a type's initializer (.cctor). - - VLDTR_E_GPC_OWNERNIL - "GenericParamConstraint has nil owner." - GenericParamConstraint has nil owner + + COR_E_MARSHALDIRECTIVE + "Invalid marshaling directives." + The marshaling directives are invalid. - - VLDTR_E_GPC_DUP - "GenericParamConstraint has duplicate by owner and constraint." - GenericParamConstraint has duplicate by owner and constraint + + COR_E_MISSINGSATELLITEASSEMBLY + "An expected satellite assembly containing the ultimate fallback resources for a given culture was not found or could not be loaded." + An expected satellite assembly containing the ultimate fallback resources - - VLDTR_E_GPC_NONCONTIGUOUS - "GenericParamConstraint is non-contiguous with preceeding constraints for same owner." - GenericParamConstraint is non-contiguous with preceeding constraints for same owner + + COR_E_FORMAT + "The format of one argument does not meet the contract of the method." + The format of one argument does not meet the contract of the method. - - VLDTR_E_MS_METHODNIL - "MethodSpec has nil method." - MethodSpec has nil method + + COR_E_SAFEARRAYRANKMISMATCH + "A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata." + A mismatch has occurred between the runtime rank of the array and the rank recorded in the metadata - - VLDTR_E_MS_DUP - "MethodSpec has duplicate based on method and instantiation." - MethodSpec has duplicate based own method and instantiation + + COR_E_PLATFORMNOTSUPPORTED + "Operation is not supported on this platform." + The method is not supported on this platform - - VLDTR_E_MS_BADCALLINGCONV - "MethodSpec signature has invalid calling convention." - MethodSpec signature has invalid calling convention + + COR_E_INVALIDPROGRAM + "Invalid IL or CLR metadata." + A program contained invalid IL or bad metadata. Usually this is a compiler bug. - - VLDTR_E_MS_MISSARITY - "MethodSpec signature is missing arity specification." - MethodSpec signature is missing arity specification + + COR_E_OPERATIONCANCELED + "The operation was cancelled." + The operation was cancelled. - - VLDTR_E_MS_MISSARG - "MethodSpec signature is missing type argument." - MethodSpec signature is missing type argument + + COR_E_INSUFFICIENTMEMORY + Not enough memory was available for an operation. - - VLDTR_E_MS_ARITYMISMATCH - "MethodSpec arity of generic method and instantiation do not match." - MethodSpec arity of generic method and instantiation do not match + + COR_E_RUNTIMEWRAPPED + An object that does not derive from System.Exception has been wrapped in a RuntimeWrappedException. - - VLDTR_E_MS_METHODNOTGENERIC - "MethodSpec method is not generic." - MethodSpec method is not generic + + COR_E_DATAMISALIGNED + "A datatype misalignment was detected in a load or store instruction." + A datatype misalignment was detected in a load or store instruction. - - VLDTR_E_SIG_MISSARITY - "Signature missing arity of instantiated generic type." - Signature missing arity of instantiated generic type + + COR_E_CODECONTRACTFAILED + "A managed code contract (ie, precondition, postcondition, invariant, or assert) failed." + A managed code contract (ie, precondition, postcondition, invariant, or assert) failed. - - VLDTR_E_SIG_ARITYMISMATCH - "Signature has generic type of arity instantiated at different arity." - Signature has generic type of arity instantiated at different arity + + COR_E_TYPEACCESS + "Access to this type is denied." + Access to this type is denied. - - VLDTR_E_MD_GENERIC_CCTOR - "Method cannot be both generic and a class constructor." - Method cannot be both generic and a class constructor + + COR_E_ACCESSING_CCW + "Fail to access a CCW because the corresponding managed object is already collected." + Fail to access a CCW because the corresponding managed object is already collected. - - VLDTR_E_MD_GENERIC_CTOR - "Method cannot be both generic and an instance constructor." - Method cannot be both generic and an instance constructor + + COR_E_KEYNOTFOUND + "The given key was not present in the dictionary." + - - VLDTR_E_MD_GENERIC_IMPORT - "Method cannot be both generic and defined on an imported type." - Method cannot be both generic and defined on an imported type + + COR_E_INSUFFICIENTEXECUTIONSTACK + "Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space." + Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. - - VLDTR_E_MD_GENERIC_BADCALLCONV - "Method cannot be both generic and have non-default calling convention." - Method cannot be both generic and have non-default calling convention + + COR_E_APPLICATION + "Application exception" + The base class for all "less serious" exceptions. - - VLDTR_E_EP_GENERIC_METHOD - "Entry point in CLR header is the token for a generic method." - Entry point in CLR header is the token for a generic method + + COR_E_INVALIDFILTERCRITERIA + "The given filter criteria does not match the filter content." + The given filter criteria does not match the filter contract. - - VLDTR_E_MD_MISSARITY - "Method signature is generic but is missing its arity." - Method signature is generic but is missing its arity + + COR_E_REFLECTIONTYPELOAD + "Could not find or load a specific class that was requested through Reflection." + Could not find or load a specific class that was requested through Reflection - - VLDTR_E_MD_ARITYZERO - "Method signature is generic but its arity is zero." - Method signature is generic but its arity is zero + + COR_E_TARGET + "Attempt to invoke non-static method with a null Object." + - If you attempt to invoke a non-static method with a null Object - If you atte - - VLDTR_E_SIG_ARITYZERO - "Signature has generic type instantiated at arity 0." - Signature has generic type instantiated at arity 0 + + COR_E_TARGETINVOCATION + "Uncaught exception thrown by method called through Reflection." + If the method called throws an exception - - VLDTR_E_MS_ARITYZERO - "MethodSpec signature has arity 0." - MethodSpec signature has arity 0 + + COR_E_CUSTOMATTRIBUTEFORMAT + "Custom attribute has invalid format." + If the binary format of a custom attribute is invalid. - - VLDTR_E_MD_GPMISMATCH - "MethodDef signature has arity n but owns m GenericParams." - MethodDef signature has arity n but owns m GenericParams + + COR_E_IO + "Error during managed I/O." + Some sort of I/O error. - - VLDTR_E_EP_GENERIC_TYPE - "Entry point in CLR header is the token for a method in a generic type." - Entry point in CLR header is the token for a method in a generic type + + COR_E_FILELOAD + "Could not find or load a specific file." + - - VLDTR_E_MI_DECLNOTGENERIC - "MethodImpl overrides non-generic method with generic method." - MethodImpl overrides non-generic method with generic method + + COR_E_OBJECTDISPOSED + "The object has already been disposed." + The object has already been disposed. - - VLDTR_E_MI_IMPLNOTGENERIC - "MethodImpl overrides non-generic method with generic method." - MethodImpl overrides non-generic method with generic method + + COR_E_FAILFAST + "Runtime operation halted by call to System.Environment.FailFast()." + Runtime operation halted by call to System.Environment.FailFast(). - - VLDTR_E_MI_ARITYMISMATCH - "MethodImpl overrides generic method of arity n with generic method of arity m." - MethodImpl overrides generic method of arity n with generic method of arity m + + COR_E_HOSTPROTECTION + "The host has forbidden this operation." + Attempted to perform an operation that was forbidden by the host. - - VLDTR_E_TD_EXTBADTYPESPEC - "TypeDef extends a TypeSpec that is not an instantiated type." - TypeDef extends a TypeSpec that is not an instantiated type + + COR_E_ILLEGAL_REENTRANCY + "Attempted to call into managed code when executing inside a low level extensibility point." + Attempted to call into managed code when executing inside a low level extensibility point. - - VLDTR_E_SIG_BYREFINST - "Signature has type instantiated at ByRef at offset i." - Signature has type instantiated at byref at offset i + + CLR_E_SHIM_RUNTIMELOAD + "Failed to load the runtime." + Failed to load the runtime - - VLDTR_E_MS_BYREFINST - "Signature has type instantiated at ByRef at offset i." - Signature has type instantiated at byref at offset i + + CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND + "A runtime has already been bound for legacy activation policy use." - - VLDTR_E_TS_EMPTY - "TypeSpec has empty signature." - TypeSpec has empty signature + + VER_E_FIELD_SIG + "[field sig]" - - VLDTR_E_TS_HASSENTINALS - "TypeSpec has signature containing one or more sentinels." - TypeSpec has signature containing one or more sentinals + + VER_E_CIRCULAR_VAR_CONSTRAINTS + "Method parent has circular class type parameter constraints." - - VLDTR_E_TD_GENERICHASEXPLAYOUT - "TypeDef is generic but has explicit layout." - TypeDef is generic but has explicit layout + + VER_E_CIRCULAR_MVAR_CONSTRAINTS + "Method has circular method type parameter constraints." - - VLDTR_E_SIG_BADTOKTYPE - "Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef." - Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef + + COR_E_Data - - VLDTR_E_IFACE_METHNOTIMPLTHISMOD - "Warning: Class does not implement interface method in this module." - Warn:Class doesn't implement interface method in this module + + VLDTR_E_SIG_BADVOID + "Illegal 'void' in signature." + Illegal "void" in signature - - TLBX_E_CIRCULAR_EXPORT2 - "TypeLib export: attempted to export an Assembly imported from a TLB." - TypeLib export: attempt to export a CLB imported from a TLB. + + VLDTR_E_GP_ILLEGAL_VARIANT_MVAR + "GenericParam is a method type parameter and must be non-variant." + GenericParam is a method type parameter and must be non-variant @@ -6261,12 +1804,6 @@ Cant intercept this exception. - - CORDBG_E_CANT_UNWIND_ABOVE_CALLBACK - "When intercepting an exception, cannot intercept above the current frame." - When intercepting an exception, cannot intercept above the current frame. - - CORDBG_E_INTERCEPT_FRAME_ALREADY_SET "The intercept frame for this exception has already been set." @@ -6309,36 +1846,18 @@ Method was not JITed in EnC mode - - CORDBG_E_ENC_NESTED_HANLDERS - "Frame cannot be updated due to change in max nesting of handlers." - Frame cant be updated due to change in max nesting of handlers - - CORDBG_E_ENC_IN_FUNCLET "Method is in a callable handler/filter. Cannot increase stack." Method is in a callable handler/filter. Cant grow stack - - CORDBG_E_ENC_LOCALLOC - "Frame cannot be updated due to localloc." - Frame cant be updated due to localloc - - CORDBG_E_ENC_EDIT_NOT_SUPPORTED "Attempt to perform unsupported edit." Attempt to perform unsupported edit - - CORDBG_E_FEABORT_DELAYED_UNTIL_THREAD_RESUMED - "Attempt to func eval abort on a suspended thread." - Attempt to func eval abort on a suspended thread. - - CORDBG_E_NOTREADY "The LS is not in a good spot to perform the requested operation." @@ -6441,12 +1960,6 @@ The operation failed because the thread is in optimized code. - - CORDBG_E_MINIDUMP_UNSUPPORTED - "The information requested is not supported by minidumps." - - - CORDBG_E_APPDOMAIN_MISMATCH "A supplied object or type belongs to the wrong AppDomain." @@ -6538,42 +2051,6 @@ A debug component is not installed - - CORDBG_E_REMOTE_MISMATCHED_CERTS - "Connection authentication failed due to mismatched certificates." - Connection authentication failed due to mismatched certificates - - - - CORDBG_E_REMOTE_NETWORK_FAILURE - "Connection failed due to a miscellaneous network error." - Connection failed due to a miscellaneous network error - - - - CORDBG_E_REMOTE_NO_LISTENER - "Connection failed due to no endpoint at remote machine (no proxy configured?)." - Connection failed due to no endpoint at remote machine (no proxy configured?) - - - - CORDBG_E_REMOTE_UNKNOWN_TARGET - "Connection failed due to inability to locate remote machine." - Connection failed due to inability to locate remote machine - - - - CORDBG_E_REMOTE_INVALID_CONFIG - "Local debugger configuration was missing or invalid." - Local debugger configuration was missing or invalid - - - - CORDBG_E_REMOTE_MISMATCHED_PROTOCOLS - "Connection failed due to protocol version mismatch between local and remote components." - Connection failed due to protocol version mismatch between local and remote components - - CORDBG_E_LIBRARY_PROVIDER_ERROR "The ICLRDebuggingLibraryProvider callback returned an error or did not provide a valid handle." @@ -6658,192 +2135,30 @@ Failure when calling a data target method. - - CORDBG_E_CODE_HAS_NO_METADATA - "Couldn't find metadata for the given executable code." - Couldn't find metadata for the given executable code. - - - - CORDBG_E_CODE_UNRECOGNIZED - "Given executable code is not managed." - Given executable code is not managed. - - CORDBG_E_NO_IMAGE_AVAILABLE "Couldn't find a native image." Couldn't find a native image. - - CORDBG_E_TYPE_NOT_FOUND - "The type doesn't exist in the given module." - The type doesn't exist in the given module. - - - - CORDBG_E_VTABLE_HAS_NO_METADATA - "Couldn't find metadata for the given vtable." - Couldn't find metadata for the given vtable. - - - - CORDBG_E_NO_GENERIC_INFO - "Couldn't find any generics information." - Couldn't find any generics information. - - - - PEFMT_E_NO_CONTENTS - "File is empty." - File is empty - - - - PEFMT_E_NO_NTHEADERS - "File has no NT headers." - File has no NT headers - - PEFMT_E_64BIT "File is PE32+." File is PE32+ - - PEFMT_E_NO_CORHEADER - "File has no COR header." - File has no COR header - - - - PEFMT_E_NOT_ILONLY - "Flag IL_ONLY not set." - Flag IL_ONLY not set - - - - PEFMT_E_IMPORT_DLLS - "Bad import DLLs." - Bad import DLLs - - - - PEFMT_E_EXE_NOENTRYPOINT - "EXE file has no mgd entry point." - EXE file has no mgd entry point - - - - PEFMT_E_BASE_RELOCS - "Bad base relocations." - Bad base relocations - - - - PEFMT_E_ENTRYPOINT - "Bad managed entry point." - Bad managed entry point - - - - PEFMT_E_ZERO_SIZEOFCODE - "OptHeader.SizeOfCode is set to zero." - OptHeader.SizeOfCode==0 - - - - PEFMT_E_BAD_CORHEADER - "File has invalid COR header." - File has invalid COR header - - PEFMT_E_32BIT "File is PE32" File is PE32 - - CLR_OPTSVC_E_CONTROLLER_INTERRUPT - "The operation was interrupted by the CLR Optimization Service controller." - Service controller interrupted work - - - - NGEN_FAILED_GET_DEPENDENCIES - "Failed to get dependencies for assembly." - Service manager failed to get ICorSvcDependencies interface - - - - NGEN_FAILED_NATIVE_IMAGE_DELETE - "Failed to delete native image." - Failed to delete native image - - - - NGEN_E_TOO_MANY_INTERFACES - "Module contains too many interfaces to successfully compile all methods." - Module contains too many interfaces to successfully compile all methods. - - - - NGEN_E_OLDER_RUNTIME - "Requested runtime does not support side-by-side NGen." - Requested runtime does not support side-by-side NGen. - - - - NGEN_E_WORKER_UNEXPECTED_EXIT - "Worker exited unexpectedly during startup" - An NGen worker process exited before it could be reached via DCOM. - - - - NGEN_E_WORKER_UNEXPECTED_SYNC - "Failed to synchronize with worker during startup" - Synchronizing with an NGen worker process returned an unexpected result. - - NGEN_E_SYS_ASM_NI_MISSING "NGen cannot proceed because Mscorlib.dll does not have a native image" Compiling any assembly other than mscorlib in the absence of mscorlib.ni.dll is not allowed. - - NGEN_E_EXE_MACHINE_TYPE_MISMATCH - "The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies." - The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies. - - - - NGEN_E_ASSEMBLY_EXCLUSION_FILE_PARSE_ERROR - "There was an error parsing the NGen assembly exclusion Xml file." - There was an error parsing the NGen assembly exclusion Xml file. - - - - NGEN_E_HARDBOUND_DEPENDENCY_MISSING - "A hardbound dependent native image is missing." - A hardbound dependent native image is missing. - - - - NGEN_E_NOT_RUNNING_IN_EXPECTED_PACKAGE - "NGen is not running in expected package." - NGen is not running in expected package. - - - - NGEN_E_FILE_NOT_ASSEMBLY - "The image being compiled is not a .NET assembly" - The image being compiled is not a .NET assembly - - CLDB_E_INTERNALERROR @@ -6938,11 +2253,6 @@ 0x80070216 // Overflow or underflow in mathematical operations. - - COR_E_BAD_PATHNAME - The specified path is invalid. - - COR_E_PATHTOOLONG The specified path was too long. diff --git a/src/inc/corinfo.h b/src/inc/corinfo.h index d430412f3bc5..89cd95f758b0 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 = { /* 0ba106c8-81a0-407f-99a1-928448c1eb62 */ - 0x0ba106c8, - 0x81a0, - 0x407f, - {0x99, 0xa1, 0x92, 0x84, 0x48, 0xc1, 0xeb, 0x62} +SELECTANY const GUID JITEEVersionIdentifier = { /* 45aafd4d-1d23-4647-9ce1-cf09a2677ca0 */ + 0x45aafd4d, + 0x1d23, + 0x4647, + {0x9c, 0xe1, 0xcf, 0x09, 0xa2, 0x67, 0x7c, 0xa0} }; ////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -977,8 +977,9 @@ enum CorInfoIntrinsics enum InfoAccessType { IAT_VALUE, // The info value is directly available - IAT_PVALUE, // The value needs to be accessed via an indirection - IAT_PPVALUE // The value needs to be accessed via a double indirection + IAT_PVALUE, // The value needs to be accessed via an indirection + IAT_PPVALUE, // The value needs to be accessed via a double indirection + IAT_RELPVALUE // The value needs to be accessed via a relative indirection }; enum CorInfoGCType @@ -1243,6 +1244,7 @@ struct CORINFO_METHOD_INFO // Constant Lookups are either: // IAT_VALUE: immediate (relocatable) values, // IAT_PVALUE: immediate values access via an indirection through an immediate (relocatable) address +// IAT_RELPVALUE: immediate values access via a relative indirection through an immediate offset // IAT_PPVALUE: immediate values access via a double indirection through an immediate (relocatable) address // // Runtime Lookups @@ -1268,9 +1270,10 @@ struct CORINFO_CONST_LOOKUP // If the handle is obtained at compile-time, then this handle is the "exact" handle (class, method, or field) // Otherwise, it's a representative... // If accessType is - // IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address - // IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle - // IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle + // IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address + // IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle + // IAT_RELPVALUE --> "addr" stores a relative pointer to a location which will hold the real handle + // IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle InfoAccessType accessType; union @@ -1361,6 +1364,7 @@ struct CORINFO_LOOKUP // Otherwise, it's a representative... If accessType is // IAT_VALUE --> "handle" stores the real handle or "addr " stores the computed address // IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle + // IAT_RELPVALUE --> "addr" stores a relative pointer to a location which will hold the real handle // IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle CORINFO_CONST_LOOKUP constLookup; }; @@ -1926,6 +1930,21 @@ struct CORINFO_VarArgInfo #include +#define SIZEOF__CORINFO_Object TARGET_POINTER_SIZE /* methTable */ + +#define OFFSETOF__CORINFO_Array__length SIZEOF__CORINFO_Object +#ifdef _TARGET_64BIT_ +#define OFFSETOF__CORINFO_Array__data (OFFSETOF__CORINFO_Array__length + sizeof(unsigned __int32) /* length */ + sizeof(unsigned __int32) /* alignpad */) +#else +#define OFFSETOF__CORINFO_Array__data (OFFSETOF__CORINFO_Array__length + sizeof(unsigned __int32) /* length */) +#endif + +#define OFFSETOF__CORINFO_TypedReference__dataPtr 0 +#define OFFSETOF__CORINFO_TypedReference__type (OFFSETOF__CORINFO_TypedReference__dataPtr + TARGET_POINTER_SIZE /* dataPtr */) + +#define OFFSETOF__CORINFO_String__stringLen SIZEOF__CORINFO_Object +#define OFFSETOF__CORINFO_String__chars (OFFSETOF__CORINFO_String__stringLen + sizeof(unsigned __int32) /* stringLen */) + enum CorInfoSecurityRuntimeChecks { CORINFO_ACCESS_SECURITY_NONE = 0, @@ -1944,9 +1963,6 @@ struct DelegateCtorArgs // use offsetof to get the offset of the fields above #include // offsetof -#ifndef offsetof -#define offsetof(s,m) ((size_t)&(((s *)0)->m)) -#endif // Guard-stack cookie for preventing against stack buffer overruns typedef SIZE_T GSCookie; @@ -3153,6 +3169,12 @@ class ICorDynamicInfo : public ICorStaticInfo CORINFO_SIG_INFO *pSig, CorInfoHelperTailCallSpecialHandling flags ) = 0; + + // Optionally, convert calli to regular method call. This is for PInvoke argument marshalling. + virtual bool convertPInvokeCalliToCall( + CORINFO_RESOLVED_TOKEN * pResolvedToken, + bool fMustConvert + ) = 0; }; /**********************************************************************************/ diff --git a/src/inc/corjithost.h b/src/inc/corjithost.h index 8242fab2b87c..b2ab80646ba3 100644 --- a/src/inc/corjithost.h +++ b/src/inc/corjithost.h @@ -15,15 +15,11 @@ class ICorJitHost { public: - // Allocate memory of the given size in bytes. All bytes of the returned block - // must be initialized to zero. If `usePageAllocator` is true, the implementation - // should use an allocator that deals in OS pages if one exists. - virtual void* allocateMemory(size_t size, bool usePageAllocator = false) = 0; + // Allocate memory of the given size in bytes. + virtual void* allocateMemory(size_t size) = 0; - // Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. The - // value of the `usePageAllocator` parameter must match the value that was - // provided to the call to used to allocate the memory. - virtual void freeMemory(void* block, bool usePageAllocator = false) = 0; + // Frees memory previous obtained by a call to `ICorJitHost::allocateMemory`. + virtual void freeMemory(void* block) = 0; // Return an integer config value for the given key, if any exists. virtual int getIntConfigValue( @@ -43,6 +39,20 @@ class ICorJitHost virtual void freeStringConfigValue( const wchar_t* value ) = 0; + + // Allocate memory slab of the given size in bytes. The host is expected to pool + // these for a good performance. + virtual void* allocateSlab(size_t size, size_t* pActualSize) + { + *pActualSize = size; + return allocateMemory(size); + } + + // Free memory slab of the given size in bytes. + virtual void freeSlab(void* slab, size_t actualSize) + { + freeMemory(slab); + } }; #endif diff --git a/src/inc/corpriv.h b/src/inc/corpriv.h index edd55e911103..9641b05644bb 100644 --- a/src/inc/corpriv.h +++ b/src/inc/corpriv.h @@ -309,9 +309,6 @@ typedef enum CorOpenFlagsInternal #endif // %%Classes: ---------------------------------------------------------------- -#ifndef offsetof -#define offsetof(s,f) ((ULONG)(&((s*)0)->f)) -#endif #ifndef lengthof #define lengthof(rg) (sizeof(rg)/sizeof(rg[0])) #endif diff --git a/src/inc/crsttypes.h b/src/inc/crsttypes.h index c4ccfff2c6b5..f0fbca4efd42 100644 --- a/src/inc/crsttypes.h +++ b/src/inc/crsttypes.h @@ -177,18 +177,19 @@ enum CrstType CrstThreadpoolWorker = 158, CrstThreadStaticDataHashTable = 159, CrstThreadStore = 160, - CrstTPMethodTable = 161, - CrstTypeEquivalenceMap = 162, - CrstTypeIDMap = 163, - CrstUMEntryThunkCache = 164, - CrstUMThunkHash = 165, - CrstUniqueStack = 166, - CrstUnresolvedClassLock = 167, - CrstUnwindInfoTableLock = 168, - CrstVSDIndirectionCellLock = 169, - CrstWinRTFactoryCache = 170, - CrstWrapperTemplate = 171, - kNumberOfCrstTypes = 172 + CrstTieredCompilation = 161, + CrstTPMethodTable = 162, + CrstTypeEquivalenceMap = 163, + CrstTypeIDMap = 164, + CrstUMEntryThunkCache = 165, + CrstUMThunkHash = 166, + CrstUniqueStack = 167, + CrstUnresolvedClassLock = 168, + CrstUnwindInfoTableLock = 169, + CrstVSDIndirectionCellLock = 170, + CrstWinRTFactoryCache = 171, + CrstWrapperTemplate = 172, + kNumberOfCrstTypes = 173 }; #endif // __CRST_TYPES_INCLUDED @@ -360,6 +361,7 @@ int g_rgCrstLevelMap[] = 11, // CrstThreadpoolWorker 4, // CrstThreadStaticDataHashTable 10, // CrstThreadStore + 9, // CrstTieredCompilation 9, // CrstTPMethodTable 3, // CrstTypeEquivalenceMap 7, // CrstTypeIDMap @@ -537,6 +539,7 @@ LPCSTR g_rgCrstNameMap[] = "CrstThreadpoolWorker", "CrstThreadStaticDataHashTable", "CrstThreadStore", + "CrstTieredCompilation", "CrstTPMethodTable", "CrstTypeEquivalenceMap", "CrstTypeIDMap", diff --git a/src/inc/fixuppointer.h b/src/inc/fixuppointer.h index 5a897e44eaa0..abed1f96a80d 100644 --- a/src/inc/fixuppointer.h +++ b/src/inc/fixuppointer.h @@ -156,6 +156,26 @@ class RelativePointer } #endif // DACCESS_COMPILE + static TADDR GetRelativeMaybeNull(TADDR base, TADDR addr) + { + LIMITED_METHOD_DAC_CONTRACT; + if (addr == NULL) + { + return NULL; + } + else + { + return addr - base; + } + } + + static TADDR GetRelative(TADDR base, TADDR addr) + { + LIMITED_METHOD_DAC_CONTRACT; + PRECONDITION(addr != NULL); + return addr - base; + } + private: #ifndef DACCESS_COMPILE Volatile m_delta; @@ -721,6 +741,19 @@ class PlainPointer } #endif + static TADDR GetRelativeMaybeNull(TADDR base, TADDR addr) + { + LIMITED_METHOD_DAC_CONTRACT; + return addr; + } + + static TADDR GetRelative(TADDR base, TADDR addr) + { + LIMITED_METHOD_DAC_CONTRACT; + PRECONDITION(addr != NULL); + return addr; + } + private: TADDR m_ptr; }; diff --git a/src/inc/gcinfodecoder.h b/src/inc/gcinfodecoder.h index ad693e1414f3..e8fe6b95233e 100644 --- a/src/inc/gcinfodecoder.h +++ b/src/inc/gcinfodecoder.h @@ -362,7 +362,7 @@ class BitStreamReader inline size_t DecodeVarLengthUnsigned( int base ) { _ASSERTE((base > 0) && (base < (int)BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; + size_t numEncodings = size_t{ 1 } << base; size_t result = 0; for(int shift=0; ; shift+=base) { @@ -381,7 +381,7 @@ class BitStreamReader inline SSIZE_T DecodeVarLengthSigned( int base ) { _ASSERTE((base > 0) && (base < (int)BITS_PER_SIZE_T)); - size_t numEncodings = 1 << base; + size_t numEncodings = size_t{ 1 } << base; SSIZE_T result = 0; for(int shift=0; ; shift+=base) { diff --git a/src/inc/gcinfotypes.h b/src/inc/gcinfotypes.h index c802d97ec689..ac82dfb2fce9 100644 --- a/src/inc/gcinfotypes.h +++ b/src/inc/gcinfotypes.h @@ -331,9 +331,6 @@ inline const char *ReturnKindToString(ReturnKind returnKind) // we use offsetof to get the offset of a field #include // offsetof -#ifndef offsetof -#define offsetof(s,m) ((size_t)&(((s *)0)->m)) -#endif enum infoHdrAdjustConstants { // Constants diff --git a/src/inc/slist.h b/src/inc/slist.h index 2b81f9ba902b..9a75e1d6d535 100644 --- a/src/inc/slist.h +++ b/src/inc/slist.h @@ -136,14 +136,14 @@ class SList } else { -#ifdef __GNUC__ - // GCC defines offsetof to be __builtin_offsetof, which doesn't use the +#if 1 + // Newer compilers define offsetof to be __builtin_offsetof, which doesn't use the // old-school memory model trick to determine offset. const UINT_PTR offset = (((UINT_PTR)&(((T *)0x1000)->*LinkPtr))-0x1000); return (T*)__PTR(dac_cast(pLink) - offset); #else - return (T*)__PTR(dac_cast(pLink) - offsetof(T, *LinkPtr)); -#endif // __GNUC__ + return (T*)__PTR(dac_cast(pLink) - offsetof(T, *LinkPtr)); +#endif } } diff --git a/src/inc/utilcode.h b/src/inc/utilcode.h index de9ba01ad740..15d18f52eea6 100644 --- a/src/inc/utilcode.h +++ b/src/inc/utilcode.h @@ -521,6 +521,14 @@ inline void *__cdecl operator new(size_t, void *_P) #define IN_WIN32(x) x #endif +#ifdef _TARGET_64BIT_ +#define IN_TARGET_64BIT(x) x +#define IN_TARGET_32BIT(x) +#else +#define IN_TARGET_64BIT(x) +#define IN_TARGET_32BIT(x) x +#endif + void * __cdecl operator new(size_t n); @@ -1049,55 +1057,36 @@ inline int CountBits(int iNum) #include "bitposition.h" -// Used to remove trailing zeros from Decimal types. -// NOTE: Assumes hi32 bits are empty (used for conversions from Cy->Dec) -inline HRESULT DecimalCanonicalize(DECIMAL* dec) +// Convert the currency to a decimal and canonicalize. +inline void VarDecFromCyCanonicalize(CY cyIn, DECIMAL* dec) { WRAPPER_NO_CONTRACT; - // Clear the VARENUM field - (*(USHORT*)dec) = 0; - - // Remove trailing zeros: - DECIMAL temp; - DECIMAL templast; - temp = templast = *dec; - - // Ensure the hi 32 bits are empty (should be if we came from a currency) - if ((DECIMAL_HI32(temp) != 0) || (DECIMAL_SCALE(temp) > 4)) - return DISP_E_OVERFLOW; - - // Return immediately if dec represents a zero. - if (DECIMAL_LO32(temp) == 0 && DECIMAL_MID32(temp) == 0) - return S_OK; - - // Compare to the original to see if we've - // lost non-zero digits (and make sure we don't overflow the scale BYTE) - -#ifdef _PREFAST_ -#pragma warning(push) -#pragma warning(disable:6219) // "Suppress PREFast warning about Implicit cast between semantically different integer types" -#endif - while ((DECIMAL_SCALE(temp) <= 4) && (VARCMP_EQ == VarDecCmp(dec, &temp))) + (*(ULONG*)dec) = 0; + DECIMAL_HI32(*dec) = 0; + if (cyIn.int64 == 0) // For compatibility, a currency of 0 emits the Decimal "0.0000" (scale set to 4). { + DECIMAL_SCALE(*dec) = 4; + DECIMAL_LO32(*dec) = 0; + DECIMAL_MID32(*dec) = 0; + return; + } -#ifdef _PREFAST_ -#pragma warning(pop) -#endif - templast = temp; - - // Remove the last digit and normalize. Ignore temp.Hi32 - // as Currency values will have a max of 64 bits of data. - DECIMAL_SCALE(temp)--; - UINT64 temp64 = (((UINT64) DECIMAL_MID32(temp)) << 32) + DECIMAL_LO32(temp); - temp64 /= 10; - - DECIMAL_MID32(temp) = (ULONG)(temp64 >> 32); - DECIMAL_LO32(temp) = (ULONG)temp64; + if (cyIn.int64 < 0) { + DECIMAL_SIGN(*dec) = DECIMAL_NEG; + cyIn.int64 = -cyIn.int64; } - *dec = templast; - return S_OK; + BYTE scale = 4; + ULONGLONG absoluteCy = (ULONGLONG)cyIn.int64; + while (scale != 0 && ((absoluteCy % 10) == 0)) + { + scale--; + absoluteCy /= 10; + } + DECIMAL_SCALE(*dec) = scale; + DECIMAL_LO32(*dec) = (ULONG)absoluteCy; + DECIMAL_MID32(*dec) = (ULONG)(absoluteCy >> 32); } //***************************************************************************** @@ -1431,6 +1420,7 @@ class CPUGroupInfo static BOOL m_threadUseAllCpuGroups; static WORD m_initialGroup; static CPU_Group_Info *m_CPUGroupInfoArray; + static bool s_hadSingleProcessorAtStartup; static BOOL InitCPUGroupInfoAPI(); static BOOL InitCPUGroupInfoArray(); @@ -1485,6 +1475,13 @@ class CPUGroupInfo static void ChooseCPUGroupAffinity(GROUP_AFFINITY *gf); static void ClearCPUGroupAffinity(GROUP_AFFINITY *gf); #endif + +public: + static bool HadSingleProcessorAtStartup() + { + LIMITED_METHOD_CONTRACT; + return s_hadSingleProcessorAtStartup; + } }; int GetCurrentProcessCpuCount(); diff --git a/src/inc/volatile.h b/src/inc/volatile.h index ecf9ffe42789..fa756ef05191 100644 --- a/src/inc/volatile.h +++ b/src/inc/volatile.h @@ -474,32 +474,6 @@ class VolatilePtr : public Volatile

} }; - -// -// Warning: workaround -// -// At the bottom of this file, we are going to #define the "volatile" keyword such that it is illegal -// to use it. Unfortunately, VC++ uses the volatile keyword in stddef.h, in the definition of "offsetof". -// GCC does not use volatile in its definition. -// -// To get around this, we include stddef.h here (even if we're on GCC, for consistency). We then need -// to redefine offsetof such that it does not use volatile, if we're building with VC++. -// -#include -#ifdef _MSC_VER -#undef offsetof -#ifdef _WIN64 -#define offsetof(s,m) (size_t)( (ptrdiff_t)&reinterpret_cast((((s *)0)->m)) ) -#else -#define offsetof(s,m) (size_t)&reinterpret_cast((((s *)0)->m)) -#endif //_WIN64 - -// These also use volatile, so we'll include them here. -//#include -//#include - -#endif //_MSC_VER - // // From here on out, we ban the use of the "volatile" keyword. If you found this while trying to define // a volatile variable, go to the top of this file and start reading. diff --git a/src/inc/warningcontrol.h b/src/inc/warningcontrol.h index 3bfb4e54c33c..e3b6f078ff19 100644 --- a/src/inc/warningcontrol.h +++ b/src/inc/warningcontrol.h @@ -15,43 +15,20 @@ #if defined(_MSC_VER) #pragma warning(error :4007) // 'main' : must be __cdecl #pragma warning(error :4013) // 'function' undefined - assuming extern returning int -#pragma warning(error :4071) // no function prototype given -#pragma warning(error :4072) // no function prototype given (fastcall) -#pragma warning(3 :4092) // sizeof returns 'unsigned long' -//#pragma warning(error :4102) // "'%$S' : unreferenced label" -#pragma warning(3 :4121) // structure is sensitive to alignment -#pragma warning(3 :4125) // decimal digit in octal sequence -#pragma warning(3 :4130) // logical operation on address of string constant -#pragma warning(3 :4132) // const object should be initialized -#pragma warning(error :4171) // no function prototype given (old style) -#pragma warning(4 :4177) // pragma data_seg s/b at global scope -#pragma warning(4 :4206) // Source File is empty -#pragma warning(3 :4212) // function declaration used ellipsis -#pragma warning(error :4259) // pure virtual function was not defined -#pragma warning(disable :4291) // delete not defined for new, c++ exception may cause leak -#pragma warning(disable :4302) // truncation from '%$S' to '%$S' -#pragma warning(disable :4311) // pointer truncation from '%$S' to '%$S' -#pragma warning(disable :4312) // '' : conversion from '%$S' to '%$S' of greater size -#pragma warning(disable :4334) // result of 32-bit shift implicitly converted to 64 bits -#pragma warning(disable :4430) // missing type specifier: C++ doesn't support default-int +#pragma warning(3 :4092) // sizeof returns 'unsigned long' +#pragma warning(error :4102) // "'%$S' : unreferenced label" +#pragma warning(3 :4121) // structure is sensitive to alignment +#pragma warning(3 :4125) // decimal digit in octal sequence +#pragma warning(3 :4130) // logical operation on address of string constant +#pragma warning(3 :4132) // const object should be initialized +#pragma warning(4 :4177) // pragma data_seg s/b at global scope +#pragma warning(3 :4212) // function declaration used ellipsis +#pragma warning(disable :4291) // delete not defined for new, c++ exception may cause leak +#pragma warning(disable :4302) // truncation from '%$S' to '%$S' +#pragma warning(disable :4311) // pointer truncation from '%$S' to '%$S' +#pragma warning(disable :4312) // '' : conversion from '%$S' to '%$S' of greater size #pragma warning(disable :4477) // format string '%$S' requires an argument of type '%$S', but variadic argument %d has type '%$S' -#pragma warning(3 :4509) // "nonstandard extension used: '%$S' uses SEH and '%$S' has destructor" - // - // But beware of doing a return from inside such a try block: - // - // int foo() - // { - // ClassWithDestructor c; - // __try { - // return 0; - // } __finally { - // printf("in finally"); - // } - // - // as (it's a bug) the return value gets toasted. So DON'T casually - // dismiss this warning if you're compiling w/o CXX EH turned on (the default). - -#pragma warning(3 :4530) // C++ exception handler used, but unwind semantics are not enabled. Specify -GX +#pragma warning(3 :4530) // C++ exception handler used, but unwind semantics are not enabled. Specify -GX #pragma warning(error :4551) // Function call missing argument list #pragma warning(error :4700) // Local used w/o being initialized diff --git a/src/jit/_typeinfo.h b/src/jit/_typeinfo.h index b024912dda72..88e640ab721f 100644 --- a/src/jit/_typeinfo.h +++ b/src/jit/_typeinfo.h @@ -185,7 +185,7 @@ inline ti_types JITtype2tiType(CorInfoType type) * can't work out the size, GC-ness etc. of the "struct". So using TI_REF * just tricks these backend parts into generating pseudo-trees for * the generic code we're verifying. These trees then get thrown away - * anyway as we do verification of genreic code in import-only mode. + * anyway as we do verification of generic code in import-only mode. * */ @@ -277,7 +277,7 @@ inline ti_types JITtype2tiType(CorInfoType type) * * The reason that there can be 2 types of byrefs (general byrefs, and byref * locals) is that byref locals initially point to uninitialized items. - * Therefore these byrefs must be tracked specialy. + * Therefore these byrefs must be tracked specially. */ class typeInfo @@ -390,8 +390,8 @@ class typeInfo public: // Note that we specifically ignore the permanent byref here. The rationale is that // the type system doesn't know about this (it's jit only), ie, signatures don't specify if - // a byref is safe, so they are fully equivalent for the jit, except for the RET instruction - // , instructions that load safe byrefs and the stack merging logic, which need to know about + // a byref is safe, so they are fully equivalent for the jit, except for the RET instruction, + // instructions that load safe byrefs and the stack merging logic, which need to know about // the bit static bool AreEquivalent(const typeInfo& li, const typeInfo& ti) { diff --git a/src/jit/alloc.cpp b/src/jit/alloc.cpp index 4cde8664dcd0..9a9d4ff2f479 100644 --- a/src/jit/alloc.cpp +++ b/src/jit/alloc.cpp @@ -8,46 +8,6 @@ #pragma hdrstop #endif // defined(_MSC_VER) -//------------------------------------------------------------------------ -// PooledAllocator: -// This subclass of `ArenaAllocator` is a singleton that always keeps -// a single default-sized page allocated. We try to use the singleton -// allocator as often as possible (i.e. for all non-concurrent -// method compilations). -class PooledAllocator : public ArenaAllocator -{ -private: - enum - { - POOLED_ALLOCATOR_NOTINITIALIZED = 0, - POOLED_ALLOCATOR_IN_USE = 1, - POOLED_ALLOCATOR_AVAILABLE = 2, - POOLED_ALLOCATOR_SHUTDOWN = 3, - }; - - static PooledAllocator s_pooledAllocator; - static LONG s_pooledAllocatorState; - - PooledAllocator() : ArenaAllocator() - { - } - PooledAllocator(IEEMemoryManager* memoryManager); - - PooledAllocator(const PooledAllocator& other) = delete; - PooledAllocator& operator=(const PooledAllocator& other) = delete; - -public: - PooledAllocator& operator=(PooledAllocator&& other); - - void destroy() override; - - static void shutdown(); - - static ArenaAllocator* getPooledAllocator(IEEMemoryManager* memoryManager); -}; - -size_t ArenaAllocator::s_defaultPageSize = 0; - //------------------------------------------------------------------------ // ArenaAllocator::bypassHostAllocator: // Indicates whether or not the ArenaAllocator should bypass the JIT @@ -76,64 +36,19 @@ bool ArenaAllocator::bypassHostAllocator() // The default size of an arena page. size_t ArenaAllocator::getDefaultPageSize() { - return s_defaultPageSize; + return DEFAULT_PAGE_SIZE; } //------------------------------------------------------------------------ // ArenaAllocator::ArenaAllocator: // Default-constructs an arena allocator. ArenaAllocator::ArenaAllocator() - : m_memoryManager(nullptr) - , m_firstPage(nullptr) - , m_lastPage(nullptr) - , m_nextFreeByte(nullptr) - , m_lastFreeByte(nullptr) + : m_firstPage(nullptr), m_lastPage(nullptr), m_nextFreeByte(nullptr), m_lastFreeByte(nullptr) { -} - -//------------------------------------------------------------------------ -// ArenaAllocator::ArenaAllocator: -// Constructs an arena allocator. -// -// Arguments: -// memoryManager - The `IEEMemoryManager` instance that will be used to -// allocate memory for arena pages. -ArenaAllocator::ArenaAllocator(IEEMemoryManager* memoryManager) - : m_memoryManager(memoryManager) - , m_firstPage(nullptr) - , m_lastPage(nullptr) - , m_nextFreeByte(nullptr) - , m_lastFreeByte(nullptr) -{ - assert(getDefaultPageSize() != 0); - assert(isInitialized()); -} - -//------------------------------------------------------------------------ -// ArenaAllocator::operator=: -// Move-assigns a `ArenaAllocator`. -ArenaAllocator& ArenaAllocator::operator=(ArenaAllocator&& other) -{ - assert(!isInitialized()); - - m_memoryManager = other.m_memoryManager; - m_firstPage = other.m_firstPage; - m_lastPage = other.m_lastPage; - m_nextFreeByte = other.m_nextFreeByte; - m_lastFreeByte = other.m_lastFreeByte; - - other.m_memoryManager = nullptr; - other.m_firstPage = nullptr; - other.m_lastPage = nullptr; - other.m_nextFreeByte = nullptr; - other.m_lastFreeByte = nullptr; - - return *this; -} - -bool ArenaAllocator::isInitialized() -{ - return m_memoryManager != nullptr; +#if MEASURE_MEM_ALLOC + memset(&m_stats, 0, sizeof(m_stats)); + memset(&m_statsAllocators, 0, sizeof(m_statsAllocators)); +#endif // MEASURE_MEM_ALLOC } //------------------------------------------------------------------------ @@ -146,21 +61,14 @@ bool ArenaAllocator::isInitialized() // // Return Value: // A pointer to the first usable byte of the newly allocated page. -void* ArenaAllocator::allocateNewPage(size_t size, bool canThrow) +void* ArenaAllocator::allocateNewPage(size_t size) { - assert(isInitialized()); - size_t pageSize = sizeof(PageDescriptor) + size; // Check for integer overflow if (pageSize < size) { - if (canThrow) - { - NOMEM(); - } - - return nullptr; + NOMEM(); } // If the current page is now full, update a few statistics @@ -173,34 +81,28 @@ void* ArenaAllocator::allocateNewPage(size_t size, bool canThrow) m_lastPage->m_usedBytes = m_nextFreeByte - m_lastPage->m_contents; } - // Round up to a default-sized page if necessary - if (pageSize <= s_defaultPageSize) - { - pageSize = s_defaultPageSize; - } + PageDescriptor* newPage = nullptr; - // Round to the nearest multiple of OS page size if necessary if (!bypassHostAllocator()) { + // Round to the nearest multiple of default page size pageSize = roundUp(pageSize, DEFAULT_PAGE_SIZE); } - // Allocate the new page - PageDescriptor* newPage = (PageDescriptor*)allocateHostMemory(pageSize); if (newPage == nullptr) { - if (canThrow) + // Allocate the new page + newPage = static_cast(allocateHostMemory(pageSize, &pageSize)); + + if (newPage == nullptr) { NOMEM(); } - - return nullptr; } // Append the new page to the end of the list newPage->m_next = nullptr; newPage->m_pageBytes = pageSize; - newPage->m_previous = m_lastPage; newPage->m_usedBytes = 0; // m_usedBytes is meaningless until a new page is allocated. // Instead of letting it contain garbage (so to confuse us), // set it to zero. @@ -229,21 +131,20 @@ void* ArenaAllocator::allocateNewPage(size_t size, bool canThrow) // Performs any necessary teardown for an `ArenaAllocator`. void ArenaAllocator::destroy() { - assert(isInitialized()); + PageDescriptor* page = m_firstPage; // Free all of the allocated pages - for (PageDescriptor *page = m_firstPage, *next; page != nullptr; page = next) + for (PageDescriptor* next; page != nullptr; page = next) { next = page->m_next; - freeHostMemory(page); + freeHostMemory(page, page->m_pageBytes); } // Clear out the allocator's fields - m_memoryManager = nullptr; - m_firstPage = nullptr; - m_lastPage = nullptr; - m_nextFreeByte = nullptr; - m_lastFreeByte = nullptr; + m_firstPage = nullptr; + m_lastPage = nullptr; + m_nextFreeByte = nullptr; + m_lastFreeByte = nullptr; } // The debug version of the allocator may allocate directly from the @@ -263,25 +164,21 @@ void ArenaAllocator::destroy() // // Arguments: // size - The number of bytes to allocate. +// pActualSize - The number of byte actually allocated. // // Return Value: // A pointer to the allocated memory. -void* ArenaAllocator::allocateHostMemory(size_t size) +void* ArenaAllocator::allocateHostMemory(size_t size, size_t* pActualSize) { - assert(isInitialized()); - #if defined(DEBUG) if (bypassHostAllocator()) { + *pActualSize = size; return ::HeapAlloc(GetProcessHeap(), 0, size); } - else - { - return ClrAllocInProcessHeap(0, S_SIZE_T(size)); - } -#else // defined(DEBUG) - return m_memoryManager->ClrVirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); #endif // !defined(DEBUG) + + return g_jitHost->allocateSlab(size, pActualSize); } //------------------------------------------------------------------------ @@ -290,22 +187,17 @@ void* ArenaAllocator::allocateHostMemory(size_t size) // // Arguments: // block - A pointer to the memory to free. -void ArenaAllocator::freeHostMemory(void* block) +void ArenaAllocator::freeHostMemory(void* block, size_t size) { - assert(isInitialized()); - #if defined(DEBUG) if (bypassHostAllocator()) { ::HeapFree(GetProcessHeap(), 0, block); + return; } - else - { - ClrFreeInProcessHeap(0, block); - } -#else // defined(DEBUG) - m_memoryManager->ClrVirtualFree(block, 0, MEM_RELEASE); #endif // !defined(DEBUG) + + g_jitHost->freeSlab(block, size); } //------------------------------------------------------------------------ @@ -317,8 +209,6 @@ void ArenaAllocator::freeHostMemory(void* block) // See above. size_t ArenaAllocator::getTotalBytesAllocated() { - assert(isInitialized()); - size_t bytes = 0; for (PageDescriptor* page = m_firstPage; page != nullptr; page = page->m_next) { @@ -345,8 +235,6 @@ size_t ArenaAllocator::getTotalBytesAllocated() // that are unused across all area pages. size_t ArenaAllocator::getTotalBytesUsed() { - assert(isInitialized()); - if (m_lastPage != nullptr) { m_lastPage->m_usedBytes = m_nextFreeByte - m_lastPage->m_contents; @@ -361,176 +249,90 @@ size_t ArenaAllocator::getTotalBytesUsed() return bytes; } -//------------------------------------------------------------------------ -// ArenaAllocator::startup: -// Performs any necessary initialization for the arena allocator -// subsystem. -void ArenaAllocator::startup() -{ - s_defaultPageSize = bypassHostAllocator() ? (size_t)MIN_PAGE_SIZE : (size_t)DEFAULT_PAGE_SIZE; -} +#if MEASURE_MEM_ALLOC +CritSecObject ArenaAllocator::s_statsLock; +ArenaAllocator::AggregateMemStats ArenaAllocator::s_aggStats; +ArenaAllocator::MemStats ArenaAllocator::s_maxStats; -//------------------------------------------------------------------------ -// ArenaAllocator::shutdown: -// Performs any necessary teardown for the arena allocator subsystem. -void ArenaAllocator::shutdown() -{ - PooledAllocator::shutdown(); -} - -PooledAllocator PooledAllocator::s_pooledAllocator; -LONG PooledAllocator::s_pooledAllocatorState = POOLED_ALLOCATOR_NOTINITIALIZED; - -//------------------------------------------------------------------------ -// PooledAllocator::PooledAllocator: -// Constructs a `PooledAllocator`. -PooledAllocator::PooledAllocator(IEEMemoryManager* memoryManager) : ArenaAllocator(memoryManager) -{ -} +const char* ArenaAllocator::MemStats::s_CompMemKindNames[] = { +#define CompMemKindMacro(kind) #kind, +#include "compmemkind.h" +}; -//------------------------------------------------------------------------ -// PooledAllocator::operator=: -// Move-assigns a `PooledAllocator`. -PooledAllocator& PooledAllocator::operator=(PooledAllocator&& other) +void ArenaAllocator::MemStats::Print(FILE* f) { - *((ArenaAllocator*)this) = std::move((ArenaAllocator &&)other); - return *this; + fprintf(f, "count: %10u, size: %10llu, max = %10llu\n", allocCnt, allocSz, allocSzMax); + fprintf(f, "allocateMemory: %10llu, nraUsed: %10llu\n", nraTotalSizeAlloc, nraTotalSizeUsed); + PrintByKind(f); } -//------------------------------------------------------------------------ -// PooledAllocator::shutdown: -// Performs any necessary teardown for the pooled allocator. -// -// Notes: -// If the allocator has been initialized and is in use when this method is called, -// it is up to whatever is using the pooled allocator to call `destroy` in order -// to free its memory. -void PooledAllocator::shutdown() +void ArenaAllocator::MemStats::PrintByKind(FILE* f) { - LONG oldState = InterlockedExchange(&s_pooledAllocatorState, POOLED_ALLOCATOR_SHUTDOWN); - switch (oldState) + fprintf(f, "\nAlloc'd bytes by kind:\n %20s | %10s | %7s\n", "kind", "size", "pct"); + fprintf(f, " %20s-+-%10s-+-%7s\n", "--------------------", "----------", "-------"); + float allocSzF = static_cast(allocSz); + for (int cmk = 0; cmk < CMK_Count; cmk++) { - case POOLED_ALLOCATOR_NOTINITIALIZED: - case POOLED_ALLOCATOR_SHUTDOWN: - case POOLED_ALLOCATOR_IN_USE: - return; - - case POOLED_ALLOCATOR_AVAILABLE: - // The pooled allocator was initialized and not in use; we must destroy it. - s_pooledAllocator.destroy(); - break; + float pct = 100.0f * static_cast(allocSzByKind[cmk]) / allocSzF; + fprintf(f, " %20s | %10llu | %6.2f%%\n", s_CompMemKindNames[cmk], allocSzByKind[cmk], pct); } + fprintf(f, "\n"); } -//------------------------------------------------------------------------ -// PooledAllocator::getPooledAllocator: -// Returns the pooled allocator if it is not already in use. -// -// Arguments: -// memoryManager: The `IEEMemoryManager` instance in use by the caller. -// -// Return Value: -// A pointer to the pooled allocator if it is available or `nullptr` -// if it is already in use. -// -// Notes: -// Calling `destroy` on the returned allocator will return it to the -// pool. -ArenaAllocator* PooledAllocator::getPooledAllocator(IEEMemoryManager* memoryManager) +void ArenaAllocator::AggregateMemStats::Print(FILE* f) { - LONG oldState = InterlockedExchange(&s_pooledAllocatorState, POOLED_ALLOCATOR_IN_USE); - switch (oldState) + fprintf(f, "For %9u methods:\n", nMethods); + if (nMethods == 0) { - case POOLED_ALLOCATOR_IN_USE: - case POOLED_ALLOCATOR_SHUTDOWN: - // Either the allocator is in use or this call raced with a call to `shutdown`. - // Return `nullptr`. - return nullptr; - - case POOLED_ALLOCATOR_AVAILABLE: - if (s_pooledAllocator.m_memoryManager != memoryManager) - { - // The allocator is available, but it was initialized with a different - // memory manager. Release it and return `nullptr`. - InterlockedExchange(&s_pooledAllocatorState, POOLED_ALLOCATOR_AVAILABLE); - return nullptr; - } - - return &s_pooledAllocator; - - case POOLED_ALLOCATOR_NOTINITIALIZED: - { - PooledAllocator allocator(memoryManager); - if (allocator.allocateNewPage(0, false) == nullptr) - { - // Failed to grab the initial memory page. - InterlockedExchange(&s_pooledAllocatorState, POOLED_ALLOCATOR_NOTINITIALIZED); - return nullptr; - } - - s_pooledAllocator = std::move(allocator); - } - - return &s_pooledAllocator; - - default: - assert(!"Unknown pooled allocator state"); - unreached(); + return; } + fprintf(f, " count: %12u (avg %7u per method)\n", allocCnt, allocCnt / nMethods); + fprintf(f, " alloc size : %12llu (avg %7llu per method)\n", allocSz, allocSz / nMethods); + fprintf(f, " max alloc : %12llu\n", allocSzMax); + fprintf(f, "\n"); + fprintf(f, " allocateMemory : %12llu (avg %7llu per method)\n", nraTotalSizeAlloc, nraTotalSizeAlloc / nMethods); + fprintf(f, " nraUsed : %12llu (avg %7llu per method)\n", nraTotalSizeUsed, nraTotalSizeUsed / nMethods); + PrintByKind(f); } -//------------------------------------------------------------------------ -// PooledAllocator::destroy: -// Performs any necessary teardown for an `PooledAllocator` and returns the allocator -// to the pool. -void PooledAllocator::destroy() +ArenaAllocator::MemStatsAllocator* ArenaAllocator::getMemStatsAllocator(CompMemKind kind) { - assert(isInitialized()); - assert(this == &s_pooledAllocator); - assert(s_pooledAllocatorState == POOLED_ALLOCATOR_IN_USE || s_pooledAllocatorState == POOLED_ALLOCATOR_SHUTDOWN); - assert(m_firstPage != nullptr); + assert(kind < CMK_Count); - // Free all but the first allocated page - for (PageDescriptor *page = m_firstPage->m_next, *next; page != nullptr; page = next) + if (m_statsAllocators[kind].m_arena == nullptr) { - next = page->m_next; - freeHostMemory(page); + m_statsAllocators[kind].m_arena = this; + m_statsAllocators[kind].m_kind = kind; } - // Reset the relevant state to point back to the first byte of the first page - m_firstPage->m_next = nullptr; - m_lastPage = m_firstPage; - m_nextFreeByte = m_firstPage->m_contents; - m_lastFreeByte = (BYTE*)m_firstPage + m_firstPage->m_pageBytes; + return &m_statsAllocators[kind]; +} - assert(getTotalBytesAllocated() == s_defaultPageSize); +void ArenaAllocator::finishMemStats() +{ + m_stats.nraTotalSizeAlloc = getTotalBytesAllocated(); + m_stats.nraTotalSizeUsed = getTotalBytesUsed(); - // If we've already been shut down, free the first page. Otherwise, return the allocator to the pool. - if (s_pooledAllocatorState == POOLED_ALLOCATOR_SHUTDOWN) - { - ArenaAllocator::destroy(); - } - else + CritSecHolder statsLock(s_statsLock); + s_aggStats.Add(m_stats); + if (m_stats.allocSz > s_maxStats.allocSz) { - InterlockedExchange(&s_pooledAllocatorState, POOLED_ALLOCATOR_AVAILABLE); + s_maxStats = m_stats; } } -//------------------------------------------------------------------------ -// ArenaAllocator::getPooledAllocator: -// Returns the pooled allocator if it is not already in use. -// -// Arguments: -// memoryManager: The `IEEMemoryManager` instance in use by the caller. -// -// Return Value: -// A pointer to the pooled allocator if it is available or `nullptr` -// if it is already in use. -// -// Notes: -// Calling `destroy` on the returned allocator will return it to the -// pool. -ArenaAllocator* ArenaAllocator::getPooledAllocator(IEEMemoryManager* memoryManager) +void ArenaAllocator::dumpMemStats(FILE* file) +{ + m_stats.Print(file); +} + +void ArenaAllocator::dumpAggregateMemStats(FILE* file) +{ + s_aggStats.Print(file); +} + +void ArenaAllocator::dumpMaxMemStats(FILE* file) { - return PooledAllocator::getPooledAllocator(memoryManager); + s_maxStats.Print(file); } +#endif // MEASURE_MEM_ALLOC diff --git a/src/jit/alloc.h b/src/jit/alloc.h index 62e5bc08486f..2945df910762 100644 --- a/src/jit/alloc.h +++ b/src/jit/alloc.h @@ -9,17 +9,27 @@ #include "host.h" #endif // defined(_HOST_H_) +// CompMemKind values are used to tag memory allocations performed via +// the compiler's allocator so that the memory usage of various compiler +// components can be tracked separately (when MEASURE_MEM_ALLOC is defined). + +enum CompMemKind +{ +#define CompMemKindMacro(kind) CMK_##kind, +#include "compmemkind.h" + CMK_Count +}; + class ArenaAllocator { private: ArenaAllocator(const ArenaAllocator& other) = delete; ArenaAllocator& operator=(const ArenaAllocator& other) = delete; + ArenaAllocator& operator=(ArenaAllocator&& other) = delete; -protected: struct PageDescriptor { PageDescriptor* m_next; - PageDescriptor* m_previous; size_t m_pageBytes; // # of bytes allocated size_t m_usedBytes; // # of bytes actually used. (This is only valid when we've allocated a new page.) @@ -28,18 +38,11 @@ class ArenaAllocator BYTE m_contents[]; }; - // Anything less than 64K leaves VM holes since the OS allocates address space in this size. - // Thus if we want to make this smaller, we need to do a reserve / commit scheme enum { - DEFAULT_PAGE_SIZE = 16 * OS_page_size, - MIN_PAGE_SIZE = sizeof(PageDescriptor) + DEFAULT_PAGE_SIZE = 0x10000, }; - static size_t s_defaultPageSize; - - IEEMemoryManager* m_memoryManager; - PageDescriptor* m_firstPage; PageDescriptor* m_lastPage; @@ -47,17 +50,91 @@ class ArenaAllocator BYTE* m_nextFreeByte; BYTE* m_lastFreeByte; - bool isInitialized(); + void* allocateNewPage(size_t size); + + static void* allocateHostMemory(size_t size, size_t* pActualSize); + static void freeHostMemory(void* block, size_t size); + +#if MEASURE_MEM_ALLOC + struct MemStats + { + unsigned allocCnt; // # of allocs + UINT64 allocSz; // total size of those alloc. + UINT64 allocSzMax; // Maximum single allocation. + UINT64 allocSzByKind[CMK_Count]; // Classified by "kind". + UINT64 nraTotalSizeAlloc; + UINT64 nraTotalSizeUsed; + + static const char* s_CompMemKindNames[]; // Names of the kinds. + + void AddAlloc(size_t sz, CompMemKind cmk) + { + allocCnt += 1; + allocSz += sz; + if (sz > allocSzMax) + { + allocSzMax = sz; + } + allocSzByKind[cmk] += sz; + } + + void Print(FILE* f); // Print these stats to file. + void PrintByKind(FILE* f); // Do just the by-kind histogram part. + }; + + struct AggregateMemStats : public MemStats + { + unsigned nMethods; + + void Add(const MemStats& ms) + { + nMethods++; + allocCnt += ms.allocCnt; + allocSz += ms.allocSz; + allocSzMax = max(allocSzMax, ms.allocSzMax); + for (int i = 0; i < CMK_Count; i++) + { + allocSzByKind[i] += ms.allocSzByKind[i]; + } + nraTotalSizeAlloc += ms.nraTotalSizeAlloc; + nraTotalSizeUsed += ms.nraTotalSizeUsed; + } + + void Print(FILE* f); // Print these stats to file. + }; + +public: + struct MemStatsAllocator + { + ArenaAllocator* m_arena; + CompMemKind m_kind; + + void* allocateMemory(size_t sz) + { + m_arena->m_stats.AddAlloc(sz, m_kind); + return m_arena->allocateMemory(sz); + } + }; - void* allocateNewPage(size_t size, bool canThrow); +private: + static CritSecObject s_statsLock; // This lock protects the data structures below. + static MemStats s_maxStats; // Stats for the allocator with the largest amount allocated. + static AggregateMemStats s_aggStats; // Aggregates statistics for all allocators. + + MemStats m_stats; + MemStatsAllocator m_statsAllocators[CMK_Count]; + +public: + MemStatsAllocator* getMemStatsAllocator(CompMemKind kind); + void finishMemStats(); + void dumpMemStats(FILE* file); - void* allocateHostMemory(size_t size); - void freeHostMemory(void* block); + static void dumpMaxMemStats(FILE* file); + static void dumpAggregateMemStats(FILE* file); +#endif // MEASURE_MEM_ALLOC public: ArenaAllocator(); - ArenaAllocator(IEEMemoryManager* memoryManager); - ArenaAllocator& operator=(ArenaAllocator&& other); // NOTE: it would be nice to have a destructor on this type to ensure that any value that // goes out of scope is either uninitialized or has been torn down via a call to @@ -65,7 +142,7 @@ class ArenaAllocator // revisiting EH in the JIT; such a destructor could be added if SEH is removed // as part of that work. - virtual void destroy(); + void destroy(); inline void* allocateMemory(size_t sz); @@ -74,11 +151,6 @@ class ArenaAllocator static bool bypassHostAllocator(); static size_t getDefaultPageSize(); - - static void startup(); - static void shutdown(); - - static ArenaAllocator* getPooledAllocator(IEEMemoryManager* memoryManager); }; //------------------------------------------------------------------------ @@ -99,11 +171,10 @@ class ArenaAllocator // inline void* ArenaAllocator::allocateMemory(size_t size) { - assert(isInitialized()); assert(size != 0); // Ensure that we always allocate in pointer sized increments. - size = (size_t)roundUp(size, sizeof(size_t)); + size = roundUp(size, sizeof(size_t)); #if defined(DEBUG) if (JitConfig.ShouldInjectFault() != 0) @@ -127,7 +198,7 @@ inline void* ArenaAllocator::allocateMemory(size_t size) if (m_nextFreeByte > m_lastFreeByte) { - block = allocateNewPage(size, true); + block = allocateNewPage(size); } #if defined(DEBUG) @@ -137,4 +208,116 @@ inline void* ArenaAllocator::allocateMemory(size_t size) return block; } +// Allows general purpose code (e.g. collection classes) to allocate +// memory of a pre-determined kind via an arena allocator. + +class CompAllocator +{ +#if MEASURE_MEM_ALLOC + ArenaAllocator::MemStatsAllocator* m_arena; +#else + ArenaAllocator* m_arena; +#endif + +public: + CompAllocator(ArenaAllocator* arena, CompMemKind cmk) +#if MEASURE_MEM_ALLOC + : m_arena(arena->getMemStatsAllocator(cmk)) +#else + : m_arena(arena) +#endif + { + } + + // Allocate a block of memory suitable to store `count` objects of type `T`. + // Zero-length allocations are not allowed. + template + T* allocate(size_t count) + { + // Ensure that count * sizeof(T) does not overflow. + if (count > (SIZE_MAX / sizeof(T))) + { + NOMEM(); + } + + void* p = m_arena->allocateMemory(count * sizeof(T)); + + // Ensure that the allocator returned sizeof(size_t) aligned memory. + assert((size_t(p) & (sizeof(size_t) - 1)) == 0); + + return static_cast(p); + } + + // Deallocate a block of memory previously allocated by `allocate`. + // The arena allocator does not release memory so this doesn't do anything. + void deallocate(void* p) + { + } +}; + +// Global operator new overloads that work with CompAllocator + +inline void* __cdecl operator new(size_t n, CompAllocator alloc) +{ + return alloc.allocate(n); +} + +inline void* __cdecl operator new[](size_t n, CompAllocator alloc) +{ + return alloc.allocate(n); +} + +// A CompAllocator wrapper that implements IAllocator and allows zero-length +// memory allocations (the arena allocator does not support zero-length +// allocation). + +class CompIAllocator : public IAllocator +{ + CompAllocator m_alloc; + char m_zeroLenAllocTarg; + +public: + CompIAllocator(CompAllocator alloc) : m_alloc(alloc) + { + } + + // Allocates a block of memory at least `sz` in size. + virtual void* Alloc(size_t sz) override + { + if (sz == 0) + { + return &m_zeroLenAllocTarg; + } + else + { + return m_alloc.allocate(sz); + } + } + + // Allocates a block of memory at least `elems * elemSize` in size. + virtual void* ArrayAlloc(size_t elems, size_t elemSize) override + { + if ((elems == 0) || (elemSize == 0)) + { + return &m_zeroLenAllocTarg; + } + else + { + // Ensure that elems * elemSize does not overflow. + if (elems > (SIZE_MAX / elemSize)) + { + NOMEM(); + } + + return m_alloc.allocate(elems * elemSize); + } + } + + // Frees the block of memory pointed to by p. + virtual void Free(void* p) override + { + m_alloc.deallocate(p); + } +}; + #endif // _ALLOC_H_ diff --git a/src/jit/arraystack.h b/src/jit/arraystack.h index c6ac6b2628e2..2565e19856d0 100644 --- a/src/jit/arraystack.h +++ b/src/jit/arraystack.h @@ -11,14 +11,12 @@ class ArrayStack static const int builtinSize = 8; public: - ArrayStack(Compiler* comp, int initialSize = builtinSize) + ArrayStack(CompAllocator alloc, int initialSize = builtinSize) : m_alloc(alloc) { - compiler = comp; - if (initialSize > builtinSize) { maxIndex = initialSize; - data = new (compiler, CMK_ArrayStack) T[initialSize]; + data = new (alloc) T[initialSize]; } else { @@ -58,7 +56,7 @@ class ArrayStack // and copy over T* oldData = data; noway_assert(maxIndex * 2 > maxIndex); - data = new (compiler, CMK_ArrayStack) T[maxIndex * 2]; + data = new (m_alloc) T[maxIndex * 2]; for (int i = 0; i < maxIndex; i++) { data[i] = oldData[i]; @@ -149,10 +147,10 @@ class ArrayStack } private: - Compiler* compiler; // needed for allocation - int tosIndex; // first free location - int maxIndex; - T* data; + CompAllocator m_alloc; + int tosIndex; // first free location + int maxIndex; + T* data; // initial allocation T builtinData[builtinSize]; }; diff --git a/src/jit/assertionprop.cpp b/src/jit/assertionprop.cpp index 3d0aa943fe84..93ca437519f4 100644 --- a/src/jit/assertionprop.cpp +++ b/src/jit/assertionprop.cpp @@ -130,7 +130,7 @@ void Compiler::optAddCopies() } // We require that the weighted ref count be significant. - if (varDsc->lvRefCntWtd <= (BB_LOOP_WEIGHT * BB_UNITY_WEIGHT / 2)) + if (varDsc->lvRefCntWtd() <= (BB_LOOP_WEIGHT * BB_UNITY_WEIGHT / 2)) { continue; } @@ -144,7 +144,7 @@ void Compiler::optAddCopies() BlockSet paramImportantUseDom(BlockSetOps::MakeFull(this)); // This will be threshold for determining heavier-than-average uses - unsigned paramAvgWtdRefDiv2 = (varDsc->lvRefCntWtd + varDsc->lvRefCnt / 2) / (varDsc->lvRefCnt * 2); + unsigned paramAvgWtdRefDiv2 = (varDsc->lvRefCntWtd() + varDsc->lvRefCnt() / 2) / (varDsc->lvRefCnt() * 2); bool paramFoundImportantUse = false; @@ -3271,7 +3271,7 @@ GenTree* Compiler::optAssertionPropLocal_RelOp(ASSERT_VALARG_TP assertions, GenT #endif else { - // We currently don't fold/optimze when the GT_LCL_VAR has been cast to a small type + // We currently don't fold/optimize when the GT_LCL_VAR has been cast to a small type return nullptr; } @@ -4687,7 +4687,24 @@ GenTree* Compiler::optVNConstantPropOnJTrue(BasicBlock* block, GenTree* stmt, Ge // Prepare the tree for replacement so any side effects can be extracted. GenTree* sideEffList = optPrepareTreeForReplacement(test, nullptr); - while (sideEffList) + // Transform the relop's operands to be both zeroes. + ValueNum vnZero = vnStore->VNZeroForType(TYP_INT); + relop->gtOp.gtOp1 = gtNewIconNode(0); + relop->gtOp.gtOp1->gtVNPair = ValueNumPair(vnZero, vnZero); + relop->gtOp.gtOp2 = gtNewIconNode(0); + relop->gtOp.gtOp2->gtVNPair = ValueNumPair(vnZero, vnZero); + + // Update the oper and restore the value numbers. + ValueNum vnCns = relop->gtVNPair.GetConservative(); + ValueNum vnLib = relop->gtVNPair.GetLiberal(); + bool evalsToTrue = (vnStore->CoercedConstantValue(vnCns) != 0); + relop->SetOper(evalsToTrue ? GT_EQ : GT_NE); + relop->gtVNPair = ValueNumPair(vnLib, vnCns); + + // Insert side effects back after they were removed from the JTrue stmt. + // It is important not to allow duplicates exist in the IR, that why we delete + // these side effects from the JTrue stmt before insert them back here. + while (sideEffList != nullptr) { GenTree* newStmt; if (sideEffList->OperGet() == GT_COMMA) @@ -4700,24 +4717,11 @@ GenTree* Compiler::optVNConstantPropOnJTrue(BasicBlock* block, GenTree* stmt, Ge newStmt = fgInsertStmtNearEnd(block, sideEffList); sideEffList = nullptr; } - + // fgMorphBlockStmt could potentially affect stmts after the current one, + // for example when it decides to fgRemoveRestOfBlock. fgMorphBlockStmt(block, newStmt->AsStmt() DEBUGARG(__FUNCTION__)); } - // Transform the relop's operands to be both zeroes. - ValueNum vnZero = vnStore->VNZeroForType(TYP_INT); - relop->gtOp.gtOp1 = gtNewIconNode(0); - relop->gtOp.gtOp1->gtVNPair = ValueNumPair(vnZero, vnZero); - relop->gtOp.gtOp2 = gtNewIconNode(0); - relop->gtOp.gtOp2->gtVNPair = ValueNumPair(vnZero, vnZero); - - // Update the oper and restore the value numbers. - ValueNum vnCns = relop->gtVNPair.GetConservative(); - ValueNum vnLib = relop->gtVNPair.GetLiberal(); - bool evalsToTrue = vnStore->CoercedConstantValue(vnCns) != 0; - relop->SetOper(evalsToTrue ? GT_EQ : GT_NE); - relop->gtVNPair = ValueNumPair(vnLib, vnCns); - return test; } @@ -4821,6 +4825,8 @@ Compiler::fgWalkResult Compiler::optVNConstantPropCurStmt(BasicBlock* block, Gen // Successful propagation, mark as assertion propagated and skip // sub-tree (with side-effects) visits. + // TODO #18291: at that moment stmt could be already removed from the stmt list. + optAssertionProp_Update(newTree, tree, stmt); JITDUMP("After constant propagation on [%06u]:\n", tree->gtTreeID); diff --git a/src/jit/bitset.cpp b/src/jit/bitset.cpp index 6802c1a717ab..5771e1858a4e 100644 --- a/src/jit/bitset.cpp +++ b/src/jit/bitset.cpp @@ -98,30 +98,30 @@ void BitSetSupport::RunTests(Env env) class TestBitSetTraits { public: - static void* Alloc(CompAllocator* alloc, size_t byteSize) + static void* Alloc(CompAllocator alloc, size_t byteSize) { - return alloc->Alloc(byteSize); + return alloc.allocate(byteSize); } - static unsigned GetSize(CompAllocator* alloc) + static unsigned GetSize(CompAllocator alloc) { return 64; } - static unsigned GetArrSize(CompAllocator* alloc, unsigned elemSize) + static unsigned GetArrSize(CompAllocator alloc, unsigned elemSize) { assert(elemSize == sizeof(size_t)); return (64 / 8) / sizeof(size_t); } - static unsigned GetEpoch(CompAllocator* alloc) + static unsigned GetEpoch(CompAllocator alloc) { return 0; } }; -void BitSetSupport::TestSuite(CompAllocator* env) +void BitSetSupport::TestSuite(CompAllocator env) { - BitSetSupport::RunTests(env); - BitSetSupport::RunTests(env); - BitSetSupport::RunTests, BSUInt64Class, CompAllocator*, + BitSetSupport::RunTests(env); + BitSetSupport::RunTests(env); + BitSetSupport::RunTests, BSUInt64Class, CompAllocator, TestBitSetTraits>(env); } #endif diff --git a/src/jit/bitset.h b/src/jit/bitset.h index df03dee50e8d..a0192e62e8de 100644 --- a/src/jit/bitset.h +++ b/src/jit/bitset.h @@ -40,7 +40,7 @@ class BitSetSupport #ifdef DEBUG // This runs the "TestSuite" method for a few important instantiations of BitSet. - static void TestSuite(CompAllocator* env); + static void TestSuite(CompAllocator env); #endif enum Operation diff --git a/src/jit/block.cpp b/src/jit/block.cpp index 265369802b63..00c70afd759e 100644 --- a/src/jit/block.cpp +++ b/src/jit/block.cpp @@ -588,7 +588,7 @@ const char* BasicBlock::dspToString(int blockNumPadding /* = 2*/) // Allocation function for MemoryPhiArg. void* BasicBlock::MemoryPhiArg::operator new(size_t sz, Compiler* comp) { - return comp->compGetMem(sz, CMK_MemoryPhiArg); + return comp->getAllocator(CMK_MemoryPhiArg).allocate(sz); } //------------------------------------------------------------------------ diff --git a/src/jit/codegen.h b/src/jit/codegen.h index 755859ad0bc9..ef2094347ef0 100644 --- a/src/jit/codegen.h +++ b/src/jit/codegen.h @@ -626,7 +626,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Tracks the last entry for each tracked register variable - siScope* siLatestTrackedScopes[lclMAX_TRACKED]; + siScope** siLatestTrackedScopes; IL_OFFSET siLastEndOffs; // IL offset of the (exclusive) end of the last block processed diff --git a/src/jit/codegenarm64.cpp b/src/jit/codegenarm64.cpp index afa30399406d..8bb04c27f298 100644 --- a/src/jit/codegenarm64.cpp +++ b/src/jit/codegenarm64.cpp @@ -2664,92 +2664,118 @@ void CodeGen::genLockedInstructions(GenTreeOp* treeNode) regNumber dataReg = data->gtRegNum; regNumber addrReg = addr->gtRegNum; - regNumber exResultReg = treeNode->ExtractTempReg(RBM_ALLINT); - regNumber storeDataReg = (treeNode->OperGet() == GT_XCHG) ? dataReg : treeNode->ExtractTempReg(RBM_ALLINT); - regNumber loadReg = (targetReg != REG_NA) ? targetReg : storeDataReg; + genConsumeAddress(addr); + genConsumeRegs(data); - // Check allocator assumptions - // - // The register allocator should have extended the lifetimes of all input and internal registers so that - // none interfere with the target. - noway_assert(addrReg != targetReg); + emitAttr dataSize = emitActualTypeSize(data); - noway_assert(addrReg != loadReg); - noway_assert(dataReg != loadReg); + if (compiler->compSupports(InstructionSet_Atomics)) + { + assert(!data->isContainedIntOrIImmed()); - noway_assert(addrReg != storeDataReg); - noway_assert((treeNode->OperGet() == GT_XCHG) || (addrReg != dataReg)); + switch (treeNode->gtOper) + { + case GT_XCHG: + getEmitter()->emitIns_R_R_R(INS_swpal, dataSize, dataReg, targetReg, addrReg); + break; + case GT_XADD: + if ((targetReg == REG_NA) || (targetReg == REG_ZR)) + { + getEmitter()->emitIns_R_R(INS_staddl, dataSize, dataReg, addrReg); + } + else + { + getEmitter()->emitIns_R_R_R(INS_ldaddal, dataSize, dataReg, targetReg, addrReg); + } + break; + default: + assert(!"Unexpected treeNode->gtOper"); + } - assert(addr->isUsedFromReg()); - noway_assert(exResultReg != REG_NA); - noway_assert(exResultReg != targetReg); - noway_assert((targetReg != REG_NA) || (treeNode->OperGet() != GT_XCHG)); + instGen_MemoryBarrier(INS_BARRIER_ISH); + } + else + { + regNumber exResultReg = treeNode->ExtractTempReg(RBM_ALLINT); + regNumber storeDataReg = (treeNode->OperGet() == GT_XCHG) ? dataReg : treeNode->ExtractTempReg(RBM_ALLINT); + regNumber loadReg = (targetReg != REG_NA) ? targetReg : storeDataReg; - // Store exclusive unpredictable cases must be avoided - noway_assert(exResultReg != storeDataReg); - noway_assert(exResultReg != addrReg); + // Check allocator assumptions + // + // The register allocator should have extended the lifetimes of all input and internal registers so that + // none interfere with the target. + noway_assert(addrReg != targetReg); - genConsumeAddress(addr); - genConsumeRegs(data); + noway_assert(addrReg != loadReg); + noway_assert(dataReg != loadReg); - // NOTE: `genConsumeAddress` marks the consumed register as not a GC pointer, as it assumes that the input registers - // die at the first instruction generated by the node. This is not the case for these atomics as the input - // registers are multiply-used. As such, we need to mark the addr register as containing a GC pointer until - // we are finished generating the code for this node. + noway_assert(addrReg != storeDataReg); + noway_assert((treeNode->OperGet() == GT_XCHG) || (addrReg != dataReg)); - gcInfo.gcMarkRegPtrVal(addrReg, addr->TypeGet()); + assert(addr->isUsedFromReg()); + noway_assert(exResultReg != REG_NA); + noway_assert(exResultReg != targetReg); + noway_assert((targetReg != REG_NA) || (treeNode->OperGet() != GT_XCHG)); - // TODO-ARM64-CQ Use ARMv8.1 atomics if available - // https://github.com/dotnet/coreclr/issues/11881 + // Store exclusive unpredictable cases must be avoided + noway_assert(exResultReg != storeDataReg); + noway_assert(exResultReg != addrReg); - // Emit code like this: - // retry: - // ldxr loadReg, [addrReg] - // add storeDataReg, loadReg, dataReg # Only for GT_XADD - // # GT_XCHG storeDataReg === dataReg - // stxr exResult, storeDataReg, [addrReg] - // cbnz exResult, retry - // dmb ish + // NOTE: `genConsumeAddress` marks the consumed register as not a GC pointer, as it assumes that the input + // registers + // die at the first instruction generated by the node. This is not the case for these atomics as the input + // registers are multiply-used. As such, we need to mark the addr register as containing a GC pointer until + // we are finished generating the code for this node. - BasicBlock* labelRetry = genCreateTempLabel(); - genDefineTempLabel(labelRetry); + gcInfo.gcMarkRegPtrVal(addrReg, addr->TypeGet()); - emitAttr dataSize = emitActualTypeSize(data); + // Emit code like this: + // retry: + // ldxr loadReg, [addrReg] + // add storeDataReg, loadReg, dataReg # Only for GT_XADD + // # GT_XCHG storeDataReg === dataReg + // stxr exResult, storeDataReg, [addrReg] + // cbnz exResult, retry + // dmb ish - // The following instruction includes a acquire half barrier - getEmitter()->emitIns_R_R(INS_ldaxr, dataSize, loadReg, addrReg); + BasicBlock* labelRetry = genCreateTempLabel(); + genDefineTempLabel(labelRetry); - switch (treeNode->OperGet()) - { - case GT_XADD: - if (data->isContainedIntOrIImmed()) - { - // Even though INS_add is specified here, the encoder will choose either - // an INS_add or an INS_sub and encode the immediate as a positive value - genInstrWithConstant(INS_add, dataSize, storeDataReg, loadReg, data->AsIntConCommon()->IconValue(), - REG_NA); - } - else - { - getEmitter()->emitIns_R_R_R(INS_add, dataSize, storeDataReg, loadReg, dataReg); - } - break; - case GT_XCHG: - assert(!data->isContained()); - storeDataReg = dataReg; - break; - default: - unreached(); - } + // The following instruction includes a acquire half barrier + getEmitter()->emitIns_R_R(INS_ldaxr, dataSize, loadReg, addrReg); - // The following instruction includes a release half barrier - getEmitter()->emitIns_R_R_R(INS_stlxr, dataSize, exResultReg, storeDataReg, addrReg); + switch (treeNode->OperGet()) + { + case GT_XADD: + if (data->isContainedIntOrIImmed()) + { + // Even though INS_add is specified here, the encoder will choose either + // an INS_add or an INS_sub and encode the immediate as a positive value + genInstrWithConstant(INS_add, dataSize, storeDataReg, loadReg, data->AsIntConCommon()->IconValue(), + REG_NA); + } + else + { + getEmitter()->emitIns_R_R_R(INS_add, dataSize, storeDataReg, loadReg, dataReg); + } + break; + case GT_XCHG: + assert(!data->isContained()); + storeDataReg = dataReg; + break; + default: + unreached(); + } + + // The following instruction includes a release half barrier + getEmitter()->emitIns_R_R_R(INS_stlxr, dataSize, exResultReg, storeDataReg, addrReg); - getEmitter()->emitIns_J_R(INS_cbnz, EA_4BYTE, labelRetry, exResultReg); + getEmitter()->emitIns_J_R(INS_cbnz, EA_4BYTE, labelRetry, exResultReg); - instGen_MemoryBarrier(INS_BARRIER_ISH); + instGen_MemoryBarrier(INS_BARRIER_ISH); - gcInfo.gcMarkRegSetNpt(addr->gtGetRegMask()); + gcInfo.gcMarkRegSetNpt(addr->gtGetRegMask()); + } if (treeNode->gtRegNum != REG_NA) { @@ -2775,88 +2801,110 @@ void CodeGen::genCodeForCmpXchg(GenTreeCmpXchg* treeNode) regNumber dataReg = data->gtRegNum; regNumber addrReg = addr->gtRegNum; regNumber comparandReg = comparand->gtRegNum; - regNumber exResultReg = treeNode->ExtractTempReg(RBM_ALLINT); - - // Check allocator assumptions - // - // The register allocator should have extended the lifetimes of all input and internal registers so that - // none interfere with the target. - noway_assert(addrReg != targetReg); - noway_assert(dataReg != targetReg); - noway_assert(comparandReg != targetReg); - noway_assert(addrReg != dataReg); - noway_assert(targetReg != REG_NA); - noway_assert(exResultReg != REG_NA); - noway_assert(exResultReg != targetReg); - - assert(addr->isUsedFromReg()); - assert(data->isUsedFromReg()); - assert(!comparand->isUsedFromMemory()); - - // Store exclusive unpredictable cases must be avoided - noway_assert(exResultReg != dataReg); - noway_assert(exResultReg != addrReg); genConsumeAddress(addr); genConsumeRegs(data); genConsumeRegs(comparand); - // NOTE: `genConsumeAddress` marks the consumed register as not a GC pointer, as it assumes that the input registers - // die at the first instruction generated by the node. This is not the case for these atomics as the input - // registers are multiply-used. As such, we need to mark the addr register as containing a GC pointer until - // we are finished generating the code for this node. - - gcInfo.gcMarkRegPtrVal(addrReg, addr->TypeGet()); - - // TODO-ARM64-CQ Use ARMv8.1 atomics if available - // https://github.com/dotnet/coreclr/issues/11881 - - // Emit code like this: - // retry: - // ldxr targetReg, [addrReg] - // cmp targetReg, comparandReg - // bne compareFail - // stxr exResult, dataReg, [addrReg] - // cbnz exResult, retry - // compareFail: - // dmb ish + if (compiler->compSupports(InstructionSet_Atomics)) + { + emitAttr dataSize = emitActualTypeSize(data); - BasicBlock* labelRetry = genCreateTempLabel(); - BasicBlock* labelCompareFail = genCreateTempLabel(); - genDefineTempLabel(labelRetry); + // casal use the comparand as the target reg + if (targetReg != comparandReg) + { + getEmitter()->emitIns_R_R(INS_mov, dataSize, targetReg, comparandReg); - // The following instruction includes a acquire half barrier - getEmitter()->emitIns_R_R(INS_ldaxr, emitTypeSize(treeNode), targetReg, addrReg); + // Catch case we destroyed data or address before use + noway_assert(addrReg != targetReg); + noway_assert(dataReg != targetReg); + } + getEmitter()->emitIns_R_R_R(INS_casal, dataSize, targetReg, dataReg, addrReg); - if (comparand->isContainedIntOrIImmed()) + instGen_MemoryBarrier(INS_BARRIER_ISH); + } + else { - if (comparand->IsIntegralConst(0)) + regNumber exResultReg = treeNode->ExtractTempReg(RBM_ALLINT); + + // Check allocator assumptions + // + // The register allocator should have extended the lifetimes of all input and internal registers so that + // none interfere with the target. + noway_assert(addrReg != targetReg); + noway_assert(dataReg != targetReg); + noway_assert(comparandReg != targetReg); + noway_assert(addrReg != dataReg); + noway_assert(targetReg != REG_NA); + noway_assert(exResultReg != REG_NA); + noway_assert(exResultReg != targetReg); + + assert(addr->isUsedFromReg()); + assert(data->isUsedFromReg()); + assert(!comparand->isUsedFromMemory()); + + // Store exclusive unpredictable cases must be avoided + noway_assert(exResultReg != dataReg); + noway_assert(exResultReg != addrReg); + + // NOTE: `genConsumeAddress` marks the consumed register as not a GC pointer, as it assumes that the input + // registers + // die at the first instruction generated by the node. This is not the case for these atomics as the input + // registers are multiply-used. As such, we need to mark the addr register as containing a GC pointer until + // we are finished generating the code for this node. + + gcInfo.gcMarkRegPtrVal(addrReg, addr->TypeGet()); + + // TODO-ARM64-CQ Use ARMv8.1 atomics if available + // https://github.com/dotnet/coreclr/issues/11881 + + // Emit code like this: + // retry: + // ldxr targetReg, [addrReg] + // cmp targetReg, comparandReg + // bne compareFail + // stxr exResult, dataReg, [addrReg] + // cbnz exResult, retry + // compareFail: + // dmb ish + + BasicBlock* labelRetry = genCreateTempLabel(); + BasicBlock* labelCompareFail = genCreateTempLabel(); + genDefineTempLabel(labelRetry); + + // The following instruction includes a acquire half barrier + getEmitter()->emitIns_R_R(INS_ldaxr, emitTypeSize(treeNode), targetReg, addrReg); + + if (comparand->isContainedIntOrIImmed()) { - getEmitter()->emitIns_J_R(INS_cbnz, emitActualTypeSize(treeNode), labelCompareFail, targetReg); + if (comparand->IsIntegralConst(0)) + { + getEmitter()->emitIns_J_R(INS_cbnz, emitActualTypeSize(treeNode), labelCompareFail, targetReg); + } + else + { + getEmitter()->emitIns_R_I(INS_cmp, emitActualTypeSize(treeNode), targetReg, + comparand->AsIntConCommon()->IconValue()); + getEmitter()->emitIns_J(INS_bne, labelCompareFail); + } } else { - getEmitter()->emitIns_R_I(INS_cmp, emitActualTypeSize(treeNode), targetReg, - comparand->AsIntConCommon()->IconValue()); + getEmitter()->emitIns_R_R(INS_cmp, emitActualTypeSize(treeNode), targetReg, comparandReg); getEmitter()->emitIns_J(INS_bne, labelCompareFail); } - } - else - { - getEmitter()->emitIns_R_R(INS_cmp, emitActualTypeSize(treeNode), targetReg, comparandReg); - getEmitter()->emitIns_J(INS_bne, labelCompareFail); - } - // The following instruction includes a release half barrier - getEmitter()->emitIns_R_R_R(INS_stlxr, emitTypeSize(treeNode), exResultReg, dataReg, addrReg); + // The following instruction includes a release half barrier + getEmitter()->emitIns_R_R_R(INS_stlxr, emitTypeSize(treeNode), exResultReg, dataReg, addrReg); - getEmitter()->emitIns_J_R(INS_cbnz, EA_4BYTE, labelRetry, exResultReg); + getEmitter()->emitIns_J_R(INS_cbnz, EA_4BYTE, labelRetry, exResultReg); - genDefineTempLabel(labelCompareFail); + genDefineTempLabel(labelCompareFail); - instGen_MemoryBarrier(INS_BARRIER_ISH); + instGen_MemoryBarrier(INS_BARRIER_ISH); - gcInfo.gcMarkRegSetNpt(addr->gtGetRegMask()); + gcInfo.gcMarkRegSetNpt(addr->gtGetRegMask()); + } genProduceReg(treeNode); } diff --git a/src/jit/codegenarmarch.cpp b/src/jit/codegenarmarch.cpp index 17bb104ed604..f5053f7beb24 100644 --- a/src/jit/codegenarmarch.cpp +++ b/src/jit/codegenarmarch.cpp @@ -325,11 +325,11 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode) genPutArgReg(treeNode->AsOp()); break; -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: genPutArgSplit(treeNode->AsPutArgSplit()); break; -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT case GT_CALL: genCallInstruction(treeNode->AsCall()); @@ -649,42 +649,7 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* treeNode) if (source->OperGet() == GT_FIELD_LIST) { - // Deal with the multi register passed struct args. - GenTreeFieldList* fieldListPtr = source->AsFieldList(); - -#ifdef _TARGET_ARM64_ - // Arm64 ABI does not include argument splitting between registers and stack - assert(fieldListPtr); - assert(fieldListPtr->gtFieldOffset == 0); -#endif // _TARGET_ARM64_ - - // Evaluate each of the GT_FIELD_LIST items into their register - // and store their register into the outgoing argument area - for (; fieldListPtr != nullptr; fieldListPtr = fieldListPtr->Rest()) - { - GenTree* nextArgNode = fieldListPtr->gtOp.gtOp1; - genConsumeReg(nextArgNode); - - regNumber reg = nextArgNode->gtRegNum; - var_types type = nextArgNode->TypeGet(); - emitAttr attr = emitTypeSize(type); - -#ifdef _TARGET_ARM64_ - // Emit store instructions to store the registers produced by the GT_FIELD_LIST into the outgoing - // argument area - emit->emitIns_S_R(ins_Store(type), attr, reg, varNumOut, argOffsetOut + fieldListPtr->gtFieldOffset); - - // We can't write beyound the outgoing area area - assert((argOffsetOut + fieldListPtr->gtFieldOffset + EA_SIZE_IN_BYTES(attr)) <= argOffsetMax); -#else - // TODO-ARM-Bug? The following code will pack copied structs - // Emit store instructions to store the registers produced by the GT_FIELD_LIST into the outgoing - // argument area - emit->emitIns_S_R(ins_Store(type), attr, reg, varNumOut, argOffsetOut); - argOffsetOut += EA_SIZE_IN_BYTES(attr); - assert(argOffsetOut <= argOffsetMax); // We can't write beyound the outgoing area area -#endif // _TARGET_ARM64_ - } + genPutArgStkFieldList(treeNode, varNumOut); } else // We must have a GT_OBJ or a GT_LCL_VAR { @@ -996,7 +961,7 @@ void CodeGen::genPutArgReg(GenTreeOp* tree) genProduceReg(tree); } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT //--------------------------------------------------------------------- // genPutArgSplit - generate code for a GT_PUTARG_SPLIT node // @@ -1043,6 +1008,7 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode) { var_types type = treeNode->GetRegType(regIndex); regNumber argReg = treeNode->GetRegNumByIdx(regIndex); +#ifdef _TARGET_ARM_ if (type == TYP_LONG) { // We should only see long fields for DOUBLEs passed in 2 integer registers, via bitcast. @@ -1060,6 +1026,7 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode) assert(argReg == treeNode->GetRegNumByIdx(regIndex)); fieldReg = nextArgNode->AsMultiRegOp()->GetRegNumByIdx(1); } +#endif // _TARGET_ARM_ // If child node is not already in the register we need, move it if (argReg != fieldReg) @@ -1210,7 +1177,7 @@ void CodeGen::genPutArgSplit(GenTreePutArgSplit* treeNode) } genProduceReg(treeNode); } -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT //---------------------------------------------------------------------------------- // genMultiRegCallStoreToLocal: store multi-reg return value of a call node to a local @@ -2238,7 +2205,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call) #endif // _TARGET_ARM_ } } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (curArgTabEntry->isSplit) { assert(curArgTabEntry->numRegs >= 1); @@ -2253,7 +2220,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call) } } } -#endif +#endif // FEATURE_ARG_SPLIT else { regNumber argReg = curArgTabEntry->regNum; @@ -2689,7 +2656,7 @@ void CodeGen::genJmpMethod(GenTree* jmp) regSet.AddMaskVars(genRegMask(argReg)); gcInfo.gcMarkRegPtrVal(argReg, loadType); - if (compiler->lvaIsMultiregStruct(varDsc)) + if (compiler->lvaIsMultiregStruct(varDsc, compiler->info.compIsVarArgs)) { if (varDsc->lvIsHfa()) { @@ -2720,7 +2687,7 @@ void CodeGen::genJmpMethod(GenTree* jmp) fixedIntArgMask |= genRegMask(argReg); - if (compiler->lvaIsMultiregStruct(varDsc)) + if (compiler->lvaIsMultiregStruct(varDsc, compiler->info.compIsVarArgs)) { assert(argRegNext != REG_NA); fixedIntArgMask |= genRegMask(argRegNext); diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index a4497562d842..8572f288ca24 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -121,7 +121,7 @@ CodeGen::CodeGen(Compiler* theCompiler) : CodeGenInterface(theCompiler) setVerbose(compiler->verbose); #endif // DEBUG - compiler->tmpInit(); + regSet.tmpInit(); instInit(); @@ -2314,7 +2314,7 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode) genFinalizeFrame(); - unsigned maxTmpSize = compiler->tmpSize; // This is precise after LSRA has pre-allocated the temps. + unsigned maxTmpSize = regSet.tmpGetTotalSize(); // This is precise after LSRA has pre-allocated the temps. getEmitter()->emitBegFN(isFramePointerUsed() #if defined(DEBUG) @@ -2581,7 +2581,7 @@ void CodeGen::genGenerateCode(void** codePtr, ULONG* nativeSizeOfCode) /* Shut down the temp logic */ - compiler->tmpDone(); + regSet.tmpDone(); #if DISPLAY_SIZES @@ -3298,15 +3298,6 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere } #endif -#ifdef _TARGET_ARM64_ - if (compiler->info.compIsVarArgs) - { - // We've already saved all int registers at the top of stack in the prolog. - // No need further action. - return; - } -#endif - unsigned argMax; // maximum argNum value plus 1, (including the RetBuffArg) unsigned argNum; // current argNum, always in [0..argMax-1] unsigned fixedRetBufIndex; // argNum value used by the fixed return buffer argument (ARM64) @@ -3401,13 +3392,18 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere // In other cases, we simply use the type of the lclVar to determine the type of the register. var_types getRegType(Compiler* compiler) { - LclVarDsc varDsc = compiler->lvaTable[varNum]; + const LclVarDsc& varDsc = compiler->lvaTable[varNum]; // Check if this is an HFA register arg and return the HFA type if (varDsc.lvIsHfaRegArg()) { +#if defined(_TARGET_WINDOWS_) + // Cannot have hfa types on windows arm targets + // in vararg methods. + assert(!compiler->info.compIsVarArgs); +#endif // defined(_TARGET_WINDOWS_) return varDsc.GetHfaType(); } - return varDsc.lvType; + return compiler->mangleVarArgsType(varDsc.lvType); } #endif // !UNIX_AMD64_ABI @@ -3415,8 +3411,11 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere unsigned varNum; LclVarDsc* varDsc; - for (varNum = 0, varDsc = compiler->lvaTable; varNum < compiler->lvaCount; varNum++, varDsc++) + + for (varNum = 0; varNum < compiler->lvaCount; ++varNum) { + varDsc = compiler->lvaTable + varNum; + // Is this variable a register arg? if (!varDsc->lvIsParam) { @@ -3466,10 +3465,16 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere } } - var_types regType = varDsc->TypeGet(); + var_types regType = compiler->mangleVarArgsType(varDsc->TypeGet()); // Change regType to the HFA type when we have a HFA argument if (varDsc->lvIsHfaRegArg()) { +#if defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + if (compiler->info.compIsVarArgs) + { + assert(!"Illegal incoming HFA arg encountered in Vararg method."); + } +#endif // defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) regType = varDsc->GetHfaType(); } @@ -3593,7 +3598,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere slots = 1; #if FEATURE_MULTIREG_ARGS - if (compiler->lvaIsMultiregStruct(varDsc)) + if (compiler->lvaIsMultiregStruct(varDsc, compiler->info.compIsVarArgs)) { if (varDsc->lvIsHfaRegArg()) { @@ -3655,11 +3660,6 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere regNumber regNum = genMapRegArgNumToRegNum(regArgNum + i, regType); #if !defined(UNIX_AMD64_ABI) - // lvArgReg could be INT or FLOAT reg. So the following assertion doesn't hold. - // The type of the register depends on the classification of the first eightbyte - // of the struct. For information on classification refer to the System V x86_64 ABI at: - // http://www.x86-64.org/documentation/abi.pdf - assert((i > 0) || (regNum == varDsc->lvArgReg)); #endif // defined(UNIX_AMD64_ABI) // Is the arg dead on entry to the method ? @@ -3678,8 +3678,9 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere // For LSRA, it may not be in regArgMaskLive if it has a zero // refcnt. This is in contrast with the non-LSRA case in which all // non-tracked args are assumed live on entry. - noway_assert((varDsc->lvRefCnt == 0) || (varDsc->lvType == TYP_STRUCT) || - (varDsc->lvAddrExposed && compiler->info.compIsVarArgs)); + noway_assert((varDsc->lvRefCnt() == 0) || (varDsc->lvType == TYP_STRUCT) || + (varDsc->lvAddrExposed && compiler->info.compIsVarArgs) || + (varDsc->lvAddrExposed && compiler->opts.compUseSoftFP)); #endif // !_TARGET_X86_ } // Mark it as processed and be done with it @@ -3965,7 +3966,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere } else // Not a struct type { - storeType = genActualType(varDsc->TypeGet()); + storeType = compiler->mangleVarArgsType(genActualType(varDsc->TypeGet())); } size = emitActualTypeSize(storeType); #ifdef _TARGET_X86_ @@ -3978,7 +3979,7 @@ void CodeGen::genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbere if (!varDsc->lvOnFrame) { - noway_assert(varDsc->lvRefCnt == 0); + noway_assert(varDsc->lvRefCnt() == 0); } else { @@ -4637,7 +4638,7 @@ void CodeGen::genCheckUseBlockInit() if (!varDsc->lvIsInReg() && !varDsc->lvOnFrame) { - noway_assert(varDsc->lvRefCnt == 0); + noway_assert(varDsc->lvRefCnt() == 0); continue; } @@ -4775,8 +4776,8 @@ void CodeGen::genCheckUseBlockInit() if (!TRACK_GC_TEMP_LIFETIMES) { - assert(compiler->tmpAllFree()); - for (TempDsc* tempThis = compiler->tmpListBeg(); tempThis != nullptr; tempThis = compiler->tmpListNxt(tempThis)) + assert(regSet.tmpAllFree()); + for (TempDsc* tempThis = regSet.tmpListBeg(); tempThis != nullptr; tempThis = regSet.tmpListNxt(tempThis)) { if (varTypeIsGC(tempThis->tdTempType())) { @@ -4980,11 +4981,6 @@ void CodeGen::genPushCalleeSavedRegisters() regMaskTP maskSaveRegsFloat = rsPushRegs & RBM_ALLFLOAT; regMaskTP maskSaveRegsInt = rsPushRegs & ~maskSaveRegsFloat; - if (compiler->info.compIsVarArgs) - { - assert(maskSaveRegsFloat == RBM_NONE); - } - int frameType = 0; // This number is arbitrary, is defined below, and corresponds to one of the frame styles we // generate based on various sizes. int calleeSaveSPDelta = 0; @@ -6541,9 +6537,8 @@ void CodeGen::genZeroInitFrame(int untrLclHi, int untrLclLo, regNumber initReg, if (!TRACK_GC_TEMP_LIFETIMES) { - assert(compiler->tmpAllFree()); - for (TempDsc* tempThis = compiler->tmpListBeg(); tempThis != nullptr; - tempThis = compiler->tmpListNxt(tempThis)) + assert(regSet.tmpAllFree()); + for (TempDsc* tempThis = regSet.tmpListBeg(); tempThis != nullptr; tempThis = regSet.tmpListNxt(tempThis)) { if (!varTypeIsGC(tempThis->tdTempType())) { @@ -7694,7 +7689,7 @@ void CodeGen::genFinalizeFrame() here (where we have committed to the final numbers for the frame offsets) This will ensure that the prolog size is always correct */ - getEmitter()->emitMaxTmpSize = compiler->tmpSize; + getEmitter()->emitMaxTmpSize = regSet.tmpGetTotalSize(); #ifdef DEBUG if (compiler->opts.dspCode || compiler->opts.disAsm || compiler->opts.disAsm2 || verbose) @@ -7881,7 +7876,7 @@ void CodeGen::genFnProlog() if (!varDsc->lvIsInReg() && !varDsc->lvOnFrame) { - noway_assert(varDsc->lvRefCnt == 0); + noway_assert(varDsc->lvRefCnt() == 0); continue; } @@ -7969,8 +7964,8 @@ void CodeGen::genFnProlog() if (!TRACK_GC_TEMP_LIFETIMES) { - assert(compiler->tmpAllFree()); - for (TempDsc* tempThis = compiler->tmpListBeg(); tempThis != nullptr; tempThis = compiler->tmpListNxt(tempThis)) + assert(regSet.tmpAllFree()); + for (TempDsc* tempThis = regSet.tmpListBeg(); tempThis != nullptr; tempThis = regSet.tmpListNxt(tempThis)) { if (!varTypeIsGC(tempThis->tdTempType())) { @@ -8497,7 +8492,7 @@ void CodeGen::genFnProlog() // (our argument pointer register has a refcount > 0). unsigned argsStartVar = compiler->lvaVarargsBaseOfStkArgs; - if (compiler->info.compIsVarArgs && compiler->lvaTable[argsStartVar].lvRefCnt > 0) + if (compiler->info.compIsVarArgs && compiler->lvaTable[argsStartVar].lvRefCnt() > 0) { varDsc = &compiler->lvaTable[argsStartVar]; @@ -8551,7 +8546,7 @@ void CodeGen::genFnProlog() getEmitter()->emitEndProlog(); compiler->unwindEndProlog(); - noway_assert(getEmitter()->emitMaxTmpSize == compiler->tmpSize); + noway_assert(getEmitter()->emitMaxTmpSize == regSet.tmpGetTotalSize()); } #ifdef _PREFAST_ #pragma warning(pop) @@ -8599,6 +8594,20 @@ void CodeGen::genFnEpilog(BasicBlock* block) bool jmpEpilog = ((block->bbFlags & BBF_HAS_JMP) != 0); + GenTree* lastNode = block->lastNode(); + + // Method handle and address info used in case of jump epilog + CORINFO_METHOD_HANDLE methHnd = nullptr; + CORINFO_CONST_LOOKUP addrInfo; + addrInfo.addr = nullptr; + addrInfo.accessType = IAT_VALUE; + + if (jmpEpilog && lastNode->gtOper == GT_JMP) + { + methHnd = (CORINFO_METHOD_HANDLE)lastNode->gtVal.gtVal1; + compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo); + } + #ifdef _TARGET_ARM_ // We delay starting the unwind codes until we have an instruction which we know // needs an unwind code. In particular, for large stack frames in methods without @@ -8643,6 +8652,30 @@ void CodeGen::genFnEpilog(BasicBlock* block) unwindStarted = true; } + if (jmpEpilog && lastNode->gtOper == GT_JMP && addrInfo.accessType == IAT_RELPVALUE) + { + // IAT_RELPVALUE jump at the end is done using relative indirection, so, + // additional helper register is required. + // We use LR just before it is going to be restored from stack, i.e. + // + // movw r12, laddr + // movt r12, haddr + // mov lr, r12 + // ldr r12, [r12] + // add r12, r12, lr + // pop {lr} + // ... + // bx r12 + + regNumber indCallReg = REG_R12; + regNumber vptrReg1 = REG_LR; + + instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr); + getEmitter()->emitIns_R_R(INS_mov, EA_PTRSIZE, vptrReg1, indCallReg); + getEmitter()->emitIns_R_R_I(INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0); + getEmitter()->emitIns_R_R(INS_add, EA_PTRSIZE, indCallReg, vptrReg1); + } + genPopCalleeSavedRegisters(jmpEpilog); if (regSet.rsMaskPreSpillRegs(true) != RBM_NONE) @@ -8655,6 +8688,12 @@ void CodeGen::genFnEpilog(BasicBlock* block) compiler->unwindAllocStack(preSpillRegArgSize); } + if (jmpEpilog) + { + // We better not have used a pop PC to return otherwise this will be unreachable code + noway_assert(!genUsedPopToReturn); + } + #else // _TARGET_ARM64_ compiler->unwindBegEpilog(); @@ -8663,20 +8702,13 @@ void CodeGen::genFnEpilog(BasicBlock* block) if (jmpEpilog) { -#ifdef _TARGET_ARMARCH_ hasTailCalls = true; -#endif // _TARGET_ARMARCH_ noway_assert(block->bbJumpKind == BBJ_RETURN); noway_assert(block->bbTreeList != nullptr); -#ifdef _TARGET_ARM_ - // We better not have used a pop PC to return otherwise this will be unreachable code - noway_assert(!genUsedPopToReturn); -#endif // _TARGET_ARM_ - /* figure out what jump we have */ - GenTree* jmpNode = block->lastNode(); + GenTree* jmpNode = lastNode; #if !FEATURE_FASTTAILCALL noway_assert(jmpNode->gtOper == GT_JMP); #else // FEATURE_FASTTAILCALL @@ -8695,10 +8727,8 @@ void CodeGen::genFnEpilog(BasicBlock* block) { // Simply emit a jump to the methodHnd. This is similar to a call so we can use // the same descriptor with some minor adjustments. - CORINFO_METHOD_HANDLE methHnd = (CORINFO_METHOD_HANDLE)jmpNode->gtVal.gtVal1; - - CORINFO_CONST_LOOKUP addrInfo; - compiler->info.compCompHnd->getFunctionEntryPoint(methHnd, &addrInfo); + assert(methHnd != nullptr); + assert(addrInfo.addr != nullptr); #ifdef _TARGET_ARM_ emitter::EmitCallType callType; @@ -8734,6 +8764,20 @@ void CodeGen::genFnEpilog(BasicBlock* block) } break; + case IAT_RELPVALUE: + { + // Load the address into a register, load relative indirect and call through a register + // We have to use R12 since we assume the argument registers are in use + // LR is used as helper register right before it is restored from stack, thus, + // all relative address calculations are performed before LR is restored. + callType = emitter::EC_INDIR_R; + indCallReg = REG_R12; + addr = NULL; + + regSet.verifyRegUsed(indCallReg); + break; + } + case IAT_PPVALUE: default: NO_WAY("Unsupported JMP indirection"); @@ -10264,28 +10308,6 @@ void CodeGen::genVzeroupperIfNeeded(bool check256bitOnly /* = true*/) #endif // defined(_TARGET_XARCH_) -//----------------------------------------------------------------------------------- -// IsMultiRegPassedType: Returns true if the type is returned in multiple registers -// -// Arguments: -// hClass - type handle -// -// Return Value: -// true if type is passed in multiple registers, false otherwise. -// -bool Compiler::IsMultiRegPassedType(CORINFO_CLASS_HANDLE hClass) -{ - if (hClass == NO_CLASS_HANDLE) - { - return false; - } - - structPassingKind howToPassStruct; - var_types returnType = getArgTypeForStruct(hClass, &howToPassStruct); - - return (varTypeIsStruct(returnType)); -} - //----------------------------------------------------------------------------------- // IsMultiRegReturnedType: Returns true if the type is returned in multiple registers // @@ -10453,46 +10475,32 @@ instruction CodeGen::genMapShiftInsToShiftByConstantIns(instruction ins, int shi // On x64 Windows the caller always creates slots (homing space) in its frame for the // first 4 arguments of a callee (register passed args). So, the the variable number // (lclNum) for the first argument with a stack slot is always 0. -// For System V systems or armarch, there is no such calling convention requirement, and the code needs to find -// the first stack passed argument from the caller. This is done by iterating over +// For System V systems or armarch, there is no such calling convention requirement, and the code +// needs to find the first stack passed argument from the caller. This is done by iterating over // all the lvParam variables and finding the first with lvArgReg equals to REG_STK. // unsigned CodeGen::getFirstArgWithStackSlot() { #if defined(UNIX_AMD64_ABI) || defined(_TARGET_ARMARCH_) unsigned baseVarNum = 0; -#if defined(FEATURE_UNIX_AMR64_STRUCT_PASSING) - baseVarNum = compiler->lvaFirstStackIncomingArgNum; - - if (compiler->lvaFirstStackIncomingArgNum != BAD_VAR_NUM) + // Iterate over all the lvParam variables in the Lcl var table until we find the first one + // that's passed on the stack. + LclVarDsc* varDsc = nullptr; + for (unsigned i = 0; i < compiler->info.compArgsCount; i++) { - baseVarNum = compiler->lvaFirstStackIncomingArgNum; - } - else -#endif // FEATURE_UNIX_ARM64_STRUCT_PASSING - { - // Iterate over all the local variables in the Lcl var table. - // They contain all the implicit arguments - thisPtr, retBuf, - // generic context, PInvoke cookie, var arg cookie,no-standard args, etc. - LclVarDsc* varDsc = nullptr; - for (unsigned i = 0; i < compiler->info.compArgsCount; i++) - { - varDsc = &(compiler->lvaTable[i]); + varDsc = &(compiler->lvaTable[i]); - // We are iterating over the arguments only. - assert(varDsc->lvIsParam); + // We should have found a stack parameter (and broken out of this loop) before + // we find any non-parameters. + assert(varDsc->lvIsParam); - if (varDsc->lvArgReg == REG_STK) - { - baseVarNum = i; -#if defined(FEATURE_UNIX_AMR64_STRUCT_PASSING) - compiler->lvaFirstStackIncomingArgNum = baseVarNum; -#endif // FEATURE_UNIX_ARM64_STRUCT_PASSING - break; - } + if (varDsc->lvArgReg == REG_STK) + { + baseVarNum = i; + break; } - assert(varDsc != nullptr); } + assert(varDsc != nullptr); return baseVarNum; #elif defined(_TARGET_AMD64_) @@ -11225,9 +11233,7 @@ void CodeGen::genIPmappingAdd(IL_OFFSETX offsx, bool isLabel) /* Create a mapping entry and append it to the list */ - Compiler::IPmappingDsc* addMapping = - (Compiler::IPmappingDsc*)compiler->compGetMem(sizeof(*addMapping), CMK_DebugInfo); - + Compiler::IPmappingDsc* addMapping = compiler->getAllocator(CMK_DebugInfo).allocate(1); addMapping->ipmdNativeLoc.CaptureLocation(getEmitter()); addMapping->ipmdILoffsx = offsx; addMapping->ipmdIsLabel = isLabel; @@ -11286,9 +11292,7 @@ void CodeGen::genIPmappingAddToFront(IL_OFFSETX offsx) /* Create a mapping entry and prepend it to the list */ - Compiler::IPmappingDsc* addMapping = - (Compiler::IPmappingDsc*)compiler->compGetMem(sizeof(*addMapping), CMK_DebugInfo); - + Compiler::IPmappingDsc* addMapping = compiler->getAllocator(CMK_DebugInfo).allocate(1); addMapping->ipmdNativeLoc.CaptureLocation(getEmitter()); addMapping->ipmdILoffsx = offsx; addMapping->ipmdIsLabel = true; diff --git a/src/jit/codegenlinear.cpp b/src/jit/codegenlinear.cpp index 8d4cd55ad62a..428b107e708d 100644 --- a/src/jit/codegenlinear.cpp +++ b/src/jit/codegenlinear.cpp @@ -42,13 +42,13 @@ void CodeGen::genCodeForBBlist() // You have to be careful if you create basic blocks from now on compiler->fgSafeBasicBlockCreation = false; - // This stress mode is not comptible with fully interruptible GC + // This stress mode is not compatible with fully interruptible GC if (genInterruptible && compiler->opts.compStackCheckOnCall) { compiler->opts.compStackCheckOnCall = false; } - // This stress mode is not comptible with fully interruptible GC + // This stress mode is not compatible with fully interruptible GC if (genInterruptible && compiler->opts.compStackCheckOnRet) { compiler->opts.compStackCheckOnRet = false; @@ -445,7 +445,7 @@ void CodeGen::genCodeForBBlist() if (block->bbNext == nullptr) { // Unit testing of the emitter: generate a bunch of instructions into the last block -// (it's as good as any, but better than the prolog, which can only be a single instruction +// (it's as good as any, but better than the prologue, which can only be a single instruction // group) then use COMPlus_JitLateDisasm=* to see if the late disassembler // thinks the instructions are the same as we do. #if defined(_TARGET_AMD64_) && defined(LATE_DISASM) @@ -676,7 +676,7 @@ void CodeGen::genCodeForBBlist() /* Finalize the temp tracking logic */ - compiler->tmpEnd(); + regSet.tmpEnd(); #ifdef DEBUG if (compiler->verbose) @@ -991,14 +991,14 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree) TempDsc* t = regSet.rsUnspillInPlace(call, unspillTreeReg, i); getEmitter()->emitIns_R_S(ins_Load(dstType), emitActualTypeSize(dstType), dstReg, t->tdTempNum(), 0); - compiler->tmpRlsTemp(t); + regSet.tmpRlsTemp(t); gcInfo.gcMarkRegPtrVal(dstReg, dstType); } } unspillTree->gtFlags &= ~GTF_SPILLED; } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (unspillTree->OperIsPutArgSplit()) { GenTreePutArgSplit* splitArg = unspillTree->AsPutArgSplit(); @@ -1019,13 +1019,14 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree) TempDsc* t = regSet.rsUnspillInPlace(splitArg, dstReg, i); getEmitter()->emitIns_R_S(ins_Load(dstType), emitActualTypeSize(dstType), dstReg, t->tdTempNum(), 0); - compiler->tmpRlsTemp(t); + regSet.tmpRlsTemp(t); gcInfo.gcMarkRegPtrVal(dstReg, dstType); } } unspillTree->gtFlags &= ~GTF_SPILLED; } +#ifdef _TARGET_ARM_ else if (unspillTree->OperIsMultiRegOp()) { GenTreeMultiRegOp* multiReg = unspillTree->AsMultiRegOp(); @@ -1045,20 +1046,21 @@ void CodeGen::genUnspillRegIfNeeded(GenTree* tree) TempDsc* t = regSet.rsUnspillInPlace(multiReg, dstReg, i); getEmitter()->emitIns_R_S(ins_Load(dstType), emitActualTypeSize(dstType), dstReg, t->tdTempNum(), 0); - compiler->tmpRlsTemp(t); + regSet.tmpRlsTemp(t); gcInfo.gcMarkRegPtrVal(dstReg, dstType); } } unspillTree->gtFlags &= ~GTF_SPILLED; } -#endif +#endif //_TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT else { TempDsc* t = regSet.rsUnspillInPlace(unspillTree, unspillTree->gtRegNum); getEmitter()->emitIns_R_S(ins_Load(unspillTree->gtType), emitActualTypeSize(unspillTree->TypeGet()), dstReg, t->tdTempNum(), 0); - compiler->tmpRlsTemp(t); + regSet.tmpRlsTemp(t); unspillTree->gtFlags &= ~GTF_SPILLED; gcInfo.gcMarkRegPtrVal(dstReg, unspillTree->TypeGet()); @@ -1442,7 +1444,7 @@ void CodeGen::genConsumePutStructArgStk(GenTreePutArgStk* putArgNode, } #endif // FEATURE_PUT_STRUCT_ARG_STK -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT //------------------------------------------------------------------------ // genConsumeArgRegSplit: Consume register(s) in Call node to set split struct argument. // Liveness update for the PutArgSplit node is not needed @@ -1465,7 +1467,47 @@ void CodeGen::genConsumeArgSplitStruct(GenTreePutArgSplit* putArgNode) genCheckConsumeNode(putArgNode); } -#endif +#endif // FEATURE_ARG_SPLIT + +//------------------------------------------------------------------------ +// genPutArgStkFieldList: Generate code for a putArgStk whose source is a GT_FIELD_LIST +// +// Arguments: +// putArgStk - The putArgStk node +// outArgVarNum - The lclVar num for the argument +// +// Notes: +// The x86 version of this is in codegenxarch.cpp, and doesn't take an +// outArgVarNum, as it pushes its args onto the stack. +// +#ifndef _TARGET_X86_ +void CodeGen::genPutArgStkFieldList(GenTreePutArgStk* putArgStk, unsigned outArgVarNum) +{ + assert(putArgStk->gtOp1->OperIs(GT_FIELD_LIST)); + + // Evaluate each of the GT_FIELD_LIST items into their register + // and store their register into the outgoing argument area. + unsigned argOffset = putArgStk->getArgOffset(); + for (GenTreeFieldList* fieldListPtr = putArgStk->gtOp1->AsFieldList(); fieldListPtr != nullptr; + fieldListPtr = fieldListPtr->Rest()) + { + GenTree* nextArgNode = fieldListPtr->gtOp.gtOp1; + genConsumeReg(nextArgNode); + + regNumber reg = nextArgNode->gtRegNum; + var_types type = nextArgNode->TypeGet(); + emitAttr attr = emitTypeSize(type); + + // Emit store instructions to store the registers produced by the GT_FIELD_LIST into the outgoing + // argument area. + unsigned thisFieldOffset = argOffset + fieldListPtr->gtFieldOffset; + getEmitter()->emitIns_S_R(ins_Store(type), attr, reg, outArgVarNum, thisFieldOffset); + + // We can't write beyound the arg area + assert((thisFieldOffset + EA_SIZE_IN_BYTES(attr)) <= compiler->lvaLclSize(outArgVarNum)); + } +} +#endif // !_TARGET_X86_ //------------------------------------------------------------------------ // genSetBlockSize: Ensure that the block size is in the given register @@ -1661,7 +1703,7 @@ void CodeGen::genProduceReg(GenTree* tree) } } } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (tree->OperIsPutArgSplit()) { GenTreePutArgSplit* argSplit = tree->AsPutArgSplit(); @@ -1678,6 +1720,7 @@ void CodeGen::genProduceReg(GenTree* tree) } } } +#ifdef _TARGET_ARM_ else if (tree->OperIsMultiRegOp()) { GenTreeMultiRegOp* multiReg = tree->AsMultiRegOp(); @@ -1695,6 +1738,7 @@ void CodeGen::genProduceReg(GenTree* tree) } } #endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT else { regSet.rsSpillTree(tree->gtRegNum, tree); diff --git a/src/jit/codegenlinear.h b/src/jit/codegenlinear.h index 5a8df9c071f0..dfa4bf0d2e4a 100644 --- a/src/jit/codegenlinear.h +++ b/src/jit/codegenlinear.h @@ -43,9 +43,9 @@ void genCodeForCompare(GenTreeOp* tree); void genIntrinsic(GenTree* treeNode); void genPutArgStk(GenTreePutArgStk* treeNode); void genPutArgReg(GenTreeOp* tree); -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT void genPutArgSplit(GenTreePutArgSplit* treeNode); -#endif +#endif // FEATURE_ARG_SPLIT #if defined(_TARGET_XARCH_) unsigned getBaseVarForPutArgStk(GenTree* treeNode); @@ -117,7 +117,7 @@ void genHWIntrinsic(GenTreeHWIntrinsic* node); #if defined(_TARGET_XARCH_) void genHWIntrinsic_R_RM(GenTreeHWIntrinsic* node, instruction ins, emitAttr attr); void genHWIntrinsic_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, int8_t ival); -void genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins); +void genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins, emitAttr attr); void genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, int8_t ival); void genHWIntrinsic_R_R_RM_R(GenTreeHWIntrinsic* node, instruction ins); void genHWIntrinsic_R_R_R_RM( @@ -194,9 +194,9 @@ void genConsumeBlockOp(GenTreeBlk* blkNode, regNumber dstReg, regNumber srcReg, #ifdef FEATURE_PUT_STRUCT_ARG_STK void genConsumePutStructArgStk(GenTreePutArgStk* putArgStkNode, regNumber dstReg, regNumber srcReg, regNumber sizeReg); #endif // FEATURE_PUT_STRUCT_ARG_STK -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT void genConsumeArgSplitStruct(GenTreePutArgSplit* putArgNode); -#endif +#endif // FEATURE_ARG_SPLIT void genConsumeRegs(GenTree* tree); void genConsumeOperands(GenTreeOp* tree); @@ -273,6 +273,10 @@ void AddNestedAlignment(unsigned adjustment) #endif +#ifndef _TARGET_X86_ +void genPutArgStkFieldList(GenTreePutArgStk* putArgStk, unsigned outArgVarNum); +#endif // !_TARGET_X86_ + #ifdef FEATURE_PUT_STRUCT_ARG_STK #ifdef _TARGET_X86_ bool genAdjustStackForPutArgStk(GenTreePutArgStk* putArgStk); diff --git a/src/jit/codegenxarch.cpp b/src/jit/codegenxarch.cpp index b24874349280..1ceb928778cd 100644 --- a/src/jit/codegenxarch.cpp +++ b/src/jit/codegenxarch.cpp @@ -162,7 +162,7 @@ void CodeGen::genEmitGSCookieCheck(bool pushReg) // cookie check as part of tail call codegen. GenExitCode() needs to special case // fast tail calls implemented as epilog+jmp or such tail calls should always get // dispatched via helper. - // 3) Materialize GS cookie check as a sperate node hanging off GT_CALL node in + // 3) Materialize GS cookie check as a separate node hanging off GT_CALL node in // right execution order during rationalization. // // There are two calls that use R11: VSD and calli pinvokes with cookie param. Tail @@ -365,7 +365,7 @@ void CodeGen::genEHCatchRet(BasicBlock* block) // Set RAX to the address the VM should return to after the catch. // Generate a RIP-relative // lea reg, [rip + disp32] ; the RIP is implicit - // which will be position-indepenent. + // which will be position-independent. getEmitter()->emitIns_R_L(INS_lea, EA_PTR_DSP_RELOC, block->bbJumpDest, REG_INTRET); } @@ -1294,7 +1294,7 @@ void CodeGen::genFloatReturn(GenTree* treeNode) TempDsc* t = regSet.rsUnspillInPlace(op1, op1->gtRegNum); inst_FS_ST(INS_fld, emitActualTypeSize(op1->gtType), t, 0); op1->gtFlags &= ~GTF_SPILLED; - compiler->tmpRlsTemp(t); + regSet.tmpRlsTemp(t); } } #endif // _TARGET_X86_ @@ -5012,11 +5012,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call) genConsumeReg(putArgRegNode); // Validate the putArgRegNode has the right type. - assert(putArgRegNode->TypeGet() == - compiler->GetTypeFromClassificationAndSizes(curArgTabEntry->structDesc - .eightByteClassifications[iterationNum], - curArgTabEntry->structDesc - .eightByteSizes[iterationNum])); + assert(varTypeIsFloating(putArgRegNode->TypeGet()) == genIsValidFloatReg(argReg)); if (putArgRegNode->gtRegNum != argReg) { inst_RV_RV(ins_Move_Extend(putArgRegNode->TypeGet(), false), argReg, putArgRegNode->gtRegNum); @@ -6004,7 +6000,7 @@ void CodeGen::genJumpKindsForTree(GenTree* cmpTree, emitJumpKind jmpKind[2], boo // jne // // As we can see from the above equalities that the operands of a compare operator need to be -// reveresed in case of BLT/CLT, BGT.UN/CGT.UN, BLE/CLE, BGE.UN/CGE.UN. +// reversed in case of BLT/CLT, BGT.UN/CGT.UN, BLE/CLE, BGE.UN/CGE.UN. void CodeGen::genCompareFloat(GenTree* treeNode) { assert(treeNode->OperIsCompare()); @@ -6517,7 +6513,7 @@ void CodeGen::genIntToIntCast(GenTree* treeNode) if (needScratchReg) { regNumber tmpReg = treeNode->GetSingleTempReg(); - inst_RV_RV(INS_mov, tmpReg, sourceReg, TYP_LONG); // Move the 64-bit value to a writeable temp reg + inst_RV_RV(INS_mov, tmpReg, sourceReg, TYP_LONG); // Move the 64-bit value to a writable temp reg inst_RV_SH(INS_SHIFT_RIGHT_LOGICAL, srcSize, tmpReg, 32); // Shift right by 32 bits genJumpToThrowHlpBlk(EJ_jne, SCK_OVERFLOW); // Throw if result shift is non-zero } @@ -6729,7 +6725,7 @@ void CodeGen::genIntToFloatCast(GenTree* treeNode) // which does a partial write to lower 4/8 bytes of xmm register keeping the other // upper bytes unmodified. If "cvtsi2ss/sd xmmReg, r32/r64" occurs inside a loop, // the partial write could introduce a false dependency and could cause a stall - // if there are further uses of xmmReg. We have such a case occuring with a + // if there are further uses of xmmReg. We have such a case occurring with a // customer reported version of SpectralNorm benchmark, resulting in 2x perf // regression. To avoid false dependency, we emit "xorps xmmReg, xmmReg" before // cvtsi2ss/sd instruction. @@ -6748,7 +6744,7 @@ void CodeGen::genIntToFloatCast(GenTree* treeNode) if (srcType == TYP_ULONG) { // The instruction sequence below is less accurate than what clang - // and gcc generate. However, we keep the current sequence for backward compatiblity. + // and gcc generate. However, we keep the current sequence for backward compatibility. // If we change the instructions below, FloatingPointUtils::convertUInt64ToDobule // should be also updated for consistent conversion result. assert(dstType == TYP_DOUBLE); @@ -6835,7 +6831,7 @@ void CodeGen::genFloatToIntCast(GenTree* treeNode) // If the dstType is TYP_UINT, we have 32-bits to encode the // float number. Any of 33rd or above bits can be the sign bit. - // To acheive it we pretend as if we are converting it to a long. + // To achieve it we pretend as if we are converting it to a long. if (varTypeIsUnsigned(dstType) && (dstSize == EA_ATTR(genTypeSize(TYP_INT)))) { dstType = TYP_LONG; @@ -6908,7 +6904,7 @@ void CodeGen::genCkfinite(GenTree* treeNode) // If the target type is TYP_DOUBLE, we want to extract the high 32 bits into the register. // There is no easy way to do this. To not require an extra register, we'll use shuffles - // to move the high 32 bits into the low 32 bits, then then shuffle it back, since we + // to move the high 32 bits into the low 32 bits, then shuffle it back, since we // need to produce the value into the target register. // // For TYP_DOUBLE, we'll generate (for targetReg != op1->gtRegNum): @@ -7281,7 +7277,7 @@ void CodeGen::genSSE41RoundOp(GenTreeOp* treeNode) varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (srcNode->isIndir()) { @@ -7770,7 +7766,7 @@ void CodeGen::genPutArgStkFieldList(GenTreePutArgStk* putArgStk) assert(fieldNode->IsRegOptional()); TempDsc* tmp = getSpillTempDsc(fieldNode); getEmitter()->emitIns_S(INS_push, emitActualTypeSize(fieldNode->TypeGet()), tmp->tdTempNum(), 0); - compiler->tmpRlsTemp(tmp); + regSet.tmpRlsTemp(tmp); } else { @@ -7907,7 +7903,12 @@ void CodeGen::genPutArgStk(GenTreePutArgStk* putArgStk) #ifdef UNIX_AMD64_ABI - if (varTypeIsStruct(targetType)) + if (data->OperIs(GT_FIELD_LIST)) + { + genPutArgStkFieldList(putArgStk, baseVarNum); + return; + } + else if (varTypeIsStruct(targetType)) { m_stkArgVarNum = baseVarNum; m_stkArgOffset = putArgStk->getArgOffset(); diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp index a75ad6cdfe0f..edfe431357c6 100644 --- a/src/jit/compiler.cpp +++ b/src/jit/compiler.cpp @@ -589,7 +589,7 @@ bool Compiler::isSingleFloat32Struct(CORINFO_CLASS_HANDLE clsHnd) // For ARM32 if we have an HFA struct that wraps a 64-bit double // we will return TYP_DOUBLE. // -var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd) +var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd, bool isVarArg) { assert(structSize != 0); @@ -605,12 +605,12 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS useType = TYP_SHORT; break; -#ifndef _TARGET_XARCH_ +#if !defined(_TARGET_XARCH_) || defined(UNIX_AMD64_ABI) case 3: useType = TYP_INT; break; -#endif // _TARGET_XARCH_ +#endif // !_TARGET_XARCH_ || UNIX_AMD64_ABI #ifdef _TARGET_64BIT_ case 4: @@ -625,14 +625,14 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS } break; -#ifndef _TARGET_XARCH_ +#if !defined(_TARGET_XARCH_) || defined(UNIX_AMD64_ABI) case 5: case 6: case 7: useType = TYP_I_IMPL; break; -#endif // _TARGET_XARCH_ +#endif // !_TARGET_XARCH_ || UNIX_AMD64_ABI #endif // _TARGET_64BIT_ case TARGET_POINTER_SIZE: @@ -640,8 +640,15 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS // For ARM_SOFTFP, HFA is unsupported so we need to check in another way // This matters only for size-4 struct cause bigger structs would be processed with RetBuf if (isSingleFloat32Struct(clsHnd)) -#else // !ARM_SOFTFP - if (IsHfa(clsHnd)) +#else // !ARM_SOFTFP + if (IsHfa(clsHnd) +#if defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + // Arm64 Windows VarArg methods arguments will not + // classify HFA types, they will need to be treated + // as if they are not HFA types. + && !isVarArg +#endif // defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + ) #endif // ARM_SOFTFP { #ifdef _TARGET_64BIT_ @@ -729,6 +736,7 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS // clsHnd - the handle for the struct type // wbPassStruct - An "out" argument with information about how // the struct is to be passed +// isVarArg - is vararg, used to ignore HFA types for Arm64 windows varargs // structSize - the size of the struct type, // or zero if we should call getClassSize(clsHnd) // @@ -756,6 +764,7 @@ var_types Compiler::getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS // var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbPassStruct, + bool isVarArg, unsigned structSize /* = 0 */) { var_types useType = TYP_UNKNOWN; @@ -767,6 +776,9 @@ var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, } assert(structSize > 0); +// Determine if we can pass the struct as a primitive type. +// Note that on x86 we never pass structs as primitive types (unless the VM unwraps them for us). +#ifndef _TARGET_X86_ #ifdef UNIX_AMD64_ABI // An 8-byte struct may need to be passed in a floating point register @@ -775,32 +787,33 @@ var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; eeGetSystemVAmd64PassStructInRegisterDescriptor(clsHnd, &structDesc); - // If we have one eightByteCount then we can set 'useType' based on that - if (structDesc.eightByteCount == 1) + if (structDesc.passedInRegisters && (structDesc.eightByteCount != 1)) + { + // We can't pass this as a primitive type. + } + else if (structDesc.eightByteClassifications[0] == SystemVClassificationTypeSSE) { - // Set 'useType' to the type of the first eightbyte item + // If this is passed as a floating type, use that. + // Otherwise, we'll use the general case - we don't want to use the "EightByteType" + // directly, because it returns `TYP_INT` for any integral type <= 4 bytes, and + // we need to preserve small types. useType = GetEightByteType(structDesc, 0); } + else +#endif // UNIX_AMD64_ABI -#elif defined(_TARGET_X86_) - - // On x86 we never pass structs as primitive types (unless the VM unwraps them for us) - useType = TYP_UNKNOWN; - -#else // all other targets - - // The largest primitive type is 8 bytes (TYP_DOUBLE) - // so we can skip calling getPrimitiveTypeForStruct when we - // have a struct that is larger than that. - // - if (structSize <= sizeof(double)) + // The largest primitive type is 8 bytes (TYP_DOUBLE) + // so we can skip calling getPrimitiveTypeForStruct when we + // have a struct that is larger than that. + // + if (structSize <= sizeof(double)) { // We set the "primitive" useType based upon the structSize // and also examine the clsHnd to see if it is an HFA of count one - useType = getPrimitiveTypeForStruct(structSize, clsHnd); + useType = getPrimitiveTypeForStruct(structSize, clsHnd, isVarArg); } -#endif // all other targets +#endif // !_TARGET_X86_ // Did we change this struct type into a simple "primitive" type? // @@ -817,7 +830,13 @@ var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, if (structSize <= MAX_PASS_MULTIREG_BYTES) { // Structs that are HFA's are passed by value in multiple registers - if (IsHfa(clsHnd)) + if (IsHfa(clsHnd) +#if defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + && !isVarArg // Arm64 Windows VarArg methods arguments will not + // classify HFA types, they will need to be treated + // as if they are not HFA types. +#endif // defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + ) { // HFA's of count one should have been handled by getPrimitiveTypeForStruct assert(GetHfaCount(clsHnd) >= 2); @@ -834,7 +853,7 @@ var_types Compiler::getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, #ifdef UNIX_AMD64_ABI // The case of (structDesc.eightByteCount == 1) should have already been handled - if (structDesc.eightByteCount > 1) + if ((structDesc.eightByteCount > 1) || !structDesc.passedInRegisters) { // setup wbPassType and useType indicate that this is passed by value in multiple registers // (when all of the parameters registers are used, then the stack will be used) @@ -973,8 +992,9 @@ var_types Compiler::getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbReturnStruct /* = nullptr */, unsigned structSize /* = 0 */) { - var_types useType = TYP_UNKNOWN; - structPassingKind howToReturnStruct = SPK_Unknown; // We must change this before we return + var_types useType = TYP_UNKNOWN; + structPassingKind howToReturnStruct = SPK_Unknown; // We must change this before we return + bool canReturnInRegister = true; assert(clsHnd != NO_CLASS_HANDLE); @@ -985,35 +1005,63 @@ var_types Compiler::getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, assert(structSize > 0); #ifdef UNIX_AMD64_ABI - // An 8-byte struct may need to be returned in a floating point register // So we always consult the struct "Classifier" routine // SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; eeGetSystemVAmd64PassStructInRegisterDescriptor(clsHnd, &structDesc); - // If we have one eightByteCount then we can set 'useType' based on that if (structDesc.eightByteCount == 1) { - // Set 'useType' to the type of the first eightbyte item - useType = GetEightByteType(structDesc, 0); - assert(structDesc.passedInRegisters == true); + assert(structSize <= sizeof(double)); + assert(structDesc.passedInRegisters); + + if (structDesc.eightByteClassifications[0] == SystemVClassificationTypeSSE) + { + // If this is returned as a floating type, use that. + // Otherwise, leave as TYP_UNKONWN and we'll sort things out below. + useType = GetEightByteType(structDesc, 0); + howToReturnStruct = SPK_PrimitiveType; + } + } + else + { + // Return classification is not always size based... + canReturnInRegister = structDesc.passedInRegisters; } -#else // not UNIX_AMD64 +#endif // UNIX_AMD64_ABI + // Check for cases where a small struct is returned in a register + // via a primitive type. + // // The largest primitive type is 8 bytes (TYP_DOUBLE) // so we can skip calling getPrimitiveTypeForStruct when we // have a struct that is larger than that. - // - if (structSize <= sizeof(double)) + if (canReturnInRegister && (useType == TYP_UNKNOWN) && (structSize <= sizeof(double))) { // We set the "primitive" useType based upon the structSize // and also examine the clsHnd to see if it is an HFA of count one - useType = getPrimitiveTypeForStruct(structSize, clsHnd); - } + // + // The ABI for struct returns in varArg methods, is same as the normal case, + // so pass false for isVararg + useType = getPrimitiveTypeForStruct(structSize, clsHnd, /*isVararg=*/false); -#endif // UNIX_AMD64_ABI + if (useType != TYP_UNKNOWN) + { + if (structSize == genTypeSize(useType)) + { + // Currently: 1, 2, 4, or 8 byte structs + howToReturnStruct = SPK_PrimitiveType; + } + else + { + // Currently: 3, 5, 6, or 7 byte structs + assert(structSize < genTypeSize(useType)); + howToReturnStruct = SPK_EnclosingType; + } + } + } #ifdef _TARGET_64BIT_ // Note this handles an odd case when FEATURE_MULTIREG_RET is disabled and HFAs are enabled @@ -1027,16 +1075,16 @@ var_types Compiler::getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, // if ((FEATURE_MULTIREG_RET == 0) && (useType == TYP_UNKNOWN) && (structSize == (2 * sizeof(float))) && IsHfa(clsHnd)) { - useType = TYP_I_IMPL; + useType = TYP_I_IMPL; + howToReturnStruct = SPK_PrimitiveType; } #endif // Did we change this struct type into a simple "primitive" type? - // if (useType != TYP_UNKNOWN) { - // Yes, we should use the "primitive" type in 'useType' - howToReturnStruct = SPK_PrimitiveType; + // If so, we should have already set howToReturnStruct, too. + assert(howToReturnStruct != SPK_Unknown); } else // We can't replace the struct with a "primitive" type { @@ -1164,11 +1212,11 @@ struct FileLine FileLine(const char* file, unsigned line, const char* condStr) : m_line(line) { size_t newSize = (strlen(file) + 1) * sizeof(char); - m_file = (char*)HostAllocator::getHostAllocator()->Alloc(newSize); + m_file = HostAllocator::getHostAllocator().allocate(newSize); strcpy_s(m_file, newSize, file); newSize = (strlen(condStr) + 1) * sizeof(char); - m_condStr = (char*)HostAllocator::getHostAllocator()->Alloc(newSize); + m_condStr = HostAllocator::getHostAllocator().allocate(newSize); strcpy_s(m_condStr, newSize, condStr); } @@ -1353,9 +1401,6 @@ void Compiler::compStartup() grossVMsize = grossNCsize = totalNCsize = 0; #endif // DISPLAY_SIZES - // Initialize the JIT's allocator. - ArenaAllocator::startup(); - /* Initialize the table of tree node sizes */ GenTree::InitNodeSize(); @@ -1404,8 +1449,6 @@ void Compiler::compShutdown() DisplayNowayAssertMap(); #endif // MEASURE_NOWAY - ArenaAllocator::shutdown(); - /* Shut down the emitter */ emitter::emitDone(); @@ -1441,21 +1484,6 @@ void Compiler::compShutdown() } #endif // FEATURE_JIT_METHOD_PERF -#if FUNC_INFO_LOGGING - if (compJitFuncInfoFile != nullptr) - { - fclose(compJitFuncInfoFile); - compJitFuncInfoFile = nullptr; - } -#endif // FUNC_INFO_LOGGING - -#if COUNT_RANGECHECKS - if (optRangeChkAll > 0) - { - fprintf(fout, "Removed %u of %u range checks\n", optRangeChkRmv, optRangeChkAll); - } -#endif // COUNT_RANGECHECKS - #if COUNT_AST_OPERS // Add up all the counts so that we can show percentages of total @@ -1669,10 +1697,10 @@ void Compiler::compShutdown() if (s_dspMemStats) { fprintf(fout, "\nAll allocations:\n"); - s_aggMemStats.Print(jitstdout); + ArenaAllocator::dumpAggregateMemStats(jitstdout); fprintf(fout, "\nLargest method:\n"); - s_maxCompMemStats.Print(jitstdout); + ArenaAllocator::dumpMaxMemStats(jitstdout); fprintf(fout, "\n"); fprintf(fout, "---------------------------------------------------\n"); @@ -1878,7 +1906,7 @@ void Compiler::compDisplayStaticSizes(FILE* fout) void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) { assert(pAlloc); - compAllocator = pAlloc; + compArenaAllocator = pAlloc; // Inlinee Compile object will only be allocated when needed for the 1st time. InlineeCompiler = nullptr; @@ -1894,32 +1922,11 @@ void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) { m_inlineStrategy = nullptr; compInlineResult = inlineInfo->inlineResult; - - // We shouldn't be using the compAllocatorGeneric for other than the root compiler. - compAllocatorGeneric = nullptr; -#if MEASURE_MEM_ALLOC - compAllocatorBitset = nullptr; - compAllocatorGC = nullptr; - compAllocatorLoopHoist = nullptr; -#ifdef DEBUG - compAllocatorDebugOnly = nullptr; -#endif // DEBUG -#endif // MEASURE_MEM_ALLOC } else { m_inlineStrategy = new (this, CMK_Inlining) InlineStrategy(this); compInlineResult = nullptr; - - compAllocatorGeneric = new (this, CMK_Unknown) CompAllocator(this, CMK_Generic); -#if MEASURE_MEM_ALLOC - compAllocatorBitset = new (this, CMK_Unknown) CompAllocator(this, CMK_bitset); - compAllocatorGC = new (this, CMK_Unknown) CompAllocator(this, CMK_GC); - compAllocatorLoopHoist = new (this, CMK_Unknown) CompAllocator(this, CMK_LoopHoist); -#ifdef DEBUG - compAllocatorDebugOnly = new (this, CMK_Unknown) CompAllocator(this, CMK_DebugOnly); -#endif // DEBUG -#endif // MEASURE_MEM_ALLOC } #ifdef FEATURE_TRACELOGGING @@ -1967,9 +1974,6 @@ void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) optLoopsCloned = 0; -#if MEASURE_MEM_ALLOC - genMemStats.Init(); -#endif // MEASURE_MEM_ALLOC #if LOOP_HOIST_STATS m_loopsConsidered = 0; m_curLoopHasHoistedExpression = false; @@ -1994,9 +1998,7 @@ void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) compQmarkUsed = false; compFloatingPointUsed = false; compUnsafeCastUsed = false; -#if CPU_USES_BLOCK_MOVE - compBlkOpUsed = false; -#endif + compNeedsGSSecurityCookie = false; compGSReorderStackLayout = false; #if STACK_PROBES @@ -2022,11 +2024,6 @@ void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) // Used to track when we should consider running EarlyProp optMethodFlags = 0; - for (unsigned i = 0; i < MAX_LOOP_NUM; i++) - { - AllVarSetOps::AssignNoCopy(this, optLoopTable[i].lpAsgVars, AllVarSetOps::UninitVal()); - } - #ifdef DEBUG m_nodeTestData = nullptr; m_loopHoistCSEClass = FIRST_LOOP_HOIST_CSE_CLASS; @@ -2063,54 +2060,7 @@ void Compiler::compInit(ArenaAllocator* pAlloc, InlineInfo* inlineInfo) fgOrder = FGOrderTree; #ifdef FEATURE_SIMD - // SIMD Types - SIMDFloatHandle = nullptr; - SIMDDoubleHandle = nullptr; - SIMDIntHandle = nullptr; - SIMDUShortHandle = nullptr; - SIMDUByteHandle = nullptr; - SIMDShortHandle = nullptr; - SIMDByteHandle = nullptr; - SIMDLongHandle = nullptr; - SIMDUIntHandle = nullptr; - SIMDULongHandle = nullptr; - SIMDVector2Handle = nullptr; - SIMDVector3Handle = nullptr; - SIMDVector4Handle = nullptr; - SIMDVectorHandle = nullptr; -#ifdef FEATURE_HW_INTRINSICS -#if defined(_TARGET_ARM64_) - Vector64FloatHandle = nullptr; - Vector64UIntHandle = nullptr; - Vector64UShortHandle = nullptr; - Vector64UByteHandle = nullptr; - Vector64IntHandle = nullptr; - Vector64ShortHandle = nullptr; - Vector64ByteHandle = nullptr; -#endif // defined(_TARGET_ARM64_) - Vector128FloatHandle = nullptr; - Vector128DoubleHandle = nullptr; - Vector128IntHandle = nullptr; - Vector128UShortHandle = nullptr; - Vector128UByteHandle = nullptr; - Vector128ShortHandle = nullptr; - Vector128ByteHandle = nullptr; - Vector128LongHandle = nullptr; - Vector128UIntHandle = nullptr; - Vector128ULongHandle = nullptr; -#if defined(_TARGET_XARCH_) - Vector256FloatHandle = nullptr; - Vector256DoubleHandle = nullptr; - Vector256IntHandle = nullptr; - Vector256UShortHandle = nullptr; - Vector256UByteHandle = nullptr; - Vector256ShortHandle = nullptr; - Vector256ByteHandle = nullptr; - Vector256LongHandle = nullptr; - Vector256UIntHandle = nullptr; - Vector256ULongHandle = nullptr; -#endif // defined(_TARGET_XARCH_) -#endif // FEATURE_HW_INTRINSICS + m_simdHandleCache = nullptr; #endif // FEATURE_SIMD compUsesThrowHelper = false; @@ -2216,47 +2166,6 @@ unsigned char Compiler::compGetJitDefaultFill() #endif // DEBUG -/***************************************************************************** - * - * The central memory allocation routine used by the compiler. Normally this - * is a simple inline method defined in compiler.hpp, but for debugging it's - * often convenient to keep it non-inline. - */ - -#ifdef DEBUG - -void* Compiler::compGetMem(size_t sz, CompMemKind cmk) -{ -#if 0 -#if SMALL_TREE_NODES - if (sz != TREE_NODE_SZ_SMALL && - sz != TREE_NODE_SZ_LARGE && sz > 32) - { - printf("Alloc %3u bytes\n", sz); - } -#else - if (sz != sizeof(GenTree) && sz > 32) - { - printf("Alloc %3u bytes\n", sz); - } -#endif -#endif // 0 - -#if MEASURE_MEM_ALLOC - genMemStats.AddAlloc(sz, cmk); -#endif - - void* ptr = compAllocator->allocateMemory(sz); - - // Verify that the current block is aligned. Only then will the next - // block allocated be on an aligned boundary. - assert((size_t(ptr) & (sizeof(size_t) - 1)) == 0); - - return ptr; -} - -#endif - /*****************************************************************************/ #ifdef DEBUG /*****************************************************************************/ @@ -2456,14 +2365,18 @@ static bool configEnableISA(InstructionSet isa) return false; } #else - // We have a retail config switch that can disable AVX/FMA/AVX2 instructions - if ((isa == InstructionSet_AVX) || (isa == InstructionSet_FMA) || (isa == InstructionSet_AVX2)) - { - return JitConfig.EnableAVX() != 0; - } - else + // We have a retail config switch that can disable instruction sets reliant on the VEX encoding + switch (isa) { - return true; + case InstructionSet_AVX: + case InstructionSet_FMA: + case InstructionSet_AVX2: + case InstructionSet_BMI1: + case InstructionSet_BMI2: + return JitConfig.EnableAVX() != 0; + + default: + return true; } #endif } @@ -2526,20 +2439,6 @@ void Compiler::compSetProcessor() opts.setSupportedISA(InstructionSet_AES); } } - if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI1)) - { - if (configEnableISA(InstructionSet_BMI1)) - { - opts.setSupportedISA(InstructionSet_BMI1); - } - } - if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI2)) - { - if (configEnableISA(InstructionSet_BMI2)) - { - opts.setSupportedISA(InstructionSet_BMI2); - } - } if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_LZCNT)) { if (configEnableISA(InstructionSet_LZCNT)) @@ -2597,7 +2496,7 @@ void Compiler::compSetProcessor() } } - // There are currently two sets of flags that control AVX, FMA, and AVX2 support: + // There are currently two sets of flags that control instruction sets that require the VEX encoding: // These are the general EnableAVX flag and the individual ISA flags. We need to // check both for any given isa. if (JitConfig.EnableAVX()) @@ -2623,6 +2522,20 @@ void Compiler::compSetProcessor() opts.setSupportedISA(InstructionSet_AVX2); } } + if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI1)) + { + if (configEnableISA(InstructionSet_BMI1)) + { + opts.setSupportedISA(InstructionSet_BMI1); + } + } + if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI2)) + { + if (configEnableISA(InstructionSet_BMI2)) + { + opts.setSupportedISA(InstructionSet_BMI2); + } + } } } @@ -4057,7 +3970,8 @@ void Compiler::compSetOptimizationLevel() if (!theMinOptsValue && (jitMinOpts > 0)) { - unsigned methodCount = Compiler::jitTotalMethodCompiled; + // jitTotalMethodCompiled does not include the method that is being compiled now, so make +1. + unsigned methodCount = Compiler::jitTotalMethodCompiled + 1; unsigned methodCountMask = methodCount & 0xFFF; unsigned kind = (jitMinOpts & 0xF000000) >> 24; switch (kind) @@ -4325,7 +4239,10 @@ bool Compiler::compRsvdRegCheck(FrameLayoutState curState) // Always do the layout even if returning early. Callers might // depend on us to do the layout. unsigned frameSize = lvaFrameSize(curState); - JITDUMP("\ncompRsvdRegCheck\n frame size = %6d\n compArgSize = %6d\n", frameSize, compArgSize); + JITDUMP("\ncompRsvdRegCheck\n" + " frame size = %6d\n" + " compArgSize = %6d\n", + frameSize, compArgSize); if (opts.MinOpts()) { @@ -4341,8 +4258,9 @@ bool Compiler::compRsvdRegCheck(FrameLayoutState curState) { calleeSavedRegMaxSz += CALLEE_SAVED_FLOAT_MAXSZ; } + calleeSavedRegMaxSz += REGSIZE_BYTES; // we always push LR. See genPushCalleeSavedRegisters - noway_assert(frameSize > calleeSavedRegMaxSz); + noway_assert(frameSize >= calleeSavedRegMaxSz); #if defined(_TARGET_ARM64_) @@ -4354,69 +4272,117 @@ bool Compiler::compRsvdRegCheck(FrameLayoutState curState) // frame layout: // - // low addresses - // inArgs compArgSize - // origSP ---> - // LR ---> - // R11 ---> - // + callee saved regs CALLEE_SAVED_REG_MAXSZ (32 bytes) - // optional saved fp regs 16 * sizeof(float) (64 bytes) - // - lclSize + // ... high addresses ... + // frame contents size + // ------------------- ------------------------ + // inArgs compArgSize (includes prespill) + // caller SP ---> + // prespill + // LR REGSIZE_BYTES + // R11 ---> R11 REGSIZE_BYTES + // callee saved regs CALLEE_SAVED_REG_MAXSZ (32 bytes) + // optional saved fp regs CALLEE_SAVED_FLOAT_MAXSZ (64 bytes) + // lclSize // incl. TEMPS MAX_SPILL_TEMP_SIZE - // + incl. outArgs + // incl. outArgs // SP ---> - // - - // high addresses - - // With codeGen->isFramePointerRequired we use R11 to access incoming args with positive offsets - // and use R11 to access LclVars with negative offsets in the non funclet or - // main region we use SP with positive offsets. The limiting factor in the - // codeGen->isFramePointerRequired case is that we need the offset to be less than or equal to 0x7C - // for negative offsets, but positive offsets can be imm12 limited by vldr/vstr - // using +/-imm8. + // ... low addresses ... // - // Subtract 4 bytes for alignment of a local var because number of temps could - // trigger a misaligned double or long. + // When codeGen->isFramePointerRequired is true, R11 will be established as a frame pointer. + // We can then use R11 to access incoming args with positive offsets, and LclVars with + // negative offsets. // - unsigned maxR11ArgLimit = (compFloatingPointUsed ? 0x03FC : 0x0FFC); - unsigned maxR11LclLimit = 0x0078; - JITDUMP(" maxR11ArgLimit = %6d\n maxR11LclLimit = %6d\n", maxR11ArgLimit, maxR11LclLimit); + // In functions with EH, in the non-funclet (or main) region, even though we will have a + // frame pointer, we can use SP with positive offsets to access any or all locals or arguments + // that we can reach with SP-relative encodings. The funclet region might require the reserved + // register, since it must use offsets from R11 to access the parent frame. + + unsigned maxR11PositiveEncodingOffset = compFloatingPointUsed ? 0x03FC : 0x0FFF; + JITDUMP(" maxR11PositiveEncodingOffset = %6d\n", maxR11PositiveEncodingOffset); + + // Floating point load/store instructions (VLDR/VSTR) can address up to -0x3FC from R11, but we + // don't know if there are either no integer locals, or if we don't need large negative offsets + // for the integer locals, so we must use the integer max negative offset, which is a + // smaller (absolute value) number. + unsigned maxR11NegativeEncodingOffset = 0x00FF; // This is a negative offset from R11. + JITDUMP(" maxR11NegativeEncodingOffset = %6d\n", maxR11NegativeEncodingOffset); + + // -1 because otherwise we are computing the address just beyond the last argument, which we don't need to do. + unsigned maxR11PositiveOffset = compArgSize + (2 * REGSIZE_BYTES) - 1; + JITDUMP(" maxR11PositiveOffset = %6d\n", maxR11PositiveOffset); + + // The value is positive, but represents a negative offset from R11. + // frameSize includes callee-saved space for R11 and LR, which are at non-negative offsets from R11 + // (+0 and +4, respectively), so don't include those in the max possible negative offset. + assert(frameSize >= (2 * REGSIZE_BYTES)); + unsigned maxR11NegativeOffset = frameSize - (2 * REGSIZE_BYTES); + JITDUMP(" maxR11NegativeOffset = %6d\n", maxR11NegativeOffset); if (codeGen->isFramePointerRequired()) { - unsigned maxR11LclOffs = frameSize; - unsigned maxR11ArgOffs = compArgSize + (2 * REGSIZE_BYTES); - JITDUMP(" maxR11LclOffs = %6d\n maxR11ArgOffs = %6d\n", maxR11LclOffs, maxR11ArgOffs) - if (maxR11LclOffs > maxR11LclLimit) + if (maxR11NegativeOffset > maxR11NegativeEncodingOffset) { - JITDUMP(" Returning true (frame reqd and maxR11LclOffs)\n\n"); + JITDUMP(" Returning true (frame required and maxR11NegativeOffset)\n\n"); return true; } - if (maxR11ArgOffs > maxR11ArgLimit) + if (maxR11PositiveOffset > maxR11PositiveEncodingOffset) { - JITDUMP(" Returning true (frame reqd and maxR11ArgOffs)\n\n"); + JITDUMP(" Returning true (frame required and maxR11PositiveOffset)\n\n"); return true; } } - // So this case is the SP based frame case, but note that we also will use SP based - // offsets for R11 based frames in the non-funclet main code area. However if we have - // passed the above max_R11_offset check these SP checks won't fire. + // Now consider the SP based frame case. Note that we will use SP based offsets to access the stack in R11 based + // frames in the non-funclet main code area. + + unsigned maxSPPositiveEncodingOffset = compFloatingPointUsed ? 0x03FC : 0x0FFF; + JITDUMP(" maxSPPositiveEncodingOffset = %6d\n", maxSPPositiveEncodingOffset); - // Check local coverage first. If vldr/vstr will be used the limit can be +/-imm8. - unsigned maxSPLclLimit = (compFloatingPointUsed ? 0x03F8 : 0x0FF8); - JITDUMP(" maxSPLclLimit = %6d\n", maxSPLclLimit); - if (frameSize > (codeGen->isFramePointerUsed() ? (maxR11LclLimit + maxSPLclLimit) : maxSPLclLimit)) + // -1 because otherwise we are computing the address just beyond the last argument, which we don't need to do. + assert(compArgSize + frameSize > 0); + unsigned maxSPPositiveOffset = compArgSize + frameSize - 1; + + if (codeGen->isFramePointerUsed()) { - JITDUMP(" Returning true (frame reqd; local coverage)\n\n"); - return true; - } + // We have a frame pointer, so we can use it to access part of the stack, even if SP can't reach those parts. + // We will still generate SP-relative offsets if SP can reach. + + // First, check that the stack between R11 and SP can be fully reached, either via negative offset from FP + // or positive offset from SP. Don't count stored R11 or LR, which are reached from positive offsets from FP. + + unsigned maxSPLocalsCombinedOffset = frameSize - (2 * REGSIZE_BYTES) - 1; + JITDUMP(" maxSPLocalsCombinedOffset = %6d\n", maxSPLocalsCombinedOffset); - // Check arguments coverage. - if ((!codeGen->isFramePointerUsed() || (compArgSize > maxR11ArgLimit)) && (compArgSize + frameSize) > maxSPLclLimit) + if (maxSPLocalsCombinedOffset > maxSPPositiveEncodingOffset) + { + // Can R11 help? + unsigned maxRemainingLocalsCombinedOffset = maxSPLocalsCombinedOffset - maxSPPositiveEncodingOffset; + JITDUMP(" maxRemainingLocalsCombinedOffset = %6d\n", maxRemainingLocalsCombinedOffset); + + if (maxRemainingLocalsCombinedOffset > maxR11NegativeEncodingOffset) + { + JITDUMP(" Returning true (frame pointer exists; R11 and SP can't reach entire stack between them)\n\n"); + return true; + } + + // Otherwise, yes, we can address the remaining parts of the locals frame with negative offsets from R11. + } + + // Check whether either R11 or SP can access the arguments. + if ((maxR11PositiveOffset > maxR11PositiveEncodingOffset) && + (maxSPPositiveOffset > maxSPPositiveEncodingOffset)) + { + JITDUMP(" Returning true (frame pointer exists; R11 and SP can't reach all arguments)\n\n"); + return true; + } + } + else { - JITDUMP(" Returning true (no frame; arg coverage)\n\n"); - return true; + if (maxSPPositiveOffset > maxSPPositiveEncodingOffset) + { + JITDUMP(" Returning true (no frame pointer exists; SP can't reach all of frame)\n\n"); + return true; + } } // We won't need to reserve REG_OPT_RSVD. @@ -5146,7 +5112,7 @@ bool Compiler::compQuirkForPPP() assert((varDscExposedStruct->lvExactSize / TARGET_POINTER_SIZE) == 8); BYTE* oldGCPtrs = varDscExposedStruct->lvGcLayout; - BYTE* newGCPtrs = (BYTE*)compGetMem(8, CMK_LvaTable); + BYTE* newGCPtrs = getAllocator(CMK_LvaTable).allocate(8); for (int i = 0; i < 4; i++) { @@ -5339,7 +5305,7 @@ int Compiler::compCompile(CORINFO_METHOD_HANDLE methodHnd, info.compMethodName = eeGetMethodName(methodHnd, &classNamePtr); unsigned len = (unsigned)roundUp(strlen(classNamePtr) + 1); - info.compClassName = (char*)compGetMem(len, CMK_DebugOnly); + info.compClassName = getAllocator(CMK_DebugOnly).allocate(len); strcpy_s((char*)info.compClassName, len, classNamePtr); info.compFullName = eeGetMethodFullName(methodHnd); @@ -5506,26 +5472,16 @@ void Compiler::compCompileFinish() #if MEASURE_MEM_ALLOC { - // Grab the relevant lock. - CritSecHolder statsLock(s_memStatsLock); - - // Make the updates. - genMemStats.nraTotalSizeAlloc = compGetAllocator()->getTotalBytesAllocated(); - genMemStats.nraTotalSizeUsed = compGetAllocator()->getTotalBytesUsed(); - memAllocHist.record((unsigned)((genMemStats.nraTotalSizeAlloc + 1023) / 1024)); - memUsedHist.record((unsigned)((genMemStats.nraTotalSizeUsed + 1023) / 1024)); - s_aggMemStats.Add(genMemStats); - if (genMemStats.allocSz > s_maxCompMemStats.allocSz) - { - s_maxCompMemStats = genMemStats; - } + compArenaAllocator->finishMemStats(); + memAllocHist.record((unsigned)((compArenaAllocator->getTotalBytesAllocated() + 1023) / 1024)); + memUsedHist.record((unsigned)((compArenaAllocator->getTotalBytesUsed() + 1023) / 1024)); } #ifdef DEBUG if (s_dspMemStats || verbose) { printf("\nAllocations for %s (MethodHash=%08x)\n", info.compFullName, info.compMethodHash()); - genMemStats.Print(jitstdout); + compArenaAllocator->dumpMemStats(jitstdout); } #endif // DEBUG #endif // MEASURE_MEM_ALLOC @@ -5553,12 +5509,12 @@ void Compiler::compCompileFinish() (info.compLocalsCount <= 32) && (!opts.MinOpts()) && // We may have too many local variables, etc (getJitStressLevel() == 0) && // We need extra memory for stress !opts.optRepeat && // We need extra memory to repeat opts - !compAllocator->bypassHostAllocator() && // ArenaAllocator::getDefaultPageSize() is artificially low for - // DirectAlloc + !compArenaAllocator->bypassHostAllocator() && // ArenaAllocator::getDefaultPageSize() is artificially low for + // DirectAlloc // Factor of 2x is because data-structures are bigger under DEBUG - (compAllocator->getTotalBytesAllocated() > (2 * ArenaAllocator::getDefaultPageSize())) && + (compArenaAllocator->getTotalBytesAllocated() > (2 * ArenaAllocator::getDefaultPageSize())) && // RyuJIT backend needs memory tuning! TODO-Cleanup: remove this case when memory tuning is complete. - (compAllocator->getTotalBytesAllocated() > (10 * ArenaAllocator::getDefaultPageSize())) && + (compArenaAllocator->getTotalBytesAllocated() > (10 * ArenaAllocator::getDefaultPageSize())) && !verbose) // We allocate lots of memory to convert sets to strings for JitDump { genSmallMethodsNeedingExtraMemoryCnt++; @@ -6661,20 +6617,11 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd, if (inlineInfo) { // Use inliner's memory allocator when compiling the inlinee. - pAlloc = inlineInfo->InlinerCompiler->compGetAllocator(); + pAlloc = inlineInfo->InlinerCompiler->compGetArenaAllocator(); } else { - IEEMemoryManager* pMemoryManager = compHnd->getMemoryManager(); - - // Try to reuse the pre-inited allocator - pAlloc = ArenaAllocator::getPooledAllocator(pMemoryManager); - - if (pAlloc == nullptr) - { - alloc = ArenaAllocator(pMemoryManager); - pAlloc = &alloc; - } + pAlloc = &alloc; } Compiler* pComp; @@ -6684,7 +6631,6 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd, { Compiler* pComp; ArenaAllocator* pAlloc; - ArenaAllocator* alloc; bool jitFallbackCompile; CORINFO_METHOD_HANDLE methodHnd; @@ -6703,7 +6649,6 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd, } param; param.pComp = nullptr; param.pAlloc = pAlloc; - param.alloc = &alloc; param.jitFallbackCompile = jitFallbackCompile; param.methodHnd = methodHnd; param.classPtr = classPtr; @@ -6771,17 +6716,18 @@ int jitNativeCode(CORINFO_METHOD_HANDLE methodHnd, } finallyErrorTrap() { - // Add a dummy touch to pComp so that it is kept alive, and is easy to get to - // during debugging since all other data can be obtained through it. + Compiler* pCompiler = pParamOuter->pComp; + + // If OOM is thrown when allocating memory for a pComp, we will end up here. + // For this case, pComp and also pCompiler will be a nullptr // - if (pParamOuter->pComp) // If OOM is thrown when allocating memory for pComp, we will end up here. - // In that case, pComp is still NULL. + if (pCompiler != nullptr) { - pParamOuter->pComp->info.compCode = nullptr; + pCompiler->info.compCode = nullptr; // pop the compiler off the TLS stack only if it was linked above - assert(JitTls::GetCompiler() == pParamOuter->pComp); - JitTls::SetCompiler(JitTls::GetCompiler()->prevCompiler); + assert(JitTls::GetCompiler() == pCompiler); + JitTls::SetCompiler(pCompiler->prevCompiler); } if (pParamOuter->inlineInfo == nullptr) @@ -8148,7 +8094,7 @@ void JitTimer::PrintCsvMethodStats(Compiler* comp) fprintf(fp, "%Iu,", comp->info.compNativeCodeSize); fprintf(fp, "%Iu,", comp->compInfoBlkSize); - fprintf(fp, "%Iu,", comp->compGetAllocator()->getTotalBytesAllocated()); + fprintf(fp, "%Iu,", comp->compGetArenaAllocator()->getTotalBytesAllocated()); fprintf(fp, "%I64u,", m_info.m_totalCycles); fprintf(fp, "%f\n", CycleTimer::CyclesPerSecond()); fclose(fp); @@ -8166,54 +8112,6 @@ void JitTimer::Terminate(Compiler* comp, CompTimeSummaryInfo& sum, bool includeP } #endif // FEATURE_JIT_METHOD_PERF -#if MEASURE_MEM_ALLOC -// static vars. -CritSecObject Compiler::s_memStatsLock; // Default constructor. -Compiler::AggregateMemStats Compiler::s_aggMemStats; // Default constructor. -Compiler::MemStats Compiler::s_maxCompMemStats; // Default constructor. - -const char* Compiler::MemStats::s_CompMemKindNames[] = { -#define CompMemKindMacro(kind) #kind, -#include "compmemkind.h" -}; - -void Compiler::MemStats::Print(FILE* f) -{ - fprintf(f, "count: %10u, size: %10llu, max = %10llu\n", allocCnt, allocSz, allocSzMax); - fprintf(f, "allocateMemory: %10llu, nraUsed: %10llu\n", nraTotalSizeAlloc, nraTotalSizeUsed); - PrintByKind(f); -} - -void Compiler::MemStats::PrintByKind(FILE* f) -{ - fprintf(f, "\nAlloc'd bytes by kind:\n %20s | %10s | %7s\n", "kind", "size", "pct"); - fprintf(f, " %20s-+-%10s-+-%7s\n", "--------------------", "----------", "-------"); - float allocSzF = static_cast(allocSz); - for (int cmk = 0; cmk < CMK_Count; cmk++) - { - float pct = 100.0f * static_cast(allocSzByKind[cmk]) / allocSzF; - fprintf(f, " %20s | %10llu | %6.2f%%\n", s_CompMemKindNames[cmk], allocSzByKind[cmk], pct); - } - fprintf(f, "\n"); -} - -void Compiler::AggregateMemStats::Print(FILE* f) -{ - fprintf(f, "For %9u methods:\n", nMethods); - if (nMethods == 0) - { - return; - } - fprintf(f, " count: %12u (avg %7u per method)\n", allocCnt, allocCnt / nMethods); - fprintf(f, " alloc size : %12llu (avg %7llu per method)\n", allocSz, allocSz / nMethods); - fprintf(f, " max alloc : %12llu\n", allocSzMax); - fprintf(f, "\n"); - fprintf(f, " allocateMemory : %12llu (avg %7llu per method)\n", nraTotalSizeAlloc, nraTotalSizeAlloc / nMethods); - fprintf(f, " nraUsed : %12llu (avg %7llu per method)\n", nraTotalSizeUsed, nraTotalSizeUsed / nMethods); - PrintByKind(f); -} -#endif // MEASURE_MEM_ALLOC - #if LOOP_HOIST_STATS // Static fields. CritSecObject Compiler::s_loopHoistStatsLock; // Default constructor. diff --git a/src/jit/compiler.h b/src/jit/compiler.h index c702aad65741..e5d4d67efe53 100644 --- a/src/jit/compiler.h +++ b/src/jit/compiler.h @@ -98,7 +98,7 @@ class Compiler; /*****************************************************************************/ // -// Declare global operator new overloads that use the Compiler::compGetMem() function for allocation. +// Declare global operator new overloads that use the compiler's arena allocator // // I wanted to make the second argument optional, with default = CMK_Unknown, but that @@ -128,17 +128,6 @@ unsigned ReinterpretHexAsDecimal(unsigned); /*****************************************************************************/ -#if defined(FEATURE_SIMD) -#if defined(_TARGET_XARCH_) -const unsigned TEMP_MAX_SIZE = YMM_REGSIZE_BYTES; -#elif defined(_TARGET_ARM64_) -const unsigned TEMP_MAX_SIZE = FP_REGSIZE_BYTES; -#endif // defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_) -#else // !FEATURE_SIMD -const unsigned TEMP_MAX_SIZE = sizeof(double); -#endif // !FEATURE_SIMD -const unsigned TEMP_SLOT_COUNT = (TEMP_MAX_SIZE / sizeof(int)); - const unsigned FLG_CCTOR = (CORINFO_FLG_CONSTRUCTOR | CORINFO_FLG_STATIC); #ifdef DEBUG @@ -602,15 +591,65 @@ class LclVarDsc regMaskSmall lvPrefReg; // set of regs it prefers to live in unsigned short lvVarIndex; // variable tracking index - unsigned short lvRefCnt; // unweighted (real) reference count. For implicit by reference + +private: + unsigned short m_lvRefCnt; // unweighted (real) reference count. For implicit by reference // parameters, this gets hijacked from fgMarkImplicitByRefArgs // through fgMarkDemotedImplicitByRefArgs, to provide a static // appearance count (computed during address-exposed analysis) // that fgMakeOutgoingStructArgCopy consults during global morph // to determine if eliding its copy is legal. - unsigned lvRefCntWtd; // weighted reference count - int lvStkOffs; // stack offset of home - unsigned lvExactSize; // (exact) size of the type in bytes + unsigned m_lvRefCntWtd; // weighted reference count + +public: + unsigned short lvRefCnt() const + { + return m_lvRefCnt; + } + + void incLvRefCnt(unsigned short delta) + { + unsigned short oldRefCnt = m_lvRefCnt; + m_lvRefCnt += delta; + assert(m_lvRefCnt >= oldRefCnt); + } + + void decLvRefCnt(unsigned short delta) + { + assert(m_lvRefCnt >= delta); + m_lvRefCnt -= delta; + } + + void setLvRefCnt(unsigned short newValue) + { + m_lvRefCnt = newValue; + } + + unsigned lvRefCntWtd() const + { + return m_lvRefCntWtd; + } + + void incLvRefCntWtd(unsigned delta) + { + unsigned oldRefCntWtd = m_lvRefCntWtd; + m_lvRefCntWtd += delta; + assert(m_lvRefCntWtd >= oldRefCntWtd); + } + + void decLvRefCntWtd(unsigned delta) + { + assert(m_lvRefCntWtd >= delta); + m_lvRefCntWtd -= delta; + } + + void setLvRefCntWtd(unsigned newValue) + { + m_lvRefCntWtd = newValue; + } + + int lvStkOffs; // stack offset of home + unsigned lvExactSize; // (exact) size of the type in bytes // Is this a promoted struct? // This method returns true only for structs (including SIMD structs), not for @@ -1133,25 +1172,19 @@ struct FuncInfoDsc struct fgArgTabEntry { - -#if defined(UNIX_AMD64_ABI) - fgArgTabEntry() - { - otherRegNum = REG_NA; - isStruct = false; // is this a struct arg - } -#endif // defined(UNIX_AMD64_ABI) - GenTree* node; // Initially points at the Op1 field of 'parent', but if the argument is replaced with an GT_ASG or - // placeholder - // it will point at the actual argument in the gtCallLateArgs list. + // placeholder it will point at the actual argument in the gtCallLateArgs list. GenTree* parent; // Points at the GT_LIST node in the gtCallArgs for this argument unsigned argNum; // The original argument number, also specifies the required argument evaluation order from the IL - regNumber regNum; // The (first) register to use when passing this argument, set to REG_STK for arguments passed on - // the stack - unsigned numRegs; // Count of number of registers that this argument uses +private: + regNumberSmall regNums[MAX_ARG_REG_COUNT]; // The registers to use when passing this argument, set to REG_STK for + // arguments passed on the stack +public: + unsigned numRegs; // Count of number of registers that this argument uses. + // Note that on ARM, if we have a double hfa, this reflects the number + // of DOUBLE registers. // A slot is a pointer sized region in the OutArg area. unsigned slotNum; // When an argument is passed in the OutArg area this is the slot number in the OutArg area @@ -1161,37 +1194,140 @@ struct fgArgTabEntry unsigned lateArgInx; // index into gtCallLateArgs list unsigned tmpNum; // the LclVar number if we had to force evaluation of this arg - bool isSplit : 1; // True when this argument is split between the registers and OutArg area bool needTmp : 1; // True when we force this argument's evaluation into a temp LclVar bool needPlace : 1; // True when we must replace this argument with a placeholder node bool isTmp : 1; // True when we setup a temp LclVar for this argument due to size issues with the struct bool processed : 1; // True when we have decided the evaluation order for this argument in the gtCallLateArgs - bool isHfaRegArg : 1; // True when the argument is passed as a HFA in FP registers. bool isBackFilled : 1; // True when the argument fills a register slot skipped due to alignment requirements of // previous arguments. bool isNonStandard : 1; // True if it is an arg that is passed in a reg other than a standard arg reg, or is forced // to be on the stack despite its arg list position. + bool isStruct : 1; // True if this is a struct arg + bool _isVararg : 1; // True if the argument is in a vararg context. +#ifdef FEATURE_ARG_SPLIT + bool _isSplit : 1; // True when this argument is split between the registers and OutArg area +#endif // FEATURE_ARG_SPLIT +#ifdef FEATURE_HFA + bool _isHfaRegArg : 1; // True when the argument is passed as a HFA in FP registers. + bool _isDoubleHfa : 1; // True when the argument is passed as an HFA, with an element type of DOUBLE. +#endif + __declspec(property(get = getRegNum)) regNumber regNum; + regNumber getRegNum() + { + return (regNumber)regNums[0]; + } + __declspec(property(get = getOtherRegNum)) regNumber otherRegNum; + regNumber getOtherRegNum() + { + return (regNumber)regNums[1]; + } #if defined(UNIX_AMD64_ABI) - bool isStruct : 1; // True if this is a struct arg + SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; +#endif - regNumber otherRegNum; // The (second) register to use when passing this argument. + void setRegNum(unsigned int i, regNumber regNum) + { + assert(i < MAX_ARG_REG_COUNT); + regNums[i] = (regNumberSmall)regNum; + } + regNumber getRegNum(unsigned int i) + { + assert(i < MAX_ARG_REG_COUNT); + return (regNumber)regNums[i]; + } - SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; -#elif !defined(_TARGET_64BIT_) - __declspec(property(get = getIsStruct)) bool isStruct; - bool getIsStruct() + __declspec(property(get = getIsSplit, put = setIsSplit)) bool isSplit; + bool getIsSplit() { - return varTypeIsStruct(node); +#ifdef FEATURE_ARG_SPLIT + return _isSplit; +#else // FEATURE_ARG_SPLIT + return false; +#endif + } + void setIsSplit(bool value) + { +#ifdef FEATURE_ARG_SPLIT + _isSplit = value; +#endif } -#endif // !_TARGET_64BIT_ -#ifdef _TARGET_ARM_ - void SetIsHfaRegArg(bool hfaRegArg) + __declspec(property(get = getIsVararg, put = setIsVararg)) bool isVararg; + bool getIsVararg() { - isHfaRegArg = hfaRegArg; +#ifdef FEATURE_VARARG + return _isVararg; +#else + return false; +#endif + } + void setIsVararg(bool value) + { +#ifdef FEATURE_VARARG + _isVararg = value; +#endif // FEATURE_VARARG + } + + __declspec(property(get = getIsHfaRegArg)) bool isHfaRegArg; + bool getIsHfaRegArg() + { +#ifdef FEATURE_HFA + return _isHfaRegArg; +#else + return false; +#endif + } + + __declspec(property(get = getHfaType)) var_types hfaType; + var_types getHfaType() + { +#ifdef FEATURE_HFA + return _isHfaRegArg ? (_isDoubleHfa ? TYP_DOUBLE : TYP_FLOAT) : TYP_UNDEF; +#else + return TYP_UNDEF; +#endif } + void setHfaType(var_types type, unsigned hfaSlots) + { +#ifdef FEATURE_HFA + if (type != TYP_UNDEF) + { + unsigned numHfaRegs = hfaSlots; +// We originally set numRegs according to the size of the struct, but if the size of the +// hfaType is not the same as the pointer size, we need to correct it. +// Note that hfaSlots is the number of registers we will use. For ARM, that is twice +// the number of "double registers". +#ifdef _TARGET_ARM_ + if (type == TYP_DOUBLE) + { + // Must be an even number of registers. + assert((numRegs & 1) == 0); + numHfaRegs = hfaSlots / 2; + } + else +#endif // _TARGET_ARM_ + { + numHfaRegs = hfaSlots; + } + if (isHfaRegArg) + { + // This should already be set correctly. + assert(hfaType == type); + assert(numRegs == numHfaRegs); + } + else + { + _isDoubleHfa = (type == TYP_DOUBLE); + _isHfaRegArg = true; + numRegs = numHfaRegs; + } + } +#endif // FEATURE_HFA + } + +#ifdef _TARGET_ARM_ void SetIsBackFilled(bool backFilled) { isBackFilled = backFilled; @@ -1202,12 +1338,6 @@ struct fgArgTabEntry return isBackFilled; } #else // !_TARGET_ARM_ - // To make the callers easier, we allow these calls (and the isHfaRegArg and isBackFilled data members) for all - // platforms. - void SetIsHfaRegArg(bool hfaRegArg) - { - } - void SetIsBackFilled(bool backFilled) { } @@ -1218,6 +1348,73 @@ struct fgArgTabEntry } #endif // !_TARGET_ARM_ + bool isPassedInRegisters() + { + return !isSplit && (numRegs != 0); + } + + bool isSingleRegOrSlot() + { + return !isSplit && ((numRegs == 1) || (numSlots == 1)); + } + + void SetMultiRegNums() + { +#if FEATURE_MULTIREG_ARGS + if (numRegs == 1) + { + return; + } + + regNumber argReg = getRegNum(0); +#ifdef _TARGET_ARM_ + unsigned int regSize = (hfaType == TYP_DOUBLE) ? 2 : 1; +#else + unsigned int regSize = 1; +#endif + for (unsigned int regIndex = 1; regIndex < numRegs; regIndex++) + { + argReg = (regNumber)(argReg + regSize); + setRegNum(regIndex, argReg); + } +#endif + } + + // Check that the value of 'isStruct' is consistent. + // A struct arg must be one of the following: + // - A node of struct type, + // - A GT_FIELD_LIST, or + // - A node of a scalar type, passed in a single register or slot + // (or two slots in the case of a struct pass on the stack as TYP_DOUBLE). + // + void checkIsStruct() + { + if (isStruct) + { + if (!varTypeIsStruct(node) && !node->OperIs(GT_FIELD_LIST)) + { + // This is the case where we are passing a struct as a primitive type. + // On most targets, this is always a single register or slot. + // However, on ARM this could be two slots if it is TYP_DOUBLE. + bool isPassedAsPrimitiveType = ((numRegs == 1) || ((numRegs == 0) && (numSlots == 1))); +#ifdef _TARGET_ARM_ + if (!isPassedAsPrimitiveType) + { + if (node->TypeGet() == TYP_DOUBLE && numRegs == 0 && (numSlots == 2)) + { + isPassedAsPrimitiveType = true; + } + } +#endif // _TARGET_ARM_ + assert(isPassedAsPrimitiveType); + } + } + else + { + assert(!varTypeIsStruct(node)); + } + } + #ifdef DEBUG void Dump(); #endif @@ -1264,8 +1461,14 @@ class fgArgInfo fgArgInfo(Compiler* comp, GenTreeCall* call, unsigned argCount); fgArgInfo(GenTreeCall* newCall, GenTreeCall* oldCall); - fgArgTabEntry* AddRegArg( - unsigned argNum, GenTree* node, GenTree* parent, regNumber regNum, unsigned numRegs, unsigned alignment); + fgArgTabEntry* AddRegArg(unsigned argNum, + GenTree* node, + GenTree* parent, + regNumber regNum, + unsigned numRegs, + unsigned alignment, + bool isStruct, + bool isVararg = false); #ifdef UNIX_AMD64_ABI fgArgTabEntry* AddRegArg(unsigned argNum, @@ -1275,7 +1478,8 @@ class fgArgInfo unsigned numRegs, unsigned alignment, const bool isStruct, - const regNumber otherRegNum = REG_NA, + const bool isVararg, + const regNumber otherRegNum, const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* const structDescPtr = nullptr); #endif // UNIX_AMD64_ABI @@ -1283,7 +1487,9 @@ class fgArgInfo GenTree* node, GenTree* parent, unsigned numSlots, - unsigned alignment UNIX_AMD64_ABI_ONLY_ARG(const bool isStruct)); + unsigned alignment, + bool isStruct, + bool isVararg = false); void RemorphReset(); fgArgTabEntry* RemorphRegArg( @@ -1524,6 +1730,8 @@ class Compiler GenTree* impAssignMultiRegTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass); #endif // FEATURE_MULTIREG_RET + GenTree* impAssignSmallStructTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass); + #ifdef ARM_SOFTFP bool isSingleFloat32Struct(CORINFO_CLASS_HANDLE hClass); #endif // ARM_SOFTFP @@ -1545,7 +1753,6 @@ class Compiler var_types GetHfaType(CORINFO_CLASS_HANDLE hClass); unsigned GetHfaCount(CORINFO_CLASS_HANDLE hClass); - bool IsMultiRegPassedType(CORINFO_CLASS_HANDLE hClass); bool IsMultiRegReturnedType(CORINFO_CLASS_HANDLE hClass); //------------------------------------------------------------------------- @@ -2015,6 +2222,8 @@ class Compiler GenTree* op1, GenTree* op2, NamedIntrinsic hwIntrinsicID); + GenTreeHWIntrinsic* gtNewScalarHWIntrinsicNode( + var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID); GenTree* gtNewMustThrowException(unsigned helper, var_types type, CORINFO_CLASS_HANDLE clsHnd); CORINFO_CLASS_HANDLE gtGetStructHandleForHWSIMD(var_types simdType, var_types simdBaseType); #endif // FEATURE_HW_INTRINSICS @@ -2360,11 +2569,6 @@ class Compiler unsigned short lvaTrackedCount; // actual # of locals being tracked unsigned lvaTrackedCountInSizeTUnits; // min # of size_t's sufficient to hold a bit for all the locals being tracked -#ifdef UNIX_AMD64_ABI - // Only for AMD64 System V cache the first caller stack homed argument. - unsigned lvaFirstStackIncomingArgNum; // First argument with stack slot in the caller. -#endif // !UNIX_AMD64_ABI - #ifdef DEBUG VARSET_TP lvaTrackedVars; // set of tracked variables #endif @@ -2383,7 +2587,7 @@ class Compiler } // reverse map of tracked number to var number - unsigned lvaTrackedToVarNum[lclMAX_TRACKED]; + unsigned* lvaTrackedToVarNum; #if DOUBLE_ALIGN #ifdef DEBUG @@ -2661,11 +2865,12 @@ class Compiler } // Returns true if this local var is a multireg struct - bool lvaIsMultiregStruct(LclVarDsc* varDsc); + bool lvaIsMultiregStruct(LclVarDsc* varDsc, bool isVararg); // If the local is a TYP_STRUCT, get/set a class handle describing it CORINFO_CLASS_HANDLE lvaGetStruct(unsigned varNum); void lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool unsafeValueClsCheck, bool setTypeInfo = true); + void lvaSetStructUsedAsVarArg(unsigned varNum); // If the local is TYP_REF, set or update the associated class information. void lvaSetClass(unsigned varNum, CORINFO_CLASS_HANDLE clsHnd, bool isExact = false); @@ -2851,8 +3056,6 @@ class Compiler #define SMALL_STACK_SIZE 16 // number of elements in impSmallStack - StackEntry impSmallStack[SMALL_STACK_SIZE]; // Use this array if possible - struct SavedStack // used to save/restore stack contents. { unsigned ssDepth; // number of values on stack @@ -3137,10 +3340,8 @@ class Compiler GenTree* impOptimizeCastClassOrIsInst(GenTree* op1, CORINFO_RESOLVED_TOKEN* pResolvedToken, bool isCastClass); - bool VarTypeIsMultiByteAndCanEnreg(var_types type, - CORINFO_CLASS_HANDLE typeClass, - unsigned* typeSize, - bool forReturn); + bool VarTypeIsMultiByteAndCanEnreg( + var_types type, CORINFO_CLASS_HANDLE typeClass, unsigned* typeSize, bool forReturn, bool isVarArg); bool IsIntrinsicImplementedByUserCall(CorInfoIntrinsics intrinsicId); bool IsTargetIntrinsic(CorInfoIntrinsics intrinsicId); @@ -3503,7 +3704,7 @@ class Compiler template T* fgAllocateTypeForEachBlk(CompMemKind cmk = CMK_Unknown) { - return (T*)compGetMem((fgBBNumMax + 1) * sizeof(T), cmk); + return getAllocator(cmk).allocate(fgBBNumMax + 1); } // BlockSets are relative to a specific set of BasicBlock numbers. If that changes @@ -3607,19 +3808,13 @@ class Compiler unsigned fgMeasureIR(); -#if OPT_BOOL_OPS // Used to detect multiple logical "not" assignments. - bool fgMultipleNots; -#endif - bool fgModified; // True if the flow graph has been modified recently bool fgComputePredsDone; // Have we computed the bbPreds list bool fgCheapPredsValid; // Is the bbCheapPreds list valid? bool fgDomsComputed; // Have we computed the dominator sets? bool fgOptimizedFinally; // Did we optimize any try-finallys? - bool fgHasSwitch; // any BBJ_SWITCH jumps? - bool fgHasPostfix; // any postfix ++/-- found? - unsigned fgIncrCount; // number of increment nodes found + bool fgHasSwitch; // any BBJ_SWITCH jumps? BlockSet fgEnterBlks; // Set of blocks which have a special transfer of control; the "entry" blocks plus EH handler // begin blocks. @@ -3797,11 +3992,6 @@ class Compiler void fgLiveVarAnalysis(bool updateInternalOnly = false); - // This is used in the liveness computation, as a temporary. When we use the - // arbitrary-length VarSet representation, it is better not to allocate a new one - // at each call. - VARSET_TP fgMarkIntfUnionVS; - void fgUpdateRefCntForClone(BasicBlock* addedToBlock, GenTree* clonedTree); void fgUpdateRefCntForExtract(GenTree* wholeTree, GenTree* keptTree); @@ -4063,6 +4253,9 @@ class Compiler { SPK_Unknown, // Invalid value, never returned SPK_PrimitiveType, // The struct is passed/returned using a primitive type. + SPK_EnclosingType, // Like SPK_Primitive type, but used for return types that + // require a primitive type temp that is larger than the struct size. + // Currently used for structs of size 3, 5, 6, or 7 bytes. SPK_ByValue, // The struct is passed/returned by value (using the ABI rules) // for ARM64 and UNIX_X64 in multiple registers. (when all of the // parameters registers are used, then the stack will be used) @@ -4077,18 +4270,24 @@ class Compiler // A "primitive" type is one of the scalar types: byte, short, int, long, ref, float, double // If we can't or shouldn't use a "primitive" type then TYP_UNKNOWN is returned. // - var_types getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd); + // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding + // hfa types. + // + var_types getPrimitiveTypeForStruct(unsigned structSize, CORINFO_CLASS_HANDLE clsHnd, bool isVarArg); // Get the type that is used to pass values of the given struct type. - // If you have already retrieved the struct size then pass it as the optional third argument + // If you have already retrieved the struct size then pass it as the optional fourth argument + // + // isVarArg is passed for use on Windows Arm64 to change the decision returned regarding + // hfa types. // var_types getArgTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbPassStruct, + bool isVarArg, unsigned structSize = 0); // Get the type that is used to return values of the given struct type. - // If you have already retrieved the struct size then pass it as the optional third argument - // + // If you have already retrieved the struct size then pass it as the optional fourth argument var_types getReturnTypeForStruct(CORINFO_CLASS_HANDLE clsHnd, structPassingKind* wbPassStruct = nullptr, unsigned structSize = 0); @@ -4223,7 +4422,7 @@ class Compiler // The switch block "switchBlk" just had an entry with value "from" modified to the value "to". // Update "this" as necessary: if "from" is no longer an element of the jump table of "switchBlk", // remove it from "this", and ensure that "to" is a member. Use "alloc" to do any required allocation. - void UpdateTarget(CompAllocator* alloc, BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); + void UpdateTarget(CompAllocator alloc, BasicBlock* switchBlk, BasicBlock* from, BasicBlock* to); }; typedef JitHashTable, SwitchUniqueSuccSet> BlockToSwitchDescMap; @@ -4411,7 +4610,7 @@ class Compiler bool fgCastNeeded(GenTree* tree, var_types toType); GenTree* fgDoNormalizeOnStore(GenTree* tree); - GenTree* fgMakeTmpArgNode(unsigned tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(const bool passedInRegisters)); + GenTree* fgMakeTmpArgNode(fgArgTabEntry* curArgTabEntry); // The following check for loops that don't execute calls bool fgLoopCallMarked; @@ -4735,12 +4934,12 @@ class Compiler GenTree* fgUnwrapProxy(GenTree* objRef); GenTreeFieldList* fgMorphLclArgToFieldlist(GenTreeLclVarCommon* lcl); GenTreeCall* fgMorphArgs(GenTreeCall* call); + GenTreeArgList* fgMorphArgList(GenTreeArgList* args, MorphAddrContext* mac); void fgMakeOutgoingStructArgCopy(GenTreeCall* call, GenTree* args, unsigned argIndex, - CORINFO_CLASS_HANDLE copyBlkClass UNIX_AMD64_ABI_ONLY_ARG( - const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* structDescPtr)); + CORINFO_CLASS_HANDLE copyBlkClass); void fgFixupStructReturn(GenTree* call); GenTree* fgMorphLocalVar(GenTree* tree, bool forceRemorph); @@ -5335,8 +5534,8 @@ class Compiler bool fgHasLoops; // True if this method has any loops, set in fgComputeReachability public: - LoopDsc optLoopTable[MAX_LOOP_NUM]; // loop descriptor table - unsigned char optLoopCount; // number of tracked loops + LoopDsc* optLoopTable; // loop descriptor table + unsigned char optLoopCount; // number of tracked loops bool optRecordLoop(BasicBlock* head, BasicBlock* first, @@ -6160,33 +6359,7 @@ class Compiler BasicBlock* slow); void optInsertLoopCloningStress(BasicBlock* head); -#if COUNT_RANGECHECKS - static unsigned optRangeChkRmv; - static unsigned optRangeChkAll; -#endif - protected: - struct arraySizes - { - unsigned arrayVar; - int arrayDim; - -#define MAX_ARRAYS 4 // a magic max number of arrays tracked for bounds check elimination - }; - - struct RngChkDsc - { - RngChkDsc* rcdNextInBucket; // used by the hash table - - unsigned short rcdHashValue; // to make matching faster - unsigned short rcdIndex; // 0..optRngChkCount-1 - - GenTree* rcdTree; // the array index tree - }; - - unsigned optRngChkCount; - static const size_t optRngChkHashSize; - ssize_t optGetArrayRefScaleAndIndex(GenTree* mul, GenTree** pIndex DEBUGARG(bool bRngChk)); GenTree* optFindLocalInit(BasicBlock* block, GenTree* local, VARSET_TP* pKilledInOut, bool* isKilledAfterInit); @@ -6700,45 +6873,6 @@ class Compiler /*****************************************************************************/ -public: - void tmpInit(); - - enum TEMP_USAGE_TYPE - { - TEMP_USAGE_FREE, - TEMP_USAGE_USED - }; - - static var_types tmpNormalizeType(var_types type); - TempDsc* tmpGetTemp(var_types type); // get temp for the given type - void tmpRlsTemp(TempDsc* temp); - TempDsc* tmpFindNum(int temp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; - - void tmpEnd(); - TempDsc* tmpListBeg(TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; - TempDsc* tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; - void tmpDone(); - -#ifdef DEBUG - bool tmpAllFree() const; -#endif // DEBUG - - void tmpPreAllocateTemps(var_types type, unsigned count); - -protected: - unsigned tmpCount; // Number of temps - unsigned tmpSize; // Size of all the temps -#ifdef DEBUG -public: - // Used by RegSet::rsSpillChk() - unsigned tmpGetCount; // Temps which haven't been released yet -#endif -private: - static unsigned tmpSlot(unsigned size); // which slot in tmpFree[] or tmpUsed[] to use - - TempDsc* tmpFree[TEMP_MAX_SIZE / sizeof(int)]; - TempDsc* tmpUsed[TEMP_MAX_SIZE / sizeof(int)]; - /* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX @@ -7123,71 +7257,89 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // by the hardware. It is allocated when/if such situations are encountered during Lowering. unsigned lvaSIMDInitTempVarNum; - // SIMD Types - CORINFO_CLASS_HANDLE SIMDFloatHandle; - CORINFO_CLASS_HANDLE SIMDDoubleHandle; - CORINFO_CLASS_HANDLE SIMDIntHandle; - CORINFO_CLASS_HANDLE SIMDUShortHandle; - CORINFO_CLASS_HANDLE SIMDUByteHandle; - CORINFO_CLASS_HANDLE SIMDShortHandle; - CORINFO_CLASS_HANDLE SIMDByteHandle; - CORINFO_CLASS_HANDLE SIMDLongHandle; - CORINFO_CLASS_HANDLE SIMDUIntHandle; - CORINFO_CLASS_HANDLE SIMDULongHandle; - CORINFO_CLASS_HANDLE SIMDVector2Handle; - CORINFO_CLASS_HANDLE SIMDVector3Handle; - CORINFO_CLASS_HANDLE SIMDVector4Handle; - CORINFO_CLASS_HANDLE SIMDVectorHandle; + struct SIMDHandlesCache + { + // SIMD Types + CORINFO_CLASS_HANDLE SIMDFloatHandle; + CORINFO_CLASS_HANDLE SIMDDoubleHandle; + CORINFO_CLASS_HANDLE SIMDIntHandle; + CORINFO_CLASS_HANDLE SIMDUShortHandle; + CORINFO_CLASS_HANDLE SIMDUByteHandle; + CORINFO_CLASS_HANDLE SIMDShortHandle; + CORINFO_CLASS_HANDLE SIMDByteHandle; + CORINFO_CLASS_HANDLE SIMDLongHandle; + CORINFO_CLASS_HANDLE SIMDUIntHandle; + CORINFO_CLASS_HANDLE SIMDULongHandle; + CORINFO_CLASS_HANDLE SIMDVector2Handle; + CORINFO_CLASS_HANDLE SIMDVector3Handle; + CORINFO_CLASS_HANDLE SIMDVector4Handle; + CORINFO_CLASS_HANDLE SIMDVectorHandle; #ifdef FEATURE_HW_INTRINSICS #if defined(_TARGET_ARM64_) - CORINFO_CLASS_HANDLE Vector64FloatHandle; - CORINFO_CLASS_HANDLE Vector64UIntHandle; - CORINFO_CLASS_HANDLE Vector64UShortHandle; - CORINFO_CLASS_HANDLE Vector64UByteHandle; - CORINFO_CLASS_HANDLE Vector64ShortHandle; - CORINFO_CLASS_HANDLE Vector64ByteHandle; - CORINFO_CLASS_HANDLE Vector64IntHandle; + CORINFO_CLASS_HANDLE Vector64FloatHandle; + CORINFO_CLASS_HANDLE Vector64UIntHandle; + CORINFO_CLASS_HANDLE Vector64UShortHandle; + CORINFO_CLASS_HANDLE Vector64UByteHandle; + CORINFO_CLASS_HANDLE Vector64ShortHandle; + CORINFO_CLASS_HANDLE Vector64ByteHandle; + CORINFO_CLASS_HANDLE Vector64IntHandle; #endif // defined(_TARGET_ARM64_) - CORINFO_CLASS_HANDLE Vector128FloatHandle; - CORINFO_CLASS_HANDLE Vector128DoubleHandle; - CORINFO_CLASS_HANDLE Vector128IntHandle; - CORINFO_CLASS_HANDLE Vector128UShortHandle; - CORINFO_CLASS_HANDLE Vector128UByteHandle; - CORINFO_CLASS_HANDLE Vector128ShortHandle; - CORINFO_CLASS_HANDLE Vector128ByteHandle; - CORINFO_CLASS_HANDLE Vector128LongHandle; - CORINFO_CLASS_HANDLE Vector128UIntHandle; - CORINFO_CLASS_HANDLE Vector128ULongHandle; + CORINFO_CLASS_HANDLE Vector128FloatHandle; + CORINFO_CLASS_HANDLE Vector128DoubleHandle; + CORINFO_CLASS_HANDLE Vector128IntHandle; + CORINFO_CLASS_HANDLE Vector128UShortHandle; + CORINFO_CLASS_HANDLE Vector128UByteHandle; + CORINFO_CLASS_HANDLE Vector128ShortHandle; + CORINFO_CLASS_HANDLE Vector128ByteHandle; + CORINFO_CLASS_HANDLE Vector128LongHandle; + CORINFO_CLASS_HANDLE Vector128UIntHandle; + CORINFO_CLASS_HANDLE Vector128ULongHandle; #if defined(_TARGET_XARCH_) - CORINFO_CLASS_HANDLE Vector256FloatHandle; - CORINFO_CLASS_HANDLE Vector256DoubleHandle; - CORINFO_CLASS_HANDLE Vector256IntHandle; - CORINFO_CLASS_HANDLE Vector256UShortHandle; - CORINFO_CLASS_HANDLE Vector256UByteHandle; - CORINFO_CLASS_HANDLE Vector256ShortHandle; - CORINFO_CLASS_HANDLE Vector256ByteHandle; - CORINFO_CLASS_HANDLE Vector256LongHandle; - CORINFO_CLASS_HANDLE Vector256UIntHandle; - CORINFO_CLASS_HANDLE Vector256ULongHandle; + CORINFO_CLASS_HANDLE Vector256FloatHandle; + CORINFO_CLASS_HANDLE Vector256DoubleHandle; + CORINFO_CLASS_HANDLE Vector256IntHandle; + CORINFO_CLASS_HANDLE Vector256UShortHandle; + CORINFO_CLASS_HANDLE Vector256UByteHandle; + CORINFO_CLASS_HANDLE Vector256ShortHandle; + CORINFO_CLASS_HANDLE Vector256ByteHandle; + CORINFO_CLASS_HANDLE Vector256LongHandle; + CORINFO_CLASS_HANDLE Vector256UIntHandle; + CORINFO_CLASS_HANDLE Vector256ULongHandle; #endif // defined(_TARGET_XARCH_) #endif // FEATURE_HW_INTRINSICS + SIMDHandlesCache() + { + memset(this, 0, sizeof(*this)); + } + }; + + SIMDHandlesCache* m_simdHandleCache; + // Get the handle for a SIMD type. CORINFO_CLASS_HANDLE gtGetStructHandleForSIMD(var_types simdType, var_types simdBaseType) { + if (m_simdHandleCache == nullptr) + { + // This may happen if the JIT generates SIMD node on its own, without importing them. + // Otherwise getBaseTypeAndSizeOfSIMDType should have created the cache. + return NO_CLASS_HANDLE; + } + if (simdBaseType == TYP_FLOAT) { switch (simdType) { case TYP_SIMD8: - return SIMDVector2Handle; + return m_simdHandleCache->SIMDVector2Handle; case TYP_SIMD12: - return SIMDVector3Handle; + return m_simdHandleCache->SIMDVector3Handle; case TYP_SIMD16: - if ((getSIMDVectorType() == TYP_SIMD32) || (SIMDVector4Handle != NO_CLASS_HANDLE)) + if ((getSIMDVectorType() == TYP_SIMD32) || + (m_simdHandleCache->SIMDVector4Handle != NO_CLASS_HANDLE)) { - return SIMDVector4Handle; + return m_simdHandleCache->SIMDVector4Handle; } break; case TYP_SIMD32: @@ -7200,36 +7352,31 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX switch (simdBaseType) { case TYP_FLOAT: - return SIMDFloatHandle; + return m_simdHandleCache->SIMDFloatHandle; case TYP_DOUBLE: - return SIMDDoubleHandle; + return m_simdHandleCache->SIMDDoubleHandle; case TYP_INT: - return SIMDIntHandle; + return m_simdHandleCache->SIMDIntHandle; case TYP_USHORT: - return SIMDUShortHandle; + return m_simdHandleCache->SIMDUShortHandle; case TYP_UBYTE: - return SIMDUByteHandle; + return m_simdHandleCache->SIMDUByteHandle; case TYP_SHORT: - return SIMDShortHandle; + return m_simdHandleCache->SIMDShortHandle; case TYP_BYTE: - return SIMDByteHandle; + return m_simdHandleCache->SIMDByteHandle; case TYP_LONG: - return SIMDLongHandle; + return m_simdHandleCache->SIMDLongHandle; case TYP_UINT: - return SIMDUIntHandle; + return m_simdHandleCache->SIMDUIntHandle; case TYP_ULONG: - return SIMDULongHandle; + return m_simdHandleCache->SIMDULongHandle; default: assert(!"Didn't find a class handle for simdType"); } return NO_CLASS_HANDLE; } - // SIMD Methods - CORINFO_METHOD_HANDLE SIMDVectorFloat_set_Item; - CORINFO_METHOD_HANDLE SIMDVectorFloat_get_Length; - CORINFO_METHOD_HANDLE SIMDVectorFloat_op_Addition; - // Returns true if the tree corresponds to a TYP_SIMD lcl var. // Note that both SIMD vector args and locals are mared as lvSIMDType = true, but // type of an arg node is TYP_BYREF and a local node is TYP_SIMD or TYP_STRUCT. @@ -7356,7 +7503,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Pops and returns GenTree node from importers type stack. // Normalizes TYP_STRUCT value in case of GT_CALL, GT_RET_EXPR and arg nodes. - GenTree* impSIMDPopStack(var_types type, bool expectAddr = false); + GenTree* impSIMDPopStack(var_types type, bool expectAddr = false, CORINFO_CLASS_HANDLE structType = nullptr); // Create a GT_SIMD tree for a Get property of SIMD vector with a fixed index. GenTreeSIMD* impSIMDGetFixed(var_types simdType, var_types baseType, unsigned simdSize, int index); @@ -7699,10 +7846,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // NOTE: These values are only reliable after // the importing is completely finished. -#if CPU_USES_BLOCK_MOVE - bool compBlkOpUsed; // Does the method do a COPYBLK or INITBLK -#endif - #ifdef DEBUG // State information - which phases have completed? // These are kept together for easy discoverability @@ -8444,95 +8587,11 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX JitFlags* compileFlags, CorInfoInstantiationVerification instVerInfo); - ArenaAllocator* compGetAllocator(); + ArenaAllocator* compGetArenaAllocator(); #if MEASURE_MEM_ALLOC - static bool s_dspMemStats; // Display per-phase memory statistics for every function - - struct MemStats - { - unsigned allocCnt; // # of allocs - UINT64 allocSz; // total size of those alloc. - UINT64 allocSzMax; // Maximum single allocation. - UINT64 allocSzByKind[CMK_Count]; // Classified by "kind". - UINT64 nraTotalSizeAlloc; - UINT64 nraTotalSizeUsed; - - static const char* s_CompMemKindNames[]; // Names of the kinds. - - MemStats() : allocCnt(0), allocSz(0), allocSzMax(0), nraTotalSizeAlloc(0), nraTotalSizeUsed(0) - { - for (int i = 0; i < CMK_Count; i++) - { - allocSzByKind[i] = 0; - } - } - MemStats(const MemStats& ms) - : allocCnt(ms.allocCnt) - , allocSz(ms.allocSz) - , allocSzMax(ms.allocSzMax) - , nraTotalSizeAlloc(ms.nraTotalSizeAlloc) - , nraTotalSizeUsed(ms.nraTotalSizeUsed) - { - for (int i = 0; i < CMK_Count; i++) - { - allocSzByKind[i] = ms.allocSzByKind[i]; - } - } - - // Until we have ubiquitous constructors. - void Init() - { - this->MemStats::MemStats(); - } - - void AddAlloc(size_t sz, CompMemKind cmk) - { - allocCnt += 1; - allocSz += sz; - if (sz > allocSzMax) - { - allocSzMax = sz; - } - allocSzByKind[cmk] += sz; - } - - void Print(FILE* f); // Print these stats to f. - void PrintByKind(FILE* f); // Do just the by-kind histogram part. - }; - MemStats genMemStats; - - struct AggregateMemStats : public MemStats - { - unsigned nMethods; - - AggregateMemStats() : MemStats(), nMethods(0) - { - } - - void Add(const MemStats& ms) - { - nMethods++; - allocCnt += ms.allocCnt; - allocSz += ms.allocSz; - allocSzMax = max(allocSzMax, ms.allocSzMax); - for (int i = 0; i < CMK_Count; i++) - { - allocSzByKind[i] += ms.allocSzByKind[i]; - } - nraTotalSizeAlloc += ms.nraTotalSizeAlloc; - nraTotalSizeUsed += ms.nraTotalSizeUsed; - } - - void Print(FILE* f); // Print these stats to jitstdout. - }; - - static CritSecObject s_memStatsLock; // This lock protects the data structures below. - static MemStats s_maxCompMemStats; // Stats for the compilation with the largest amount allocated. - static AggregateMemStats s_aggMemStats; // Aggregates statistics for all compilations. - -#endif // MEASURE_MEM_ALLOC +#endif // MEASURE_MEM_ALLOC #if LOOP_HOIST_STATS unsigned m_loopsConsidered; @@ -8551,10 +8610,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX static void PrintAggregateLoopHoistStats(FILE* f); #endif // LOOP_HOIST_STATS - void* compGetMemArray(size_t numElem, size_t elemSize, CompMemKind cmk = CMK_Unknown); - void* compGetMem(size_t sz, CompMemKind cmk = CMK_Unknown); - void compFreeMem(void*); - bool compIsForImportOnly(); bool compIsForInlining(); bool compDonotInline(); @@ -8578,7 +8633,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX { VarScopeDsc* data; VarScopeListNode* next; - static VarScopeListNode* Create(VarScopeDsc* value, CompAllocator* alloc) + static VarScopeListNode* Create(VarScopeDsc* value, CompAllocator alloc) { VarScopeListNode* node = new (alloc) VarScopeListNode; node->data = value; @@ -8591,7 +8646,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX { VarScopeListNode* head; VarScopeListNode* tail; - static VarScopeMapInfo* Create(VarScopeListNode* node, CompAllocator* alloc) + static VarScopeMapInfo* Create(VarScopeListNode* node, CompAllocator alloc) { VarScopeMapInfo* info = new (alloc) VarScopeMapInfo; info->head = node; @@ -8661,19 +8716,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX bool skipMethod(); #endif - ArenaAllocator* compAllocator; + ArenaAllocator* compArenaAllocator; public: - CompAllocator* compAllocatorGeneric; // An allocator that uses the CMK_Generic tracker. -#if MEASURE_MEM_ALLOC - CompAllocator* compAllocatorBitset; // An allocator that uses the CMK_bitset tracker. - CompAllocator* compAllocatorGC; // An allocator that uses the CMK_GC tracker. - CompAllocator* compAllocatorLoopHoist; // An allocator that uses the CMK_LoopHoist tracker. -#ifdef DEBUG - CompAllocator* compAllocatorDebugOnly; // An allocator that uses the CMK_DebugOnly tracker. -#endif // DEBUG -#endif // MEASURE_MEM_ALLOC - void compFunctionTraceStart(); void compFunctionTraceEnd(void* methodCodePtr, ULONG methodCodeSize, bool isNYI); @@ -8711,47 +8756,25 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // Assumes called as part of process shutdown; does any compiler-specific work associated with that. static void ProcessShutdownWork(ICorStaticInfo* statInfo); - CompAllocator* getAllocator() + CompAllocator getAllocator(CompMemKind cmk = CMK_Generic) { - return compAllocatorGeneric; + return CompAllocator(compArenaAllocator, cmk); } -#if MEASURE_MEM_ALLOC - CompAllocator* getAllocatorBitset() - { - return compAllocatorBitset; - } - CompAllocator* getAllocatorGC() - { - return compAllocatorGC; - } - CompAllocator* getAllocatorLoopHoist() - { - return compAllocatorLoopHoist; - } -#else // !MEASURE_MEM_ALLOC - CompAllocator* getAllocatorBitset() + CompAllocator getAllocatorGC() { - return compAllocatorGeneric; + return getAllocator(CMK_GC); } - CompAllocator* getAllocatorGC() - { - return compAllocatorGeneric; - } - CompAllocator* getAllocatorLoopHoist() + + CompAllocator getAllocatorLoopHoist() { - return compAllocatorGeneric; + return getAllocator(CMK_LoopHoist); } -#endif // !MEASURE_MEM_ALLOC #ifdef DEBUG - CompAllocator* getAllocatorDebugOnly() + CompAllocator getAllocatorDebugOnly() { -#if MEASURE_MEM_ALLOC - return compAllocatorDebugOnly; -#else // !MEASURE_MEM_ALLOC - return compAllocatorGeneric; -#endif // !MEASURE_MEM_ALLOC + return getAllocator(CMK_DebugOnly); } #endif // DEBUG @@ -9122,7 +9145,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (compRoot->m_fieldSeqStore == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_FieldSeqStore, and use that for allocation. - CompAllocator* ialloc = new (this, CMK_FieldSeqStore) CompAllocator(this, CMK_FieldSeqStore); + CompAllocator ialloc(getAllocator(CMK_FieldSeqStore)); compRoot->m_fieldSeqStore = new (ialloc) FieldSeqStore(ialloc); } return compRoot->m_fieldSeqStore; @@ -9143,8 +9166,8 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX { // Create a CompAllocator that labels sub-structure with CMK_ZeroOffsetFieldMap, and use that for // allocation. - CompAllocator* ialloc = new (this, CMK_ZeroOffsetFieldMap) CompAllocator(this, CMK_ZeroOffsetFieldMap); - m_zeroOffsetFieldMap = new (ialloc) NodeToFieldSeqMap(ialloc); + CompAllocator ialloc(getAllocator(CMK_ZeroOffsetFieldMap)); + m_zeroOffsetFieldMap = new (ialloc) NodeToFieldSeqMap(ialloc); } return m_zeroOffsetFieldMap; } @@ -9170,7 +9193,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (compRoot->m_arrayInfoMap == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. - CompAllocator* ialloc = new (this, CMK_ArrayInfoMap) CompAllocator(this, CMK_ArrayInfoMap); + CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_arrayInfoMap = new (ialloc) NodeToArrayInfoMap(ialloc); } return compRoot->m_arrayInfoMap; @@ -9225,7 +9248,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX if (compRoot->m_memorySsaMap[memoryKind] == nullptr) { // Create a CompAllocator that labels sub-structure with CMK_ArrayInfoMap, and use that for allocation. - CompAllocator* ialloc = new (this, CMK_ArrayInfoMap) CompAllocator(this, CMK_ArrayInfoMap); + CompAllocator ialloc(getAllocator(CMK_ArrayInfoMap)); compRoot->m_memorySsaMap[memoryKind] = new (ialloc) NodeToUnsignedMap(ialloc); } return compRoot->m_memorySsaMap[memoryKind]; @@ -9276,7 +9299,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX unsigned __int8* offset0, unsigned __int8* offset1); - void fgMorphSystemVStructArgs(GenTreeCall* call, bool hasStructArgument); #endif // defined(UNIX_AMD64_ABI) void fgMorphMultiregStructArgs(GenTreeCall* call); @@ -9286,25 +9308,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX }; // end of class Compiler -// Inline methods of CompAllocator. -void* CompAllocator::Alloc(size_t sz) -{ -#if MEASURE_MEM_ALLOC - return m_comp->compGetMem(sz, m_cmk); -#else - return m_comp->compGetMem(sz); -#endif -} - -void* CompAllocator::ArrayAlloc(size_t elems, size_t elemSize) -{ -#if MEASURE_MEM_ALLOC - return m_comp->compGetMemArray(elems, elemSize, m_cmk); -#else - return m_comp->compGetMemArray(elems, elemSize); -#endif -} - // LclVarDsc constructor. Uses Compiler, so must come after Compiler definition. inline LclVarDsc::LclVarDsc(Compiler* comp) : // Initialize the ArgRegs to REG_STK. @@ -9394,7 +9397,7 @@ class GenTreeVisitor Compiler* m_compiler; ArrayStack m_ancestors; - GenTreeVisitor(Compiler* compiler) : m_compiler(compiler), m_ancestors(compiler) + GenTreeVisitor(Compiler* compiler) : m_compiler(compiler), m_ancestors(compiler->getAllocator(CMK_ArrayStack)) { assert(compiler != nullptr); diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp index 4e606e6273bb..c4a50c0fa9d7 100644 --- a/src/jit/compiler.hpp +++ b/src/jit/compiler.hpp @@ -690,11 +690,12 @@ inline bool isRegParamType(var_types type) // typeSize - Out param (if non-null) is updated with the size of 'type'. // forReturn - this is true when we asking about a GT_RETURN context; // this is false when we are asking about an argument context +// isVarArg - whether or not this is a vararg fixed arg or variable argument +// - if so on arm64 windows getArgTypeForStruct will ignore HFA +// - types // -inline bool Compiler::VarTypeIsMultiByteAndCanEnreg(var_types type, - CORINFO_CLASS_HANDLE typeClass, - unsigned* typeSize, - bool forReturn) +inline bool Compiler::VarTypeIsMultiByteAndCanEnreg( + var_types type, CORINFO_CLASS_HANDLE typeClass, unsigned* typeSize, bool forReturn, bool isVarArg) { bool result = false; unsigned size = 0; @@ -710,7 +711,7 @@ inline bool Compiler::VarTypeIsMultiByteAndCanEnreg(var_types type, else { structPassingKind howToPassStruct; - type = getArgTypeForStruct(typeClass, &howToPassStruct, size); + type = getArgTypeForStruct(typeClass, &howToPassStruct, isVarArg, size); } if (type != TYP_UNKNOWN) { @@ -887,7 +888,7 @@ void* GenTree::operator new(size_t sz, Compiler* comp, genTreeOps oper) #endif // MEASURE_NODE_SIZE assert(size >= sz); - return comp->compGetMem(size, CMK_ASTNode); + return comp->getAllocator(CMK_ASTNode).allocate(size); } // GenTree constructor @@ -1662,8 +1663,7 @@ inline unsigned Compiler::lvaGrabTemp(bool shortLifetime DEBUGARG(const char* re IMPL_LIMITATION("too many locals"); } - // Note: compGetMemArray might throw. - LclVarDsc* newLvaTable = (LclVarDsc*)compGetMemArray(newLvaTableCnt, sizeof(*lvaTable), CMK_LvaTable); + LclVarDsc* newLvaTable = getAllocator(CMK_LvaTable).allocate(newLvaTableCnt); memcpy(newLvaTable, lvaTable, lvaCount * sizeof(*lvaTable)); memset(newLvaTable + lvaCount, 0, (newLvaTableCnt - lvaCount) * sizeof(*lvaTable)); @@ -1737,8 +1737,7 @@ inline unsigned Compiler::lvaGrabTemps(unsigned cnt DEBUGARG(const char* reason) IMPL_LIMITATION("too many locals"); } - // Note: compGetMemArray might throw. - LclVarDsc* newLvaTable = (LclVarDsc*)compGetMemArray(newLvaTableCnt, sizeof(*lvaTable), CMK_LvaTable); + LclVarDsc* newLvaTable = getAllocator(CMK_LvaTable).allocate(newLvaTableCnt); memcpy(newLvaTable, lvaTable, lvaCount * sizeof(*lvaTable)); memset(newLvaTable + lvaCount, 0, (newLvaTableCnt - lvaCount) * sizeof(*lvaTable)); @@ -1799,8 +1798,8 @@ inline unsigned Compiler::lvaGrabTempWithImplicitUse(bool shortLifetime DEBUGARG lvaSetVarAddrExposed(lclNum); // We need lvRefCnt to be non-zero to prevent various asserts from firing. - varDsc->lvRefCnt = 1; - varDsc->lvRefCntWtd = BB_UNITY_WEIGHT; + varDsc->setLvRefCnt(1); + varDsc->setLvRefCntWtd(BB_UNITY_WEIGHT); return lclNum; } @@ -1820,9 +1819,9 @@ inline void LclVarDsc::lvaResetSortAgainFlag(Compiler* comp) comp->lvaSortAgain = true; } /* Set weighted ref count to zero if ref count is zero */ - if (lvRefCnt == 0) + if (lvRefCnt() == 0) { - lvRefCntWtd = 0; + setLvRefCntWtd(0); } } @@ -1845,17 +1844,17 @@ inline void LclVarDsc::decRefCnts(BasicBlock::weight_t weight, Compiler* comp, b // if (lvType != TYP_STRUCT || promotionType != Compiler::PROMOTION_TYPE_INDEPENDENT) { - assert(lvRefCnt); // Can't decrement below zero + assert(lvRefCnt()); // Can't decrement below zero // TODO: Well, the assert above could be bogus. // If lvRefCnt has overflowed before, then might drop to 0. // Therefore we do need the following check to keep lvRefCnt from underflow: - if (lvRefCnt > 0) + if (lvRefCnt() > 0) { // // Decrement lvRefCnt // - lvRefCnt--; + decLvRefCnt(1); // // Decrement lvRefCntWtd @@ -1867,13 +1866,13 @@ inline void LclVarDsc::decRefCnts(BasicBlock::weight_t weight, Compiler* comp, b weight *= 2; } - if (lvRefCntWtd <= weight) + if (lvRefCntWtd() <= weight) { // Can't go below zero - lvRefCntWtd = 0; + setLvRefCntWtd(0); } else { - lvRefCntWtd -= weight; + decLvRefCntWtd(weight); } } } @@ -1911,7 +1910,8 @@ inline void LclVarDsc::decRefCnts(BasicBlock::weight_t weight, Compiler* comp, b { unsigned varNum = (unsigned)(this - comp->lvaTable); assert(&comp->lvaTable[varNum] == this); - printf("New refCnts for V%02u: refCnt = %2u, refCntWtd = %s\n", varNum, lvRefCnt, refCntWtd2str(lvRefCntWtd)); + printf("New refCnts for V%02u: refCnt = %2u, refCntWtd = %s\n", varNum, lvRefCnt(), + refCntWtd2str(lvRefCntWtd())); } #endif } @@ -1937,10 +1937,10 @@ inline void LclVarDsc::incRefCnts(BasicBlock::weight_t weight, Compiler* comp, b // // Increment lvRefCnt // - int newRefCnt = lvRefCnt + 1; + int newRefCnt = lvRefCnt() + 1; if (newRefCnt == (unsigned short)newRefCnt) // lvRefCnt is an "unsigned short". Don't overflow it. { - lvRefCnt = (unsigned short)newRefCnt; + setLvRefCnt((unsigned short)newRefCnt); } // This fires when an uninitialize value for 'weight' is used (see lvaMarkRefsWeight) @@ -1957,14 +1957,14 @@ inline void LclVarDsc::incRefCnts(BasicBlock::weight_t weight, Compiler* comp, b weight *= 2; } - unsigned newWeight = lvRefCntWtd + weight; - if (newWeight >= lvRefCntWtd) + unsigned newWeight = lvRefCntWtd() + weight; + if (newWeight >= lvRefCntWtd()) { // lvRefCntWtd is an "unsigned". Don't overflow it - lvRefCntWtd = newWeight; + setLvRefCntWtd(newWeight); } else { // On overflow we assign ULONG_MAX - lvRefCntWtd = ULONG_MAX; + setLvRefCntWtd(ULONG_MAX); } } } @@ -2001,7 +2001,8 @@ inline void LclVarDsc::incRefCnts(BasicBlock::weight_t weight, Compiler* comp, b { unsigned varNum = (unsigned)(this - comp->lvaTable); assert(&comp->lvaTable[varNum] == this); - printf("New refCnts for V%02u: refCnt = %2u, refCntWtd = %s\n", varNum, lvRefCnt, refCntWtd2str(lvRefCntWtd)); + printf("New refCnts for V%02u: refCnt = %2u, refCntWtd = %s\n", varNum, lvRefCnt(), + refCntWtd2str(lvRefCntWtd())); } #endif } @@ -2355,11 +2356,11 @@ inline FPbased = isFramePointerUsed(); if (lvaDoneFrameLayout == Compiler::FINAL_FRAME_LAYOUT) { - TempDsc* tmpDsc = tmpFindNum(varNum); + TempDsc* tmpDsc = codeGen->regSet.tmpFindNum(varNum); // The temp might be in use, since this might be during code generation. if (tmpDsc == nullptr) { - tmpDsc = tmpFindNum(varNum, Compiler::TEMP_USAGE_USED); + tmpDsc = codeGen->regSet.tmpFindNum(varNum, RegSet::TEMP_USAGE_USED); } assert(tmpDsc != nullptr); offset = tmpDsc->tdTempOffs(); @@ -2424,40 +2425,39 @@ inline { *pBaseReg = REG_FPBASE; } - // Change the FP-based addressing to the SP-based addressing when possible because + // Change the Frame Pointer (R11)-based addressing to the SP-based addressing when possible because // it generates smaller code on ARM. See frame picture above for the math. else { // If it is the final frame layout phase, we don't have a choice, we should stick // to either FP based or SP based that we decided in the earlier phase. Because - // we have already selected the instruction. Min-opts will have R10 enabled, so just - // use that. - - int spOffset = fConservative ? compLclFrameSize : offset + codeGen->genSPtoFPdelta(); - int actualOffset = (spOffset + addrModeOffset); - int ldrEncodeLimit = (varTypeIsFloating(type) ? 0x3FC : 0xFFC); - // Use ldr sp imm encoding. - if (lvaDoneFrameLayout == FINAL_FRAME_LAYOUT || opts.MinOpts() || (actualOffset <= ldrEncodeLimit)) + // we have already selected the instruction. MinOpts will always reserve R10, so + // for MinOpts always use SP-based offsets, using R10 as necessary, for simplicity. + + int spOffset = fConservative ? compLclFrameSize : offset + codeGen->genSPtoFPdelta(); + int actualOffset = spOffset + addrModeOffset; + int encodingLimitUpper = varTypeIsFloating(type) ? 0x3FC : 0xFFF; + int encodingLimitLower = varTypeIsFloating(type) ? -0x3FC : -0xFF; + + // Use SP-based encoding. During encoding, we'll pick the best encoding for the actual offset we have. + if (opts.MinOpts() || (actualOffset <= encodingLimitUpper)) { offset = spOffset; *pBaseReg = compLocallocUsed ? REG_SAVED_LOCALLOC_SP : REG_SPBASE; } - // Use ldr +/-imm8 encoding. - else if (offset >= -0x7C && offset <= ldrEncodeLimit) + // Use Frame Pointer (R11)-based encoding. + else if ((encodingLimitLower <= offset) && (offset <= encodingLimitUpper)) { *pBaseReg = REG_FPBASE; } - // Use a single movw. prefer locals. - else if (actualOffset <= 0xFFFC) // Fix 383910 ARM ILGEN + // Otherwise, use SP-based encoding. This is either (1) a small positive offset using a single movw, + // (2) a large offset using movw/movt. In either case, we must have already reserved + // the "reserved register", which will get used during encoding. + else { offset = spOffset; *pBaseReg = compLocallocUsed ? REG_SAVED_LOCALLOC_SP : REG_SPBASE; } - // Use movw, movt. - else - { - *pBaseReg = REG_FPBASE; - } } } else @@ -2601,11 +2601,25 @@ inline unsigned Compiler::compMapILargNum(unsigned ILargNum) return (ILargNum); } -// For ARM varargs, all arguments go in integer registers, so swizzle the type +//------------------------------------------------------------------------ +// Compiler::mangleVarArgsType: Retype float types to their corresponding +// : int/long types. +// +// Notes: +// +// The mangling of types will only occur for incoming vararg fixed arguments +// on windows arm|64 or on armel (softFP). +// +// NO-OP for all other cases. +// inline var_types Compiler::mangleVarArgsType(var_types type) { -#ifdef _TARGET_ARMARCH_ - if (info.compIsVarArgs || opts.compUseSoftFP) +#if defined(_TARGET_ARMARCH_) + if (opts.compUseSoftFP +#if defined(_TARGET_WINDOWS_) + || info.compIsVarArgs +#endif // defined(_TARGET_WINDOWS_) + ) { switch (type) { @@ -2617,7 +2631,7 @@ inline var_types Compiler::mangleVarArgsType(var_types type) break; } } -#endif // _TARGET_ARMARCH_ +#endif // defined(_TARGET_ARMARCH_) return type; } @@ -3065,7 +3079,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /*****************************************************************************/ -/* static */ inline unsigned Compiler::tmpSlot(unsigned size) +/* static */ inline unsigned RegSet::tmpSlot(unsigned size) { noway_assert(size >= sizeof(int)); noway_assert(size <= TEMP_MAX_SIZE); @@ -3081,10 +3095,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * over a function body. */ -inline void Compiler::tmpEnd() +inline void RegSet::tmpEnd() { #ifdef DEBUG - if (verbose && (tmpCount > 0)) + if (m_rsCompiler->verbose && (tmpCount > 0)) { printf("%d tmps used\n", tmpCount); } @@ -3097,7 +3111,7 @@ inline void Compiler::tmpEnd() * compiled. */ -inline void Compiler::tmpDone() +inline void RegSet::tmpDone() { #ifdef DEBUG unsigned count; @@ -4069,75 +4083,9 @@ inline bool Compiler::compStressCompile(compStressArea stressArea, unsigned weig } #endif -inline ArenaAllocator* Compiler::compGetAllocator() -{ - return compAllocator; -} - -/***************************************************************************** - * - * Allocate memory from the no-release allocator. All such memory will be - * freed up simulataneously at the end of the procedure - */ - -#ifndef DEBUG - -inline void* Compiler::compGetMem(size_t sz, CompMemKind cmk) -{ - assert(sz); - -#if MEASURE_MEM_ALLOC - genMemStats.AddAlloc(sz, cmk); -#endif - - return compAllocator->allocateMemory(sz); -} - -#endif - -// Wrapper for Compiler::compGetMem that can be forward-declared for use in template -// types which Compiler depends on but which need to allocate heap memory. -inline void* compGetMem(Compiler* comp, size_t sz) -{ - return comp->compGetMem(sz); -} - -/***************************************************************************** - * - * A common memory allocation for arrays of structures involves the - * multiplication of the number of elements with the size of each element. - * If this computation overflows, then the memory allocation might succeed, - * but not allocate sufficient memory for all the elements. This can cause - * us to overwrite the allocation, and AV or worse, corrupt memory. - * - * This method checks for overflow, and succeeds only when it detects - * that there's no overflow. It should be cheap, because when inlined with - * a constant elemSize, the division should be done in compile time, and so - * at run time we simply have a check of numElem against some number (this - * is why we __forceinline). - */ - -#define MAX_MEMORY_PER_ALLOCATION (512 * 1024 * 1024) - -__forceinline void* Compiler::compGetMemArray(size_t numElem, size_t elemSize, CompMemKind cmk) -{ - if (numElem > (MAX_MEMORY_PER_ALLOCATION / elemSize)) - { - NOMEM(); - } - - return compGetMem(numElem * elemSize, cmk); -} - -/****************************************************************************** - * - * Roundup the allocated size so that if this memory block is aligned, - * then the next block allocated too will be aligned. - * The JIT will always try to keep all the blocks aligned. - */ - -inline void Compiler::compFreeMem(void* ptr) +inline ArenaAllocator* Compiler::compGetArenaAllocator() { + return compArenaAllocator; } inline bool Compiler::compIsProfilerHookNeeded() @@ -4681,9 +4629,9 @@ void GenTree::VisitOperands(TVisitor visitor) case GT_NULLCHECK: case GT_PUTARG_REG: case GT_PUTARG_STK: -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: -#endif +#endif // FEATURE_ARG_SPLIT case GT_RETURNTRAP: visitor(this->AsUnOp()->gtOp1); return; @@ -4909,18 +4857,18 @@ void GenTree::VisitBinOpOperands(TVisitor visitor) /***************************************************************************** * operator new * - * Note that compGetMem is an arena allocator that returns memory that is + * Note that compiler's allocator is an arena allocator that returns memory that is * not zero-initialized and can contain data from a prior allocation lifetime. */ -inline void* __cdecl operator new(size_t sz, Compiler* context, CompMemKind cmk) +inline void* __cdecl operator new(size_t sz, Compiler* compiler, CompMemKind cmk) { - return context->compGetMem(sz, cmk); + return compiler->getAllocator(cmk).allocate(sz); } -inline void* __cdecl operator new[](size_t sz, Compiler* context, CompMemKind cmk) +inline void* __cdecl operator new[](size_t sz, Compiler* compiler, CompMemKind cmk) { - return context->compGetMem(sz, cmk); + return compiler->getAllocator(cmk).allocate(sz); } inline void* __cdecl operator new(size_t sz, void* p, const jitstd::placement_t& /* syntax_difference */) diff --git a/src/jit/compilerbitsettraits.hpp b/src/jit/compilerbitsettraits.hpp index be305647014e..e6c6b1326bbd 100644 --- a/src/jit/compilerbitsettraits.hpp +++ b/src/jit/compilerbitsettraits.hpp @@ -17,14 +17,14 @@ // static void* CompAllocBitSetTraits::Alloc(Compiler* comp, size_t byteSize) { - return comp->compGetMem(byteSize, CMK_bitset); + return comp->getAllocator(CMK_bitset).allocate(byteSize); } #ifdef DEBUG // static void* CompAllocBitSetTraits::DebugAlloc(Compiler* comp, size_t byteSize) { - return comp->compGetMem(byteSize, CMK_DebugOnly); + return comp->getAllocator(CMK_DebugOnly).allocate(byteSize); } #endif // DEBUG @@ -141,14 +141,14 @@ BitSetSupport::BitSetOpCounter* BasicBlockBitSetTraits::GetOpCounter(Compiler* c // static void* BitVecTraits::Alloc(BitVecTraits* b, size_t byteSize) { - return b->comp->compGetMem(byteSize, CMK_bitset); + return b->comp->getAllocator(CMK_bitset).allocate(byteSize); } #ifdef DEBUG // static void* BitVecTraits::DebugAlloc(BitVecTraits* b, size_t byteSize) { - return b->comp->compGetMem(byteSize, CMK_DebugOnly); + return b->comp->getAllocator(CMK_DebugOnly).allocate(byteSize); } #endif // DEBUG diff --git a/src/jit/copyprop.cpp b/src/jit/copyprop.cpp index 6c21d45c1ff0..c09fa91509b1 100644 --- a/src/jit/copyprop.cpp +++ b/src/jit/copyprop.cpp @@ -21,12 +21,6 @@ #include "ssabuilder.h" #include "treelifeupdater.h" -template -inline static T* allocate_any(jitstd::allocator& alloc, size_t count = 1) -{ - return jitstd::allocator(alloc).allocate(count); -} - /************************************************************************************** * * Corresponding to the live definition pushes, pop the stack as we finish a sub-paths @@ -370,7 +364,7 @@ void Compiler::optBlockCopyProp(BasicBlock* block, LclNumToGenTreePtrStack* curS GenTreePtrStack* stack; if (!curSsaName->Lookup(lclNum, &stack)) { - stack = new (curSsaName->GetAllocator()) GenTreePtrStack(this); + stack = new (curSsaName->GetAllocator()) GenTreePtrStack(curSsaName->GetAllocator()); } stack->Push(tree); curSsaName->Set(lclNum, stack); @@ -383,7 +377,7 @@ void Compiler::optBlockCopyProp(BasicBlock* block, LclNumToGenTreePtrStack* curS GenTreePtrStack* stack; if (!curSsaName->Lookup(lclNum, &stack)) { - stack = new (curSsaName->GetAllocator()) GenTreePtrStack(this); + stack = new (curSsaName->GetAllocator()) GenTreePtrStack(curSsaName->GetAllocator()); stack->Push(tree); curSsaName->Set(lclNum, stack); } @@ -431,10 +425,10 @@ void Compiler::optVnCopyProp() return; } - CompAllocator allocator(this, CMK_CopyProp); + CompAllocator allocator(getAllocator(CMK_CopyProp)); // Compute the domTree to use. - BlkToBlkVectorMap* domTree = new (&allocator) BlkToBlkVectorMap(&allocator); + BlkToBlkVectorMap* domTree = new (allocator) BlkToBlkVectorMap(allocator); domTree->Reallocate(fgBBcount * 3 / 2); // Prime the allocation SsaBuilder::ComputeDominators(this, domTree); @@ -453,9 +447,9 @@ void Compiler::optVnCopyProp() VarSetOps::AssignNoCopy(this, optCopyPropKillSet, VarSetOps::MakeEmpty(this)); // The map from lclNum to its recently live definitions as a stack. - LclNumToGenTreePtrStack curSsaName(&allocator); + LclNumToGenTreePtrStack curSsaName(allocator); - BlockWorkStack* worklist = new (&allocator) BlockWorkStack(&allocator); + BlockWorkStack* worklist = new (allocator) BlockWorkStack(allocator); worklist->push_back(BlockWork(fgFirstBB)); while (!worklist->empty()) diff --git a/src/jit/disasm.cpp b/src/jit/disasm.cpp index e76d5b364dc3..99b71ace844b 100644 --- a/src/jit/disasm.cpp +++ b/src/jit/disasm.cpp @@ -864,7 +864,6 @@ AddrToMethodHandleMap* DisAssembler::GetAddrToMethodHandleMap() { if (disAddrToMethodHandleMap == nullptr) { - assert(disComp->getAllocator() != nullptr); disAddrToMethodHandleMap = new (disComp->getAllocator()) AddrToMethodHandleMap(disComp->getAllocator()); } return disAddrToMethodHandleMap; @@ -877,7 +876,6 @@ AddrToMethodHandleMap* DisAssembler::GetHelperAddrToMethodHandleMap() { if (disHelperAddrToMethodHandleMap == nullptr) { - assert(disComp->getAllocator() != nullptr); disHelperAddrToMethodHandleMap = new (disComp->getAllocator()) AddrToMethodHandleMap(disComp->getAllocator()); } return disHelperAddrToMethodHandleMap; @@ -890,7 +888,6 @@ AddrToAddrMap* DisAssembler::GetRelocationMap() { if (disRelocationMap == nullptr) { - assert(disComp->getAllocator() != nullptr); disRelocationMap = new (disComp->getAllocator()) AddrToAddrMap(disComp->getAllocator()); } return disRelocationMap; diff --git a/src/jit/earlyprop.cpp b/src/jit/earlyprop.cpp index 46f89584a2d9..f97c0ac448fd 100644 --- a/src/jit/earlyprop.cpp +++ b/src/jit/earlyprop.cpp @@ -155,7 +155,7 @@ GenTree* Compiler::getObjectHandleNodeFromAllocation(GenTree* tree) // an object reference pointer, is treated in the same way as an array reference pointer. // // Null check folding tries to find GT_INDIR(obj + const) that GT_NULLCHECK(obj) can be folded into -/// and removed. Currently, the algorithm only matches GT_INDIR and GT_NULLCHECK in the same basic block. +// and removed. Currently, the algorithm only matches GT_INDIR and GT_NULLCHECK in the same basic block. void Compiler::optEarlyProp() { diff --git a/src/jit/ee_il_dll.cpp b/src/jit/ee_il_dll.cpp index b4abcc80068a..88612bcfdaf3 100644 --- a/src/jit/ee_il_dll.cpp +++ b/src/jit/ee_il_dll.cpp @@ -475,6 +475,15 @@ unsigned Compiler::eeGetArgSize(CORINFO_ARG_LIST_HANDLE list, CORINFO_SIG_INFO* { var_types hfaType = GetHfaType(argClass); // set to float or double if it is an HFA, otherwise TYP_UNDEF bool isHfa = (hfaType != TYP_UNDEF); +#ifndef _TARGET_UNIX_ + if (info.compIsVarArgs) + { + // Arm64 Varargs ABI requires passing in general purpose + // registers. Force the decision of whether this is an HFA + // to false to correctly pass as if it was not an HFA. + isHfa = false; + } +#endif // _TARGET_UNIX_ if (!isHfa) { // This struct is passed by reference using a single 'slot' @@ -524,7 +533,7 @@ GenTree* Compiler::eeGetPInvokeCookie(CORINFO_SIG_INFO* szMetaSig) unsigned Compiler::eeGetArrayDataOffset(var_types type) { - return varTypeIsGC(type) ? eeGetEEInfo()->offsetOfObjArrayData : offsetof(CORINFO_Array, u1Elems); + return varTypeIsGC(type) ? eeGetEEInfo()->offsetOfObjArrayData : OFFSETOF__CORINFO_Array__data; } //------------------------------------------------------------------------ @@ -724,7 +733,7 @@ void Compiler::eeGetVars() { // Allocate a bit-array for all the variables and initialize to false - bool* varInfoProvided = (bool*)compGetMem(info.compLocalsCount * sizeof(varInfoProvided[0])); + bool* varInfoProvided = getAllocator(CMK_Unknown).allocate(info.compLocalsCount); unsigned i; for (i = 0; i < info.compLocalsCount; i++) { diff --git a/src/jit/eeinterface.cpp b/src/jit/eeinterface.cpp index 658123097841..5a0e412afa6c 100644 --- a/src/jit/eeinterface.cpp +++ b/src/jit/eeinterface.cpp @@ -149,7 +149,7 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd) length += param.siglength + 2; - char* retName = (char*)compGetMem(length, CMK_DebugOnly); + char* retName = getAllocator(CMK_DebugOnly).allocate(length); /* Now generate the full signature string in the allocated buffer */ diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp index 89a2bca1d007..748e1c3c00e8 100644 --- a/src/jit/emit.cpp +++ b/src/jit/emit.cpp @@ -514,7 +514,7 @@ void* emitter::emitGetMem(size_t sz) emitTotMemAlloc += sz; #endif - return emitComp->compGetMem(sz, CMK_InstDesc); + return emitComp->getAllocator(CMK_InstDesc).allocate(sz); } /***************************************************************************** @@ -1343,29 +1343,32 @@ void* emitter::emitAllocInstr(size_t sz, emitAttr opsz) #ifdef DEBUG -/***************************************************************************** - * - * Make sure the code offsets of all instruction groups look reasonable. - */ +//------------------------------------------------------------------------ +// emitCheckIGoffsets: Make sure the code offsets of all instruction groups look reasonable. +// +// Note: It checks that each instruction group starts right after the previous ig. +// For the first cold ig offset is also should be the last hot ig + its size. +// emitCurCodeOffs maintains distance for the split case to look like they are consistent. +// Also it checks total code size. +// void emitter::emitCheckIGoffsets() { - insGroup* tempIG; - size_t offsIG; + size_t currentOffset = 0; - for (tempIG = emitIGlist, offsIG = 0; tempIG; tempIG = tempIG->igNext) + for (insGroup* tempIG = emitIGlist; tempIG != nullptr; tempIG = tempIG->igNext) { - if (tempIG->igOffs != offsIG) + if (tempIG->igOffs != currentOffset) { - printf("Block #%u has offset %08X, expected %08X\n", tempIG->igNum, tempIG->igOffs, offsIG); + printf("Block #%u has offset %08X, expected %08X\n", tempIG->igNum, tempIG->igOffs, currentOffset); assert(!"bad block offset"); } - offsIG += tempIG->igSize; + currentOffset += tempIG->igSize; } - if (emitTotalCodeSize && emitTotalCodeSize != offsIG) + if (emitTotalCodeSize != 0 && emitTotalCodeSize != currentOffset) { - printf("Total code size is %08X, expected %08X\n", emitTotalCodeSize, offsIG); + printf("Total code size is %08X, expected %08X\n", emitTotalCodeSize, currentOffset); assert(!"bad total code size"); } @@ -3632,8 +3635,13 @@ void emitter::emitJumpDistBind() { lstIG = lstIG->igNext; assert(lstIG); - // printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs, - // lstIG->igOffs - adjIG); +#ifdef DEBUG + if (EMITVERBOSE) + { + printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs, + lstIG->igOffs - adjIG); + } +#endif // DEBUG lstIG->igOffs -= adjIG; assert(IsCodeAligned(lstIG->igOffs)); } while (lstIG != jmpIG); @@ -4100,8 +4108,13 @@ void emitter::emitJumpDistBind() { break; } - // printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs, - // lstIG->igOffs - adjIG); +#ifdef DEBUG + if (EMITVERBOSE) + { + printf("Adjusted offset of block %02u from %04X to %04X\n", lstIG->igNum, lstIG->igOffs, + lstIG->igOffs - adjIG); + } +#endif // DEBUG lstIG->igOffs -= adjIG; assert(IsCodeAligned(lstIG->igOffs)); } @@ -4143,6 +4156,15 @@ void emitter::emitJumpDistBind() goto AGAIN; } } +#ifdef DEBUG + if (EMIT_INSTLIST_VERBOSE) + { + printf("\nLabels list after the jump dist binding:\n\n"); + emitDispIGlist(false); + } + + emitCheckIGoffsets(); +#endif // DEBUG } void emitter::emitCheckFuncletBranch(instrDesc* jmp, insGroup* jmpIG) @@ -4310,8 +4332,6 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, } #endif - insGroup* ig; - BYTE* consBlock; BYTE* codeBlock; BYTE* coldCodeBlock; @@ -4636,7 +4656,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, assert(!dsc->lvRegister); assert(dsc->lvTracked); - assert(dsc->lvRefCnt != 0); + assert(dsc->lvRefCnt() != 0); assert(dsc->TypeGet() == TYP_REF || dsc->TypeGet() == TYP_BYREF); @@ -4684,20 +4704,14 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, #define DEFAULT_CODE_BUFFER_INIT 0xcc - for (ig = emitIGlist; ig; ig = ig->igNext) + for (insGroup* ig = emitIGlist; ig != nullptr; ig = ig->igNext) { assert(!(ig->igFlags & IGF_PLACEHOLDER)); // There better not be any placeholder groups left /* Is this the first cold block? */ if (ig == emitFirstColdIG) { - unsigned actualHotCodeSize = emitCurCodeOffs(cp); - - /* Fill in eventual unused space */ - while (emitCurCodeOffs(cp) < emitTotalHotCodeSize) - { - *cp++ = DEFAULT_CODE_BUFFER_INIT; - } + assert(emitCurCodeOffs(cp) == emitTotalHotCodeSize); assert(coldCodeBlock); cp = coldCodeBlock; @@ -4710,7 +4724,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, } /* Are we overflowing? */ - if (ig->igNext && ig->igNum + 1 != ig->igNext->igNum) + if (ig->igNext && (ig->igNum + 1 != ig->igNext->igNum)) { NO_WAY("Too many instruction groups"); } @@ -4830,6 +4844,27 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, emitCurIG = nullptr; assert(ig->igSize >= cp - bp); + + // Is it the last ig in the hot part? + bool lastHotIG = (emitFirstColdIG != nullptr && ig->igNext == emitFirstColdIG); + if (lastHotIG) + { + unsigned actualHotCodeSize = emitCurCodeOffs(cp); + unsigned allocatedHotCodeSize = emitTotalHotCodeSize; + assert(actualHotCodeSize <= allocatedHotCodeSize); + if (actualHotCodeSize < allocatedHotCodeSize) + { + // The allocated chunk is bigger than used, fill in unused space in it. + unsigned unusedSize = allocatedHotCodeSize - emitCurCodeOffs(cp); + for (unsigned i = 0; i < unusedSize; ++i) + { + *cp++ = DEFAULT_CODE_BUFFER_INIT; + } + assert(allocatedHotCodeSize == emitCurCodeOffs(cp)); + } + } + + assert((ig->igSize >= cp - bp) || lastHotIG); ig->igSize = (unsigned short)(cp - bp); } @@ -4839,14 +4874,14 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, /* Output any initialized data we may have */ - if (emitConsDsc.dsdOffs) + if (emitConsDsc.dsdOffs != 0) { emitOutputDataSec(&emitConsDsc, consBlock); } /* Make sure all GC ref variables are marked as dead */ - if (emitGCrFrameOffsCnt) + if (emitGCrFrameOffsCnt != 0) { unsigned vn; int of; @@ -4877,15 +4912,12 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, if (emitFwdJumps) { - instrDescJmp* jmp; - - for (jmp = emitJumpList; jmp; jmp = jmp->idjNext) + for (instrDescJmp* jmp = emitJumpList; jmp != nullptr; jmp = jmp->idjNext) { - insGroup* tgt; #ifdef _TARGET_XARCH_ assert(jmp->idInsFmt() == IF_LABEL || jmp->idInsFmt() == IF_RWR_LABEL || jmp->idInsFmt() == IF_SWR_LABEL); #endif - tgt = jmp->idAddr()->iiaIGlabel; + insGroup* tgt = jmp->idAddr()->iiaIGlabel; if (jmp->idjTemp.idjAddr == nullptr) { @@ -4902,7 +4934,7 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, #endif #if DEBUG_EMIT - if (jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM || INTERESTING_JUMP_NUM == 0) + if ((jmp->idDebugOnlyInfo()->idNum == (unsigned)INTERESTING_JUMP_NUM) || (INTERESTING_JUMP_NUM == 0)) { #ifdef _TARGET_ARM_ printf("[5] This output is broken for ARM, since it doesn't properly decode the jump offsets of " @@ -4975,17 +5007,24 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, unsigned actualCodeSize = emitCurCodeOffs(cp); - /* Fill in eventual unused space */ - while (emitCurCodeOffs(cp) < emitTotalCodeSize) - { - *cp++ = DEFAULT_CODE_BUFFER_INIT; - } - #if EMITTER_STATS totAllocdSize += emitTotalCodeSize; totActualSize += actualCodeSize; #endif + // Fill in eventual unused space, but do not report this space as used. + // If you add this padding during the emitIGlist loop, then it will + // emit offsets after the loop with wrong value (for example for GC ref variables). + unsigned unusedSize = emitTotalCodeSize - emitCurCodeOffs(cp); + for (unsigned i = 0; i < unusedSize; ++i) + { + *cp++ = DEFAULT_CODE_BUFFER_INIT; + } + assert(emitTotalCodeSize == emitCurCodeOffs(cp)); + + // Total code size is sum of all IG->size and doesn't include padding in the last IG. + emitTotalCodeSize = actualCodeSize; + #ifdef DEBUG // Make sure these didn't change during the "issuing" phase @@ -4998,7 +5037,15 @@ unsigned emitter::emitEndCodeGen(Compiler* comp, assert(emitInitGCrefRegs == 0xBAADFEED); assert(emitInitByrefRegs == 0xBAADFEED); -#endif + if (EMIT_INSTLIST_VERBOSE) + { + printf("\nLabels list after the end of codegen:\n\n"); + emitDispIGlist(false); + } + + emitCheckIGoffsets(); + +#endif // DEBUG // Assign the real prolog size *prologSize = emitCodeOffset(emitPrologIG, emitPrologEndPos); @@ -7177,10 +7224,9 @@ const char* emitter::emitOffsetToLabel(unsigned offs) static char buf[4][TEMP_BUFFER_LEN]; char* retbuf; - insGroup* ig; UNATIVE_OFFSET nextof = 0; - for (ig = emitIGlist; ig != nullptr; ig = ig->igNext) + for (insGroup* ig = emitIGlist; ig != nullptr; ig = ig->igNext) { assert(nextof == ig->igOffs); diff --git a/src/jit/emit.h b/src/jit/emit.h index 987aa4b28a71..03f4d42cf195 100644 --- a/src/jit/emit.h +++ b/src/jit/emit.h @@ -1255,6 +1255,8 @@ class emitter int iddcDspVal; }; +#ifdef _TARGET_XARCH_ + struct instrDescAmd : instrDesc // large addrmode disp { ssize_t idaAmdVal; @@ -1266,6 +1268,8 @@ class emitter ssize_t idacAmdVal; }; +#endif // _TARGET_XARCH_ + struct instrDescCGCA : instrDesc // call with ... { VARSET_TP idcGCvars; // ... updated GC vars or @@ -1297,13 +1301,6 @@ class emitter #endif // MULTIREG_HAS_SECOND_GC_RET }; - struct instrDescArmFP : instrDesc - { - regNumber r1; - regNumber r2; - regNumber r3; - }; - insUpdateModes emitInsUpdateMode(instruction ins); insFormat emitInsModeFormat(instruction ins, insFormat base); @@ -1315,17 +1312,21 @@ class emitter size_t emitGetInstrDescSize(const instrDesc* id); size_t emitGetInstrDescSizeSC(const instrDesc* id); +#ifdef _TARGET_XARCH_ + ssize_t emitGetInsCns(instrDesc* id); ssize_t emitGetInsDsp(instrDesc* id); ssize_t emitGetInsAmd(instrDesc* id); - ssize_t emitGetInsCnsDsp(instrDesc* id, ssize_t* dspPtr); - ssize_t emitGetInsSC(instrDesc* id); + ssize_t emitGetInsCIdisp(instrDesc* id); unsigned emitGetInsCIargs(instrDesc* id); // Return the argument count for a direct call "id". int emitGetInsCDinfo(instrDesc* id); +#endif // _TARGET_XARCH_ + + ssize_t emitGetInsSC(instrDesc* id); unsigned emitInsCount; /************************************************************************/ @@ -1791,6 +1792,8 @@ class emitter return (instrDescCnsDsp*)emitAllocInstr(sizeof(instrDescCnsDsp), attr); } +#ifdef _TARGET_XARCH_ + instrDescAmd* emitAllocInstrAmd(emitAttr attr) { return (instrDescAmd*)emitAllocInstr(sizeof(instrDescAmd), attr); @@ -1801,6 +1804,8 @@ class emitter return (instrDescCnsAmd*)emitAllocInstr(sizeof(instrDescCnsAmd), attr); } +#endif // _TARGET_XARCH_ + instrDescCGCA* emitAllocInstrCGCA(emitAttr attr) { return (instrDescCGCA*)emitAllocInstr(sizeof(instrDescCGCA), attr); @@ -2423,6 +2428,8 @@ inline size_t emitter::emitGetInstrDescSizeSC(const instrDesc* id) } } +#ifdef _TARGET_XARCH_ + /***************************************************************************** * * The following helpers should be used to access the various values that @@ -2447,36 +2454,6 @@ inline ssize_t emitter::emitGetInsDsp(instrDesc* id) return 0; } -inline ssize_t emitter::emitGetInsCnsDsp(instrDesc* id, ssize_t* dspPtr) -{ - if (id->idIsLargeCns()) - { - if (id->idIsLargeDsp()) - { - *dspPtr = ((instrDescCnsDsp*)id)->iddcDspVal; - return ((instrDescCnsDsp*)id)->iddcCnsVal; - } - else - { - *dspPtr = 0; - return ((instrDescCns*)id)->idcCnsVal; - } - } - else - { - if (id->idIsLargeDsp()) - { - *dspPtr = ((instrDescDsp*)id)->iddDspVal; - return id->idSmallCns(); - } - else - { - *dspPtr = 0; - return id->idSmallCns(); - } - } -} - /***************************************************************************** * * Get hold of the argument count for an indirect call. @@ -2499,6 +2476,8 @@ inline unsigned emitter::emitGetInsCIargs(instrDesc* id) } } +#endif // _TARGET_XARCH_ + /***************************************************************************** * * Returns true if the given register contains a live GC ref. diff --git a/src/jit/emitarm.cpp b/src/jit/emitarm.cpp index 81381fe25f84..b32b974e235f 100644 --- a/src/jit/emitarm.cpp +++ b/src/jit/emitarm.cpp @@ -3451,7 +3451,7 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va // Its better to fail later with a better error message than // to fail here when the RBM_OPT_RSVD is not available // - if (undisp <= 0x03fb) + if (undisp <= 0x03fc) { fmt = IF_T2_VLDST; } @@ -3466,15 +3466,15 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va } else if (emitInsIsLoadOrStore(ins)) { - if (isLowRegister(reg1) && (reg2 == REG_SP) && (ins == INS_ldr) && ((disp & 0x03fc) == disp && disp <= 0x03f8)) + if (isLowRegister(reg1) && (reg2 == REG_SP) && (ins == INS_ldr) && ((disp & 0x03fc) == disp)) { fmt = IF_T1_J2; } - else if (disp >= 0 && disp <= 0x0ffb) + else if (disp >= 0 && disp <= 0x0fff) { fmt = IF_T2_K1; } - else if (undisp <= 0x0fb) + else if (undisp <= 0x0ff) { fmt = IF_T2_H0; } @@ -3488,11 +3488,11 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber reg1, int va } else if (ins == INS_add) { - if (isLowRegister(reg1) && (reg2 == REG_SP) && ((disp & 0x03fc) == disp && disp <= 0x03f8)) + if (isLowRegister(reg1) && (reg2 == REG_SP) && ((disp & 0x03fc) == disp)) { fmt = IF_T1_J2; } - else if (undisp <= 0x0ffb) + else if (undisp <= 0x0fff) { if (disp < 0) { @@ -3610,7 +3610,7 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va // Its better to fail later with a better error message than // to fail here when the RBM_OPT_RSVD is not available // - if (undisp <= 0x03fb) + if (undisp <= 0x03fc) { fmt = IF_T2_VLDST; } @@ -3623,15 +3623,15 @@ void emitter::emitIns_S_R(instruction ins, emitAttr attr, regNumber reg1, int va return; } } - else if (isLowRegister(reg1) && (reg2 == REG_SP) && (ins == INS_str) && ((disp & 0x03fc) == disp && disp <= 0x03f8)) + else if (isLowRegister(reg1) && (reg2 == REG_SP) && (ins == INS_str) && ((disp & 0x03fc) == disp)) { fmt = IF_T1_J2; } - else if (disp >= 0 && disp <= 0x0ffb) + else if (disp >= 0 && disp <= 0x0fff) { fmt = IF_T2_K1; } - else if (undisp <= 0x0fb) + else if (undisp <= 0x0ff) { fmt = IF_T2_H0; } @@ -5454,20 +5454,6 @@ BYTE* emitter::emitOutputIT(BYTE* dst, instruction ins, insFormat fmt, code_t co #endif // FEATURE_ITINSTRUCTION -/***************************************************************************** - * - * Output a 32-bit nop instruction. - */ - -BYTE* emitter::emitOutputNOP(BYTE* dst, instruction ins, insFormat fmt) -{ - code_t code = emitInsCode(ins, fmt); - - dst += emitOutput_Thumb2Instr(dst, code); - - return dst; -} - /***************************************************************************** * * Append the machine code corresponding to the given instruction descriptor @@ -6351,7 +6337,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) } else { - TempDsc* tmpDsc = emitComp->tmpFindNum(varNum); + TempDsc* tmpDsc = codeGen->regSet.tmpFindNum(varNum); vt = tmpDsc->tdTempType(); } if (vt == TYP_REF || vt == TYP_BYREF) @@ -6457,27 +6443,6 @@ void emitter::emitDispInst(instruction ins, insFlags flags) } while (len < 8); } -/***************************************************************************** - * - * Display an reloc value - * If we are formatting for an assembly listing don't print the hex value - * since it will prevent us from doing assembly diffs - */ -void emitter::emitDispReloc(int value, bool addComma) -{ - if (emitComp->opts.disAsm) - { - printf("(reloc)"); - } - else - { - printf("(reloc 0x%x)", dspPtr(value)); - } - - if (addComma) - printf(", "); -} - #define STRICT_ARM_ASM 0 /***************************************************************************** @@ -6626,10 +6591,6 @@ void emitter::emitDispReg(regNumber reg, emitAttr attr, bool addComma) printf(", "); } -void emitter::emitDispFloatReg(regNumber reg, emitAttr attr, bool addComma) -{ -} - /***************************************************************************** * * Display an addressing operand [reg] diff --git a/src/jit/emitarm.h b/src/jit/emitarm.h index 966db8e545dd..702588a8c174 100644 --- a/src/jit/emitarm.h +++ b/src/jit/emitarm.h @@ -20,18 +20,9 @@ struct CnsVal insSize emitInsSize(insFormat insFmt); -BYTE* emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = NULL); -BYTE* emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = NULL); -BYTE* emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc = NULL); - -BYTE* emitOutputR(BYTE* dst, instrDesc* id); -BYTE* emitOutputRI(BYTE* dst, instrDesc* id); -BYTE* emitOutputRR(BYTE* dst, instrDesc* id); -BYTE* emitOutputIV(BYTE* dst, instrDesc* id); #ifdef FEATURE_ITINSTRUCTION BYTE* emitOutputIT(BYTE* dst, instruction ins, insFormat fmt, code_t condcode); #endif // FEATURE_ITINSTRUCTION -BYTE* emitOutputNOP(BYTE* dst, instruction ins, insFormat fmt); BYTE* emitOutputLJ(insGroup* ig, BYTE* dst, instrDesc* id); BYTE* emitOutputShortBranch(BYTE* dst, instruction ins, insFormat fmt, ssize_t distVal, instrDescJmp* id); @@ -45,17 +36,13 @@ static unsigned emitOutput_Thumb2Instr(BYTE* dst, code_t code); #ifdef DEBUG -const char* emitFPregName(unsigned reg, bool varName = true); - void emitDispInst(instruction ins, insFlags flags); -void emitDispReloc(int value, bool addComma); void emitDispImm(int imm, bool addComma, bool alwaysHex = false); void emitDispCond(int cond); void emitDispShiftOpts(insOpts opt); void emitDispRegmask(int imm, bool encodedPC_LR); void emitDispRegRange(regNumber reg, int len, emitAttr attr); void emitDispReg(regNumber reg, emitAttr attr, bool addComma); -void emitDispFloatReg(regNumber reg, emitAttr attr, bool addComma); void emitDispAddrR(regNumber reg, emitAttr attr); void emitDispAddrRI(regNumber reg, int imm, emitAttr attr); void emitDispAddrRR(regNumber reg1, regNumber reg2, emitAttr attr); @@ -87,20 +74,12 @@ void emitDispIns(instrDesc* id, /************************************************************************/ private: -instrDesc* emitNewInstrAmd(emitAttr attr, int dsp); -instrDesc* emitNewInstrAmdCns(emitAttr attr, int dsp, int cns); - instrDesc* emitNewInstrCallDir( int argCnt, VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, emitAttr retSize); instrDesc* emitNewInstrCallInd( int argCnt, ssize_t disp, VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, regMaskTP byrefRegs, emitAttr retSize); -void emitGetInsCns(instrDesc* id, CnsVal* cv); -int emitGetInsAmdCns(instrDesc* id, CnsVal* cv); -void emitGetInsDcmCns(instrDesc* id, CnsVal* cv); -int emitGetInsAmdAny(instrDesc* id); - /************************************************************************/ /* Private helpers for instruction output */ /************************************************************************/ @@ -119,28 +98,7 @@ emitter::code_t emitInsCode(instruction ins, insFormat fmt); void emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataReg, GenTreeIndir* indir); void emitInsLoadStoreOp(instruction ins, emitAttr attr, regNumber dataReg, GenTreeIndir* indir, int offset); -/***************************************************************************** -* -* Convert between an index scale in bytes to a smaller encoding used for -* storage in instruction descriptors. -*/ - -inline emitter::opSize emitEncodeScale(size_t scale) -{ - assert(scale == 1 || scale == 2 || scale == 4 || scale == 8); - - return emitSizeEncode[scale - 1]; -} - -inline emitAttr emitDecodeScale(unsigned ensz) -{ - assert(ensz < 4); - - return emitter::emitSizeDecode[ensz]; -} - static bool isModImmConst(int imm); - static int encodeModImmConst(int imm); static int insUnscaleImm(int imm, emitAttr size); @@ -324,7 +282,7 @@ void emitIns_R_C(instruction ins, emitAttr attr, regNumber reg, CORINFO_FIELD_HA void emitIns_C_R(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fldHnd, regNumber reg, int offs); -void emitIns_C_I(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fdlHnd, ssize_t offs, ssize_t val); +void emitIns_C_I(instruction ins, emitAttr attr, CORINFO_FIELD_HANDLE fdlHnd, int offs, ssize_t val); void emitIns_R_L(instruction ins, emitAttr attr, BasicBlock* dst, regNumber reg); diff --git a/src/jit/emitarm64.cpp b/src/jit/emitarm64.cpp index 15f44a1f6f62..fed3b5d8a508 100644 --- a/src/jit/emitarm64.cpp +++ b/src/jit/emitarm64.cpp @@ -3545,7 +3545,7 @@ void emitter::emitIns_R_I(instruction ins, emitAttr attr, regNumber reg, ssize_t { if (loByte == 0xFF) { - imm8 |= (1 << pos); + imm8 |= (ssize_t{1} << pos); } uimm >>= 8; pos++; @@ -10164,7 +10164,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) } else { - TempDsc* tmpDsc = emitComp->tmpFindNum(varNum); + TempDsc* tmpDsc = codeGen->regSet.tmpFindNum(varNum); vt = tmpDsc->tdTempType(); } if (vt == TYP_REF || vt == TYP_BYREF) @@ -10188,7 +10188,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) } else { - TempDsc* tmpDsc = emitComp->tmpFindNum(varNum); + TempDsc* tmpDsc = codeGen->regSet.tmpFindNum(varNum); vt = tmpDsc->tdTempType(); } if (vt == TYP_REF || vt == TYP_BYREF) @@ -10658,7 +10658,7 @@ void emitter::emitDispExtendReg(regNumber reg, insOpts opt, ssize_t imm) if (imm > 0) { printf("*"); - emitDispImm(1 << imm, false); + emitDispImm(ssize_t{1} << imm, false); } } } @@ -11350,7 +11350,7 @@ void emitter::emitDispIns( const ssize_t mask8 = 0xFF; for (unsigned b = 0; b < 8; b++) { - if (imm & (1 << b)) + if (imm & (ssize_t{1} << b)) { imm64 |= (mask8 << (b * 8)); } diff --git a/src/jit/emitarm64.h b/src/jit/emitarm64.h index 0838d6e336e0..1b03dffd143a 100644 --- a/src/jit/emitarm64.h +++ b/src/jit/emitarm64.h @@ -67,9 +67,6 @@ void emitDispIns(instrDesc* id, /************************************************************************/ private: -instrDesc* emitNewInstrAmd(emitAttr attr, int dsp); -instrDesc* emitNewInstrAmdCns(emitAttr attr, int dsp, int cns); - instrDesc* emitNewInstrCallDir(int argCnt, VARSET_VALARG_TP GCvars, regMaskTP gcrefRegs, @@ -85,11 +82,6 @@ instrDesc* emitNewInstrCallInd(int argCnt, emitAttr retSize, emitAttr secondRetSize); -void emitGetInsCns(instrDesc* id, CnsVal* cv); -ssize_t emitGetInsAmdCns(instrDesc* id, CnsVal* cv); -void emitGetInsDcmCns(instrDesc* id, CnsVal* cv); -ssize_t emitGetInsAmdAny(instrDesc* id); - /************************************************************************/ /* Private helpers for instruction output */ /************************************************************************/ diff --git a/src/jit/emitfmtsxarch.h b/src/jit/emitfmtsxarch.h index 84bc0f8aec60..190a6e0ea9cd 100644 --- a/src/jit/emitfmtsxarch.h +++ b/src/jit/emitfmtsxarch.h @@ -111,7 +111,7 @@ IF_DEF(RRW_RRW_CNS, IS_R1_RW|IS_R2_RW, SCNS) // r/w reg , r/w r IF_DEF(RWR_RRD_RRD, IS_R1_WR|IS_R2_RD|IS_R3_RD, NONE) // write reg , read reg2 , read reg3 IF_DEF(RWR_RRD_RRD_CNS, IS_R1_WR|IS_R2_RD|IS_R3_RD, SCNS) // write reg , read reg2 , read reg3, const -IF_DEF(RWR_RRD_RRD_RRD, IS_R1_WR|IS_R2_RD|IS_R3_RD|IS_R4_RD, NONE) // write reg , read reg2 , read reg3 , read reg4 +IF_DEF(RWR_RRD_RRD_RRD, IS_R1_WR|IS_R2_RD|IS_R3_RD|IS_R4_RD, CNS) // write reg , read reg2 , read reg3 , read reg4 //---------------------------------------------------------------------------- // The following formats are used for direct addresses (e.g. static data members) //---------------------------------------------------------------------------- diff --git a/src/jit/emitinl.h b/src/jit/emitinl.h index 82ad53d34169..b53cf6932348 100644 --- a/src/jit/emitinl.h +++ b/src/jit/emitinl.h @@ -118,6 +118,8 @@ inline regNumber emitter::inst3opImulReg(instruction ins) * get stored in different places within the instruction descriptor. */ +#ifdef _TARGET_XARCH_ + inline ssize_t emitter::emitGetInsAmd(instrDesc* id) { return id->idIsLargeDsp() ? ((instrDescAmd*)id)->idaAmdVal : id->idAddr()->iiaAddrMode.amDisp; @@ -220,6 +222,8 @@ inline ssize_t emitter::emitGetInsAmdAny(instrDesc* id) return id->idAddr()->iiaAddrMode.amDisp; } +#endif // _TARGET_XARCH_ + /***************************************************************************** * * Convert between a register mask and a smaller version for storage. diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp index b3011fc9682e..17aae89488ff 100644 --- a/src/jit/emitxarch.cpp +++ b/src/jit/emitxarch.cpp @@ -50,6 +50,38 @@ bool IsFMAInstruction(instruction ins) return (ins >= INS_FIRST_FMA_INSTRUCTION) && (ins <= INS_LAST_FMA_INSTRUCTION); } +bool IsBMIInstruction(instruction ins) +{ + return (ins >= INS_FIRST_BMI_INSTRUCTION) && (ins <= INS_LAST_BMI_INSTRUCTION); +} + +regNumber getBmiRegNumber(instruction ins) +{ + switch (ins) + { + case INS_blsi: + { + return (regNumber)3; + } + + case INS_blsmsk: + { + return (regNumber)2; + } + + case INS_blsr: + { + return (regNumber)1; + } + + default: + { + assert(IsBMIInstruction(ins)); + return REG_NA; + } + } +} + regNumber getSseShiftRegNumber(instruction ins) { switch (ins) @@ -113,12 +145,16 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins) case INS_addss: case INS_addsubpd: case INS_addsubps: + case INS_andn: case INS_andnpd: case INS_andnps: case INS_andpd: case INS_andps: case INS_blendpd: case INS_blendps: + case INS_blsi: + case INS_blsmsk: + case INS_blsr: case INS_cmppd: case INS_cmpps: case INS_cmpsd: @@ -181,6 +217,8 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins) case INS_pcmpgtd: case INS_pcmpgtq: case INS_pcmpgtw: + case INS_pdep: + case INS_pext: case INS_phaddd: case INS_phaddsw: case INS_phaddw: @@ -255,6 +293,9 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins) case INS_unpcklps: case INS_unpckhpd: case INS_unpcklpd: + case INS_vblendvps: + case INS_vblendvpd: + case INS_vpblendvb: case INS_vfmadd132pd: case INS_vfmadd213pd: case INS_vfmadd231pd: @@ -319,6 +360,7 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins) case INS_vinserti128: case INS_vmaskmovps: case INS_vmaskmovpd: + case INS_vpblendd: case INS_vperm2i128: case INS_vperm2f128: case INS_vpermilpsvar: @@ -571,6 +613,10 @@ bool TakesRexWPrefix(instruction ins, emitAttr attr) { switch (ins) { + case INS_andn: + case INS_blsi: + case INS_blsmsk: + case INS_blsr: case INS_cvttsd2si: case INS_cvttss2si: case INS_cvtsd2si: @@ -580,6 +626,8 @@ bool TakesRexWPrefix(instruction ins, emitAttr attr) case INS_mov_xmm2i: case INS_mov_i2xmm: case INS_movnti: + case INS_pdep: + case INS_pext: return true; default: return false; @@ -799,7 +847,7 @@ unsigned emitter::emitOutputRexOrVexPrefixIfNeeded(instruction ins, BYTE* dst, c // 4-byte opcode: with the bytes ordered as 0x22114433 // check for a prefix in the 11 position BYTE sizePrefix = (code >> 16) & 0xFF; - if (sizePrefix != 0 && isPrefix(sizePrefix)) + if ((sizePrefix != 0) && isPrefix(sizePrefix)) { // 'pp' bits in byte2 of VEX prefix allows us to encode SIMD size prefixes as two bits // @@ -810,7 +858,33 @@ unsigned emitter::emitOutputRexOrVexPrefixIfNeeded(instruction ins, BYTE* dst, c switch (sizePrefix) { case 0x66: - vexPrefix |= 0x01; + if (IsBMIInstruction(ins)) + { + switch (ins) + { + case INS_pdep: + { + vexPrefix |= 0x03; + break; + } + + case INS_pext: + { + vexPrefix |= 0x02; + break; + } + + default: + { + vexPrefix |= 0x00; + break; + } + } + } + else + { + vexPrefix |= 0x01; + } break; case 0xF3: vexPrefix |= 0x02; @@ -1865,11 +1939,11 @@ inline UNATIVE_OFFSET emitter::emitInsSizeSV(code_t code, int var, int dsp) } // The offset is already assigned. Find the temp. - TempDsc* tmp = emitComp->tmpFindNum(var, Compiler::TEMP_USAGE_USED); + TempDsc* tmp = codeGen->regSet.tmpFindNum(var, RegSet::TEMP_USAGE_USED); if (tmp == nullptr) { // It might be in the free lists, if we're working on zero initializing the temps. - tmp = emitComp->tmpFindNum(var, Compiler::TEMP_USAGE_FREE); + tmp = codeGen->regSet.tmpFindNum(var, RegSet::TEMP_USAGE_FREE); } assert(tmp != nullptr); offs = tmp->tdTempOffs(); @@ -3131,7 +3205,7 @@ regNumber emitter::emitInsBinary(instruction ins, emitAttr attr, GenTree* dst, G varNum = tmpDsc->tdTempNum(); offset = 0; - emitComp->tmpRlsTemp(tmpDsc); + codeGen->regSet.tmpRlsTemp(tmpDsc); } else if (memOp->isIndir()) { @@ -4236,8 +4310,7 @@ void emitter::emitIns_R_R_C( attr = EA_SET_FLG(attr, EA_DSP_RELOC_FLG); } - instrDesc* id = emitNewInstrDsp(attr, offs); - UNATIVE_OFFSET sz = emitInsSizeCV(id, insCodeRM(ins)); + instrDesc* id = emitNewInstrDsp(attr, offs); id->idIns(ins); id->idInsFmt(IF_RWR_RRD_MRD); @@ -4245,6 +4318,7 @@ void emitter::emitIns_R_R_C( id->idReg2(reg2); id->idAddr()->iiaFieldHnd = fldHnd; + UNATIVE_OFFSET sz = emitInsSizeCV(id, insCodeRM(ins)); id->idCodeSize(sz); dispIns(id); @@ -4442,10 +4516,13 @@ void emitter::emitIns_R_R_S_I( // opReg encoded in imm[7:4] static int encodeXmmRegAsIval(regNumber opReg) { - assert(opReg >= XMMBASE); // AVX/AVX2 supports 4-reg format for vblendvps/vblendvpd/vpblendvb, // which encodes the fourth register into imm8[7:4] - return (opReg - XMMBASE) << 4; + assert(opReg >= XMMBASE); + int ival = (opReg - XMMBASE) << 4; + + assert((ival >= 0) && (ival <= 255)); + return (int8_t)ival; } //------------------------------------------------------------------------ @@ -6512,6 +6589,11 @@ void emitter::emitIns_R_S(instruction ins, emitAttr attr, regNumber ireg, int va sz += emitGetRexPrefixSize(ins); } + if (ins == INS_crc32) + { + sz += 1; + } + id->idIns(ins); id->idInsFmt(fmt); id->idReg1(ireg); @@ -8287,7 +8369,7 @@ void emitter::emitDispIns( val = emitGetInsSC(id); #ifdef _TARGET_AMD64_ // no 8-byte immediates allowed here! - assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); + assert((val >= (ssize_t)0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); #endif if (id->idIsCnsReloc()) { @@ -8368,6 +8450,12 @@ void emitter::emitDispIns( { printf("%s, %s", emitRegName(id->idReg1(), EA_PTRSIZE), sstr); } + else if ((ins == INS_crc32) && (attr != EA_8BYTE)) + { + // The idReg1 is always 4 bytes, but the size of idReg2 can vary. + // This logic ensures that we print `crc32 eax, bx` instead of `crc32 ax, bx` + printf("%s, %s", emitRegName(id->idReg1(), EA_4BYTE), emitRegName(id->idReg2(), attr)); + } else { printf("%s, %s", emitRegName(id->idReg1(), attr), sstr); @@ -8481,7 +8569,7 @@ void emitter::emitDispIns( val = cnsVal.cnsVal; #ifdef _TARGET_AMD64_ // no 8-byte immediates allowed here! - assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); + assert((val >= (ssize_t)0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); #endif if (id->idInsFmt() == IF_ARW_SHF) { @@ -8549,7 +8637,7 @@ void emitter::emitDispIns( val = cnsVal.cnsVal; #ifdef _TARGET_AMD64_ // no 8-byte immediates allowed here! - assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); + assert((val >= (ssize_t)0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); #endif if (id->idInsFmt() == IF_SRW_SHF) { @@ -8583,6 +8671,12 @@ void emitter::emitDispIns( { printf("%s, %s", emitRegName(id->idReg1(), EA_PTRSIZE), sstr); } + else if ((ins == INS_crc32) && (attr != EA_8BYTE)) + { + // The idReg1 is always 4 bytes, but the size of idReg2 can vary. + // This logic ensures that we print `crc32 eax, bx` instead of `crc32 ax, bx` + printf("%s, %s", emitRegName(id->idReg1(), EA_4BYTE), emitRegName(id->idReg2(), attr)); + } else { printf("%s, %s", emitRegName(id->idReg1(), attr), sstr); @@ -8696,6 +8790,8 @@ void emitter::emitDispIns( #ifdef FEATURE_HW_INTRINSICS else if (ins == INS_crc32 && attr != EA_8BYTE) { + // The idReg1 is always 4 bytes, but the size of idReg2 can vary. + // This logic ensures that we print `crc32 eax, bx` instead of `crc32 ax, bx` printf("%s, %s", emitRegName(id->idReg1(), EA_4BYTE), emitRegName(id->idReg2(), attr)); } #endif // FEATURE_HW_INTRINSICS @@ -8741,7 +8837,7 @@ void emitter::emitDispIns( val = emitGetInsSC(id); #ifdef _TARGET_AMD64_ // no 8-byte immediates allowed here! - assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); + assert((val >= (ssize_t)0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); #endif printf(", "); if (id->idIsCnsReloc()) @@ -8780,6 +8876,12 @@ void emitter::emitDispIns( attr = EA_PTRSIZE; } #endif + else if ((ins == INS_crc32) && (attr != EA_8BYTE)) + { + // The idReg1 is always 4 bytes, but the size of idReg2 can vary. + // This logic ensures that we print `crc32 eax, bx` instead of `crc32 ax, bx` + printf("%s, %s", emitRegName(id->idReg1(), EA_4BYTE), emitRegName(id->idReg2(), attr)); + } printf("%s, %s", emitRegName(id->idReg1(), attr), sstr); offs = emitGetInsDsp(id); emitDispClsVar(id->idAddr()->iiaFieldHnd, offs, ID_INFO_DSP_RELOC); @@ -8903,7 +9005,7 @@ void emitter::emitDispIns( val = cnsVal.cnsVal; #ifdef _TARGET_AMD64_ // no 8-byte immediates allowed here! - assert((val >= 0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); + assert((val >= (ssize_t)0xFFFFFFFF80000000LL) && (val <= 0x000000007FFFFFFFLL)); #endif if (cnsVal.cnsReloc) { @@ -9284,7 +9386,8 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) { regNumber src1 = id->idReg2(); - if ((id->idInsFmt() != IF_RWR_RRD_ARD) && (id->idInsFmt() != IF_RWR_RRD_ARD_CNS)) + if ((id->idInsFmt() != IF_RWR_RRD_ARD) && (id->idInsFmt() != IF_RWR_RRD_ARD_CNS) && + (id->idInsFmt() != IF_RWR_RRD_ARD_RRD)) { src1 = id->idReg1(); } @@ -9319,12 +9422,32 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } // Special case emitting AVX instructions - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { - unsigned regcode = insEncodeReg345(ins, id->idReg1(), size, &code); + if ((ins == INS_crc32) && (size > EA_1BYTE)) + { + code |= 0x0100; + + if (size == EA_2BYTE) + { + dst += emitOutputByte(dst, 0x66); + } + } + + regNumber reg345 = REG_NA; + if (IsBMIInstruction(ins)) + { + reg345 = getBmiRegNumber(ins); + } + if (reg345 == REG_NA) + { + reg345 = id->idReg1(); + } + unsigned regcode = insEncodeReg345(ins, reg345, size, &code); + dst += emitOutputRexOrVexPrefixIfNeeded(ins, dst, code); - if (UseVEXEncoding()) + if (UseVEXEncoding() && (ins != INS_crc32)) { // Emit last opcode byte // TODO-XArch-CQ: Right now support 4-byte opcode instructions only @@ -9450,6 +9573,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) switch (reg) { case REG_NA: + { if (id->idIsDspReloc()) { INT32 addlDelta = 0; @@ -9457,7 +9581,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) // The address is of the form "[disp]" // On x86 - disp is relative to zero // On Amd64 - disp is relative to RIP - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst += emitOutputByte(dst, code | 0x05); } @@ -9513,7 +9637,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) else { #ifdef _TARGET_X86_ - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst += emitOutputByte(dst, code | 0x05); } @@ -9543,9 +9667,11 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) dst += emitOutputLong(dst, dsp); } break; + } case REG_EBP: - if (Is4ByteSSE4OrAVXInstruction(ins)) + { + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { // Does the offset fit in a byte? if (dspInByte) @@ -9584,9 +9710,11 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } } break; + } case REG_ESP: - if (Is4ByteSSE4OrAVXInstruction(ins)) + { + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { // Is the offset 0 or does it at least fit in a byte? if (dspIsZero) @@ -9637,9 +9765,11 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } } break; + } default: - if (Is4ByteSSE4OrAVXInstruction(ins)) + { + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { // Put the register in the opcode code |= insEncodeReg012(ins, reg, EA_PTRSIZE, nullptr); @@ -9701,6 +9831,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } break; + } } } else @@ -9720,7 +9851,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) regByte = insEncodeReg012(ins, reg, EA_PTRSIZE, nullptr) | insEncodeReg345(ins, rgx, EA_PTRSIZE, nullptr) | insSSval(mul); - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { // Emit [ebp + {2/4/8} * rgz] as [ebp + {2/4/8} * rgx + 0] if (dspIsZero && reg != REG_EBP) @@ -9787,7 +9918,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) regByte = insEncodeReg012(ins, REG_EBP, EA_PTRSIZE, nullptr) | insEncodeReg345(ins, rgx, EA_PTRSIZE, nullptr) | insSSval(mul); - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst += emitOutputByte(dst, code | 0x04); } @@ -9816,7 +9947,7 @@ BYTE* emitter::emitOutputAM(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) // The address is "[reg+rgx+dsp]" regByte = insEncodeReg012(ins, reg, EA_PTRSIZE, nullptr) | insEncodeReg345(ins, rgx, EA_PTRSIZE, nullptr); - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { if (dspIsZero && reg != REG_EBP) { @@ -10043,12 +10174,36 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) } // Special case emitting AVX instructions - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { - unsigned regcode = insEncodeReg345(ins, id->idReg1(), size, &code); + if ((ins == INS_crc32) && (size > EA_1BYTE)) + { + code |= 0x0100; + + if (size == EA_2BYTE) + { + dst += emitOutputByte(dst, 0x66); + } + } + + regNumber reg345 = REG_NA; + if (IsBMIInstruction(ins)) + { + reg345 = getBmiRegNumber(ins); + } + if (reg345 == REG_NA) + { + reg345 = id->idReg1(); + } + else + { + code = insEncodeReg3456(ins, id->idReg1(), size, code); + } + unsigned regcode = insEncodeReg345(ins, reg345, size, &code); + dst += emitOutputRexOrVexPrefixIfNeeded(ins, dst, code); - if (UseVEXEncoding()) + if (UseVEXEncoding() && (ins != INS_crc32)) { // Emit last opcode byte // TODO-XArch-CQ: Right now support 4-byte opcode instructions only @@ -10174,7 +10329,7 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) if (EBPbased) { // EBP-based variable: does the offset fit in a byte? - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { if (dspInByte) { @@ -10213,7 +10368,7 @@ BYTE* emitter::emitOutputSV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) dspIsZero = (dsp == 0); // Does the offset fit in a byte? - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { if (dspInByte) { @@ -10483,12 +10638,36 @@ BYTE* emitter::emitOutputCV(BYTE* dst, instrDesc* id, code_t code, CnsVal* addc) #endif //_TARGET_X86_ // Special case emitting AVX instructions - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { - unsigned regcode = insEncodeReg345(ins, id->idReg1(), size, &code); + if ((ins == INS_crc32) && (size > EA_1BYTE)) + { + code |= 0x0100; + + if (size == EA_2BYTE) + { + dst += emitOutputByte(dst, 0x66); + } + } + + regNumber reg345 = REG_NA; + if (IsBMIInstruction(ins)) + { + reg345 = getBmiRegNumber(ins); + } + if (reg345 == REG_NA) + { + reg345 = id->idReg1(); + } + else + { + code = insEncodeReg3456(ins, id->idReg1(), size, code); + } + unsigned regcode = insEncodeReg345(ins, reg345, size, &code); + dst += emitOutputRexOrVexPrefixIfNeeded(ins, dst, code); - if (UseVEXEncoding()) + if (UseVEXEncoding() && (ins != INS_crc32)) { // Emit last opcode byte // TODO-XArch-CQ: Right now support 4-byte opcode instructions only @@ -11073,7 +11252,7 @@ BYTE* emitter::emitOutputRR(BYTE* dst, instrDesc* id) #endif // _TARGET_AMD64_ } #ifdef FEATURE_HW_INTRINSICS - else if ((ins == INS_crc32) || (ins == INS_lzcnt) || (ins == INS_popcnt)) + else if ((ins == INS_crc32) || (ins == INS_lzcnt) || (ins == INS_popcnt) || (ins == INS_tzcnt)) { code = insEncodeRMreg(ins, code); if ((ins == INS_crc32) && (size > EA_1BYTE)) @@ -11138,7 +11317,16 @@ BYTE* emitter::emitOutputRR(BYTE* dst, instrDesc* id) } } - unsigned regCode = insEncodeReg345(ins, reg1, size, &code); + regNumber reg345 = REG_NA; + if (IsBMIInstruction(ins)) + { + reg345 = getBmiRegNumber(ins); + } + if (reg345 == REG_NA) + { + reg345 = id->idReg1(); + } + unsigned regCode = insEncodeReg345(ins, reg345, size, &code); regCode |= insEncodeReg012(ins, reg2, size, &code); if (TakesVexPrefix(ins)) @@ -12813,8 +13001,9 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) case IF_RWR_ARD: case IF_RRW_ARD: case IF_RWR_RRD_ARD: + { code = insCodeRM(ins); - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst = emitOutputAM(dst, id, code); } @@ -12826,6 +13015,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) } sz = emitSizeOfInsDsc(id); break; + } case IF_RWR_RRD_ARD_CNS: case IF_RWR_RRD_ARD_RRD: @@ -12954,11 +13144,12 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) case IF_RRD_SRD: case IF_RWR_SRD: case IF_RRW_SRD: + { code = insCodeRM(ins); // 4-byte AVX instructions are special cased inside emitOutputSV // since they do not have space to encode ModRM byte. - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst = emitOutputSV(dst, id, code); } @@ -12975,7 +13166,10 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); dst = emitOutputSV(dst, id, code | regcode); } + + sz = emitSizeOfInsDsc(id); break; + } case IF_RWR_RRD_SRD: { @@ -13115,9 +13309,11 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) case IF_RRD_MRD: case IF_RWR_MRD: case IF_RRW_MRD: + { code = insCodeRM(ins); + // Special case 4-byte AVX instructions - if (Is4ByteSSE4OrAVXInstruction(ins)) + if (Is4ByteSSE4OrAVXInstruction(ins) || (ins == INS_crc32)) { dst = emitOutputCV(dst, id, code); } @@ -13134,8 +13330,10 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp) regcode = (insEncodeReg345(ins, id->idReg1(), size, &code) << 8); dst = emitOutputCV(dst, id, code | regcode | 0x0500); } + sz = emitSizeOfInsDsc(id); break; + } case IF_RWR_RRD_MRD: { diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp index 3d5c37b397e2..46eefa416796 100644 --- a/src/jit/flowgraph.cpp +++ b/src/jit/flowgraph.cpp @@ -126,8 +126,6 @@ void Compiler::fgInit() /* This global flag is set whenever we add a throw block for a RngChk */ fgRngChkThrowAdded = false; /* reset flag for fgIsCodeAdded() */ - fgIncrCount = 0; - /* We will record a list of all BBJ_RETURN blocks here */ fgReturnBlocks = nullptr; @@ -2337,7 +2335,7 @@ void Compiler::fgDfsInvPostOrderHelper(BasicBlock* block, BlockSet& visited, uns // Allocate a local stack to hold the DFS traversal actions necessary // to compute pre/post-ordering of the control flowgraph. - ArrayStack stack(this); + ArrayStack stack(getAllocator(CMK_ArrayStack)); // Push the first block on the stack to seed the traversal. stack.Push(DfsBlockEntry(DSS_Pre, block)); @@ -2778,7 +2776,7 @@ void Compiler::fgTraverseDomTree(unsigned bbNum, BasicBlockList** domTree, unsig // Allocate a local stack to hold the Dfs traversal actions necessary // to compute pre/post-ordering of the dominator tree. - ArrayStack stack(this); + ArrayStack stack(getAllocator(CMK_ArrayStack)); // Push the first entry number on the stack to seed the traversal. stack.Push(DfsNumEntry(DSS_Pre, bbNum)); @@ -3350,10 +3348,10 @@ Compiler::SwitchUniqueSuccSet Compiler::GetDescriptorForSwitch(BasicBlock* switc } } -void Compiler::SwitchUniqueSuccSet::UpdateTarget(CompAllocator* alloc, - BasicBlock* switchBlk, - BasicBlock* from, - BasicBlock* to) +void Compiler::SwitchUniqueSuccSet::UpdateTarget(CompAllocator alloc, + BasicBlock* switchBlk, + BasicBlock* from, + BasicBlock* to) { assert(switchBlk->bbJumpKind == BBJ_SWITCH); // Precondition. unsigned jmpTabCnt = switchBlk->bbJumpSwt->bbsCount; @@ -4752,6 +4750,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE* } break; +#if !defined(FEATURE_CORECLR) case CEE_CALLI: // CEE_CALLI should not be inlined if the call indirect target has a calling convention other than @@ -4784,6 +4783,7 @@ void Compiler::fgFindJumpTargets(const BYTE* codeAddr, IL_OFFSET codeSize, BYTE* } } break; +#endif // FEATURE_CORECLR case CEE_JMP: retBlocks++; @@ -6806,8 +6806,6 @@ unsigned Compiler::fgGetNestingLevel(BasicBlock* block, unsigned* pFinallyNestin void Compiler::fgImport() { - fgHasPostfix = false; - impImport(fgFirstBB); if (!opts.jitFlags->IsSet(JitFlags::JIT_FLAG_SKIP_VERIFICATION)) @@ -9549,8 +9547,8 @@ void Compiler::fgSimpleLowering() noway_assert(arr->gtNext == tree); - noway_assert(arrLen->ArrLenOffset() == offsetof(CORINFO_Array, length) || - arrLen->ArrLenOffset() == offsetof(CORINFO_String, stringLen)); + noway_assert(arrLen->ArrLenOffset() == OFFSETOF__CORINFO_Array__length || + arrLen->ArrLenOffset() == OFFSETOF__CORINFO_String__stringLen); if ((arr->gtOper == GT_CNS_INT) && (arr->gtIntCon.gtIconVal == 0)) { @@ -9918,10 +9916,8 @@ void Compiler::fgRemoveStmt(BasicBlock* block, statement boundaries. Or should we leave a GT_NO_OP in its place? */ } - /* Is it the first statement in the list? */ - GenTreeStmt* firstStmt = block->firstStmt(); - if (firstStmt == stmt) + if (firstStmt == stmt) // Is it the first statement in the list? { if (firstStmt->gtNext == nullptr) { @@ -9935,26 +9931,21 @@ void Compiler::fgRemoveStmt(BasicBlock* block, block->bbTreeList = tree->gtNext; block->bbTreeList->gtPrev = tree->gtPrev; } - goto DONE; } - - /* Is it the last statement in the list? */ - - if (stmt == block->lastStmt()) + else if (stmt == block->lastStmt()) // Is it the last statement in the list? { stmt->gtPrev->gtNext = nullptr; block->bbTreeList->gtPrev = stmt->gtPrev; - goto DONE; } + else // The statement is in the middle. + { + assert(stmt->gtPrevStmt != nullptr && stmt->gtNext != nullptr); - tree = stmt->gtPrevStmt; - noway_assert(tree); - - tree->gtNext = stmt->gtNext; - stmt->gtNext->gtPrev = tree; + tree = stmt->gtPrevStmt; -DONE: - fgStmtRemoved = true; + tree->gtNext = stmt->gtNext; + stmt->gtNext->gtPrev = tree; + } noway_assert(!optValnumCSE_phase); @@ -9966,6 +9957,8 @@ void Compiler::fgRemoveStmt(BasicBlock* block, } } + fgStmtRemoved = true; + #ifdef DEBUG if (verbose) { @@ -19290,7 +19283,7 @@ const char* Compiler::fgProcessEscapes(const char* nameIn, escapeMapping_t* map) if (subsitutionRequired) { - char* newName = (char*)compGetMem(lengthOut, CMK_DebugOnly); + char* newName = getAllocator(CMK_DebugOnly).allocate(lengthOut); char* pDest; pDest = newName; pChar = nameIn; @@ -21162,7 +21155,7 @@ void Compiler::fgDebugCheckFlags(GenTree* tree) case GT_FIELD_LIST: if ((op2 != nullptr) && op2->OperIsAnyList()) { - ArrayStack stack(this); + ArrayStack stack(getAllocator(CMK_DebugOnly)); while ((tree->gtGetOp2() != nullptr) && tree->gtGetOp2()->OperIsAnyList()) { stack.Push(tree); @@ -22327,33 +22320,113 @@ Compiler::fgWalkResult Compiler::fgUpdateInlineReturnExpressionPlaceHolder(GenTr } } -#if FEATURE_MULTIREG_RET - - // Did we record a struct return class handle above? + // If an inline was rejected and the call returns a struct, we may + // have deferred some work when importing call for cases where the + // struct is returned in register(s). + // + // See the bail-out clauses in impFixupCallStructReturn for inline + // candidates. // + // Do the deferred work now. if (retClsHnd != NO_CLASS_HANDLE) { - // Is this a type that is returned in multiple registers? - // if so we need to force into into a form we accept. - // i.e. LclVar = call() - // - if (comp->IsMultiRegReturnedType(retClsHnd)) + structPassingKind howToReturnStruct; + var_types returnType = comp->getReturnTypeForStruct(retClsHnd, &howToReturnStruct); + GenTree* parent = data->parent; + + switch (howToReturnStruct) { - GenTree* parent = data->parent; - // See assert below, we only look one level above for an asg parent. - if (parent->gtOper == GT_ASG) + +#if FEATURE_MULTIREG_RET + + // Is this a type that is returned in multiple registers + // or a via a primitve type that is larger than the struct type? + // if so we need to force into into a form we accept. + // i.e. LclVar = call() + case SPK_ByValue: + case SPK_ByValueAsHfa: { - // Either lhs is a call V05 = call(); or lhs is addr, and asg becomes a copyBlk. - comp->fgAttachStructInlineeToAsg(parent, tree, retClsHnd); + // See assert below, we only look one level above for an asg parent. + if (parent->gtOper == GT_ASG) + { + // Either lhs is a call V05 = call(); or lhs is addr, and asg becomes a copyBlk. + comp->fgAttachStructInlineeToAsg(parent, tree, retClsHnd); + } + else + { + // Just assign the inlinee to a variable to keep it simple. + tree->ReplaceWith(comp->fgAssignStructInlineeToVar(tree, retClsHnd), comp); + } } - else + break; + +#endif // FEATURE_MULTIREG_RET + + case SPK_EnclosingType: { - // Just assign the inlinee to a variable to keep it simple. - tree->ReplaceWith(comp->fgAssignStructInlineeToVar(tree, retClsHnd), comp); + // For enclosing type returns, we must return the call value to a temp since + // the return type is larger than the struct type. + if (!tree->IsCall()) + { + break; + } + + GenTreeCall* call = tree->AsCall(); + + assert(call->gtReturnType == TYP_STRUCT); + + if (call->gtReturnType != TYP_STRUCT) + { + break; + } + + JITDUMP("\nCall returns small struct via enclosing type, retyping. Before:\n"); + DISPTREE(call); + + // Create new struct typed temp for return value + const unsigned tmpNum = + comp->lvaGrabTemp(true DEBUGARG("small struct return temp for rejected inline")); + comp->lvaSetStruct(tmpNum, retClsHnd, false); + GenTree* assign = comp->gtNewTempAssign(tmpNum, call); + + // Modify assign tree and call return types to the primitive return type + call->gtReturnType = returnType; + call->gtType = returnType; + assign->gtType = returnType; + + // Modify the temp reference in the assign as a primitive reference via GT_LCL_FLD + GenTree* tempAsPrimitive = assign->gtOp.gtOp1; + assert(tempAsPrimitive->gtOper == GT_LCL_VAR); + tempAsPrimitive->gtType = returnType; + tempAsPrimitive->ChangeOper(GT_LCL_FLD); + + // Return temp as value of call tree via comma + GenTree* tempAsStruct = comp->gtNewLclvNode(tmpNum, TYP_STRUCT); + GenTree* comma = comp->gtNewOperNode(GT_COMMA, TYP_STRUCT, assign, tempAsStruct); + parent->ReplaceOperand(pTree, comma); + + JITDUMP("\nAfter:\n"); + DISPTREE(comma); } + break; + + case SPK_PrimitiveType: + // We should have already retyped the call as a primitive type + // when we first imported the call + break; + + case SPK_ByReference: + // We should have already added the return buffer + // when we first imported the call + break; + + default: + noway_assert(!"Unexpected struct passing kind"); + break; } } +#if FEATURE_MULTIREG_RET #if defined(DEBUG) // Make sure we don't have a tree like so: V05 = (, , , retExpr); @@ -23736,6 +23809,11 @@ void Compiler::fgRemoveEmptyFinally() BasicBlock* const leaveBlock = currentBlock->bbNext; BasicBlock* const postTryFinallyBlock = leaveBlock->bbJumpDest; + JITDUMP("Modifying callfinally BB%02u leave BB%02u finally BB%02u continuation BB%02u\n", + currentBlock->bbNum, leaveBlock->bbNum, firstBlock->bbNum, postTryFinallyBlock->bbNum); + JITDUMP("so that BB%02u jumps to BB%02u; then remove BB%02u\n", currentBlock->bbNum, + postTryFinallyBlock->bbNum, leaveBlock->bbNum); + noway_assert(leaveBlock->bbJumpKind == BBJ_ALWAYS); currentBlock->bbJumpDest = postTryFinallyBlock; @@ -23763,6 +23841,8 @@ void Compiler::fgRemoveEmptyFinally() currentBlock = nextBlock; } + JITDUMP("Remove now-unreachable handler BB%02u\n", firstBlock->bbNum); + // Handler block should now be unreferenced, since the only // explicit references to it were in call finallys. firstBlock->bbRefs = 0; @@ -24397,15 +24477,27 @@ void Compiler::fgCloneFinally() for (BasicBlock* block = lastTryBlock; block != beforeTryBlock; block = block->bbPrev) { #if FEATURE_EH_CALLFINALLY_THUNKS - // Look for blocks that are always jumps to a call finally - // pair that targets our finally. - if (block->bbJumpKind != BBJ_ALWAYS) + // Blocks that transfer control to callfinallies are usually + // BBJ_ALWAYS blocks, but the last block of a try may fall + // through to a callfinally. + BasicBlock* jumpDest = nullptr; + + if ((block->bbJumpKind == BBJ_NONE) && (block == lastTryBlock)) { - continue; + jumpDest = block->bbNext; + } + else if (block->bbJumpKind == BBJ_ALWAYS) + { + jumpDest = block->bbJumpDest; } - BasicBlock* const jumpDest = block->bbJumpDest; + if (jumpDest == nullptr) + { + continue; + } + // The jumpDest must be a callfinally that in turn invokes the + // finally of interest. if (!jumpDest->isBBCallAlwaysPair() || (jumpDest->bbJumpDest != firstBlock)) { continue; diff --git a/src/jit/gcencode.cpp b/src/jit/gcencode.cpp index a05e8eb08d38..d74282251146 100644 --- a/src/jit/gcencode.cpp +++ b/src/jit/gcencode.cpp @@ -1906,7 +1906,7 @@ PendingArgsStack::PendingArgsStack(unsigned maxDepth, Compiler* pComp) /* Do we need an array as well as the mask ? */ if (pasMaxDepth > BITS_IN_pasMask) - pasTopArray = (BYTE*)pComp->compGetMem(pasMaxDepth - BITS_IN_pasMask); + pasTopArray = pComp->getAllocator(CMK_Unknown).allocate(pasMaxDepth - BITS_IN_pasMask); } //----------------------------------------------------------------------------- @@ -2240,7 +2240,7 @@ size_t GCInfo::gcMakeRegPtrTable(BYTE* dest, int mask, const InfoHdr& header, un /* If this non-enregistered pointer arg is never * used, we don't need to report it */ - assert(varDsc->lvRefCnt == 0); // This assert is currently a known issue for X86-RyuJit + assert(varDsc->lvRefCnt() == 0); // This assert is currently a known issue for X86-RyuJit continue; } else if (varDsc->lvIsRegArg && varDsc->lvTracked) @@ -2365,8 +2365,9 @@ size_t GCInfo::gcMakeRegPtrTable(BYTE* dest, int mask, const InfoHdr& header, un /* Count&Write spill temps that hold pointers */ - assert(compiler->tmpAllFree()); - for (TempDsc* tempItem = compiler->tmpListBeg(); tempItem != nullptr; tempItem = compiler->tmpListNxt(tempItem)) + assert(compiler->codeGen->regSet.tmpAllFree()); + for (TempDsc* tempItem = compiler->codeGen->regSet.tmpListBeg(); tempItem != nullptr; + tempItem = compiler->codeGen->regSet.tmpListNxt(tempItem)) { if (varTypeIsGC(tempItem->tdTempType())) { @@ -4219,7 +4220,7 @@ void GCInfo::gcMakeRegPtrTable( { // If this non-enregistered pointer arg is never // used, we don't need to report it. - assert(varDsc->lvRefCnt == 0); + assert(varDsc->lvRefCnt() == 0); continue; } else if (varDsc->lvIsRegArg && varDsc->lvTracked) @@ -4330,8 +4331,9 @@ void GCInfo::gcMakeRegPtrTable( { // Count&Write spill temps that hold pointers. - assert(compiler->tmpAllFree()); - for (TempDsc* tempItem = compiler->tmpListBeg(); tempItem != nullptr; tempItem = compiler->tmpListNxt(tempItem)) + assert(compiler->codeGen->regSet.tmpAllFree()); + for (TempDsc* tempItem = compiler->codeGen->regSet.tmpListBeg(); tempItem != nullptr; + tempItem = compiler->codeGen->regSet.tmpListNxt(tempItem)) { if (varTypeIsGC(tempItem->tdTempType())) { diff --git a/src/jit/gcinfo.cpp b/src/jit/gcinfo.cpp index 36c7de0dcf98..0ec4933001ee 100644 --- a/src/jit/gcinfo.cpp +++ b/src/jit/gcinfo.cpp @@ -427,7 +427,7 @@ void GCInfo::gcCountForHeader(UNALIGNED unsigned int* untrackedCount, UNALIGNED /* If this non-enregistered pointer arg is never * used, we don't need to report it */ - assert(varDsc->lvRefCnt == 0); + assert(varDsc->lvRefCnt() == 0); continue; } else if (varDsc->lvIsRegArg && varDsc->lvTracked) @@ -499,8 +499,8 @@ void GCInfo::gcCountForHeader(UNALIGNED unsigned int* untrackedCount, UNALIGNED /* Also count spill temps that hold pointers */ - assert(compiler->tmpAllFree()); - for (TempDsc* tempThis = compiler->tmpListBeg(); tempThis != nullptr; tempThis = compiler->tmpListNxt(tempThis)) + assert(regSet->tmpAllFree()); + for (TempDsc* tempThis = regSet->tmpListBeg(); tempThis != nullptr; tempThis = regSet->tmpListNxt(tempThis)) { if (varTypeIsGC(tempThis->tdTempType()) == false) { diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp index 88a02f3b58e2..1f60fe61698d 100644 --- a/src/jit/gentree.cpp +++ b/src/jit/gentree.cpp @@ -73,7 +73,7 @@ struct IndentStack const char** indents; // Constructor for IndentStack. Uses 'compiler' to determine the mode of printing. - IndentStack(Compiler* compiler) : stack(compiler) + IndentStack(Compiler* compiler) : stack(compiler->getAllocator(CMK_DebugOnly)) { if (compiler->asciiTrees) { @@ -289,9 +289,9 @@ void GenTree::InitNodeSize() // TODO-Throughput: This should not need to be a large node. The object info should be // obtained from the child node. GenTree::s_gtNodeSizes[GT_PUTARG_STK] = TREE_NODE_SZ_LARGE; -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT GenTree::s_gtNodeSizes[GT_PUTARG_SPLIT] = TREE_NODE_SZ_LARGE; -#endif +#endif // FEATURE_ARG_SPLIT #endif // FEATURE_PUT_STRUCT_ARG_STK assert(GenTree::s_gtNodeSizes[GT_RETURN] == GenTree::s_gtNodeSizes[GT_ASG]); @@ -352,9 +352,9 @@ void GenTree::InitNodeSize() // TODO-Throughput: This should not need to be a large node. The object info should be // obtained from the child node. static_assert_no_msg(sizeof(GenTreePutArgStk) <= TREE_NODE_SZ_LARGE); -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT static_assert_no_msg(sizeof(GenTreePutArgSplit) <= TREE_NODE_SZ_LARGE); -#endif +#endif // FEATURE_ARG_SPLIT #endif // FEATURE_PUT_STRUCT_ARG_STK #ifdef FEATURE_SIMD @@ -742,7 +742,7 @@ int GenTree::GetRegisterDstCount() const { return gtGetOp1()->GetRegisterDstCount(); } -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT else if (OperIsPutArgSplit()) { return (const_cast(this))->AsPutArgSplit()->gtNumRegs; @@ -751,10 +751,14 @@ int GenTree::GetRegisterDstCount() const // either for all double parameters w/SoftFP or for varargs). else { +#ifdef _TARGET_ARM_ assert(OperIsMultiRegOp()); return (TypeGet() == TYP_LONG) ? 2 : 1; +#else + unreached(); +#endif // _TARGET_ARM_ } -#endif // defined(_TARGET_ARM_) +#endif // FEATURE_ARG_SPLIT assert(!"Unexpected multi-reg node"); return 0; } @@ -800,7 +804,7 @@ regMaskTP GenTree::gtGetRegMask() const } } } -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT else if (OperIsPutArgSplit()) { GenTree* tree = const_cast(this); @@ -815,7 +819,7 @@ regMaskTP GenTree::gtGetRegMask() const resultMask |= genRegMask(reg); } } -#endif +#endif // FEATURE_ARG_SPLIT else { resultMask = genRegMask(gtRegNum); @@ -2718,7 +2722,7 @@ unsigned Compiler::gtSetListOrder(GenTree* list, bool isListCallArgs, bool callA assert((list != nullptr) && list->OperIsAnyList()); assert(!callArgsInRegs || isListCallArgs); - ArrayStack listNodes(this); + ArrayStack listNodes(getAllocator(CMK_ArrayStack)); do { @@ -2979,7 +2983,7 @@ bool Compiler::gtIsLikelyRegVar(GenTree* tree) return false; } - if (varDsc->lvRefCntWtd < (BB_UNITY_WEIGHT * 3)) + if (varDsc->lvRefCntWtd() < (BB_UNITY_WEIGHT * 3)) { return false; } @@ -5150,7 +5154,7 @@ bool GenTree::TryGetUse(GenTree* def, GenTree*** use) case GT_FIELD_LIST: return TryGetUseList(def, use); -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: if (this->AsUnOp()->gtOp1->gtOper == GT_FIELD_LIST) { @@ -5162,7 +5166,7 @@ bool GenTree::TryGetUse(GenTree* def, GenTree*** use) return true; } return false; -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT #ifdef FEATURE_SIMD case GT_SIMD: @@ -6101,7 +6105,7 @@ GenTree* Compiler::gtNewZeroConNode(var_types type) break; default: - assert(!"Bad type"); + noway_assert(!"Bad type in gtNewZeroConNode"); zero = nullptr; break; } @@ -6110,30 +6114,31 @@ GenTree* Compiler::gtNewZeroConNode(var_types type) GenTree* Compiler::gtNewOneConNode(var_types type) { + GenTree* one; switch (type) { case TYP_INT: case TYP_UINT: - return gtNewIconNode(1); + one = gtNewIconNode(1); + break; case TYP_LONG: case TYP_ULONG: - return gtNewLconNode(1); + one = gtNewLconNode(1); + break; case TYP_FLOAT: - { - GenTree* one = gtNewDconNode(1.0); - one->gtType = type; - return one; - } - case TYP_DOUBLE: - return gtNewDconNode(1.0); + one = gtNewDconNode(1.0); + one->gtType = type; + break; default: - assert(!"Bad type"); - return nullptr; + noway_assert(!"Bad type in gtNewOneConNode"); + one = nullptr; + break; } + return one; } #ifdef FEATURE_SIMD @@ -8772,9 +8777,9 @@ GenTreeUseEdgeIterator::GenTreeUseEdgeIterator(GenTree* node) case GT_NULLCHECK: case GT_PUTARG_REG: case GT_PUTARG_STK: -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT case GT_RETURNTRAP: m_edge = &m_node->AsUnOp()->gtOp1; assert(*m_edge != nullptr); @@ -11622,28 +11627,11 @@ void Compiler::gtGetLateArgMsg( #if FEATURE_MULTIREG_ARGS if (curArgTabEntry->numRegs >= 2) { - regNumber otherRegNum; -#if defined(UNIX_AMD64_ABI) - assert(curArgTabEntry->numRegs == 2); - otherRegNum = curArgTabEntry->otherRegNum; -#else - otherRegNum = (regNumber)(((unsigned)curArgTabEntry->regNum) + curArgTabEntry->numRegs - 1); -#endif // UNIX_AMD64_ABI - - if (listCount == -1) - { - char seperator = (curArgTabEntry->numRegs == 2) ? ',' : '-'; - - sprintf_s(bufp, bufLength, "arg%d %s%c%s%c", curArgTabEntry->argNum, compRegVarName(argReg), - seperator, compRegVarName(otherRegNum), 0); - } - else // listCount is 0,1,2 or 3 - { - assert(listCount <= MAX_ARG_REG_COUNT); - regNumber curReg = (listCount == 1) ? otherRegNum : (regNumber)((unsigned)(argReg) + listCount); - sprintf_s(bufp, bufLength, "arg%d m%d %s%c", curArgTabEntry->argNum, listCount, - compRegVarName(curReg), 0); - } + // listCount could be -1 but it is signed, so this comparison is OK. + assert(listCount <= MAX_ARG_REG_COUNT); + char separator = (curArgTabEntry->numRegs == 2) ? ',' : '-'; + sprintf_s(bufp, bufLength, "arg%d %s%c%s%c", curArgTabEntry->argNum, compRegVarName(argReg), separator, + compRegVarName(curArgTabEntry->getRegNum(curArgTabEntry->numRegs - 1)), 0); } else #endif @@ -17012,7 +17000,7 @@ void GenTree::ParseArrayAddressWork( // If one op is a constant, continue parsing down. if (gtOp.gtOp2->IsCnsIntOrI()) { - ssize_t subMul = 1 << gtOp.gtOp2->gtIntConCommon.IconValue(); + ssize_t subMul = ssize_t{1} << gtOp.gtOp2->gtIntConCommon.IconValue(); gtOp.gtOp1->ParseArrayAddressWork(comp, inputMul * subMul, pArr, pInxVN, pOffset, pFldSeq); return; } @@ -17206,7 +17194,7 @@ void GenTree::LabelIndex(Compiler* comp, bool isConst) FieldSeqNode FieldSeqStore::s_notAField(nullptr, nullptr); // FieldSeqStore methods. -FieldSeqStore::FieldSeqStore(CompAllocator* alloc) : m_alloc(alloc), m_canonMap(new (alloc) FieldSeqNodeCanonMap(alloc)) +FieldSeqStore::FieldSeqStore(CompAllocator alloc) : m_alloc(alloc), m_canonMap(new (alloc) FieldSeqNodeCanonMap(alloc)) { } @@ -17220,7 +17208,7 @@ FieldSeqNode* FieldSeqStore::CreateSingleton(CORINFO_FIELD_HANDLE fieldHnd) } else { - res = reinterpret_cast(m_alloc->Alloc(sizeof(FieldSeqNode))); + res = m_alloc.allocate(1); *res = fsn; m_canonMap->Set(fsn, res); return res; @@ -17263,7 +17251,7 @@ FieldSeqNode* FieldSeqStore::Append(FieldSeqNode* a, FieldSeqNode* b) } else { - res = reinterpret_cast(m_alloc->Alloc(sizeof(FieldSeqNode))); + res = m_alloc.allocate(1); *res = fsn; m_canonMap->Set(fsn, res); return res; @@ -17524,6 +17512,17 @@ GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode(var_types type, return new (this, GT_HWIntrinsic) GenTreeHWIntrinsic(type, op1, op2, hwIntrinsicID, TYP_UNKNOWN, 0); } +GenTreeHWIntrinsic* Compiler::gtNewScalarHWIntrinsicNode( + var_types type, GenTree* op1, GenTree* op2, GenTree* op3, NamedIntrinsic hwIntrinsicID) +{ + SetOpLclRelatedToSIMDIntrinsic(op1); + SetOpLclRelatedToSIMDIntrinsic(op2); + SetOpLclRelatedToSIMDIntrinsic(op3); + + return new (this, GT_HWIntrinsic) + GenTreeHWIntrinsic(type, gtNewArgList(op1, op2, op3), hwIntrinsicID, TYP_UNKNOWN, 0); +} + //--------------------------------------------------------------------------------------- // gtNewMustThrowException: // create a throw node (calling into JIT helper) that must be thrown. @@ -17692,6 +17691,10 @@ void ReturnTypeDesc::InitializeStructReturnType(Compiler* comp, CORINFO_CLASS_HA switch (howToReturnStruct) { + case Compiler::SPK_EnclosingType: + m_isEnclosingType = true; + __fallthrough; + case Compiler::SPK_PrimitiveType: { assert(returnType != TYP_UNKNOWN); diff --git a/src/jit/gentree.h b/src/jit/gentree.h index e41819eecc16..83f07d321349 100644 --- a/src/jit/gentree.h +++ b/src/jit/gentree.h @@ -258,7 +258,7 @@ class FieldSeqStore { typedef JitHashTable FieldSeqNodeCanonMap; - CompAllocator* m_alloc; + CompAllocator m_alloc; FieldSeqNodeCanonMap* m_canonMap; static FieldSeqNode s_notAField; // No value, just exists to provide an address. @@ -268,7 +268,7 @@ class FieldSeqStore static int ConstantIndexPseudoFieldStruct; public: - FieldSeqStore(CompAllocator* alloc); + FieldSeqStore(CompAllocator alloc); // Returns the (canonical in the store) singleton field sequence for the given handle. FieldSeqNode* CreateSingleton(CORINFO_FIELD_HANDLE fieldHnd); @@ -1182,9 +1182,9 @@ struct GenTree bool OperIsPutArgSplit() const { -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT return gtOper == GT_PUTARG_SPLIT; -#else +#else // !FEATURE_ARG_SPLIT return false; #endif } @@ -1463,25 +1463,25 @@ struct GenTree bool OperIsImplicitIndir() const; - bool OperIsStore() const + static bool OperIsAtomicOp(genTreeOps gtOper) { - return OperIsStore(gtOper); + return (gtOper == GT_XADD || gtOper == GT_XCHG || gtOper == GT_LOCKADD || gtOper == GT_CMPXCHG); } - static bool OperIsStore(genTreeOps gtOper) + bool OperIsAtomicOp() const { - return (gtOper == GT_STOREIND || gtOper == GT_STORE_LCL_VAR || gtOper == GT_STORE_LCL_FLD || - gtOper == GT_STORE_BLK || gtOper == GT_STORE_OBJ || gtOper == GT_STORE_DYN_BLK); + return OperIsAtomicOp(gtOper); } - static bool OperIsAtomicOp(genTreeOps gtOper) + bool OperIsStore() const { - return (gtOper == GT_XADD || gtOper == GT_XCHG || gtOper == GT_LOCKADD || gtOper == GT_CMPXCHG); + return OperIsStore(gtOper); } - bool OperIsAtomicOp() const + static bool OperIsStore(genTreeOps gtOper) { - return OperIsAtomicOp(gtOper); + return (gtOper == GT_STOREIND || gtOper == GT_STORE_LCL_VAR || gtOper == GT_STORE_LCL_FLD || + OperIsStoreBlk(gtOper) || OperIsAtomicOp(gtOper)); } // This is here for cleaner FEATURE_SIMD #ifdefs. @@ -1721,6 +1721,9 @@ struct GenTree // Returns true if it is a node returning its value in more than one register inline bool IsMultiRegNode() const; + // Returns the regIndex'th register defined by a possibly-multireg node. + regNumber GetRegByIndex(int regIndex); + // Returns true if it is a GT_COPY or GT_RELOAD node inline bool IsCopyOrReload() const; @@ -3089,6 +3092,7 @@ struct ReturnTypeDesc { private: var_types m_regType[MAX_RET_REG_COUNT]; + bool m_isEnclosingType; #ifdef DEBUG bool m_inited; @@ -3114,6 +3118,7 @@ struct ReturnTypeDesc { m_regType[i] = TYP_UNKNOWN; } + m_isEnclosingType = false; #ifdef DEBUG m_inited = false; #endif @@ -3206,6 +3211,13 @@ struct ReturnTypeDesc return result; } + // True if this value is returned in integer register + // that is larger than the type itself. + bool IsEnclosingType() const + { + return m_isEnclosingType; + } + // Get ith ABI return register regNumber GetABIReturnReg(unsigned idx); @@ -5195,7 +5207,7 @@ struct GenTreePutArgStk : public GenTreeUnOp #endif }; -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT // Represent the struct argument: split value in register(s) and stack struct GenTreePutArgSplit : public GenTreePutArgStk { @@ -5398,7 +5410,7 @@ struct GenTreePutArgSplit : public GenTreePutArgStk } #endif }; -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT // Represents GT_COPY or GT_RELOAD node struct GenTreeCopyOrReload : public GenTreeUnOp @@ -5801,29 +5813,6 @@ inline bool GenTree::IsValidCallArgument() #else // FEATURE_MULTIREG_ARGS or FEATURE_PUT_STRUCT_ARG_STK -#ifdef UNIX_AMD64_ABI - // For UNIX ABI we currently only allow a GT_FIELD_LIST of GT_LCL_FLDs nodes - GenTree* gtListPtr = this; - while (gtListPtr != nullptr) - { - // ToDo: fix UNIX_AMD64 so that we do not generate this kind of a List - // Note the list as currently created is malformed, as the last entry is a nullptr - if (gtListPtr->Current() == nullptr) - { - break; - } - - // Only a list of GT_LCL_FLDs is allowed - if (gtListPtr->Current()->OperGet() != GT_LCL_FLD) - { - return false; - } - gtListPtr = gtListPtr->MoveNext(); - } -#endif // UNIX_AMD64_ABI - - // Note that for non-UNIX ABI the GT_FIELD_LIST may contain any node - // // We allow this GT_FIELD_LIST as an argument return true; @@ -6020,6 +6009,47 @@ inline bool GenTree::IsMultiRegNode() const return false; } +//----------------------------------------------------------------------------------- +// GetRegByIndex: Get a specific register, based on regIndex, that is produced +// by this node. +// +// Arguments: +// regIndex - which register to return (must be 0 for non-multireg nodes) +// +// Return Value: +// The register, if any, assigned to this index for this node. +// +inline regNumber GenTree::GetRegByIndex(int regIndex) +{ + if (regIndex == 0) + { + return gtRegNum; + } + if (IsMultiRegCall()) + { + return AsCall()->GetRegNumByIdx(regIndex); + } + +#if FEATURE_ARG_SPLIT + if (OperIsPutArgSplit()) + { + return AsPutArgSplit()->GetRegNumByIdx(regIndex); + } +#endif +#if defined(_TARGET_ARM_) + if (OperIsMultiRegOp()) + { + return AsMultiRegOp()->GetRegNumByIdx(regIndex); + } + if (OperIs(GT_COPY, GT_RELOAD)) + { + return AsCopyOrReload()->GetRegNumByIdx(regIndex); + } +#endif + assert(!"Invalid regIndex for GetRegFromMultiRegNode"); + return REG_NA; +} + //------------------------------------------------------------------------- // IsCopyOrReload: whether this is a GT_COPY or GT_RELOAD node. // diff --git a/src/jit/gtlist.h b/src/jit/gtlist.h index bbd9bcbcd1a7..dd972b6d0d8a 100644 --- a/src/jit/gtlist.h +++ b/src/jit/gtlist.h @@ -294,9 +294,9 @@ GTNODE(PUTARG_REG , GenTreeMultiRegOp ,0,GTK_UNOP) 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 -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT GTNODE(PUTARG_SPLIT , GenTreePutArgSplit ,0,GTK_UNOP) // operator that places outgoing arg in registers with stack (split struct in ARM32) -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT 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 diff --git a/src/jit/gtstructs.h b/src/jit/gtstructs.h index fe67a2fcd941..bc64a34169df 100644 --- a/src/jit/gtstructs.h +++ b/src/jit/gtstructs.h @@ -105,12 +105,12 @@ GTSTRUCT_1(Qmark , GT_QMARK) GTSTRUCT_1(PhiArg , GT_PHI_ARG) GTSTRUCT_1(StoreInd , GT_STOREIND) GTSTRUCT_N(Indir , GT_STOREIND, GT_IND, GT_NULLCHECK, GT_BLK, GT_STORE_BLK, GT_OBJ, GT_STORE_OBJ, GT_DYN_BLK, GT_STORE_DYN_BLK) -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT GTSTRUCT_2_SPECIAL(PutArgStk, GT_PUTARG_STK, GT_PUTARG_SPLIT) GTSTRUCT_1(PutArgSplit , GT_PUTARG_SPLIT) -#else // !defined(_TARGET_ARM_) +#else // !FEATURE_ARG_SPLIT GTSTRUCT_1(PutArgStk , GT_PUTARG_STK) -#endif // !defined(_TARGET_ARM_) +#endif // !FEATURE_ARG_SPLIT GTSTRUCT_1(PhysReg , GT_PHYSREG) #ifdef FEATURE_SIMD GTSTRUCT_1(SIMD , GT_SIMD) diff --git a/src/jit/hashbv.cpp b/src/jit/hashbv.cpp index db8dda1a7beb..6aee93ee33aa 100644 --- a/src/jit/hashbv.cpp +++ b/src/jit/hashbv.cpp @@ -358,7 +358,7 @@ bool hashBvNode::sameAs(hashBvNode* other) hashBv::hashBv(Compiler* comp) { this->compiler = comp; - this->log2_hashSize = globalData()->hbvHashSizeLog2; + this->log2_hashSize = 0; int hts = hashtable_size(); nodeArr = getNewVector(hts); @@ -424,20 +424,6 @@ hashBv*& hashBv::hbvFreeList(hashBvGlobalData* data) return data->hbvFreeList; } -void hashBv::freeVector(hashBvNode* vect, int vectorLength) -{ - // not enough space to do anything with it - if (vectorLength < 2) - { - return; - } - - hbvFreeListNode* f = (hbvFreeListNode*)vect; - f->next = globalData()->hbvFreeVectorList; - globalData()->hbvFreeVectorList = f; - f->size = vectorLength; -} - void hashBv::hbvFree() { Compiler* comp = this->compiler; @@ -547,7 +533,6 @@ void hashBv::Resize(int newSize) return; } - int oldSizeLog2 = log2_hashSize; int log2_newSize = genLog2((unsigned)newSize); hashBvNode** newNodes = this->getNewVector(newSize); @@ -1297,7 +1282,6 @@ bool hashBv::MultiTraverseLHSBigger(hashBv* other) // this is larger hashBvNode*** cursors; - int shiftFactor = this->log2_hashSize - other->log2_hashSize; int expansionFactor = hts / ots; cursors = (hashBvNode***)alloca(expansionFactor * sizeof(void*)); @@ -2016,12 +2000,3 @@ indexType hashBvIterator::nextBit() goto more_data; } } - -indexType HbvNext(hashBv* bv, Compiler* comp) -{ - if (bv) - { - bv->globalData()->hashBvNextIterator.initFrom(bv); - } - return bv->globalData()->hashBvNextIterator.nextBit(); -} diff --git a/src/jit/hashbv.h b/src/jit/hashbv.h index cadb182cc663..b07b3d89c8de 100644 --- a/src/jit/hashbv.h +++ b/src/jit/hashbv.h @@ -186,8 +186,6 @@ class hashBv public: hashBv(Compiler* comp); - hashBv(hashBv* other); - // hashBv() {} static hashBv* Create(Compiler* comp); static void Init(Compiler* comp); static hashBv* CreateFrom(hashBv* other, Compiler* comp); @@ -215,11 +213,8 @@ class hashBv // maintain free lists for vectors hashBvNode** getNewVector(int vectorLength); - void freeVector(hashBvNode* vect, int vectorLength); int getNodeCount(); - hashBvNode* getFreeList(); - public: inline hashBvNode* getOrAddNodeForIndex(indexType index) { @@ -281,16 +276,6 @@ class hashBv // -------------------------------------------------------------------- // -------------------------------------------------------------------- -class hbvFreeListNode -{ -public: - hbvFreeListNode* next; - int size; -}; - -// -------------------------------------------------------------------- -// -------------------------------------------------------------------- - class hashBvIterator { public: @@ -318,17 +303,10 @@ class hashBvGlobalData friend class hashBv; friend class hashBvNode; - hashBvNode* hbvNodeFreeList; - hashBv* hbvFreeList; - unsigned short hbvHashSizeLog2; - hbvFreeListNode* hbvFreeVectorList; - -public: - hashBvIterator hashBvNextIterator; + hashBvNode* hbvNodeFreeList; + hashBv* hbvFreeList; }; -indexType HbvNext(hashBv* bv, Compiler* comp); - // clang-format off #define FOREACH_HBV_BIT_SET(index, bv) \ { \ diff --git a/src/jit/host.h b/src/jit/host.h index 87e13d418003..95894a5e324b 100644 --- a/src/jit/host.h +++ b/src/jit/host.h @@ -52,8 +52,6 @@ extern "C" void __cdecl assertAbort(const char* why, const char* file, unsigned #define _HOST_H_ /*****************************************************************************/ -const size_t OS_page_size = (4 * 1024); - extern FILE* jitstdout; inline FILE* procstdout() diff --git a/src/jit/hostallocator.cpp b/src/jit/hostallocator.cpp index b737424ee889..112bf1c10738 100644 --- a/src/jit/hostallocator.cpp +++ b/src/jit/hostallocator.cpp @@ -5,36 +5,14 @@ #include "jitpch.h" #include "hostallocator.h" -HostAllocator HostAllocator::s_hostAllocator; - -void* HostAllocator::Alloc(size_t size) -{ - assert(g_jitHost != nullptr); - return g_jitHost->allocateMemory(size, false); -} - -void* HostAllocator::ArrayAlloc(size_t elemSize, size_t numElems) +void* HostAllocator::allocateHostMemory(size_t size) { assert(g_jitHost != nullptr); - - ClrSafeInt safeElemSize(elemSize); - ClrSafeInt safeNumElems(numElems); - ClrSafeInt size = safeElemSize * safeNumElems; - if (size.IsOverflow()) - { - return nullptr; - } - - return g_jitHost->allocateMemory(size.Value(), false); + return g_jitHost->allocateMemory(size); } -void HostAllocator::Free(void* p) +void HostAllocator::freeHostMemory(void* p) { assert(g_jitHost != nullptr); - g_jitHost->freeMemory(p, false); -} - -HostAllocator* HostAllocator::getHostAllocator() -{ - return &s_hostAllocator; + g_jitHost->freeMemory(p); } diff --git a/src/jit/hostallocator.h b/src/jit/hostallocator.h index 39a32ef49b86..447fc67eb14d 100644 --- a/src/jit/hostallocator.h +++ b/src/jit/hostallocator.h @@ -7,30 +7,48 @@ class HostAllocator final { private: - static HostAllocator s_hostAllocator; - HostAllocator() { } public: - void* Alloc(size_t size); + template + T* allocate(size_t count) + { + ClrSafeInt safeElemSize(sizeof(T)); + ClrSafeInt safeCount(count); + ClrSafeInt size = safeElemSize * safeCount; + if (size.IsOverflow()) + { + return nullptr; + } + + return static_cast(allocateHostMemory(size.Value())); + } - void* ArrayAlloc(size_t elemSize, size_t numElems); + void deallocate(void* p) + { + freeHostMemory(p); + } - void Free(void* p); + static HostAllocator getHostAllocator() + { + return HostAllocator(); + } - static HostAllocator* getHostAllocator(); +private: + void* allocateHostMemory(size_t size); + void freeHostMemory(void* p); }; // Global operator new overloads that work with HostAllocator -inline void* __cdecl operator new(size_t n, HostAllocator* alloc) +inline void* __cdecl operator new(size_t n, HostAllocator alloc) { - return alloc->Alloc(n); + return alloc.allocate(n); } -inline void* __cdecl operator new[](size_t n, HostAllocator* alloc) +inline void* __cdecl operator new[](size_t n, HostAllocator alloc) { - return alloc->Alloc(n); + return alloc.allocate(n); } diff --git a/src/jit/hwintrinsic.cpp b/src/jit/hwintrinsic.cpp index e3b36d918918..a2f741e1e0e8 100644 --- a/src/jit/hwintrinsic.cpp +++ b/src/jit/hwintrinsic.cpp @@ -57,25 +57,25 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, va switch (simdBaseType) { case TYP_FLOAT: - return Vector128FloatHandle; + return m_simdHandleCache->Vector128FloatHandle; case TYP_DOUBLE: - return Vector128DoubleHandle; + return m_simdHandleCache->Vector128DoubleHandle; case TYP_INT: - return Vector128IntHandle; + return m_simdHandleCache->Vector128IntHandle; case TYP_USHORT: - return Vector128UShortHandle; + return m_simdHandleCache->Vector128UShortHandle; case TYP_UBYTE: - return Vector128UByteHandle; + return m_simdHandleCache->Vector128UByteHandle; case TYP_SHORT: - return Vector128ShortHandle; + return m_simdHandleCache->Vector128ShortHandle; case TYP_BYTE: - return Vector128ByteHandle; + return m_simdHandleCache->Vector128ByteHandle; case TYP_LONG: - return Vector128LongHandle; + return m_simdHandleCache->Vector128LongHandle; case TYP_UINT: - return Vector128UIntHandle; + return m_simdHandleCache->Vector128UIntHandle; case TYP_ULONG: - return Vector128ULongHandle; + return m_simdHandleCache->Vector128ULongHandle; default: assert(!"Didn't find a class handle for simdType"); } @@ -86,25 +86,25 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, va switch (simdBaseType) { case TYP_FLOAT: - return Vector256FloatHandle; + return m_simdHandleCache->Vector256FloatHandle; case TYP_DOUBLE: - return Vector256DoubleHandle; + return m_simdHandleCache->Vector256DoubleHandle; case TYP_INT: - return Vector256IntHandle; + return m_simdHandleCache->Vector256IntHandle; case TYP_USHORT: - return Vector256UShortHandle; + return m_simdHandleCache->Vector256UShortHandle; case TYP_UBYTE: - return Vector256UByteHandle; + return m_simdHandleCache->Vector256UByteHandle; case TYP_SHORT: - return Vector256ShortHandle; + return m_simdHandleCache->Vector256ShortHandle; case TYP_BYTE: - return Vector256ByteHandle; + return m_simdHandleCache->Vector256ByteHandle; case TYP_LONG: - return Vector256LongHandle; + return m_simdHandleCache->Vector256LongHandle; case TYP_UINT: - return Vector256UIntHandle; + return m_simdHandleCache->Vector256UIntHandle; case TYP_ULONG: - return Vector256ULongHandle; + return m_simdHandleCache->Vector256ULongHandle; default: assert(!"Didn't find a class handle for simdType"); } @@ -116,19 +116,19 @@ CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, va switch (simdBaseType) { case TYP_FLOAT: - return Vector64FloatHandle; + return m_simdHandleCache->Vector64FloatHandle; case TYP_UINT: - return Vector64UIntHandle; + return m_simdHandleCache->Vector64UIntHandle; case TYP_USHORT: - return Vector64UShortHandle; + return m_simdHandleCache->Vector64UShortHandle; case TYP_UBYTE: - return Vector64UByteHandle; + return m_simdHandleCache->Vector64UByteHandle; case TYP_SHORT: - return Vector64ShortHandle; + return m_simdHandleCache->Vector64ShortHandle; case TYP_BYTE: - return Vector64ByteHandle; + return m_simdHandleCache->Vector64ByteHandle; case TYP_INT: - return Vector64IntHandle; + return m_simdHandleCache->Vector64IntHandle; default: assert(!"Didn't find a class handle for simdType"); } diff --git a/src/jit/hwintrinsiccodegenxarch.cpp b/src/jit/hwintrinsiccodegenxarch.cpp index 1468f035d60a..dafb45a1dc8a 100644 --- a/src/jit/hwintrinsiccodegenxarch.cpp +++ b/src/jit/hwintrinsiccodegenxarch.cpp @@ -24,6 +24,33 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "gcinfo.h" #include "gcinfoencoder.h" +//------------------------------------------------------------------------ +// assertIsContainableHWIntrinsicOp: Asserts that op is containable by node +// +// Arguments: +// lowering - The lowering phase from the compiler +// node - The HWIntrinsic node that has the contained node +// op - The op that is contained +// +static void assertIsContainableHWIntrinsicOp(Lowering* lowering, GenTreeHWIntrinsic* node, GenTree* op) +{ +#if DEBUG + // The Lowering::IsContainableHWIntrinsicOp call is not quite right, since it follows pre-register allocation + // logic. However, this check is still important due to the various containment rules that SIMD intrinsics follow. + // + // We use isContainable to track the special HWIntrinsic node containment rules (for things like LoadAligned and + // LoadUnaligned) and we use the supportsRegOptional check to support general-purpose loads (both from stack + // spillage + // and for isUsedFromMemory contained nodes, in the case where the register allocator decided to not allocate a + // register + // in the first place). + + bool supportsRegOptional = false; + bool isContainable = lowering->IsContainableHWIntrinsicOp(node, op, &supportsRegOptional); + assert(isContainable || supportsRegOptional); +#endif // DEBUG +} + //------------------------------------------------------------------------ // genIsTableDrivenHWIntrinsic: // @@ -176,7 +203,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) } else { - genHWIntrinsic_R_R_RM(node, ins); + genHWIntrinsic_R_R_RM(node, ins, EA_ATTR(node->gtSIMDSize)); } break; } @@ -212,27 +239,10 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) { ssize_t ival = op3->AsIntCon()->IconValue(); assert((ival >= 0) && (ival <= 255)); - - if ((intrinsicId == NI_SSE41_Insert) && (baseType == TYP_FLOAT)) - { - // Bits 6 and 7 impact the index that is selected from op2 - // when op2 is already in register. However, our API exposes - // op2 as a scalar and so bits 6 and 7 must be set to 0. - ival &= 0x3F; - } - emitSwCase((int8_t)ival); } else { - if ((intrinsicId == NI_SSE41_Insert) && (baseType == TYP_FLOAT)) - { - // Bits 6 and 7 impact the index that is selected from op2 - // when op2 is already in register. However, our API exposes - // op2 as a scalar and so bits 6 and 7 must be set to 0. - emit->emitIns_R_I(INS_and, EA_1BYTE, op3Reg, 0x3F); - } - // We emit a fallback case for the scenario when the imm-op is not a constant. This should // normally happen when the intrinsic is called indirectly, such as via Reflection. However, it // can also occur if the consumer calls it directly and just doesn't pass a constant value. @@ -342,21 +352,34 @@ void CodeGen::genHWIntrinsic_R_RM(GenTreeHWIntrinsic* node, instruction ins, emi var_types targetType = node->TypeGet(); regNumber targetReg = node->gtRegNum; GenTree* op1 = node->gtGetOp1(); + GenTree* op2 = node->gtGetOp2(); emitter* emit = getEmitter(); + if (op2 != nullptr) + { + // The Compare*OrderedScalar and Compare*UnorderedScalar intrinsics come down this + // code path. They are all MultiIns, as the return value comes from the flags and + // we have two operands instead. + + assert(HWIntrinsicInfo::GeneratesMultipleIns(node->gtHWIntrinsicId)); + assert(targetReg != REG_NA); + + targetReg = op1->gtRegNum; + op1 = op2; + op2 = nullptr; + } + else + { + assert(!node->OperIsCommutative()); + } + assert(targetReg != REG_NA); - assert(node->gtGetOp2() == nullptr); - assert(!node->OperIsCommutative()); + assert(op2 == nullptr); if (op1->isContained() || op1->isUsedFromSpillTemp()) { assert(HWIntrinsicInfo::SupportsContainment(node->gtHWIntrinsicId)); - -#if DEBUG - bool supportsRegOptional = false; - bool isContainable = compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op1, &supportsRegOptional); - assert(isContainable || (supportsRegOptional && op1->IsRegOptional())); -#endif // DEBUG + assertIsContainableHWIntrinsicOp(compiler->m_pLowering, node, op1); TempDsc* tmpDsc = nullptr; unsigned varNum = BAD_VAR_NUM; @@ -370,7 +393,7 @@ void CodeGen::genHWIntrinsic_R_RM(GenTreeHWIntrinsic* node, instruction ins, emi varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op1->OperIsHWIntrinsic()) { @@ -480,12 +503,7 @@ void CodeGen::genHWIntrinsic_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, i if (op1->isContained() || op1->isUsedFromSpillTemp()) { assert(HWIntrinsicInfo::SupportsContainment(node->gtHWIntrinsicId)); - -#if DEBUG - bool supportsRegOptional = false; - bool isContainable = compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op1, &supportsRegOptional); - assert(isContainable || (supportsRegOptional && op1->IsRegOptional())); -#endif // DEBUG + assertIsContainableHWIntrinsicOp(compiler->m_pLowering, node, op1); TempDsc* tmpDsc = nullptr; unsigned varNum = BAD_VAR_NUM; @@ -499,7 +517,7 @@ void CodeGen::genHWIntrinsic_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, i varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op1->OperIsHWIntrinsic()) { @@ -589,13 +607,12 @@ void CodeGen::genHWIntrinsic_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, i // node - The hardware intrinsic node // ins - The instruction being generated // -void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) +void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins, emitAttr attr) { var_types targetType = node->TypeGet(); regNumber targetReg = node->gtRegNum; GenTree* op1 = node->gtGetOp1(); GenTree* op2 = node->gtGetOp2(); - emitAttr simdSize = EA_ATTR(node->gtSIMDSize); emitter* emit = getEmitter(); // TODO-XArch-CQ: Commutative operations can have op1 be contained @@ -609,12 +626,7 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) if (op2->isContained() || op2->isUsedFromSpillTemp()) { assert(HWIntrinsicInfo::SupportsContainment(node->gtHWIntrinsicId)); - -#if DEBUG - bool supportsRegOptional = false; - bool isContainable = compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op2, &supportsRegOptional); - assert(isContainable || (supportsRegOptional && op2->IsRegOptional())); -#endif // DEBUG + assertIsContainableHWIntrinsicOp(compiler->m_pLowering, node, op2); TempDsc* tmpDsc = nullptr; unsigned varNum = BAD_VAR_NUM; @@ -628,11 +640,11 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op2->OperIsHWIntrinsic()) { - emit->emitIns_SIMD_R_R_AR(ins, simdSize, targetReg, op1Reg, op2->gtGetOp1()->gtRegNum); + emit->emitIns_SIMD_R_R_AR(ins, attr, targetReg, op1Reg, op2->gtGetOp1()->gtRegNum); return; } else if (op2->isIndir()) @@ -657,13 +669,13 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) case GT_CLS_VAR_ADDR: { - emit->emitIns_SIMD_R_R_C(ins, simdSize, targetReg, op1Reg, memBase->gtClsVar.gtClsVarHnd, 0); + emit->emitIns_SIMD_R_R_C(ins, attr, targetReg, op1Reg, memBase->gtClsVar.gtClsVarHnd, 0); return; } default: { - emit->emitIns_SIMD_R_R_A(ins, simdSize, targetReg, op1Reg, memIndir); + emit->emitIns_SIMD_R_R_A(ins, attr, targetReg, op1Reg, memIndir); return; } } @@ -701,7 +713,7 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) assert((varNum != BAD_VAR_NUM) || (tmpDsc != nullptr)); assert(offset != (unsigned)-1); - emit->emitIns_SIMD_R_R_S(ins, simdSize, targetReg, op1Reg, varNum, offset); + emit->emitIns_SIMD_R_R_S(ins, attr, targetReg, op1Reg, varNum, offset); } else { @@ -721,7 +733,7 @@ void CodeGen::genHWIntrinsic_R_R_RM(GenTreeHWIntrinsic* node, instruction ins) op1Reg = targetReg; } - emit->emitIns_SIMD_R_R_R(ins, simdSize, targetReg, op1Reg, op2Reg); + emit->emitIns_SIMD_R_R_R(ins, attr, targetReg, op1Reg, op2Reg); } } @@ -770,12 +782,7 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, if (op2->isContained() || op2->isUsedFromSpillTemp()) { assert(HWIntrinsicInfo::SupportsContainment(node->gtHWIntrinsicId)); - -#if DEBUG - bool supportsRegOptional = false; - bool isContainable = compiler->m_pLowering->IsContainableHWIntrinsicOp(node, op2, &supportsRegOptional); - assert(isContainable || (supportsRegOptional && op2->IsRegOptional())); -#endif // DEBUG + assertIsContainableHWIntrinsicOp(compiler->m_pLowering, node, op2); TempDsc* tmpDsc = nullptr; unsigned varNum = BAD_VAR_NUM; @@ -789,7 +796,7 @@ void CodeGen::genHWIntrinsic_R_R_RM_I(GenTreeHWIntrinsic* node, instruction ins, varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op2->OperIsHWIntrinsic()) { @@ -928,6 +935,9 @@ void CodeGen::genHWIntrinsic_R_R_RM_R(GenTreeHWIntrinsic* node, instruction ins) if (op2->isContained() || op2->isUsedFromSpillTemp()) { + assert(HWIntrinsicInfo::SupportsContainment(node->gtHWIntrinsicId)); + assertIsContainableHWIntrinsicOp(compiler->m_pLowering, node, op2); + TempDsc* tmpDsc = nullptr; unsigned varNum = BAD_VAR_NUM; unsigned offset = (unsigned)-1; @@ -942,11 +952,11 @@ void CodeGen::genHWIntrinsic_R_R_RM_R(GenTreeHWIntrinsic* node, instruction ins) varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op2->OperIsHWIntrinsic()) { - emit->emitIns_SIMD_R_R_AR_R(ins, simdSize, targetReg, op1Reg, op2->gtGetOp1()->gtRegNum, op3Reg); + emit->emitIns_SIMD_R_R_AR_R(ins, simdSize, targetReg, op1Reg, op3Reg, op2->gtGetOp1()->gtRegNum); return; } else if (op2->isIndir()) @@ -1061,7 +1071,7 @@ void CodeGen::genHWIntrinsic_R_R_R_RM( varNum = tmpDsc->tdTempNum(); offset = 0; - compiler->tmpRlsTemp(tmpDsc); + regSet.tmpRlsTemp(tmpDsc); } else if (op3->OperIsHWIntrinsic()) { @@ -1245,14 +1255,13 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareEqualUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; regNumber tmpReg = node->GetSingleTempReg(); instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); // Ensure we aren't overwriting targetReg assert(tmpReg != targetReg); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setpo, EA_1BYTE, targetReg); emit->emitIns_R(INS_sete, EA_1BYTE, tmpReg); emit->emitIns_R_R(INS_and, EA_1BYTE, tmpReg, targetReg); @@ -1264,10 +1273,9 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareGreaterThanUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; - instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1277,10 +1285,9 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareGreaterThanOrEqualUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; - instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setae, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1290,10 +1297,9 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareLessThanUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; - instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op2Reg, op1Reg); + + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1303,10 +1309,9 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareLessThanOrEqualUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; - instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op2Reg, op1Reg); + + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setae, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1316,14 +1321,13 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE_CompareNotEqualUnorderedScalar: { assert(baseType == TYP_FLOAT); - op2Reg = op2->gtRegNum; regNumber tmpReg = node->GetSingleTempReg(); instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType); // Ensure we aren't overwriting targetReg assert(tmpReg != targetReg); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setpe, EA_1BYTE, targetReg); emit->emitIns_R(INS_setne, EA_1BYTE, tmpReg); emit->emitIns_R_R(INS_or, EA_1BYTE, tmpReg, targetReg); @@ -1332,7 +1336,6 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node) } case NI_SSE_ConvertToSingle: - case NI_SSE_StaticCast: { assert(op2 == nullptr); if (op1Reg != targetReg) @@ -1461,14 +1464,13 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareEqualUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; regNumber tmpReg = node->GetSingleTempReg(); instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); // Ensure we aren't overwriting targetReg assert(tmpReg != targetReg); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setpo, EA_1BYTE, targetReg); emit->emitIns_R(INS_sete, EA_1BYTE, tmpReg); emit->emitIns_R_R(INS_and, EA_1BYTE, tmpReg, targetReg); @@ -1480,10 +1482,9 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareGreaterThanUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1493,10 +1494,9 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareGreaterThanOrEqualUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setae, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1506,10 +1506,9 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareLessThanUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op2Reg, op1Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1519,10 +1518,9 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareLessThanOrEqualUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op2Reg, op1Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setae, EA_1BYTE, targetReg); emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; @@ -1532,14 +1530,13 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_CompareNotEqualUnorderedScalar: { assert(baseType == TYP_DOUBLE); - op2Reg = op2->gtRegNum; instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); regNumber tmpReg = node->GetSingleTempReg(); // Ensure we aren't overwriting targetReg assert(tmpReg != targetReg); - emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), op1Reg, op2Reg); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setpe, EA_1BYTE, targetReg); emit->emitIns_R(INS_setne, EA_1BYTE, tmpReg); emit->emitIns_R_R(INS_or, EA_1BYTE, tmpReg, targetReg); @@ -1554,7 +1551,7 @@ void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node) assert(op1 != nullptr); assert(op2 != nullptr); instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); - genHWIntrinsic_R_R_RM(node, ins); + genHWIntrinsic_R_R_RM(node, ins, EA_ATTR(node->gtSIMDSize)); break; } @@ -1720,9 +1717,9 @@ void CodeGen::genSSE41Intrinsic(GenTreeHWIntrinsic* node) regNumber tmpReg = node->GetSingleTempReg(); assert(HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType) == INS_ptest); emit->emitIns_SIMD_R_R_R(INS_pcmpeqd, emitTypeSize(TYP_SIMD16), tmpReg, tmpReg, tmpReg); - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); emit->emitIns_R_R(INS_ptest, emitTypeSize(TYP_SIMD16), op1Reg, tmpReg); emit->emitIns_R(INS_setb, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } @@ -1730,18 +1727,18 @@ void CodeGen::genSSE41Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE41_TestZ: { assert(HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType) == INS_ptest); - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(INS_ptest, emitTypeSize(TYP_SIMD16), op1Reg, op2->gtRegNum); + genHWIntrinsic_R_RM(node, INS_ptest, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_sete, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } case NI_SSE41_TestC: { assert(HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType) == INS_ptest); - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(INS_ptest, emitTypeSize(TYP_SIMD16), op1Reg, op2->gtRegNum); + genHWIntrinsic_R_RM(node, INS_ptest, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_setb, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } @@ -1749,9 +1746,9 @@ void CodeGen::genSSE41Intrinsic(GenTreeHWIntrinsic* node) case NI_SSE41_TestNotZAndNotC: { assert(HWIntrinsicInfo::lookupIns(intrinsicId, node->gtSIMDBaseType) == INS_ptest); - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(INS_ptest, emitTypeSize(TYP_SIMD16), op1Reg, op2->gtRegNum); + genHWIntrinsic_R_RM(node, INS_ptest, emitTypeSize(TYP_SIMD16)); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } @@ -1812,43 +1809,58 @@ void CodeGen::genSSE41Intrinsic(GenTreeHWIntrinsic* node) void CodeGen::genSSE42Intrinsic(GenTreeHWIntrinsic* node) { NamedIntrinsic intrinsicId = node->gtHWIntrinsicId; + regNumber targetReg = node->gtRegNum; GenTree* op1 = node->gtGetOp1(); GenTree* op2 = node->gtGetOp2(); - regNumber targetReg = node->gtRegNum; - assert(targetReg != REG_NA); - var_types targetType = node->TypeGet(); - var_types baseType = node->gtSIMDBaseType; + var_types baseType = node->gtSIMDBaseType; + var_types targetType = node->TypeGet(); + emitter* emit = getEmitter(); regNumber op1Reg = op1->gtRegNum; - regNumber op2Reg = op2->gtRegNum; genConsumeOperands(node); + assert(targetReg != REG_NA); + assert(op1Reg != REG_NA); + assert(op2 != nullptr); + assert(!node->OperIsCommutative()); + switch (intrinsicId) { case NI_SSE42_Crc32: + { if (op1Reg != targetReg) { - assert(op2Reg != targetReg); - inst_RV_RV(INS_mov, targetReg, op1Reg, targetType, emitTypeSize(targetType)); + assert(op2->gtRegNum != targetReg); + emit->emitIns_R_R(INS_mov, emitTypeSize(targetType), targetReg, op1Reg); } - if (baseType == TYP_UBYTE || baseType == TYP_USHORT) // baseType is the type of the second argument + // This makes the genHWIntrinsic_R_RM code much simpler, as we don't need an + // overload that explicitly takes the operands. + node->gtOp1 = op2; + node->gtOp2 = nullptr; + + if ((baseType == TYP_UBYTE) || (baseType == TYP_USHORT)) // baseType is the type of the second argument { assert(targetType == TYP_INT); - inst_RV_RV(INS_crc32, targetReg, op2Reg, baseType, emitTypeSize(baseType)); + genHWIntrinsic_R_RM(node, INS_crc32, emitTypeSize(baseType)); } else { assert(op1->TypeGet() == op2->TypeGet()); - assert(targetType == TYP_INT || targetType == TYP_LONG); - inst_RV_RV(INS_crc32, targetReg, op2Reg, targetType, emitTypeSize(targetType)); + assert((targetType == TYP_INT) || (targetType == TYP_LONG)); + genHWIntrinsic_R_RM(node, INS_crc32, emitTypeSize(targetType)); } break; + } + default: + { unreached(); break; + } } + genProduceReg(node); } @@ -1875,11 +1887,33 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) if ((op1 != nullptr) && !op1->OperIsList()) { + op1Reg = op1->gtRegNum; genConsumeOperands(node); } switch (intrinsicId) { + case NI_AVX2_ConvertToDouble: + { + assert(op2 == nullptr); + if (op1Reg != targetReg) + { + instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); + emit->emitIns_R_R(ins, emitTypeSize(targetType), targetReg, op1Reg); + } + break; + } + + case NI_AVX2_ConvertToInt32: + case NI_AVX2_ConvertToUInt32: + { + assert(op2 == nullptr); + assert((baseType == TYP_INT) || (baseType == TYP_UINT)); + instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, baseType); + emit->emitIns_R_R(ins, emitActualTypeSize(baseType), op1Reg, targetReg); + break; + } + case NI_AVX_SetZeroVector256: { assert(op1 == nullptr); @@ -1901,7 +1935,6 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) { assert(op1 != nullptr); assert(op2 == nullptr); - op1Reg = op1->gtRegNum; if (varTypeIsIntegral(baseType)) { // If the argument is a integer, it needs to be moved into a XMM register @@ -1965,17 +1998,13 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) // to ensure that Bits MAXVL-1:128 are zeroed. assert(op2 == nullptr); - regNumber op1Reg = op1->gtRegNum; emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD16), targetReg, op1Reg); break; } case NI_AVX_GetLowerHalf: - case NI_AVX_StaticCast: { assert(op2 == nullptr); - regNumber op1Reg = op1->gtRegNum; - if (op1Reg != targetReg) { emit->emitIns_R_R(ins, emitTypeSize(TYP_SIMD32), targetReg, op1Reg); @@ -1985,25 +2014,25 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) case NI_AVX_TestC: { - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum); + genHWIntrinsic_R_RM(node, ins, attr); emit->emitIns_R(INS_setb, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } case NI_AVX_TestNotZAndNotC: { - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum); + genHWIntrinsic_R_RM(node, ins, attr); emit->emitIns_R(INS_seta, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } case NI_AVX_TestZ: { - emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg); - emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum); + genHWIntrinsic_R_RM(node, ins, attr); emit->emitIns_R(INS_sete, EA_1BYTE, targetReg); + emit->emitIns_R_R(INS_movzx, EA_1BYTE, targetReg, targetReg); break; } @@ -2016,7 +2045,6 @@ void CodeGen::genAvxOrAvx2Intrinsic(GenTreeHWIntrinsic* node) if (numArgs == 2) { assert(intrinsicId == NI_AVX_ExtractVector128 || NI_AVX_ExtractVector128); - op1Reg = op1->gtRegNum; op2Reg = op2->gtRegNum; lastOp = op2; } @@ -2114,7 +2142,53 @@ void CodeGen::genAESIntrinsic(GenTreeHWIntrinsic* node) // void CodeGen::genBMI1Intrinsic(GenTreeHWIntrinsic* node) { - NYI("Implement BMI1 intrinsic code generation"); + NamedIntrinsic intrinsicId = node->gtHWIntrinsicId; + regNumber targetReg = node->gtRegNum; + GenTree* op1 = node->gtGetOp1(); + GenTree* op2 = node->gtGetOp2(); + var_types baseType = node->gtSIMDBaseType; + var_types targetType = node->TypeGet(); + instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, targetType); + emitter* emit = getEmitter(); + + assert(targetReg != REG_NA); + assert(op1 != nullptr); + + if (!op1->OperIsList()) + { + genConsumeOperands(node); + } + + switch (intrinsicId) + { + case NI_BMI1_AndNot: + { + assert(op2 != nullptr); + assert(op1->TypeGet() == op2->TypeGet()); + assert((targetType == TYP_INT) || (targetType == TYP_LONG)); + genHWIntrinsic_R_R_RM(node, ins, emitTypeSize(node->TypeGet())); + break; + } + + case NI_BMI1_ExtractLowestSetBit: + case NI_BMI1_GetMaskUpToLowestSetBit: + case NI_BMI1_ResetLowestSetBit: + case NI_BMI1_TrailingZeroCount: + { + assert(op2 == nullptr); + assert((targetType == TYP_INT) || (targetType == TYP_LONG)); + genHWIntrinsic_R_RM(node, ins, emitTypeSize(node->TypeGet())); + break; + } + + default: + { + unreached(); + break; + } + } + + genProduceReg(node); } //------------------------------------------------------------------------ @@ -2125,7 +2199,43 @@ void CodeGen::genBMI1Intrinsic(GenTreeHWIntrinsic* node) // void CodeGen::genBMI2Intrinsic(GenTreeHWIntrinsic* node) { - NYI("Implement BMI2 intrinsic code generation"); + NamedIntrinsic intrinsicId = node->gtHWIntrinsicId; + regNumber targetReg = node->gtRegNum; + GenTree* op1 = node->gtGetOp1(); + GenTree* op2 = node->gtGetOp2(); + var_types baseType = node->gtSIMDBaseType; + var_types targetType = node->TypeGet(); + instruction ins = HWIntrinsicInfo::lookupIns(intrinsicId, targetType); + emitter* emit = getEmitter(); + + assert(targetReg != REG_NA); + assert(op1 != nullptr); + + if (!op1->OperIsList()) + { + genConsumeOperands(node); + } + + switch (intrinsicId) + { + case NI_BMI2_ParallelBitDeposit: + case NI_BMI2_ParallelBitExtract: + { + assert(op2 != nullptr); + assert(op1->TypeGet() == op2->TypeGet()); + assert((targetType == TYP_INT) || (targetType == TYP_LONG)); + genHWIntrinsic_R_R_RM(node, ins, emitTypeSize(node->TypeGet())); + break; + } + + default: + { + unreached(); + break; + } + } + + genProduceReg(node); } //------------------------------------------------------------------------ diff --git a/src/jit/hwintrinsiclistxarch.h b/src/jit/hwintrinsiclistxarch.h index 5c91e2ebf406..bfb9cece4a8b 100644 --- a/src/jit/hwintrinsiclistxarch.h +++ b/src/jit/hwintrinsiclistxarch.h @@ -34,29 +34,29 @@ HARDWARE_INTRINSIC(SSE_AddScalar, "AddScalar", HARDWARE_INTRINSIC(SSE_And, "And", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_andps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(SSE_AndNot, "AndNot", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_andnps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSE_CompareEqual, "CompareEqual", SSE, 0, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) -HARDWARE_INTRINSIC(SSE_CompareEqualOrderedScalar, "CompareEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareEqualOrderedScalar, "CompareEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareEqualScalar, "CompareEqualScalar", SSE, 0, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareEqualUnorderedScalar, "CompareEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareEqualUnorderedScalar, "CompareEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareGreaterThan, "CompareGreaterThan", SSE, 6, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrderedScalar, "CompareGreaterThanOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrderedScalar, "CompareGreaterThanOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareGreaterThanScalar, "CompareGreaterThanScalar", SSE, 6, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareGreaterThanUnorderedScalar, "CompareGreaterThanUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareGreaterThanUnorderedScalar, "CompareGreaterThanUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqual, "CompareGreaterThanOrEqual", SSE, 5, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqualOrderedScalar, "CompareGreaterThanOrEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqualOrderedScalar, "CompareGreaterThanOrEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqualScalar, "CompareGreaterThanOrEqualScalar", SSE, 5, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqualUnorderedScalar, "CompareGreaterThanOrEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareGreaterThanOrEqualUnorderedScalar, "CompareGreaterThanOrEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareLessThan, "CompareLessThan", SSE, 1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE_CompareLessThanOrderedScalar, "CompareLessThanOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareLessThanOrderedScalar, "CompareLessThanOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareLessThanScalar, "CompareLessThanScalar", SSE, 1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareLessThanUnorderedScalar, "CompareLessThanUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareLessThanUnorderedScalar, "CompareLessThanUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqual, "CompareLessThanOrEqual", SSE, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqualOrderedScalar, "CompareLessThanOrEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqualOrderedScalar, "CompareLessThanOrEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqualScalar, "CompareLessThanOrEqualScalar", SSE, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqualUnorderedScalar, "CompareLessThanOrEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareLessThanOrEqualUnorderedScalar, "CompareLessThanOrEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareNotEqual, "CompareNotEqual", SSE, 4, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) -HARDWARE_INTRINSIC(SSE_CompareNotEqualOrderedScalar, "CompareNotEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareNotEqualOrderedScalar, "CompareNotEqualOrderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareNotEqualScalar, "CompareNotEqualScalar", SSE, 4, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_CompareNotEqualUnorderedScalar, "CompareNotEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_CompareNotEqualUnorderedScalar, "CompareNotEqualUnorderedScalar", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomiss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_CompareNotGreaterThan, "CompareNotGreaterThan", SSE, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSE_CompareNotGreaterThanScalar, "CompareNotGreaterThanScalar", SSE, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) HARDWARE_INTRINSIC(SSE_CompareNotGreaterThanOrEqual, "CompareNotGreaterThanOrEqual", SSE, 1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) @@ -106,7 +106,7 @@ HARDWARE_INTRINSIC(SSE_SetZeroVector128, "SetZeroVect HARDWARE_INTRINSIC(SSE_Shuffle, "Shuffle", SSE, -1, 16, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_shufps, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(SSE_Sqrt, "Sqrt", SSE, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sqrtps, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_SqrtScalar, "SqrtScalar", SSE, -1, 16, -1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sqrtss, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE_StaticCast, "StaticCast", SSE, -1, 16, 1, {INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps}, HW_Category_Helper, HW_Flag_NoContainment|HW_Flag_TwoTypeGeneric|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE_StaticCast, "StaticCast", SSE, -1, 16, 1, {INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps, INS_movaps}, HW_Category_Helper, HW_Flag_NoCodeGen|HW_Flag_TwoTypeGeneric) HARDWARE_INTRINSIC(SSE_Store, "Store", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movups, INS_invalid}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_StoreAligned, "StoreAligned", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movaps, INS_invalid}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE_StoreAlignedNonTemporal, "StoreAlignedNonTemporal", SSE, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movntps, INS_invalid}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) @@ -133,29 +133,29 @@ HARDWARE_INTRINSIC(SSE2_And, "And", HARDWARE_INTRINSIC(SSE2_AndNot, "AndNot", SSE2, -1, 16, 2, {INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_invalid, INS_andnpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSE2_Average, "Average", SSE2, -1, 16, 2, {INS_invalid, INS_pavgb, INS_invalid, INS_pavgw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(SSE2_CompareEqual, "CompareEqual", SSE2, 0, 16, 2, {INS_pcmpeqb, INS_pcmpeqb, INS_pcmpeqw, INS_pcmpeqw, INS_pcmpeqd, INS_pcmpeqd, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_Commutative) -HARDWARE_INTRINSIC(SSE2_CompareEqualOrderedScalar, "CompareEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareEqualOrderedScalar, "CompareEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareEqualScalar, "CompareEqualScalar", SSE2, 0, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareEqualUnorderedScalar, "CompareEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareEqualUnorderedScalar, "CompareEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareGreaterThan, "CompareGreaterThan", SSE2, 6, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrderedScalar, "CompareGreaterThanOrderedScalar", SSE2, -1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrderedScalar, "CompareGreaterThanOrderedScalar", SSE2, -1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareGreaterThanScalar, "CompareGreaterThanScalar", SSE2, 6, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareGreaterThanUnorderedScalar, "CompareGreaterThanUnorderedScalar", SSE2, -1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareGreaterThanUnorderedScalar, "CompareGreaterThanUnorderedScalar", SSE2, -1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqual, "CompareGreaterThanOrEqual", SSE2, 5, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqualOrderedScalar, "CompareGreaterThanOrEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqualOrderedScalar, "CompareGreaterThanOrEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqualScalar, "CompareGreaterThanOrEqualScalar", SSE2, 5, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqualUnorderedScalar, "CompareGreaterThanOrEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqualUnorderedScalar, "CompareGreaterThanOrEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareLessThan, "CompareLessThan", SSE2, 1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_Special, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE2_CompareLessThanOrderedScalar, "CompareLessThanOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareLessThanOrderedScalar, "CompareLessThanOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareLessThanScalar, "CompareLessThanScalar", SSE2, 1, 16, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareLessThanUnorderedScalar, "CompareLessThanUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareLessThanUnorderedScalar, "CompareLessThanUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqual, "CompareLessThanOrEqual", SSE2, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqualOrderedScalar, "CompareLessThanOrEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqualOrderedScalar, "CompareLessThanOrEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqualScalar, "CompareLessThanOrEqualScalar", SSE2, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqualUnorderedScalar, "CompareLessThanOrEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqualUnorderedScalar, "CompareLessThanOrEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareNotEqual, "CompareNotEqual", SSE2, 4, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_Commutative) -HARDWARE_INTRINSIC(SSE2_CompareNotEqualOrderedScalar, "CompareNotEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareNotEqualOrderedScalar, "CompareNotEqualOrderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_comisd}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareNotEqualScalar, "CompareNotEqualScalar", SSE2, 4, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) -HARDWARE_INTRINSIC(SSE2_CompareNotEqualUnorderedScalar, "CompareNotEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE2_CompareNotEqualUnorderedScalar, "CompareNotEqualUnorderedScalar", SSE2, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_ucomisd}, HW_Category_SIMDScalar, HW_Flag_Commutative|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE2_CompareNotGreaterThan, "CompareNotGreaterThan", SSE2, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSE2_CompareNotGreaterThanScalar, "CompareNotGreaterThanScalar", SSE2, 2, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmpsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) HARDWARE_INTRINSIC(SSE2_CompareNotGreaterThanOrEqual, "CompareNotGreaterThanOrEqual", SSE2, 1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_cmppd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) @@ -249,9 +249,9 @@ HARDWARE_INTRINSIC(SSE3_HorizontalAdd, "HorizontalA HARDWARE_INTRINSIC(SSE3_HorizontalSubtract, "HorizontalSubtract", SSE3, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_hsubps, INS_hsubpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSE3_LoadAndDuplicateToVector128, "LoadAndDuplicateToVector128", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_lddqu, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movddup}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE3_LoadDquVector128, "LoadDquVector128", SSE3, -1, 16, 1, {INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_lddqu, INS_invalid, INS_invalid}, HW_Category_MemoryLoad, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(SSE3_MoveAndDuplicate, "MoveAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movddup}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(SSE3_MoveHighAndDuplicate, "MoveHighAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movshdup, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(SSE3_MoveLowAndDuplicate, "MoveLowAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movsldup, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE3_MoveAndDuplicate, "MoveAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movddup}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE3_MoveHighAndDuplicate, "MoveHighAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movshdup, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE3_MoveLowAndDuplicate, "MoveLowAndDuplicate", SSE3, -1, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movsldup, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Intrinsic ID Function name ISA ival SIMD size NumArg instructions Category Flags @@ -267,7 +267,7 @@ HARDWARE_INTRINSIC(SSSE3_HorizontalSubtract, "HorizontalS HARDWARE_INTRINSIC(SSSE3_HorizontalSubtractSaturate, "HorizontalSubtractSaturate", SSSE3, -1, 16, 2, {INS_invalid, INS_invalid, INS_phsubsw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSSE3_MultiplyAddAdjacent, "MultiplyAddAdjacent", SSSE3, -1, 16, 2, {INS_invalid, INS_invalid, INS_pmaddubsw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSSE3_MultiplyHighRoundScale, "MultiplyHighRoundScale", SSSE3, -1, 16, 2, {INS_invalid, INS_invalid, INS_pmulhrsw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(SSSE3_Shuffle, "Shuffle", SSSE3, -1, 16, 2, {INS_pshufb, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) +HARDWARE_INTRINSIC(SSSE3_Shuffle, "Shuffle", SSSE3, -1, 16, 2, {INS_pshufb, INS_pshufb, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(SSSE3_Sign, "Sign", SSSE3, -1, 16, 2, {INS_psignb, INS_invalid, INS_psignw, INS_invalid, INS_psignd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** @@ -281,9 +281,9 @@ HARDWARE_INTRINSIC(SSE41_BlendVariable, "BlendVariab HARDWARE_INTRINSIC(SSE41_Ceiling, "Ceiling", SSE41, 10, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundps, INS_roundpd}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE41_CeilingScalar, "CeilingScalar", SSE41, 10, 16, -1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundss, INS_roundsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) HARDWARE_INTRINSIC(SSE41_CompareEqual, "CompareEqual", SSE41, -1, 16, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_pcmpeqq, INS_pcmpeqq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) -HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int16, "ConvertToVector128Int16", SSE41, -1, 16, 1, {INS_pmovsxbw, INS_pmovzxbw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int32, "ConvertToVector128Int32", SSE41, -1, 16, 1, {INS_pmovsxbd, INS_pmovzxbd, INS_pmovsxwd, INS_pmovzxwd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int64, "ConvertToVector128Int64", SSE41, -1, 16, 1, {INS_pmovsxbq, INS_pmovzxbq, INS_pmovsxwq, INS_pmovzxwq, INS_pmovsxdq, INS_pmovzxdq, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int16, "ConvertToVector128Int16", SSE41, -1, 16, 1, {INS_pmovsxbw, INS_pmovzxbw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int32, "ConvertToVector128Int32", SSE41, -1, 16, 1, {INS_pmovsxbd, INS_pmovzxbd, INS_pmovsxwd, INS_pmovzxwd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(SSE41_ConvertToVector128Int64, "ConvertToVector128Int64", SSE41, -1, 16, 1, {INS_pmovsxbq, INS_pmovzxbq, INS_pmovsxwq, INS_pmovzxwq, INS_pmovsxdq, INS_pmovzxdq, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE41_DotProduct, "DotProduct", SSE41, -1, 16, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_dpps, INS_dppd}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(SSE41_Extract, "Extract", SSE41, -1, 16, 2, {INS_pextrb, INS_pextrb, INS_invalid, INS_invalid, INS_pextrd, INS_pextrd, INS_pextrq, INS_pextrq, INS_extractps, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM|HW_Flag_BaseTypeFromFirstArg|HW_Flag_MultiIns|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE41_Floor, "Floor", SSE41, 9, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundps, INS_roundpd}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) @@ -308,11 +308,11 @@ HARDWARE_INTRINSIC(SSE41_RoundToPositiveInfinityScalar, "RoundToPosi HARDWARE_INTRINSIC(SSE41_RoundToZero, "RoundToZero", SSE41, 11, 16, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundps, INS_roundpd}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(SSE41_RoundToZeroScalar, "RoundToZeroScalar", SSE41, 11, 16, -1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_roundss, INS_roundsd}, HW_Category_SIMDScalar, HW_Flag_CopyUpperBits) HARDWARE_INTRINSIC(SSE41_TestAllOnes, "TestAllOnes", SSE41, -1, 16, 1, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_NoRMWSemantics|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(SSE41_TestAllZeros, "TestAllZeros", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(SSE41_TestC, "TestC", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(SSE41_TestMixOnesZeros, "TestMixOnesZeros", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(SSE41_TestNotZAndNotC, "TestNotZAndNotC", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(SSE41_TestZ, "TestZ", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(SSE41_TestAllZeros, "TestAllZeros", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(SSE41_TestC, "TestC", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(SSE41_TestMixOnesZeros, "TestMixOnesZeros", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(SSE41_TestNotZAndNotC, "TestNotZAndNotC", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(SSE41_TestZ, "TestZ", SSE41, -1, 16, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Intrinsic ID Function name ISA ival SIMD size NumArg instructions Category Flags @@ -387,14 +387,14 @@ HARDWARE_INTRINSIC(AVX_SetAllVector256, "SetAllVecto HARDWARE_INTRINSIC(AVX_SetZeroVector256, "SetZeroVector256", AVX, -1, 32, 0, {INS_pxor, INS_pxor, INS_pxor, INS_pxor, INS_pxor, INS_pxor, INS_pxor, INS_pxor, INS_xorps, INS_xorpd}, HW_Category_Helper, HW_Flag_NoContainment|HW_Flag_OneTypeGeneric|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_Shuffle, "Shuffle", AVX, -1, 32, 3, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_shufps, INS_shufpd}, HW_Category_IMM, HW_Flag_NoRMWSemantics|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX_Sqrt, "Sqrt", AVX, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sqrtps, INS_sqrtpd}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) -HARDWARE_INTRINSIC(AVX_StaticCast, "StaticCast", AVX, -1, 32, 1, {INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movaps, INS_movapd}, HW_Category_Helper, HW_Flag_NoContainment|HW_Flag_TwoTypeGeneric|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(AVX_StaticCast, "StaticCast", AVX, -1, 32, 1, {INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movaps, INS_movapd}, HW_Category_Helper, HW_Flag_NoCodeGen|HW_Flag_TwoTypeGeneric) HARDWARE_INTRINSIC(AVX_Store, "Store", AVX, -1, 32, 2, {INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movdqu, INS_movups, INS_movupd}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_StoreAligned, "StoreAligned", AVX, -1, 32, 2, {INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movdqa, INS_movaps, INS_movapd}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_StoreAlignedNonTemporal, "StoreAlignedNonTemporal", AVX, -1, 32, 2, {INS_movntdq, INS_movntdq, INS_movntdq, INS_movntdq, INS_movntdq, INS_movntdq, INS_movntdq, INS_movntdq, INS_movntps, INS_movntpd}, HW_Category_MemoryStore, HW_Flag_NoContainment|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX_Subtract, "Subtract", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_subps, INS_subpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) -HARDWARE_INTRINSIC(AVX_TestC, "TestC", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(AVX_TestNotZAndNotC, "TestNotZAndNotC", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) -HARDWARE_INTRINSIC(AVX_TestZ, "TestZ", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(AVX_TestC, "TestC", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(AVX_TestNotZAndNotC, "TestNotZAndNotC", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) +HARDWARE_INTRINSIC(AVX_TestZ, "TestZ", AVX, -1, 0, 2, {INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_ptest, INS_vtestps, INS_vtestpd}, HW_Category_SimpleSIMD, HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(AVX_UnpackHigh, "UnpackHigh", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_unpckhps, INS_unpckhpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX_UnpackLow, "UnpackLow", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_unpcklps, INS_unpcklpd}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX_Xor, "Xor", AVX, -1, 32, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_xorps, INS_xorpd}, HW_Category_SimpleSIMD, HW_Flag_Commutative) @@ -408,9 +408,11 @@ HARDWARE_INTRINSIC(AVX2_IsSupported, "get_IsSuppo HARDWARE_INTRINSIC(AVX2_Abs, "Abs", AVX2, -1, 32, 1, {INS_pabsb, INS_pabsb, INS_pabsw, INS_pabsw, INS_pabsd, INS_pabsd, INS_paddq, INS_paddq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX2_Add, "Add", AVX2, -1, 32, 2, {INS_paddb, INS_paddb, INS_paddw, INS_paddw, INS_paddd, INS_paddd, INS_paddq, INS_paddq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(AVX2_AddSaturate, "AddSaturate", AVX2, -1, 32, 2, {INS_paddsb, INS_paddusb, INS_paddsw, INS_paddusw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) +HARDWARE_INTRINSIC(AVX2_AlignRight, "AlignRight", AVX2, -1, 32, 3, {INS_palignr, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_And, "And", AVX2, -1, 32, 2, {INS_pand, INS_pand, INS_pand, INS_pand, INS_pand, INS_pand, INS_pand, INS_pand, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(AVX2_AndNot, "AndNot", AVX2, -1, 32, 2, {INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_pandn, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_Average, "Average", AVX2, -1, 32, 2, {INS_invalid, INS_pavgb, INS_invalid, INS_pavgw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) +HARDWARE_INTRINSIC(AVX2_Blend, "Blend", AVX2, -1, 0, 3, {INS_invalid, INS_invalid, INS_pblendw, INS_pblendw, INS_vpblendd, INS_vpblendd, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_UnfixedSIMDSize|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_BlendVariable, "BlendVariable", AVX2, -1, 32, 3, {INS_vpblendvb, INS_vpblendvb, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_BroadcastScalarToVector128, "BroadcastScalarToVector128", AVX2, -1, 16, 1, {INS_vpbroadcastb, INS_vpbroadcastb, INS_vpbroadcastw, INS_vpbroadcastw, INS_vpbroadcastd, INS_vpbroadcastd, INS_vpbroadcastq, INS_vpbroadcastq, INS_vbroadcastss, INS_movddup}, HW_Category_SIMDScalar, HW_Flag_OneTypeGeneric) HARDWARE_INTRINSIC(AVX2_BroadcastScalarToVector256, "BroadcastScalarToVector256", AVX2, -1, 32, 1, {INS_vpbroadcastb, INS_vpbroadcastb, INS_vpbroadcastw, INS_vpbroadcastw, INS_vpbroadcastd, INS_vpbroadcastd, INS_vpbroadcastq, INS_vpbroadcastq, INS_vbroadcastss, INS_vbroadcastsd}, HW_Category_SIMDScalar, HW_Flag_OneTypeGeneric) @@ -418,6 +420,9 @@ HARDWARE_INTRINSIC(AVX2_BroadcastVector128ToVector256, "BroadcastVe HARDWARE_INTRINSIC(AVX2_CompareEqual, "CompareEqual", AVX2, -1, 32, 2, {INS_pcmpeqb, INS_pcmpeqb, INS_pcmpeqw, INS_pcmpeqw, INS_pcmpeqd, INS_pcmpeqd, INS_pcmpeqq, INS_pcmpeqq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_Commutative) HARDWARE_INTRINSIC(AVX2_CompareGreaterThan, "CompareGreaterThan", AVX2, -1, 32, 2, {INS_pcmpgtb, INS_invalid, INS_pcmpgtw, INS_invalid, INS_pcmpgtd, INS_invalid, INS_pcmpgtq, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_ExtractVector128, "ExtractVector128", AVX2, -1, 32, -1, {INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_vextracti128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_SpecialImport|HW_Flag_SpecialCodeGen|HW_Flag_FullRangeIMM) +HARDWARE_INTRINSIC(AVX2_ConvertToDouble, "ConvertToDouble", AVX2, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_movsdsse2}, HW_Category_Helper, HW_Flag_NoContainment|HW_Flag_BaseTypeFromFirstArg|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(AVX2_ConvertToInt32, "ConvertToInt32", AVX2, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_mov_xmm2i, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(AVX2_ConvertToUInt32, "ConvertToUInt32", AVX2, -1, 32, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_mov_xmm2i, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SIMDScalar, HW_Flag_BaseTypeFromFirstArg|HW_Flag_SpecialCodeGen|HW_Flag_NoRMWSemantics) HARDWARE_INTRINSIC(AVX2_ConvertToVector256Int16, "ConvertToVector256Int16", AVX2, -1, 32, 1, {INS_pmovsxbw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(AVX2_ConvertToVector256UInt16, "ConvertToVector256UInt16", AVX2, -1, 32, 1, {INS_invalid, INS_pmovzxbw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) HARDWARE_INTRINSIC(AVX2_ConvertToVector256Int32, "ConvertToVector256Int32", AVX2, -1, 32, 1, {INS_pmovsxbd, INS_invalid, INS_pmovsxwd, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_BaseTypeFromFirstArg) @@ -438,11 +443,11 @@ HARDWARE_INTRINSIC(AVX2_Or, "Or", HARDWARE_INTRINSIC(AVX2_Permute2x128, "Permute2x128", AVX2, -1, 32, 3, {INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_vperm2i128, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_OneTypeGeneric|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_ShiftLeftLogical, "ShiftLeftLogical", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_psllw, INS_psllw, INS_pslld, INS_pslld, INS_psllq, INS_psllq, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_MaybeIMM|HW_Flag_NoJmpTableIMM|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_ShiftLeftLogical128BitLane, "ShiftLeftLogical128BitLane", AVX2, -1, 32, 2, {INS_pslldq, INS_pslldq, INS_pslldq, INS_pslldq, INS_pslldq, INS_pslldq, INS_pslldq, INS_pslldq, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) -HARDWARE_INTRINSIC(AVX2_ShiftLeftLogicalVariable, "ShiftLeftLogicalVariable", AVX2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpsllvd, INS_vpsllvd, INS_vpsllvq, INS_vpsllvq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_UnfixedSIMDSize|HW_Flag_NoContainment) +HARDWARE_INTRINSIC(AVX2_ShiftLeftLogicalVariable, "ShiftLeftLogicalVariable", AVX2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpsllvd, INS_vpsllvd, INS_vpsllvq, INS_vpsllvq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_UnfixedSIMDSize) HARDWARE_INTRINSIC(AVX2_ShiftRightArithmetic, "ShiftRightArithmetic", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_psraw, INS_invalid, INS_psrad, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_MaybeIMM|HW_Flag_NoJmpTableIMM|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_ShiftRightLogical, "ShiftRightLogical", AVX2, -1, 32, 2, {INS_invalid, INS_invalid, INS_psrlw, INS_psrlw, INS_psrld, INS_psrld, INS_psrlq, INS_psrlq, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_MaybeIMM|HW_Flag_NoJmpTableIMM|HW_Flag_FullRangeIMM) HARDWARE_INTRINSIC(AVX2_ShiftRightLogical128BitLane, "ShiftRightLogical128BitLane", AVX2, -1, 32, 2, {INS_psrldq, INS_psrldq, INS_psrldq, INS_psrldq, INS_psrldq, INS_psrldq, INS_psrldq, INS_psrldq, INS_invalid, INS_invalid}, HW_Category_IMM, HW_Flag_FullRangeIMM) -HARDWARE_INTRINSIC(AVX2_ShiftRightLogicalVariable, "ShiftRightLogicalVariable", AVX2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpsrlvd, INS_vpsrlvd, INS_vpsrlvq, INS_vpsrlvq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_UnfixedSIMDSize|HW_Flag_NoContainment) +HARDWARE_INTRINSIC(AVX2_ShiftRightLogicalVariable, "ShiftRightLogicalVariable", AVX2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_vpsrlvd, INS_vpsrlvd, INS_vpsrlvq, INS_vpsrlvq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_UnfixedSIMDSize) HARDWARE_INTRINSIC(AVX2_Subtract, "Subtract", AVX2, -1, 32, 2, {INS_psubb, INS_psubb, INS_psubw, INS_psubw, INS_psubd, INS_psubd, INS_psubq, INS_psubq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_SubtractSaturate, "SubtractSaturate", AVX2, -1, 32, 2, {INS_psubsb, INS_psubusb, INS_psubsw, INS_psubusw, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) HARDWARE_INTRINSIC(AVX2_UnpackHigh, "UnpackHigh", AVX2, -1, 32, 2, {INS_punpckhbw, INS_punpckhbw, INS_punpckhwd, INS_punpckhwd, INS_punpckhdq, INS_punpckhdq, INS_punpckhqdq, INS_punpckhqdq, INS_invalid, INS_invalid}, HW_Category_SimpleSIMD, HW_Flag_NoFlag) @@ -462,6 +467,11 @@ HARDWARE_INTRINSIC(AES_IsSupported, "get_IsSuppo // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // BMI1 Intrinsics HARDWARE_INTRINSIC(BMI1_IsSupported, "get_IsSupported", BMI1, -1, 0, 0, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IsSupportedProperty, HW_Flag_NoFlag) +HARDWARE_INTRINSIC(BMI1_AndNot, "AndNot", BMI1, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_andn, INS_andn, INS_andn, INS_andn, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(BMI1_ExtractLowestSetBit, "ExtractLowestSetBit", BMI1, -1, 0, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_blsi, INS_blsi, INS_blsi, INS_blsi, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(BMI1_GetMaskUpToLowestSetBit, "GetMaskUpToLowestSetBit", BMI1, -1, 0, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_blsmsk, INS_blsmsk, INS_blsmsk, INS_blsmsk, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(BMI1_ResetLowestSetBit, "ResetLowestSetBit", BMI1, -1, 0, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_blsr, INS_blsr, INS_blsr, INS_blsr, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(BMI1_TrailingZeroCount, "TrailingZeroCount", BMI1, -1, 0, 1, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_tzcnt, INS_tzcnt, INS_tzcnt, INS_tzcnt, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Intrinsic ID Function name ISA ival SIMD size NumArg instructions Category Flags @@ -469,6 +479,8 @@ HARDWARE_INTRINSIC(BMI1_IsSupported, "get_IsSuppo // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // BMI2 Intrinsics HARDWARE_INTRINSIC(BMI2_IsSupported, "get_IsSupported", BMI2, -1, 0, 0, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid}, HW_Category_IsSupportedProperty, HW_Flag_NoFlag) +HARDWARE_INTRINSIC(BMI2_ParallelBitDeposit, "ParallelBitDeposit", BMI2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_pdep, INS_pdep, INS_pdep, INS_pdep, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) +HARDWARE_INTRINSIC(BMI2_ParallelBitExtract, "ParallelBitExtract", BMI2, -1, 0, 2, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_pext, INS_pext, INS_pext, INS_pext, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_NoFloatingPointUsed|HW_Flag_NoRMWSemantics) // *************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************** // Intrinsic ID Function name ISA ival SIMD size NumArg instructions Category Flags diff --git a/src/jit/hwintrinsicxarch.cpp b/src/jit/hwintrinsicxarch.cpp index 5cc91d7e783c..700962413f33 100644 --- a/src/jit/hwintrinsicxarch.cpp +++ b/src/jit/hwintrinsicxarch.cpp @@ -379,8 +379,6 @@ bool HWIntrinsicInfo::isFullyImplementedIsa(InstructionSet isa) { // These ISAs have no implementation case InstructionSet_AES: - case InstructionSet_BMI1: - case InstructionSet_BMI2: case InstructionSet_PCLMULQDQ: { return false; @@ -389,6 +387,8 @@ bool HWIntrinsicInfo::isFullyImplementedIsa(InstructionSet isa) // These ISAs are partially implemented case InstructionSet_AVX: case InstructionSet_AVX2: + case InstructionSet_BMI1: + case InstructionSet_BMI2: case InstructionSet_SSE42: { return true; @@ -905,6 +905,18 @@ GenTree* Compiler::impSSEIntrinsic(NamedIntrinsic intrinsic, break; } + case NI_SSE_StaticCast: + { + // We fold away the static cast here, as it only exists to satisfy + // the type system. It is safe to do this here since the retNode type + // and the signature return type are both TYP_SIMD16. + assert(sig->numArgs == 1); + retNode = impSIMDPopStack(TYP_SIMD16, false, sig->retTypeClass); + SetOpLclRelatedToSIMDIntrinsic(retNode); + assert(retNode->gtType == getSIMDTypeForSize(getSIMDTypeSizeInBytes(sig->retTypeSigClass))); + break; + } + case NI_SSE_StoreFence: assert(sig->numArgs == 0); assert(JITtype2varType(sig->retType) == TYP_VOID); @@ -1214,6 +1226,18 @@ GenTree* Compiler::impAvxOrAvx2Intrinsic(NamedIntrinsic intrinsic, break; } + case NI_AVX_StaticCast: + { + // We fold away the static cast here, as it only exists to satisfy + // the type system. It is safe to do this here since the retNode type + // and the signature return type are both TYP_SIMD32. + assert(sig->numArgs == 1); + retNode = impSIMDPopStack(TYP_SIMD32, false, sig->retTypeClass); + SetOpLclRelatedToSIMDIntrinsic(retNode); + assert(retNode->gtType == getSIMDTypeForSize(getSIMDTypeSizeInBytes(sig->retTypeSigClass))); + break; + } + case NI_AVX_ExtractVector128: case NI_AVX2_ExtractVector128: { @@ -1263,7 +1287,36 @@ GenTree* Compiler::impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_SIG_INFO* sig, bool mustExpand) { - return nullptr; + var_types callType = JITtype2varType(sig->retType); + + switch (intrinsic) + { + case NI_BMI1_AndNot: + { + assert(sig->numArgs == 2); + + GenTree* op2 = impPopStack().val; + GenTree* op1 = impPopStack().val; + + return gtNewScalarHWIntrinsicNode(callType, op1, op2, intrinsic); + } + + case NI_BMI1_ExtractLowestSetBit: + case NI_BMI1_GetMaskUpToLowestSetBit: + case NI_BMI1_ResetLowestSetBit: + case NI_BMI1_TrailingZeroCount: + { + assert(sig->numArgs == 1); + GenTree* op1 = impPopStack().val; + return gtNewScalarHWIntrinsicNode(callType, op1, intrinsic); + } + + default: + { + unreached(); + return nullptr; + } + } } GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, @@ -1271,7 +1324,27 @@ GenTree* Compiler::impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_SIG_INFO* sig, bool mustExpand) { - return nullptr; + var_types callType = JITtype2varType(sig->retType); + + switch (intrinsic) + { + case NI_BMI2_ParallelBitDeposit: + case NI_BMI2_ParallelBitExtract: + { + assert(sig->numArgs == 2); + + GenTree* op2 = impPopStack().val; + GenTree* op1 = impPopStack().val; + + return gtNewScalarHWIntrinsicNode(callType, op1, op2, intrinsic); + } + + default: + { + unreached(); + return nullptr; + } + } } GenTree* Compiler::impFMAIntrinsic(NamedIntrinsic intrinsic, diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index dc3a383e9edf..fa72bb1fdb60 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -1269,11 +1269,11 @@ GenTree* Compiler::impAssignStructPtr(GenTree* destAddr, destAddr = impCloneExpr(destAddr, &destAddrClone, structHnd, curLevel, pAfterStmt DEBUGARG("MKREFANY assignment")); - assert(offsetof(CORINFO_RefAny, dataPtr) == 0); + assert(OFFSETOF__CORINFO_TypedReference__dataPtr == 0); assert(destAddr->gtType == TYP_I_IMPL || destAddr->gtType == TYP_BYREF); GetZeroOffsetFieldMap()->Set(destAddr, GetFieldSeqStore()->CreateSingleton(GetRefanyDataField())); GenTree* ptrSlot = gtNewOperNode(GT_IND, TYP_I_IMPL, destAddr); - GenTreeIntCon* typeFieldOffset = gtNewIconNode(offsetof(CORINFO_RefAny, type), TYP_I_IMPL); + GenTreeIntCon* typeFieldOffset = gtNewIconNode(OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL); typeFieldOffset->gtFieldSeq = GetFieldSeqStore()->CreateSingleton(GetRefanyTypeField()); GenTree* typeSlot = gtNewOperNode(GT_IND, TYP_I_IMPL, gtNewOperNode(GT_ADD, destAddr->gtType, destAddrClone, typeFieldOffset)); @@ -1784,7 +1784,7 @@ GenTree* Compiler::impLookupToTree(CORINFO_RESOLVED_TOKEN* pResolvedToken, CORINFO_GENERIC_HANDLE handle = nullptr; void* pIndirection = nullptr; - assert(pLookup->constLookup.accessType != IAT_PPVALUE); + assert(pLookup->constLookup.accessType != IAT_PPVALUE && pLookup->constLookup.accessType != IAT_RELPVALUE); if (pLookup->constLookup.accessType == IAT_VALUE) { @@ -1819,7 +1819,7 @@ GenTree* Compiler::impReadyToRunLookupToTree(CORINFO_CONST_LOOKUP* pLookup, { CORINFO_GENERIC_HANDLE handle = nullptr; void* pIndirection = nullptr; - assert(pLookup->accessType != IAT_PPVALUE); + assert(pLookup->accessType != IAT_PPVALUE && pLookup->accessType != IAT_RELPVALUE); if (pLookup->accessType == IAT_VALUE) { @@ -3530,14 +3530,14 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, op1 = impPopStack().val; if (!opts.MinOpts() && !opts.compDbgCode) { - GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, op1, offsetof(CORINFO_String, stringLen)); + GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, op1, OFFSETOF__CORINFO_String__stringLen); op1 = arrLen; } else { /* Create the expression "*(str_addr + stringLengthOffset)" */ op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1, - gtNewIconNode(offsetof(CORINFO_String, stringLen), TYP_I_IMPL)); + gtNewIconNode(OFFSETOF__CORINFO_String__stringLen, TYP_I_IMPL)); op1 = gtNewOperNode(GT_IND, TYP_INT, op1); } @@ -4753,7 +4753,7 @@ bool Compiler::verCheckTailCallConstraint( if (opcode == CEE_CALLI) { /* Get the call sig */ - eeGetSig(pResolvedToken->token, info.compScopeHnd, impTokenLookupContextHandle, &sig); + eeGetSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &sig); // We don't know the target method, so we have to infer the flags, or // assume the worst-case. @@ -4781,7 +4781,7 @@ bool Compiler::verCheckTailCallConstraint( if ((sig.callConv & CORINFO_CALLCONV_MASK) == CORINFO_CALLCONV_VARARG) { - eeGetCallSiteSig(pResolvedToken->token, info.compScopeHnd, impTokenLookupContextHandle, &sig); + eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &sig); } // check compatibility of the arguments @@ -4849,7 +4849,7 @@ bool Compiler::verCheckTailCallConstraint( if (methodClassFlgs & CORINFO_FLG_ARRAY) { assert(opcode != CEE_CALLI); - eeGetCallSiteSig(pResolvedToken->token, info.compScopeHnd, impTokenLookupContextHandle, &sig); + eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &sig); } } @@ -6097,8 +6097,11 @@ void Compiler::impCheckForPInvokeCall( } optNativeCallCount++; - if (opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && methHnd == nullptr) + if (methHnd == nullptr && (opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) || IsTargetAbi(CORINFO_CORERT_ABI))) { + // PInvoke in CoreRT ABI must be always inlined. Non-inlineable CALLI cases have been + // converted to regular method calls earlier using convertPInvokeCalliToCall. + // PInvoke CALLI in IL stubs must be inlined } else @@ -6109,9 +6112,9 @@ void Compiler::impCheckForPInvokeCall( return; } - // PInvoke CALL in IL stubs must be inlined on CoreRT. Skip the ambient conditions checks and - // profitability checks - if (!(opts.jitFlags->IsSet(JitFlags::JIT_FLAG_IL_STUB) && IsTargetAbi(CORINFO_CORERT_ABI))) + // Legal PInvoke CALL in PInvoke IL stubs must be inlined to avoid infinite recursive + // inlining in CoreRT. Skip the ambient conditions checks and profitability checks. + if (!IsTargetAbi(CORINFO_CORERT_ABI) || (info.compFlags & CORINFO_FLG_PINVOKE) == 0) { if (!impCanPInvokeInline()) { @@ -6703,9 +6706,9 @@ bool Compiler::impTailCallRetTypeCompatible(var_types callerRetType, unsigned callerRetTypeSize = 0; unsigned calleeRetTypeSize = 0; bool isCallerRetTypMBEnreg = - VarTypeIsMultiByteAndCanEnreg(callerRetType, callerRetTypeClass, &callerRetTypeSize, true); + VarTypeIsMultiByteAndCanEnreg(callerRetType, callerRetTypeClass, &callerRetTypeSize, true, info.compIsVarArgs); bool isCalleeRetTypMBEnreg = - VarTypeIsMultiByteAndCanEnreg(calleeRetType, calleeRetTypeClass, &calleeRetTypeSize, true); + VarTypeIsMultiByteAndCanEnreg(calleeRetType, calleeRetTypeClass, &calleeRetTypeSize, true, info.compIsVarArgs); if (varTypeIsIntegral(callerRetType) || isCallerRetTypMBEnreg) { @@ -6967,8 +6970,19 @@ var_types Compiler::impImportCall(OPCODE opcode, if (opcode == CEE_CALLI) { + if (IsTargetAbi(CORINFO_CORERT_ABI)) + { + // See comment in impCheckForPInvokeCall + BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; + if (info.compCompHnd->convertPInvokeCalliToCall(pResolvedToken, !impCanPInvokeInlineCallSite(block))) + { + eeGetCallInfo(pResolvedToken, nullptr, CORINFO_CALLINFO_ALLOWINSTPARAM, callInfo); + return impImportCall(CEE_CALL, pResolvedToken, nullptr, nullptr, prefixFlags, callInfo, rawILOffset); + } + } + /* Get the call site sig */ - eeGetSig(pResolvedToken->token, info.compScopeHnd, impTokenLookupContextHandle, &calliSig); + eeGetSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, &calliSig); callRetTyp = JITtype2varType(calliSig.retType); @@ -7262,7 +7276,8 @@ var_types Compiler::impImportCall(OPCODE opcode, call = gtNewCallNode(CT_USER_FUNC, callInfo->hMethod, callRetTyp, nullptr, ilOffset); call->gtCall.gtStubCallStubAddr = callInfo->stubLookup.constLookup.addr; call->gtFlags |= GTF_CALL_VIRT_STUB; - assert(callInfo->stubLookup.constLookup.accessType != IAT_PPVALUE); + assert(callInfo->stubLookup.constLookup.accessType != IAT_PPVALUE && + callInfo->stubLookup.constLookup.accessType != IAT_RELPVALUE); if (callInfo->stubLookup.constLookup.accessType == IAT_PVALUE) { call->gtCall.gtCallMoreFlags |= GTF_CALL_M_VIRTSTUB_REL_INDIRECT; @@ -7532,7 +7547,7 @@ var_types Compiler::impImportCall(OPCODE opcode, #ifdef DEBUG unsigned numArgsDef = sig->numArgs; #endif - eeGetCallSiteSig(pResolvedToken->token, info.compScopeHnd, impTokenLookupContextHandle, sig); + eeGetCallSiteSig(pResolvedToken->token, pResolvedToken->tokenScope, pResolvedToken->tokenContext, sig); #ifdef DEBUG // We cannot lazily obtain the signature of a vararg call because using its method @@ -8450,8 +8465,24 @@ GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HAN { if (retRegCount == 1) { - // struct returned in a single register - call->gtReturnType = retTypeDesc->GetReturnRegType(0); + // See if the struct size is smaller than the return + // type size... + if (retTypeDesc->IsEnclosingType()) + { + // If we know for sure this call will remain a call, + // retype and return value via a suitable temp. + if ((!call->CanTailCall()) && (!call->IsInlineCandidate())) + { + call->gtReturnType = retTypeDesc->GetReturnRegType(0); + return impAssignSmallStructTypeToVar(call, retClsHnd); + } + } + else + { + // Return type is same size as struct, so we can + // simply retype the call. + call->gtReturnType = retTypeDesc->GetReturnRegType(0); + } } else { @@ -8493,7 +8524,25 @@ GenTree* Compiler::impFixupCallStructReturn(GenTreeCall* call, CORINFO_CLASS_HAN else { assert(returnType != TYP_UNKNOWN); - call->gtReturnType = returnType; + + // See if the struct size is smaller than the return + // type size... + if (howToReturnStruct == SPK_EnclosingType) + { + // If we know for sure this call will remain a call, + // retype and return value via a suitable temp. + if ((!call->CanTailCall()) && (!call->IsInlineCandidate())) + { + call->gtReturnType = returnType; + return impAssignSmallStructTypeToVar(call, retClsHnd); + } + } + else + { + // Return type is same size as struct, so we can + // simply retype the call. + call->gtReturnType = returnType; + } // ToDo: Refactor this common code sequence into its own method as it is used 4+ times if ((returnType == TYP_LONG) && (compLongUsed == false)) @@ -8541,6 +8590,9 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE re assert(varTypeIsStruct(info.compRetType)); assert(info.compRetBuffArg == BAD_VAR_NUM); + JITDUMP("\nimpFixupStructReturnType: retyping\n"); + DISPTREE(op); + #if defined(_TARGET_XARCH_) #ifdef UNIX_AMD64_ABI @@ -8654,7 +8706,12 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE re // and no normalizing if (op->gtOper == GT_LCL_VAR) { - op->ChangeOper(GT_LCL_FLD); + // It is possible that we now have a lclVar of scalar type. + // If so, don't transform it to GT_LCL_FLD. + if (varTypeIsStruct(lvaTable[op->AsLclVar()->gtLclNum].lvType)) + { + op->ChangeOper(GT_LCL_FLD); + } } else if (op->gtOper == GT_OBJ) { @@ -8706,9 +8763,7 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE re } else { - assert(info.compRetNativeType == op->gtCall.gtReturnType); - - // Don't change the gtType of the node just yet, it will get changed later. + // Don't change the gtType of the call just yet, it will get changed later. return op; } } @@ -8731,6 +8786,9 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op, CORINFO_CLASS_HANDLE re op->gtType = info.compRetNativeType; + JITDUMP("\nimpFixupStructReturnType: result of retyping is\n"); + DISPTREE(op); + return op; } @@ -12482,6 +12540,8 @@ void Compiler::impImportBlockCode(BasicBlock* block) if (varTypeIsStruct(op1)) { + JITDUMP("\n ... CEE_POP struct ...\n"); + DISPTREE(op1); #ifdef UNIX_AMD64_ABI // Non-calls, such as obj or ret_expr, have to go through this. // Calls with large struct return value have to go through this. @@ -12491,7 +12551,20 @@ void Compiler::impImportBlockCode(BasicBlock* block) op1->AsCall()->gtCallType == CT_HELPER) #endif // UNIX_AMD64_ABI { - op1 = impGetStructAddr(op1, clsHnd, (unsigned)CHECK_SPILL_ALL, false); + // If the value being produced comes from loading + // via an underlying address, just null check the address. + if (op1->OperIs(GT_FIELD, GT_IND, GT_OBJ)) + { + op1->ChangeOper(GT_NULLCHECK); + op1->gtType = TYP_BYTE; + } + else + { + op1 = impGetStructAddr(op1, clsHnd, (unsigned)CHECK_SPILL_ALL, false); + } + + JITDUMP("\n ... optimized to ...\n"); + DISPTREE(op1); } } @@ -13312,7 +13385,9 @@ void Compiler::impImportBlockCode(BasicBlock* block) memset(&resolvedToken, 0, sizeof(resolvedToken)); memset(&callInfo, 0, sizeof(callInfo)); - resolvedToken.token = getU4LittleEndian(codeAddr); + resolvedToken.token = getU4LittleEndian(codeAddr); + resolvedToken.tokenContext = impTokenLookupContextHandle; + resolvedToken.tokenScope = info.compScopeHnd; } CALL: // memberRef should be set. @@ -13411,31 +13486,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) // For delegates, this is the call to the delegate constructor, not the access check on the // LD(virt)FTN. impHandleAccessAllowed(callInfo.accessAllowed, &callInfo.callsiteCalloutHelper); - -#if 0 // DevDiv 410397 - This breaks too many obfuscated apps to do this in an in-place release - - // DevDiv 291703 - we need to check for accessibility between the caller of InitializeArray - // and the field it is reading, thus it is now unverifiable to not immediately precede with - // ldtoken , and we now check accessibility - if ((callInfo.methodFlags & CORINFO_FLG_INTRINSIC) && - (info.compCompHnd->getIntrinsicID(callInfo.hMethod) == CORINFO_INTRINSIC_InitializeArray)) - { - if (prevOpcode != CEE_LDTOKEN) - { - Verify(prevOpcode == CEE_LDTOKEN, "Need ldtoken for InitializeArray"); - } - else - { - assert(lastLoadToken != NULL); - // Now that we know we have a token, verify that it is accessible for loading - CORINFO_RESOLVED_TOKEN resolvedLoadField; - impResolveToken(lastLoadToken, &resolvedLoadField, CORINFO_TOKENKIND_Field); - eeGetFieldInfo(&resolvedLoadField, CORINFO_ACCESS_INIT_ARRAY, &fieldInfo); - impHandleAccessAllowed(fieldInfo.accessAllowed, &fieldInfo.accessCalloutHelper); - } - } - -#endif // DevDiv 410397 } if (tiVerificationNeeded) @@ -13445,21 +13495,6 @@ void Compiler::impImportBlockCode(BasicBlock* block) &callInfo DEBUGARG(info.compFullName)); } - // Insert delegate callout here. - if (opcode == CEE_NEWOBJ && (mflags & CORINFO_FLG_CONSTRUCTOR) && (clsFlags & CORINFO_FLG_DELEGATE)) - { -#ifdef DEBUG - // We should do this only if verification is enabled - // If verification is disabled, delegateCreateStart will not be initialized correctly - if (tiVerificationNeeded) - { - mdMemberRef delegateMethodRef = mdMemberRefNil; - // We should get here only for well formed delegate creation. - assert(verCheckDelegateCreation(delegateCreateStart, codeAddr - 1, delegateMethodRef)); - } -#endif - } - callTyp = impImportCall(opcode, &resolvedToken, constraintCall ? &constrainedResolvedToken : nullptr, newObjThisPtr, prefixFlags, &callInfo, opcodeOffs); if (compDonotInline()) @@ -14361,10 +14396,13 @@ void Compiler::impImportBlockCode(BasicBlock* block) op1 = gtNewOperNode(GT_ADDR, TYP_I_IMPL, op1); convertedToLocal = true; - // Ensure we have stack security for this method. - // Reorder layout since the converted localloc is treated as an unsafe buffer. - setNeedsGSSecurityCookie(); - compGSReorderStackLayout = true; + if (!this->opts.compDbgEnC) + { + // Ensure we have stack security for this method. + // Reorder layout since the converted localloc is treated as an unsafe buffer. + setNeedsGSSecurityCookie(); + compGSReorderStackLayout = true; + } } } } @@ -14538,7 +14576,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) // Fetch the type from the correct slot op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1, - gtNewIconNode(offsetof(CORINFO_RefAny, type), TYP_I_IMPL)); + gtNewIconNode(OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL)); op1 = gtNewOperNode(GT_IND, TYP_BYREF, op1); } else @@ -15448,7 +15486,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) if (!opts.MinOpts() && !opts.compDbgCode) { /* Use GT_ARR_LENGTH operator so rng check opts see this */ - GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, op1, offsetof(CORINFO_Array, length)); + GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, op1, OFFSETOF__CORINFO_Array__length); /* Mark the block as containing a length expression */ @@ -15463,7 +15501,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) { /* Create the expression "*(array_addr + ArrLenOffs)" */ op1 = gtNewOperNode(GT_ADD, TYP_BYREF, op1, - gtNewIconNode(offsetof(CORINFO_Array, length), TYP_I_IMPL)); + gtNewIconNode(OFFSETOF__CORINFO_Array__length, TYP_I_IMPL)); op1 = gtNewIndir(TYP_INT, op1); op1->gtFlags |= GTF_IND_ARR_LEN; } @@ -15666,7 +15704,45 @@ void Compiler::impMarkLclDstNotPromotable(unsigned tmpNum, GenTree* src, CORINFO } #endif // _TARGET_ARM_ +//------------------------------------------------------------------------ +// impAssignSmallStructTypeToVar: ensure calls that return small structs whose +// sizes are not supported integral type sizes return values to temps. +// +// Arguments: +// op -- call returning a small struct in a register +// hClass -- class handle for struct +// +// Returns: +// Tree with reference to struct local to use as call return value. +// +// Remarks: +// The call will be spilled into a preceding statement. +// Currently handles struct returns for 3, 5, 6, and 7 byte structs. + +GenTree* Compiler::impAssignSmallStructTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass) +{ + unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Return value temp for small struct return.")); + impAssignTempGen(tmpNum, op, hClass, (unsigned)CHECK_SPILL_ALL); + GenTree* ret = gtNewLclvNode(tmpNum, lvaTable[tmpNum].lvType); + + // TODO-1stClassStructs: Handle constant propagation and CSE-ing of small struct returns. + ret->gtFlags |= GTF_DONT_CSE; + + return ret; +} + #if FEATURE_MULTIREG_RET +//------------------------------------------------------------------------ +// impAssignMultiRegTypeToVar: ensure calls that return structs in multiple +// registers return values to suitable temps. +// +// Arguments: +// op -- call returning a struct in a registers +// hClass -- class handle for struct +// +// Returns: +// Tree with reference to struct local to use as call return value. + GenTree* Compiler::impAssignMultiRegTypeToVar(GenTree* op, CORINFO_CLASS_HANDLE hClass) { unsigned tmpNum = lvaGrabTemp(true DEBUGARG("Return value temp for multireg return.")); @@ -16987,7 +17063,7 @@ void* Compiler::BlockListNode::operator new(size_t sz, Compiler* comp) { if (comp->impBlockListNodeFreeList == nullptr) { - return (BlockListNode*)comp->compGetMem(sizeof(BlockListNode), CMK_BasicBlock); + return comp->getAllocator(CMK_BasicBlock).allocate(1); } else { @@ -17214,7 +17290,7 @@ void Compiler::verInitBBEntryState(BasicBlock* block, EntryState* srcState) return; } - block->bbEntryState = (EntryState*)compGetMem(sizeof(EntryState)); + block->bbEntryState = getAllocator(CMK_Unknown).allocate(1); // block->bbEntryState.esRefcount = 1; @@ -17380,26 +17456,39 @@ void Compiler::impImport(BasicBlock* method) } #endif - /* Allocate the stack contents */ + Compiler* inlineRoot = impInlineRoot(); - if (info.compMaxStack <= _countof(impSmallStack)) + if (info.compMaxStack <= SMALL_STACK_SIZE) { - /* Use local variable, don't waste time allocating on the heap */ - - impStkSize = _countof(impSmallStack); - verCurrentState.esStack = impSmallStack; + impStkSize = SMALL_STACK_SIZE; } else { - impStkSize = info.compMaxStack; + impStkSize = info.compMaxStack; + } + + if (this == inlineRoot) + { + // Allocate the stack contents verCurrentState.esStack = new (this, CMK_ImpStack) StackEntry[impStkSize]; } + else + { + // This is the inlinee compiler, steal the stack from the inliner compiler + // (after ensuring that it is large enough). + if (inlineRoot->impStkSize < impStkSize) + { + inlineRoot->impStkSize = impStkSize; + inlineRoot->verCurrentState.esStack = new (this, CMK_ImpStack) StackEntry[impStkSize]; + } + + verCurrentState.esStack = inlineRoot->verCurrentState.esStack; + } // initialize the entry state at start of method verInitCurrentState(); // Initialize stuff related to figuring "spill cliques" (see spec comment for impGetSpillTmpBase). - Compiler* inlineRoot = impInlineRoot(); if (this == inlineRoot) // These are only used on the root of the inlining tree. { // We have initialized these previously, but to size 0. Make them larger. @@ -18754,6 +18843,10 @@ GenTree* Compiler::impInlineFetchArg(unsigned lclNum, InlArgInfo* inlArgInfo, In if (varTypeIsStruct(lclTyp)) { lvaSetStruct(tmpNum, lclInfo.lclVerTypeInfo.GetClassHandle(), true /* unsafe value cls check */); + if (info.compIsVarArgs) + { + lvaSetStructUsedAsVarArg(tmpNum); + } } else { @@ -19072,6 +19165,19 @@ void Compiler::impMarkInlineCandidate(GenTree* callNode, return; } + /* Check legality of PInvoke callsite (for inlining of marshalling code) */ + + if (methAttr & CORINFO_FLG_PINVOKE) + { + // See comment in impCheckForPInvokeCall + BasicBlock* block = compIsForInlining() ? impInlineInfo->iciBlock : compCurBB; + if (!impCanPInvokeInlineCallSite(block)) + { + inlineResult.NoteFatal(InlineObservation::CALLSITE_PINVOKE_EH); + return; + } + } + InlineCandidateInfo* inlineCandidateInfo = nullptr; impCheckCanInline(call, fncHandle, methAttr, exactContextHnd, &inlineCandidateInfo, &inlineResult); @@ -19764,7 +19870,7 @@ CORINFO_CLASS_HANDLE Compiler::impGetSpecialIntrinsicExactReturnType(CORINFO_MET // pointer to token into jit-allocated memory. CORINFO_RESOLVED_TOKEN* Compiler::impAllocateToken(CORINFO_RESOLVED_TOKEN token) { - CORINFO_RESOLVED_TOKEN* memory = (CORINFO_RESOLVED_TOKEN*)compGetMem(sizeof(token)); + CORINFO_RESOLVED_TOKEN* memory = getAllocator(CMK_Unknown).allocate(1); *memory = token; return memory; } diff --git a/src/jit/inline.def b/src/jit/inline.def index 4dd67402fb7f..2594c072d4e9 100644 --- a/src/jit/inline.def +++ b/src/jit/inline.def @@ -159,6 +159,7 @@ INLINE_OBSERVATION(REQUIRES_SAME_THIS, bool, "requires same this", INLINE_OBSERVATION(RETURN_TYPE_MISMATCH, bool, "return type mismatch", FATAL, CALLSITE) INLINE_OBSERVATION(STFLD_NEEDS_HELPER, bool, "stfld needs helper", FATAL, CALLSITE) INLINE_OBSERVATION(TOO_MANY_LOCALS, bool, "too many locals", FATAL, CALLSITE) +INLINE_OBSERVATION(PINVOKE_EH, bool, "PInvoke call site with EH", FATAL, CALLSITE) // ------ Call Site Performance ------- diff --git a/src/jit/inlinepolicy.h b/src/jit/inlinepolicy.h index c7a8dc52c5f4..e831b9a7183e 100644 --- a/src/jit/inlinepolicy.h +++ b/src/jit/inlinepolicy.h @@ -339,7 +339,7 @@ class RandomPolicy : public DiscretionaryPolicy // FullPolicy is an experimental policy that will always inline if // possible, subject to externally settable depth and size limits. // -// It's useful for unconvering the full set of possible inlines for +// It's useful for uncovering the full set of possible inlines for // methods. class FullPolicy : public DiscretionaryPolicy diff --git a/src/jit/instrsxarch.h b/src/jit/instrsxarch.h index 489baa8ec369..87fd76a5d695 100644 --- a/src/jit/instrsxarch.h +++ b/src/jit/instrsxarch.h @@ -480,6 +480,7 @@ INST3( vinserti128, "inserti128" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SS INST3( vzeroupper, "zeroupper" , 0, IUM_WR, 0, 0, 0xC577F8, BAD_CODE, BAD_CODE) // Zero upper 128-bits of all YMM regs (includes 2-byte fixed VEX prefix) INST3( vperm2i128, "perm2i128" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x46)) // Permute 128-bit halves of input register INST3( vpermq, "permq" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x00)) // Permute 64-bit of input register +INST3( vpblendd, "pblendd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x02)) // Blend Packed DWORDs INST3( vblendvps, "blendvps" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4A)) // Variable Blend Packed Singles INST3( vblendvpd, "blendvpd" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4B)) // Variable Blend Packed Doubles INST3( vpblendvb, "pblendvb" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE3A(0x4C)) // Variable Blend Packed Bytes @@ -564,11 +565,26 @@ INST3(vfnmsub213ss, "fmnsub213ss", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, INST3(vfnmsub231ss, "fmnsub231ss", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xBF)) // INST3(LAST_FMA_INSTRUCTION, "LAST_FMA_INSTRUCTION", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, BAD_CODE) +// BMI1 +INST3(FIRST_BMI_INSTRUCTION, "FIRST_BMI_INSTRUCTION", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, BAD_CODE) +INST3(andn, "andn", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF2)) // Logical AND NOT +INST3(blsi, "blsi", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF3)) // Extract Lowest Set Isolated Bit +INST3(blsmsk, "blsmsk", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF3)) // Get Mask Up to Lowest Set Bit +INST3(blsr, "blsr", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF3)) // Reset Lowest Set Bit + +// BMI2 +INST3(pdep, "pdep", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF5)) // Parallel Bits Deposit +INST3(pext, "pext", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSE38(0xF5)) // Parallel Bits Extract +INST3(LAST_BMI_INSTRUCTION, "LAST_BMI_INSTRUCTION", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, BAD_CODE) + INST3(LAST_AVX_INSTRUCTION, "LAST_AVX_INSTRUCTION", 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, BAD_CODE) // Scalar instructions in SSE4.2 INST3( crc32, "crc32" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, PACK4(0xF2, 0x0F, 0x38, 0xF0)) +// BMI1 +INST3( tzcnt, "tzcnt" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSEFLT(0xBC)) // Count the Number of Trailing Zero Bits + // LZCNT INST3( lzcnt, "lzcnt" , 0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSEFLT(0xBD)) diff --git a/src/jit/jit.h b/src/jit/jit.h index 2cc070b797f8..f09b31d49d47 100644 --- a/src/jit/jit.h +++ b/src/jit/jit.h @@ -33,7 +33,7 @@ #pragma warning(disable : 4511) // can't generate copy constructor #pragma warning(disable : 4512) // can't generate assignment constructor #pragma warning(disable : 4610) // user defined constructor required -#pragma warning(disable : 4211) // nonstandard extention used (char name[0] in structs) +#pragma warning(disable : 4211) // nonstandard extension used (char name[0] in structs) #pragma warning(disable : 4127) // conditional expression constant #pragma warning(disable : 4201) // "nonstandard extension used : nameless struct/union" @@ -208,6 +208,10 @@ #define _TARGET_UNIX_ #endif +#ifndef _TARGET_UNIX_ +#define _TARGET_WINDOWS_ +#endif // !_TARGET_UNIX_ + // -------------------------------------------------------------------------------- // IMAGE_FILE_MACHINE_TARGET // -------------------------------------------------------------------------------- @@ -272,14 +276,15 @@ #define UNIX_AMD64_ABI_ONLY(x) #endif // defined(UNIX_AMD64_ABI) -#if defined(UNIX_AMD64_ABI) || !defined(_TARGET_64BIT_) +#if defined(UNIX_AMD64_ABI) || !defined(_TARGET_64BIT_) || (defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_)) #define FEATURE_PUT_STRUCT_ARG_STK 1 #define PUT_STRUCT_ARG_STK_ONLY_ARG(x) , x #define PUT_STRUCT_ARG_STK_ONLY(x) x -#else // !(defined(UNIX_AMD64_ABI) || !defined(_TARGET_64BIT_)) +#else // !(defined(UNIX_AMD64_ABI) && defined(_TARGET_64BIT_) && !(defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_)) #define PUT_STRUCT_ARG_STK_ONLY_ARG(x) #define PUT_STRUCT_ARG_STK_ONLY(x) -#endif // !(defined(UNIX_AMD64_ABI)|| !defined(_TARGET_64BIT_)) +#endif // !(defined(UNIX_AMD64_ABI) && defined(_TARGET_64BIT_) && !(defined(_TARGET_WINDOWS_) && + // defined(_TARGET_ARM64_)) #if defined(UNIX_AMD64_ABI) #define UNIX_AMD64_ABI_ONLY_ARG(x) , x @@ -299,6 +304,15 @@ #define MULTIREG_HAS_SECOND_GC_RET_ONLY(x) #endif // defined(UNIX_AMD64_ABI) +// Arm64 Windows supports FEATURE_ARG_SPLIT, note this is different from +// the official Arm64 ABI. +// Case: splitting 16 byte struct between x7 and stack +#if (defined(_TARGET_ARM_) || (defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_))) +#define FEATURE_ARG_SPLIT 1 +#else +#define FEATURE_ARG_SPLIT 0 +#endif // (defined(_TARGET_ARM_) || (defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_))) + // To get rid of warning 4701 : local variable may be used without being initialized #define DUMMY_INIT(x) (x) @@ -457,7 +471,6 @@ typedef ptrdiff_t ssize_t; // case of single block methods. #define COUNT_LOOPS 0 // Collect stats about loops, such as the total number of natural loops, a histogram of // the number of loop exits, etc. -#define COUNT_RANGECHECKS 0 // Count range checks removed (in lexical CSE?). #define DATAFLOW_ITER 0 // Count iterations in lexical CSE and constant folding dataflow. #define DISPLAY_SIZES 0 // Display generated code, data, and GC information sizes. #define MEASURE_BLOCK_SIZE 0 // Collect stats about basic block and flowList node sizes and memory allocations. @@ -816,110 +829,8 @@ const int MIN_SHORT_AS_INT = -32768; /*****************************************************************************/ -// CompMemKind values are used to tag memory allocations performed via -// the compiler's allocator so that the memory usage of various compiler -// components can be tracked separately (when MEASURE_MEM_ALLOC is defined). - -enum CompMemKind -{ -#define CompMemKindMacro(kind) CMK_##kind, -#include "compmemkind.h" - CMK_Count -}; - class Compiler; -// Allows general purpose code (e.g. collection classes) to allocate memory -// of a pre-determined kind via the compiler's allocator. - -class CompAllocator -{ - Compiler* const m_comp; -#if MEASURE_MEM_ALLOC - CompMemKind const m_cmk; -#endif -public: - CompAllocator(Compiler* comp, CompMemKind cmk) - : m_comp(comp) -#if MEASURE_MEM_ALLOC - , m_cmk(cmk) -#endif - { - } - - // Allocates a block of memory at least `sz` in size. - // Zero-length allocation are not allowed. - inline void* Alloc(size_t sz); - - // Allocates a block of memory at least `elems * elemSize` in size. - // Zero-length allocation are not allowed. - inline void* ArrayAlloc(size_t elems, size_t elemSize); - - // For the compiler's ArenaAllocator, free operations are no-ops. - void Free(void* p) - { - } -}; - -// Global operator new overloads that work with CompAllocator - -inline void* __cdecl operator new(size_t n, CompAllocator* alloc) -{ - return alloc->Alloc(n); -} - -inline void* __cdecl operator new[](size_t n, CompAllocator* alloc) -{ - return alloc->Alloc(n); -} - -// A CompAllocator wrapper that implements IAllocator and allows zero-length -// memory allocations (the compiler's ArenAllocator does not support zero-length -// allocation). - -class CompIAllocator : public IAllocator -{ - CompAllocator* const m_alloc; - char m_zeroLenAllocTarg; - -public: - CompIAllocator(CompAllocator* alloc) : m_alloc(alloc) - { - } - - // Allocates a block of memory at least `sz` in size. - virtual void* Alloc(size_t sz) override - { - if (sz == 0) - { - return &m_zeroLenAllocTarg; - } - else - { - return m_alloc->Alloc(sz); - } - } - - // Allocates a block of memory at least `elems * elemSize` in size. - virtual void* ArrayAlloc(size_t elemSize, size_t numElems) override - { - if ((elemSize == 0) || (numElems == 0)) - { - return &m_zeroLenAllocTarg; - } - else - { - return m_alloc->ArrayAlloc(elemSize, numElems); - } - } - - // Frees the block of memory pointed to by p. - virtual void Free(void* p) override - { - m_alloc->Free(p); - } -}; - class JitTls { #ifdef DEBUG diff --git a/src/jit/jitexpandarray.h b/src/jit/jitexpandarray.h index 03d81f50f3c4..abe086c33762 100644 --- a/src/jit/jitexpandarray.h +++ b/src/jit/jitexpandarray.h @@ -11,10 +11,10 @@ template class JitExpandArray { protected: - CompAllocator* m_alloc; // The allocator object that should be used to allocate members. - T* m_members; // Pointer to the element array. - unsigned m_size; // The size of the element array. - unsigned m_minSize; // The minimum size of the element array. + CompAllocator m_alloc; // The allocator object that should be used to allocate members. + T* m_members; // Pointer to the element array. + unsigned m_size; // The size of the element array. + unsigned m_minSize; // The minimum size of the element array. // Ensure that the element array is large enough for the specified index to be valid. void EnsureCoversInd(unsigned idx); @@ -54,7 +54,7 @@ class JitExpandArray // time an array element (having index `idx`) is accessed, an array // of size max(`minSize`, `idx`) is allocated. // - JitExpandArray(CompAllocator* alloc, unsigned minSize = 1) + JitExpandArray(CompAllocator alloc, unsigned minSize = 1) : m_alloc(alloc), m_members(nullptr), m_size(0), m_minSize(minSize) { assert(minSize > 0); @@ -71,7 +71,7 @@ class JitExpandArray { if (m_members != nullptr) { - m_alloc->Free(m_members); + m_alloc.deallocate(m_members); } } @@ -86,11 +86,11 @@ class JitExpandArray // This is equivalent to calling the destructor and then constructing // the array again. // - void Init(CompAllocator* alloc, unsigned minSize = 1) + void Init(CompAllocator alloc, unsigned minSize = 1) { if (m_members != nullptr) { - m_alloc->Free(m_members); + m_alloc.deallocate(m_members); } m_alloc = alloc; m_members = nullptr; @@ -220,7 +220,7 @@ class JitExpandArrayStack : public JitExpandArray // Notes: // See JitExpandArray constructor notes. // - JitExpandArrayStack(CompAllocator* alloc, unsigned minSize = 1) : JitExpandArray(alloc, minSize), m_used(0) + JitExpandArrayStack(CompAllocator alloc, unsigned minSize = 1) : JitExpandArray(alloc, minSize), m_used(0) { } @@ -391,18 +391,11 @@ void JitExpandArray::EnsureCoversInd(unsigned idx) unsigned oldSize = m_size; T* oldMembers = m_members; m_size = max(idx + 1, max(m_minSize, m_size * 2)); - if (sizeof(T) < sizeof(int)) - { - m_members = (T*)m_alloc->ArrayAlloc(ALIGN_UP(m_size * sizeof(T), sizeof(int)), sizeof(BYTE)); - } - else - { - m_members = (T*)m_alloc->ArrayAlloc(m_size, sizeof(T)); - } + m_members = m_alloc.allocate(m_size); if (oldMembers != nullptr) { memcpy(m_members, oldMembers, oldSize * sizeof(T)); - m_alloc->Free(oldMembers); + m_alloc.deallocate(oldMembers); } InitializeRange(oldSize, m_size); } diff --git a/src/jit/jithashtable.h b/src/jit/jithashtable.h index e47fa04d358a..d411a2b87064 100644 --- a/src/jit/jithashtable.h +++ b/src/jit/jithashtable.h @@ -147,10 +147,8 @@ class JitHashTable // JitHashTable always starts out empty, with no allocation overhead. // Call Reallocate to prime with an initial size if desired. // - JitHashTable(Allocator* alloc) : m_alloc(alloc), m_table(nullptr), m_tableSizeInfo(), m_tableCount(0), m_tableMax(0) + JitHashTable(Allocator alloc) : m_alloc(alloc), m_table(nullptr), m_tableSizeInfo(), m_tableCount(0), m_tableMax(0) { - assert(m_alloc != nullptr); - #ifndef __GNUC__ // these crash GCC static_assert_no_msg(Behavior::s_growth_factor_numerator > Behavior::s_growth_factor_denominator); static_assert_no_msg(Behavior::s_density_factor_numerator < Behavior::s_density_factor_denominator); @@ -361,7 +359,7 @@ class JitHashTable pN = pNext; } } - m_alloc->Free(m_table); + m_alloc.deallocate(m_table); m_table = nullptr; m_tableSizeInfo = JitPrimeInfo(); @@ -391,7 +389,7 @@ class JitHashTable } // Get the allocator used by this hash table. - Allocator* GetAllocator() + Allocator GetAllocator() { return m_alloc; } @@ -513,7 +511,7 @@ class JitHashTable JitPrimeInfo newPrime = NextPrime(newTableSize); newTableSize = newPrime.prime; - Node** newTable = (Node**)m_alloc->ArrayAlloc(newTableSize, sizeof(Node*)); + Node** newTable = m_alloc.template allocate(newTableSize); for (unsigned i = 0; i < newTableSize; i++) { @@ -539,7 +537,7 @@ class JitHashTable if (m_table != nullptr) { - m_alloc->Free(m_table); + m_alloc.deallocate(m_table); } m_table = newTable; @@ -763,19 +761,19 @@ class JitHashTable { } - void* operator new(size_t sz, Allocator* alloc) + void* operator new(size_t sz, Allocator alloc) { - return alloc->Alloc(sz); + return alloc.template allocate(sz); } - void operator delete(void* p, Allocator* alloc) + void operator delete(void* p, Allocator alloc) { - alloc->Free(p); + alloc.deallocate(p); } }; // Instance members - Allocator* m_alloc; // Allocator to use in this table. + Allocator m_alloc; // Allocator to use in this table. Node** m_table; // pointer to table JitPrimeInfo m_tableSizeInfo; // size of table (a prime) and information about it unsigned m_tableCount; // number of elements in table diff --git a/src/jit/jitstd/allocator.h b/src/jit/jitstd/allocator.h index f370af8e9d24..a6a25deae45c 100644 --- a/src/jit/jitstd/allocator.h +++ b/src/jit/jitstd/allocator.h @@ -32,7 +32,7 @@ class allocator allocator(); public: - inline allocator(CompAllocator* pAlloc); + inline allocator(CompAllocator alloc); template inline allocator(const allocator& alloc); @@ -43,31 +43,31 @@ class allocator inline allocator& operator=(const allocator& alloc); private: - CompAllocator* m_pAlloc; + CompAllocator m_alloc; template friend class allocator; }; -allocator::allocator(CompAllocator* pAlloc) - : m_pAlloc(pAlloc) +allocator::allocator(CompAllocator alloc) + : m_alloc(alloc) { } allocator::allocator(const allocator& alloc) - : m_pAlloc(alloc.m_pAlloc) + : m_alloc(alloc.m_alloc) { } template allocator::allocator(const allocator& alloc) - : m_pAlloc(alloc.m_pAlloc) + : m_alloc(alloc.m_alloc) { } template allocator& allocator::operator=(const allocator& alloc) { - m_pAlloc = alloc.m_pAlloc; + m_alloc = alloc.m_alloc; return *this; } @@ -86,7 +86,7 @@ class allocator private: allocator(); public: - allocator(CompAllocator* pAlloc); + allocator(CompAllocator alloc); template allocator(const allocator& alloc); @@ -110,7 +110,7 @@ class allocator }; private: - CompAllocator* m_pAlloc; + CompAllocator m_alloc; template friend class allocator; }; @@ -122,21 +122,21 @@ namespace jitstd { template -allocator::allocator(CompAllocator* pAlloc) - : m_pAlloc(pAlloc) +allocator::allocator(CompAllocator alloc) + : m_alloc(alloc) { } template template allocator::allocator(const allocator& alloc) - : m_pAlloc(alloc.m_pAlloc) + : m_alloc(alloc.m_alloc) { } template allocator::allocator(const allocator& alloc) - : m_pAlloc(alloc.m_pAlloc) + : m_alloc(alloc.m_alloc) { } @@ -144,7 +144,7 @@ template template allocator& allocator::operator=(const allocator& alloc) { - m_pAlloc = alloc.m_pAlloc; + m_alloc = alloc.m_alloc; return *this; } @@ -163,7 +163,7 @@ typename allocator::const_pointer allocator::address(const_reference val) template T* allocator::allocate(size_type count, allocator::const_pointer hint) { - return (pointer) m_pAlloc->Alloc(sizeof(value_type) * count); + return m_alloc.allocate(count); } template @@ -175,7 +175,7 @@ void allocator::construct(pointer ptr, const_reference val) template void allocator::deallocate(pointer ptr, size_type size) { - // m_pAlloc->Free(ptr); + m_alloc.deallocate(ptr); } template diff --git a/src/jit/jitstd/utility.h b/src/jit/jitstd/utility.h index 80ce58e4d7ce..1930be8fbe3f 100644 --- a/src/jit/jitstd/utility.h +++ b/src/jit/jitstd/utility.h @@ -45,19 +45,6 @@ namespace utility }; - // Helper to allocate objects of any type, given an allocator of void type. - // - // @param alloc An allocator of void type used to create an allocator of type T. - // @param count The number of objects of type T that need to be allocated. - // - // @return A pointer to an object or an array of objects that was allocated. - template - inline - static T* allocate(jitstd::allocator& alloc, size_t count = 1) - { - return jitstd::allocator(alloc).allocate(count); - } - // Ensures that "wset" is the union of the initial state of "wset" and "rset". // Elements from "rset" that were not in "wset" are added to "cset." template diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp index 19dadfca0947..e72ae11cf5ca 100644 --- a/src/jit/lclvars.cpp +++ b/src/jit/lclvars.cpp @@ -40,6 +40,8 @@ void Compiler::lvaInit() lvaGenericsContextUseCount = 0; + lvaTrackedToVarNum = nullptr; + lvaSortAgain = false; // false: We don't need to call lvaSortOnly() lvaTrackedFixed = false; // false: We can still add new tracked variables @@ -79,9 +81,6 @@ void Compiler::lvaInit() lvaSIMDInitTempVarNum = BAD_VAR_NUM; #endif // FEATURE_SIMD lvaCurEpoch = 0; -#ifdef UNIX_AMD64_ABI - lvaFirstStackIncomingArgNum = BAD_VAR_NUM; -#endif // UNIX_AMD64_ABI } /*****************************************************************************/ @@ -144,7 +143,8 @@ void Compiler::lvaInitTypeRef() Compiler::structPassingKind howToReturnStruct; var_types returnType = getReturnTypeForStruct(retClsHnd, &howToReturnStruct); - if (howToReturnStruct == SPK_PrimitiveType) + // We can safely widen the return type for enclosed structs. + if ((howToReturnStruct == SPK_PrimitiveType) || (howToReturnStruct == SPK_EnclosingType)) { assert(returnType != TYP_UNKNOWN); assert(!varTypeIsStruct(returnType)); @@ -216,7 +216,7 @@ void Compiler::lvaInitTypeRef() lvaTableCnt = 16; } - lvaTable = (LclVarDsc*)compGetMemArray(lvaTableCnt, sizeof(*lvaTable), CMK_LvaTable); + lvaTable = getAllocator(CMK_LvaTable).allocate(lvaTableCnt); size_t tableSize = lvaTableCnt * sizeof(*lvaTable); memset(lvaTable, 0, tableSize); for (unsigned i = 0; i < lvaTableCnt; i++) @@ -588,8 +588,13 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) bool isHfaArg = false; var_types hfaType = TYP_UNDEF; +#if defined(_TARGET_ARM64_) && defined(_TARGET_UNIX_) + // Native varargs on arm64 unix use the regular calling convention. + if (!opts.compUseSoftFP) +#else // Methods that use VarArg or SoftFP cannot have HFA arguments if (!info.compIsVarArgs && !opts.compUseSoftFP) +#endif // defined(_TARGET_ARM64_) && defined(_TARGET_UNIX_) { // If the argType is a struct, then check if it is an HFA if (varTypeIsStruct(argType)) @@ -598,6 +603,18 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) isHfaArg = varTypeIsFloating(hfaType); } } + else if (info.compIsVarArgs) + { +#ifdef _TARGET_UNIX_ + // Currently native varargs is not implemented on non windows targets. + // + // Note that some targets like Arm64 Unix should not need much work as + // the ABI is the same. While other targets may only need small changes + // such as amd64 Unix, which just expects RAX to pass numFPArguments. + NYI("InitUserArgs for Vararg callee is not yet implemented on non Windows targets."); +#endif + } + if (isHfaArg) { // We have an HFA argument, so from here on out treat the type as a float or double. @@ -612,6 +629,24 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) // it enregistered, as long as we can split the rest onto the stack. unsigned cSlotsToEnregister = cSlots; +#if defined(_TARGET_ARM64_) && FEATURE_ARG_SPLIT + + // On arm64 Windows we will need to properly handle the case where a >8byte <=16byte + // struct is split between register r7 and virtual stack slot s[0] + // We will only do this for calls to vararg methods on Windows Arm64 + // + // !!This does not affect the normal arm64 calling convention or Unix Arm64!! + if (this->info.compIsVarArgs && argType == TYP_STRUCT) + { + if (varDscInfo->canEnreg(TYP_INT, 1) && // The beginning of the struct can go in a register + !varDscInfo->canEnreg(TYP_INT, cSlots)) // The end of the struct can't fit in a register + { + cSlotsToEnregister = 1; // Force the split + } + } + +#endif // defined(_TARGET_ARM64_) && FEATURE_ARG_SPLIT + #ifdef _TARGET_ARM_ // On ARM we pass the first 4 words of integer arguments and non-HFA structs in registers. // But we pre-spill user arguments in varargs methods and structs. @@ -629,6 +664,8 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) // arguments passed in the integer registers but get homed immediately after the prolog. if (!isHfaArg) { + // TODO-Arm32-Windows: vararg struct should be forced to split like + // ARM64 above. cSlotsToEnregister = 1; // HFAs must be totally enregistered or not, but other structs can be split. preSpill = true; } @@ -841,8 +878,6 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) printf("Arg #%u passed in register(s) ", varDscInfo->varNum); bool isFloat = false; #if defined(UNIX_AMD64_ABI) - // In case of one eightbyte struct the type is already normalized earlier. - // The varTypeIsFloating(argType) is good for this case. if (varTypeIsStruct(argType) && (structDesc.eightByteCount >= 1)) { isFloat = varTypeIsFloating(firstEightByteType); @@ -883,6 +918,7 @@ void Compiler::lvaInitUserArgs(InitVarDscInfo* varDscInfo) else #endif // defined(UNIX_AMD64_ABI) { + isFloat = varTypeIsFloating(argType); unsigned regArgNum = genMapRegNumToRegArgNum(varDsc->lvArgReg, argType); for (unsigned ix = 0; ix < cSlots; ix++, regArgNum++) @@ -1252,6 +1288,10 @@ void Compiler::lvaInitVarDsc(LclVarDsc* varDsc, if ((varTypeIsStruct(type))) { lvaSetStruct(varNum, typeHnd, typeHnd != nullptr, !tiVerificationNeeded); + if (info.compIsVarArgs) + { + lvaSetStructUsedAsVarArg(varNum); + } } else { @@ -1859,7 +1899,7 @@ bool Compiler::lvaShouldPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo #if FEATURE_MULTIREG_STRUCT_PROMOTE // Is this a variable holding a value with exactly two fields passed in // multiple registers? - if ((structPromotionInfo->fieldCnt != 2) && lvaIsMultiregStruct(varDsc)) + if ((structPromotionInfo->fieldCnt != 2) && lvaIsMultiregStruct(varDsc, this->info.compIsVarArgs)) { JITDUMP("Not promoting multireg struct local V%02u, because lvIsParam is true and #fields != 2\n", lclNum); shouldPromote = false; @@ -1974,7 +2014,7 @@ void Compiler::lvaPromoteStructVar(unsigned lclNum, lvaStructPromotionInfo* Stru fieldVarDsc->lvArgReg = varDsc->lvArgReg; fieldVarDsc->setPrefReg(varDsc->lvArgReg, this); // Set the preferred register #if FEATURE_MULTIREG_ARGS && defined(FEATURE_SIMD) - if (varTypeIsSIMD(fieldVarDsc)) + if (varTypeIsSIMD(fieldVarDsc) && !lvaIsImplicitByRefLocal(lclNum)) { // This field is a SIMD type, and will be considered to be passed in multiple registers // if the parent struct was. Note that this code relies on the fact that if there is @@ -2030,7 +2070,7 @@ void Compiler::lvaPromoteLongVars() { LclVarDsc* varDsc = &lvaTable[lclNum]; if (!varTypeIsLong(varDsc) || varDsc->lvDoNotEnregister || varDsc->lvIsMultiRegArgOrRet() || - (varDsc->lvRefCnt == 0) || varDsc->lvIsStructField || (fgNoStructPromotion && varDsc->lvIsParam)) + (varDsc->lvRefCnt() == 0) || varDsc->lvIsStructField || (fgNoStructPromotion && varDsc->lvIsParam)) { continue; } @@ -2224,14 +2264,14 @@ void Compiler::lvaSetVarDoNotEnregister(unsigned varNum DEBUGARG(DoNotEnregister } // Returns true if this local var is a multireg struct -bool Compiler::lvaIsMultiregStruct(LclVarDsc* varDsc) +bool Compiler::lvaIsMultiregStruct(LclVarDsc* varDsc, bool isVarArg) { if (varTypeIsStruct(varDsc->TypeGet())) { CORINFO_CLASS_HANDLE clsHnd = varDsc->lvVerTypeInfo.GetClassHandleForValueClass(); structPassingKind howToPassStruct; - var_types type = getArgTypeForStruct(clsHnd, &howToPassStruct, varDsc->lvExactSize); + var_types type = getArgTypeForStruct(clsHnd, &howToPassStruct, isVarArg, varDsc->lvExactSize); if (howToPassStruct == SPK_ByValueAsHfa) { @@ -2276,7 +2316,7 @@ void Compiler::lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool size_t lvSize = varDsc->lvSize(); assert((lvSize % TARGET_POINTER_SIZE) == 0); // The struct needs to be a multiple of TARGET_POINTER_SIZE bytes for getClassGClayout() to be valid. - varDsc->lvGcLayout = (BYTE*)compGetMem((lvSize / TARGET_POINTER_SIZE) * sizeof(BYTE), CMK_LvaTable); + varDsc->lvGcLayout = getAllocator(CMK_LvaTable).allocate(lvSize / TARGET_POINTER_SIZE); unsigned numGCVars; var_types simdBaseType = TYP_UNKNOWN; varDsc->lvType = impNormStructType(typeHnd, varDsc->lvGcLayout, &numGCVars, &simdBaseType); @@ -2354,6 +2394,30 @@ void Compiler::lvaSetStruct(unsigned varNum, CORINFO_CLASS_HANDLE typeHnd, bool } } +//------------------------------------------------------------------------ +// lvaSetStructUsedAsVarArg: update hfa information for vararg struct args +// +// Arguments: +// varNum -- number of the variable +// +// Notes: +// This only affects arm64 varargs on windows where we need to pass +// hfa arguments as if they are not HFAs. +// +// This function should only be called if the struct is used in a varargs +// method. + +void Compiler::lvaSetStructUsedAsVarArg(unsigned varNum) +{ +#if defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + LclVarDsc* varDsc = &lvaTable[varNum]; + // For varargs methods incoming and outgoing arguments should not be treated + // as HFA. + varDsc->_lvIsHfa = false; + varDsc->_lvHfaTypeIsFloat = false; +#endif // defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) +} + //------------------------------------------------------------------------ // lvaSetClass: set class information for a local var. // @@ -2941,8 +3005,8 @@ int __cdecl Compiler::RefCntCmp(const void* op1, const void* op2) return (dsc2->lvTracked) ? +1 : -1; } - unsigned weight1 = dsc1->lvRefCnt; - unsigned weight2 = dsc2->lvRefCnt; + unsigned weight1 = dsc1->lvRefCnt(); + unsigned weight2 = dsc2->lvRefCnt(); #ifndef _TARGET_ARM_ // ARM-TODO: this was disabled for ARM under !FEATURE_FP_REGALLOC; it was probably a left-over from @@ -2975,7 +3039,7 @@ int __cdecl Compiler::RefCntCmp(const void* op1, const void* op2) /* The unweighted ref counts were the same */ /* If the weighted ref counts are different then use their difference */ - diff = dsc2->lvRefCntWtd - dsc1->lvRefCntWtd; + diff = dsc2->lvRefCntWtd() - dsc1->lvRefCntWtd(); if (diff != 0) { @@ -3081,8 +3145,8 @@ int __cdecl Compiler::WtdRefCntCmp(const void* op1, const void* op2) return (dsc2->lvTracked) ? +1 : -1; } - unsigned weight1 = dsc1->lvRefCntWtd; - unsigned weight2 = dsc2->lvRefCntWtd; + unsigned weight1 = dsc1->lvRefCntWtd(); + unsigned weight2 = dsc2->lvRefCntWtd(); #ifndef _TARGET_ARM_ // ARM-TODO: this was disabled for ARM under !FEATURE_FP_REGALLOC; it was probably a left-over from @@ -3145,7 +3209,7 @@ int __cdecl Compiler::WtdRefCntCmp(const void* op1, const void* op2) // Otherwise, we have equal weighted ref counts. /* If the unweighted ref counts are different then use their difference */ - int diff = (int)dsc2->lvRefCnt - (int)dsc1->lvRefCnt; + int diff = (int)dsc2->lvRefCnt() - (int)dsc1->lvRefCnt(); if (diff != 0) { @@ -3224,12 +3288,12 @@ void Compiler::lvaDumpRefCounts() for (unsigned lclNum = 0; lclNum < lvaCount; lclNum++) { - unsigned refCnt = lvaRefSorted[lclNum]->lvRefCnt; + unsigned refCnt = lvaRefSorted[lclNum]->lvRefCnt(); if (refCnt == 0) { break; } - unsigned refCntWtd = lvaRefSorted[lclNum]->lvRefCntWtd; + unsigned refCntWtd = lvaRefSorted[lclNum]->lvRefCntWtd(); printf(" "); gtDispLclVar((unsigned)(lvaRefSorted[lclNum] - lvaTable)); @@ -3310,11 +3374,11 @@ void Compiler::lvaSortByRefCount() varDsc->lvTracked = 1; /* If the ref count is zero */ - if (varDsc->lvRefCnt == 0) + if (varDsc->lvRefCnt() == 0) { /* Zero ref count, make this untracked */ - varDsc->lvTracked = 0; - varDsc->lvRefCntWtd = 0; + varDsc->lvTracked = 0; + varDsc->setLvRefCntWtd(0); } #if !defined(_TARGET_64BIT_) @@ -3446,9 +3510,14 @@ void Compiler::lvaSortByRefCount() } } + if (lvaTrackedToVarNum == nullptr) + { + lvaTrackedToVarNum = new (getAllocator(CMK_LvaTable)) unsigned[lclMAX_TRACKED]; + } + #ifdef DEBUG // Re-Initialize to -1 for safety in debug build. - memset(lvaTrackedToVarNum, -1, sizeof(lvaTrackedToVarNum)); + memset(lvaTrackedToVarNum, -1, lclMAX_TRACKED * sizeof(unsigned)); #endif /* Assign indices to all the variables we've decided to track */ @@ -3458,7 +3527,7 @@ void Compiler::lvaSortByRefCount() varDsc = lvaRefSorted[lclNum]; if (varDsc->lvTracked) { - noway_assert(varDsc->lvRefCnt > 0); + noway_assert(varDsc->lvRefCnt() > 0); /* This variable will be tracked - assign it an index */ @@ -3959,8 +4028,8 @@ void Compiler::lvaMarkLocalVars() /* Set the refCnt, it is used in the prolog and return block(s) */ - lvaTable[info.compLvFrameListRoot].lvRefCnt = 2; - lvaTable[info.compLvFrameListRoot].lvRefCntWtd = 2 * BB_UNITY_WEIGHT; + lvaTable[info.compLvFrameListRoot].setLvRefCnt(2); + lvaTable[info.compLvFrameListRoot].setLvRefCntWtd(2 * BB_UNITY_WEIGHT); } } @@ -4063,7 +4132,7 @@ void Compiler::lvaMarkLocalVars() break; // early exit for loop } - if ((varDsc->lvIsRegArg) && (varDsc->lvRefCnt > 0)) + if ((varDsc->lvIsRegArg) && (varDsc->lvRefCnt() > 0)) { // Fix 388376 ARM JitStress WP7 varDsc->incRefCnts(BB_UNITY_WEIGHT, this); @@ -4079,16 +4148,16 @@ void Compiler::lvaMarkLocalVars() } #endif - if (lvaKeepAliveAndReportThis() && lvaTable[0].lvRefCnt == 0) + if (lvaKeepAliveAndReportThis() && lvaTable[0].lvRefCnt() == 0) { - lvaTable[0].lvRefCnt = 1; + lvaTable[0].setLvRefCnt(1); // This isn't strictly needed as we will make a copy of the param-type-arg // in the prolog. However, this ensures that the LclVarDsc corresponding to // info.compTypeCtxtArg is valid. } - else if (lvaReportParamTypeArg() && lvaTable[info.compTypeCtxtArg].lvRefCnt == 0) + else if (lvaReportParamTypeArg() && lvaTable[info.compTypeCtxtArg].lvRefCnt() == 0) { - lvaTable[info.compTypeCtxtArg].lvRefCnt = 1; + lvaTable[info.compTypeCtxtArg].setLvRefCnt(1); } lvaLocalVarRefCounted = true; @@ -4111,8 +4180,8 @@ void Compiler::lvaAllocOutgoingArgSpaceVar() /* Set the refCnts */ - lvaTable[lvaOutgoingArgSpaceVar].lvRefCnt = 1; - lvaTable[lvaOutgoingArgSpaceVar].lvRefCntWtd = BB_UNITY_WEIGHT; + lvaTable[lvaOutgoingArgSpaceVar].setLvRefCnt(1); + lvaTable[lvaOutgoingArgSpaceVar].setLvRefCntWtd(BB_UNITY_WEIGHT); } noway_assert(lvaOutgoingArgSpaceVar >= info.compLocalsCount && lvaOutgoingArgSpaceVar < lvaCount); @@ -4164,7 +4233,7 @@ unsigned Compiler::lvaGetMaxSpillTempSize() if (lvaDoneFrameLayout >= REGALLOC_FRAME_LAYOUT) { - result = tmpSize; + result = codeGen->regSet.tmpGetTotalSize(); } else { @@ -4733,8 +4802,8 @@ void Compiler::lvaFixVirtualFrameOffsets() } } - assert(tmpAllFree()); - for (TempDsc* temp = tmpListBeg(); temp != nullptr; temp = tmpListNxt(temp)) + assert(codeGen->regSet.tmpAllFree()); + for (TempDsc* temp = codeGen->regSet.tmpListBeg(); temp != nullptr; temp = codeGen->regSet.tmpListNxt(temp)) { temp->tdAdjustTempOffs(delta); } @@ -5169,6 +5238,20 @@ int Compiler::lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, argOffs += TARGET_POINTER_SIZE; #elif defined(_TARGET_ARM64_) // Register arguments on ARM64 only take stack space when they have a frame home. +// Unless on windows and in a vararg method. +#if FEATURE_ARG_SPLIT + if (this->info.compIsVarArgs) + { + if (varDsc->lvType == TYP_STRUCT && varDsc->lvOtherArgReg >= MAX_REG_ARG && varDsc->lvOtherArgReg != REG_NA) + { + // This is a split struct. It will account for an extra (8 bytes) + // of alignment. + varDsc->lvStkOffs += TARGET_POINTER_SIZE; + argOffs += TARGET_POINTER_SIZE; + } + } +#endif // FEATURE_ARG_SPLIT + #elif defined(_TARGET_ARM_) // On ARM we spill the registers in codeGen->regSet.rsMaskPreSpillRegArg // in the prolog, so we have to fill in lvStkOffs here @@ -5829,13 +5912,14 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals() } #ifdef _TARGET_ARM64_ - if (info.compIsVarArgs) + if (info.compIsVarArgs && varDsc->lvArgReg != theFixedRetBuffArgNum()) { // Stack offset to varargs (parameters) should point to home area which will be preallocated. varDsc->lvStkOffs = -initialStkOffs + genMapIntRegNumToRegArgNum(varDsc->GetArgReg()) * REGSIZE_BYTES; continue; } + #endif #ifdef _TARGET_ARM_ @@ -6396,7 +6480,7 @@ void Compiler::lvaAssignFrameOffsetsToPromotedStructs() else { varDsc->lvOnFrame = false; - noway_assert(varDsc->lvRefCnt == 0); + noway_assert(varDsc->lvRefCnt() == 0); } } } @@ -6435,11 +6519,11 @@ int Compiler::lvaAllocateTemps(int stkOffs, bool mustDoubleAlign) assignDone = true; } - assert(tmpAllFree()); + assert(codeGen->regSet.tmpAllFree()); AGAIN2: - for (TempDsc* temp = tmpListBeg(); temp != nullptr; temp = tmpListNxt(temp)) + for (TempDsc* temp = codeGen->regSet.tmpListBeg(); temp != nullptr; temp = codeGen->regSet.tmpListNxt(temp)) { var_types tempType = temp->tdTempType(); unsigned size; @@ -6618,7 +6702,7 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r } else { - if (varDsc->lvRefCnt == 0) + if (varDsc->lvRefCnt() == 0) { // Print this with a special indicator that the variable is unused. Even though the // variable itself is unused, it might be a struct that is promoted, so seeing it @@ -6653,7 +6737,7 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r printf(" ]"); } - printf(" (%3u,%*s)", varDsc->lvRefCnt, (int)refCntWtdWidth, refCntWtd2str(varDsc->lvRefCntWtd)); + printf(" (%3u,%*s)", varDsc->lvRefCnt(), (int)refCntWtdWidth, refCntWtd2str(varDsc->lvRefCntWtd())); printf(" %7s ", varTypeName(type)); if (genTypeSize(type) == 0) @@ -6666,7 +6750,7 @@ void Compiler::lvaDumpEntry(unsigned lclNum, FrameLayoutState curState, size_t r } // The register or stack location field is 11 characters wide. - if (varDsc->lvRefCnt == 0) + if (varDsc->lvRefCnt() == 0) { printf("zero-ref "); } @@ -6903,7 +6987,7 @@ void Compiler::lvaTableDump(FrameLayoutState curState) { for (lclNum = 0, varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++) { - size_t width = strlen(refCntWtd2str(varDsc->lvRefCntWtd)); + size_t width = strlen(refCntWtd2str(varDsc->lvRefCntWtd())); if (width > refCntWtdWidth) { refCntWtdWidth = width; @@ -6921,8 +7005,8 @@ void Compiler::lvaTableDump(FrameLayoutState curState) //------------------------------------------------------------------------- // Display the code-gen temps - assert(tmpAllFree()); - for (TempDsc* temp = tmpListBeg(); temp != nullptr; temp = tmpListNxt(temp)) + assert(codeGen->regSet.tmpAllFree()); + for (TempDsc* temp = codeGen->regSet.tmpListBeg(); temp != nullptr; temp = codeGen->regSet.tmpListNxt(temp)) { printf("; TEMP_%02u %26s%*s%7s -> ", -temp->tdTempNum(), " ", refCntWtdWidth, " ", varTypeName(temp->tdTempType())); diff --git a/src/jit/lir.cpp b/src/jit/lir.cpp index 5a05e23c8e38..0ba18a2d6df4 100644 --- a/src/jit/lir.cpp +++ b/src/jit/lir.cpp @@ -171,7 +171,7 @@ void LIR::Use::AssertIsValid() const // /--* t18 int // * jmpTrue void // -// Elminating the now-dead compare and its operands using `LIR::Range::Remove` +// Eliminating the now-dead compare and its operands using `LIR::Range::Remove` // would then give us: // // t18 = const int 1 @@ -1435,7 +1435,7 @@ class CheckLclVarSemanticsHelper CheckLclVarSemanticsHelper(Compiler* compiler, const LIR::Range* range, SmallHashTable& unusedDefs) - : compiler(compiler), range(range), unusedDefs(unusedDefs), unusedLclVarReads(compiler) + : compiler(compiler), range(range), unusedDefs(unusedDefs), unusedLclVarReads(compiler->getAllocator()) { } @@ -1572,7 +1572,7 @@ bool LIR::Range::CheckLIR(Compiler* compiler, bool checkUnusedValues) const slowNode = slowNode->gtNext; } - SmallHashTable unusedDefs(compiler); + SmallHashTable unusedDefs(compiler->getAllocator()); bool pastPhis = false; GenTree* prev = nullptr; diff --git a/src/jit/liveness.cpp b/src/jit/liveness.cpp index a959358db5b3..3c34681daa92 100644 --- a/src/jit/liveness.cpp +++ b/src/jit/liveness.cpp @@ -31,11 +31,11 @@ void Compiler::fgMarkUseDef(GenTreeLclVarCommon* tree) LclVarDsc* const varDsc = &lvaTable[lclNum]; // We should never encounter a reference to a lclVar that has a zero refCnt. - if (varDsc->lvRefCnt == 0 && (!varTypeIsPromotable(varDsc) || !varDsc->lvPromoted)) + if (varDsc->lvRefCnt() == 0 && (!varTypeIsPromotable(varDsc) || !varDsc->lvPromoted)) { JITDUMP("Found reference to V%02u with zero refCnt.\n", lclNum); assert(!"We should never encounter a reference to a lclVar that has a zero refCnt."); - varDsc->lvRefCnt = 1; + varDsc->setLvRefCnt(1); } const bool isDef = (tree->gtFlags & GTF_VAR_DEF) != 0; @@ -1047,9 +1047,9 @@ void Compiler::fgExtendDbgLifetimes() unsigned lclNum = 0; for (LclVarDsc *varDsc = lvaTable; lclNum < lvaCount; lclNum++, varDsc++) { - if (varDsc->lvRefCnt == 0 && varDsc->lvIsRegArg) + if (varDsc->lvRefCnt() == 0 && varDsc->lvIsRegArg) { - varDsc->lvRefCnt = 1; + varDsc->setLvRefCnt(1); } } @@ -2511,9 +2511,6 @@ void Compiler::fgInterBlockLocalVarLiveness() * Now fill in liveness info within each basic block - Backward DataFlow */ - // This is used in the liveness computation, as a temporary. - VarSetOps::AssignNoCopy(this, fgMarkIntfUnionVS, VarSetOps::MakeEmpty(this)); - for (block = fgFirstBB; block; block = block->bbNext) { /* Tell everyone what block we're working on */ diff --git a/src/jit/loopcloning.cpp b/src/jit/loopcloning.cpp index 5eea37c51ee5..f741ff81b7b9 100644 --- a/src/jit/loopcloning.cpp +++ b/src/jit/loopcloning.cpp @@ -43,7 +43,7 @@ GenTree* LC_Array::ToGenTree(Compiler* comp) // If asked for arrlen invoke arr length operator. if (oper == ArrLen) { - GenTree* arrLen = comp->gtNewArrLen(TYP_INT, arr, offsetof(CORINFO_Array, length)); + GenTree* arrLen = comp->gtNewArrLen(TYP_INT, arr, OFFSETOF__CORINFO_Array__length); return arrLen; } else @@ -789,7 +789,7 @@ void LC_Deref::DeriveLevelConditions(JitExpandArrayStack* children, unsigned lcl); void DeriveLevelConditions(JitExpandArrayStack*>* len); @@ -560,7 +560,7 @@ struct LC_Deref */ struct LoopCloneContext { - CompAllocator* alloc; // The allocator + CompAllocator alloc; // The allocator JitExpandArrayStack** optInfo; // The array of optimization opportunities found in each loop. (loop x // optimization-opportunities) JitExpandArrayStack** conditions; // The array of conditions that influence which path to take for @@ -572,7 +572,7 @@ struct LoopCloneContext // conditions for // each loop. (loop x level x conditions) - LoopCloneContext(unsigned loopCount, CompAllocator* alloc) : alloc(alloc) + LoopCloneContext(unsigned loopCount, CompAllocator alloc) : alloc(alloc) { optInfo = new (alloc) JitExpandArrayStack*[loopCount]; conditions = new (alloc) JitExpandArrayStack*[loopCount]; diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index 6671aa6d6e3a..1c4cc1a9b16d 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -269,6 +269,13 @@ GenTree* Lowering::LowerNode(GenTree* node) break; #endif // FEATURE_HW_INTRINSICS + case GT_LCL_FLD: + { + // We should only encounter this for lclVars that are lvDoNotEnregister. + verifyLclFldDoNotEnregister(node->AsLclVarCommon()->gtLclNum); + break; + } + case GT_LCL_VAR: WidenSIMD12IfNecessary(node->AsLclVarCommon()); break; @@ -329,6 +336,16 @@ GenTree* Lowering::LowerNode(GenTree* node) break; #endif +#ifndef _TARGET_ARM_ + // TODO-ARM-CQ: We should contain this as long as the offset fits. + case GT_OBJ: + if (node->AsObj()->Addr()->OperIsLocalAddr()) + { + node->AsObj()->Addr()->SetContained(); + } + break; +#endif // !_TARGET_ARM_ + default: break; } @@ -462,10 +479,10 @@ GenTree* Lowering::LowerSwitch(GenTree* node) // the result of the child subtree to a temp. GenTree* rhs = node->gtOp.gtOp1; - unsigned lclNum = comp->lvaGrabTemp(true DEBUGARG("Lowering is creating a new local variable")); - comp->lvaSortAgain = true; - comp->lvaTable[lclNum].lvType = rhs->TypeGet(); - comp->lvaTable[lclNum].lvRefCnt = 1; + unsigned lclNum = comp->lvaGrabTemp(true DEBUGARG("Lowering is creating a new local variable")); + comp->lvaSortAgain = true; + comp->lvaTable[lclNum].lvType = rhs->TypeGet(); + comp->lvaTable[lclNum].setLvRefCnt(1); GenTreeLclVar* store = new (comp, GT_STORE_LCL_VAR) GenTreeLclVar(GT_STORE_LCL_VAR, rhs->TypeGet(), lclNum, BAD_IL_OFFSET); @@ -800,8 +817,8 @@ GenTree* Lowering::LowerSwitch(GenTree* node) // If the jump table contains less than 32 (64 on 64 bit targets) entries and there // are at most 2 distinct jump targets then the jump table can be converted to a word // of bits where a 0 bit corresponds to one jump target and a 1 bit corresponds to the -// other jump target. Instead of the indirect jump a BT-JCC sequnce is used to jump -// to the appropiate target: +// other jump target. Instead of the indirect jump a BT-JCC sequence is used to jump +// to the appropriate target: // mov eax, 245 ; jump table converted to a "bit table" // bt eax, ebx ; ebx is supposed to contain the switch value // jc target1 @@ -1007,22 +1024,11 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf bool updateArgTable = true; bool isOnStack = true; -#ifdef UNIX_AMD64_ABI - if (varTypeIsStruct(type)) - { - isOnStack = !info->structDesc.passedInRegisters; - } - else - { - isOnStack = info->regNum == REG_STK; - } -#else // !UNIX_AMD64_ABI - isOnStack = info->regNum == REG_STK; -#endif // !UNIX_AMD64_ABI + isOnStack = info->regNum == REG_STK; #ifdef _TARGET_ARMARCH_ // Mark contained when we pass struct - // GT_FIELD_LIST is always marked conatained when it is generated + // GT_FIELD_LIST is always marked contained when it is generated if (type == TYP_STRUCT) { arg->SetContained(); @@ -1033,7 +1039,7 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf } #endif -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT // Struct can be split into register(s) and stack on ARM if (info->isSplit) { @@ -1041,19 +1047,25 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf // TODO: Need to check correctness for FastTailCall if (call->IsFastTailCall()) { +#ifdef _TARGET_ARM_ NYI_ARM("lower: struct argument by fast tail call"); +#endif // _TARGET_ARM_ } putArg = new (comp, GT_PUTARG_SPLIT) GenTreePutArgSplit(arg, info->slotNum PUT_STRUCT_ARG_STK_ONLY_ARG(info->numSlots), info->numRegs, call->IsFastTailCall(), call); - putArg->gtRegNum = info->regNum; // If struct argument is morphed to GT_FIELD_LIST node(s), // we can know GC info by type of each GT_FIELD_LIST node. // So we skip setting GC Pointer info. // GenTreePutArgSplit* argSplit = putArg->AsPutArgSplit(); + for (unsigned regIndex = 0; regIndex < info->numRegs; regIndex++) + { + argSplit->SetRegNumByIdx(info->getRegNum(regIndex), regIndex); + } + if (arg->OperGet() == GT_OBJ) { BYTE* gcLayout = nullptr; @@ -1094,138 +1106,21 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf } } else -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT { if (!isOnStack) { -#if defined(UNIX_AMD64_ABI) - if (info->isStruct) - { - // The following code makes sure a register passed struct arg is moved to - // the register before the call is made. - // There are two cases (comments added in the code below.) - // 1. The struct is of size one eightbyte: - // In this case a new tree is created that is GT_PUTARG_REG - // with a op1 the original argument. - // 2. The struct is contained in 2 eightbytes: - // in this case the arg comes as a GT_FIELD_LIST of two GT_LCL_FLDs - // - the two eightbytes of the struct. - // The code creates a GT_PUTARG_REG node for each GT_LCL_FLD in the GT_FIELD_LIST - // and splices it in the list with the corresponding original GT_LCL_FLD tree as op1. - - assert(info->structDesc.eightByteCount != 0); - - if (info->structDesc.eightByteCount == 1) - { - // clang-format off - // Case 1 above: Create a GT_PUTARG_REG node with op1 of the original tree. - // - // Here the IR for this operation: - // lowering call : - // N001(3, 2)[000017] ------ - N---- / --* &lclVar byref V00 loc0 - // N003(6, 5)[000052] * --XG------ - / --* indir int - // N004(3, 2)[000046] ------ - N---- + --* &lclVar byref V02 tmp0 - // (13, 11)[000070] -- - XG-- - R-- - arg0 in out + 00 / --* storeIndir int - // N009(3, 4)[000054] ------ - N----arg0 in rdi + --* lclFld int V02 tmp0[+0](last use) - // N011(33, 21)[000018] --CXG------ - *call void Test.Foo.test1 - // - // args : - // lowering arg : (13, 11)[000070] -- - XG-- - R-- - *storeIndir int - // - // late : - // lowering arg : N009(3, 4)[000054] ------ - N---- * lclFld int V02 tmp0[+0](last use) - // new node is : (3, 4)[000071] ------------ * putarg_reg int RV - // - // after : - // N001(3, 2)[000017] ------ - N---- / --* &lclVar byref V00 loc0 - // N003(6, 5)[000052] * --XG------ - / --* indir int - // N004(3, 2)[000046] ------ - N---- + --* &lclVar byref V02 tmp0 - // (13, 11)[000070] -- - XG-- - R-- - arg0 in out + 00 / --* storeIndir int - // N009(3, 4)[000054] ------ - N---- | / --* lclFld int V02 tmp0[+0](last use) - // (3, 4)[000071] ------------arg0 in rdi + --* putarg_reg int RV - // N011(33, 21)[000018] --CXG------ - *call void Test.Foo.test1 - // - // clang-format on - - putArg = comp->gtNewPutArgReg(type, arg, info->regNum); - } - else if (info->structDesc.eightByteCount == 2) - { - // clang-format off - // Case 2 above: Convert the LCL_FLDs to PUTARG_REG - // - // lowering call : - // N001(3, 2) [000025] ------ - N----Source / --* &lclVar byref V01 loc1 - // N003(3, 2) [000056] ------ - N----Destination + --* &lclVar byref V03 tmp1 - // N006(1, 1) [000058] ------------ + --* const int 16 - // N007(12, 12)[000059] - A--G---- - L - arg0 SETUP / --* copyBlk void - // N009(3, 4) [000061] ------ - N----arg0 in rdi + --* lclFld long V03 tmp1[+0] - // N010(3, 4) [000063] ------------arg0 in rsi + --* lclFld long V03 tmp1[+8](last use) - // N014(40, 31)[000026] --CXG------ - *call void Test.Foo.test2 - // - // args : - // lowering arg : N007(12, 12)[000059] - A--G---- - L - *copyBlk void - // - // late : - // lowering arg : N012(11, 13)[000065] ------------ * struct - // - // after : - // N001(3, 2)[000025] ------ - N----Source / --* &lclVar byref V01 loc1 - // N003(3, 2)[000056] ------ - N----Destination + --* &lclVar byref V03 tmp1 - // N006(1, 1)[000058] ------------ + --* const int 16 - // N007(12, 12)[000059] - A--G---- - L - arg0 SETUP / --* copyBlk void - // N009(3, 4)[000061] ------ - N---- | / --* lclFld long V03 tmp1[+0] - // (3, 4)[000072] ------------arg0 in rdi + --* putarg_reg long - // N010(3, 4)[000063] ------------ | / --* lclFld long V03 tmp1[+8](last use) - // (3, 4)[000073] ------------arg0 in rsi + --* putarg_reg long - // N014(40, 31)[000026] --CXG------ - *call void Test.Foo.test2 - // - // clang-format on - - assert(arg->OperGet() == GT_FIELD_LIST); - - GenTreeFieldList* fieldListPtr = arg->AsFieldList(); - assert(fieldListPtr->IsFieldListHead()); - - for (unsigned ctr = 0; fieldListPtr != nullptr; fieldListPtr = fieldListPtr->Rest(), ctr++) - { - // Create a new GT_PUTARG_REG node with op1 the original GT_LCL_FLD. - GenTree* newOper = comp->gtNewPutArgReg( - comp->GetTypeFromClassificationAndSizes(info->structDesc.eightByteClassifications[ctr], - info->structDesc.eightByteSizes[ctr]), - fieldListPtr->gtOp.gtOp1, (ctr == 0) ? info->regNum : info->otherRegNum); - - // Splice in the new GT_PUTARG_REG node in the GT_FIELD_LIST - ReplaceArgWithPutArgOrBitcast(&fieldListPtr->gtOp.gtOp1, newOper); - - // Initialize all the gtRegNum's since the list won't be traversed in an LIR traversal. - fieldListPtr->gtRegNum = REG_NA; - } - - // Just return arg. The GT_FIELD_LIST is not replaced. - // Nothing more to do. - return arg; - } - else - { - assert(false && "Illegal count of eightbytes for the CLR type system"); // No more than 2 eightbytes - // for the CLR. - } - } - else -#else // not defined(UNIX_AMD64_ABI) #if FEATURE_MULTIREG_ARGS if ((info->numRegs > 1) && (arg->OperGet() == GT_FIELD_LIST)) { assert(arg->OperGet() == GT_FIELD_LIST); - GenTreeFieldList* fieldListPtr = arg->AsFieldList(); - assert(fieldListPtr->IsFieldListHead()); - - // There could be up to 2-4 PUTARG_REGs in the list (3 or 4 can only occur for HFAs) - regNumber argReg = info->regNum; - for (unsigned ctr = 0; fieldListPtr != nullptr; fieldListPtr = fieldListPtr->Rest(), ctr++) + assert(arg->AsFieldList()->IsFieldListHead()); + unsigned int regIndex = 0; + for (GenTreeFieldList* fieldListPtr = arg->AsFieldList(); fieldListPtr != nullptr; + fieldListPtr = fieldListPtr->Rest()) { + regNumber argReg = info->getRegNum(regIndex); GenTree* curOp = fieldListPtr->gtOp.gtOp1; var_types curTyp = curOp->TypeGet(); @@ -1234,17 +1129,8 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf // Splice in the new GT_PUTARG_REG node in the GT_FIELD_LIST ReplaceArgWithPutArgOrBitcast(&fieldListPtr->gtOp.gtOp1, newOper); + regIndex++; - // Update argReg for the next putarg_reg (if any) - argReg = genRegArgNext(argReg); - -#if defined(_TARGET_ARM_) - // A double register is modelled as an even-numbered single one - if (fieldListPtr->Current()->TypeGet() == TYP_DOUBLE) - { - argReg = genRegArgNext(argReg); - } -#endif // _TARGET_ARM_ // Initialize all the gtRegNum's since the list won't be traversed in an LIR traversal. fieldListPtr->gtRegNum = REG_NA; } @@ -1255,7 +1141,6 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf } else #endif // FEATURE_MULTIREG_ARGS -#endif // not defined(UNIX_AMD64_ABI) { putArg = comp->gtNewPutArgReg(type, arg, info->regNum); } @@ -1270,7 +1155,7 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf // a result. So the type of its operand must be the correct type to push on the stack. // For a FIELD_LIST, this will be the type of the field (not the type of the arg), // but otherwise it is generally the type of the operand. - PUT_STRUCT_ARG_STK_ONLY(assert(info->isStruct == varTypeIsStruct(type))); + info->checkIsStruct(); if ((arg->OperGet() != GT_FIELD_LIST)) { #if defined(FEATURE_SIMD) && defined(FEATURE_PUT_STRUCT_ARG_STK) @@ -1300,13 +1185,13 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf // pair copying using XMM registers or rep mov instructions. if (info->isStruct) { - // We use GT_OBJ for non-SIMD struct arguments. However, for - // SIMD arguments the GT_OBJ has already been transformed. - if (arg->gtOper != GT_OBJ) + // We use GT_OBJ only for non-lclVar, non-SIMD, non-FIELD_LIST struct arguments. + if (arg->OperIsLocal()) { - assert(varTypeIsSIMD(arg)); + // This must have a type with a known size (SIMD or has been morphed to a primitive type). + assert(arg->TypeGet() != TYP_STRUCT); } - else + else if (arg->OperIs(GT_OBJ)) { unsigned numRefs = 0; BYTE* gcLayout = new (comp, CMK_Codegen) BYTE[info->numSlots]; @@ -1351,6 +1236,10 @@ GenTree* Lowering::NewPutArg(GenTreeCall* call, GenTree* arg, fgArgTabEntry* inf } #endif // _TARGET_X86_ } + else if (!arg->OperIs(GT_FIELD_LIST)) + { + assert(varTypeIsSIMD(arg) || (info->numSlots == 1)); + } } #endif // FEATURE_PUT_STRUCT_ARG_STK } @@ -2050,7 +1939,7 @@ void Lowering::LowerFastTailCall(GenTreeCall* call) // call could over-write the stack arg that is setup earlier. GenTree* firstPutArgStk = nullptr; GenTreeArgList* args; - ArrayStack putargs(comp); + ArrayStack putargs(comp->getAllocator(CMK_ArrayStack)); for (args = call->gtCallArgs; args; args = args->Rest()) { @@ -2163,9 +2052,9 @@ void Lowering::LowerFastTailCall(GenTreeCall* call) tmpLclNum = comp->lvaGrabTemp( true DEBUGARG("Fast tail call lowering is creating a new local variable")); - comp->lvaSortAgain = true; - comp->lvaTable[tmpLclNum].lvType = tmpType; - comp->lvaTable[tmpLclNum].lvRefCnt = 1; + comp->lvaSortAgain = true; + comp->lvaTable[tmpLclNum].lvType = tmpType; + comp->lvaTable[tmpLclNum].setLvRefCnt(1); comp->lvaTable[tmpLclNum].lvDoNotEnregister = comp->lvaTable[lcl->gtLclNum].lvDoNotEnregister; } @@ -3200,6 +3089,16 @@ GenTree* Lowering::LowerDirectCall(GenTreeCall* call) result = Ind(Ind(result)); break; + case IAT_RELPVALUE: + { + // Non-virtual direct calls to addresses accessed by + // a single relative indirection. + GenTree* cellAddr = AddrGen(addr); + GenTree* indir = Ind(cellAddr); + result = comp->gtNewOperNode(GT_ADD, TYP_I_IMPL, indir, AddrGen(addr)); + break; + } + default: noway_assert(!"Bad accessType"); break; @@ -3989,6 +3888,9 @@ GenTree* Lowering::LowerNonvirtPinvokeCall(GenTreeCall* call) case IAT_PPVALUE: result = Ind(Ind(AddrGen(addr))); break; + + case IAT_RELPVALUE: + unreached(); } } @@ -4085,19 +3987,24 @@ GenTree* Lowering::LowerVirtualVtableCall(GenTreeCall* call) // // Save relative offset to tmp (vtab is virtual table pointer, vtabOffsOfIndirection is offset of // vtable-1st-level-indirection): - // tmp = [vtab + vtabOffsOfIndirection] + // tmp = vtab // // Save address of method to result (vtabOffsAfterIndirection is offset of vtable-2nd-level-indirection): - // result = [vtab + vtabOffsOfIndirection + vtabOffsAfterIndirection + tmp] + // result = [tmp + vtabOffsOfIndirection + vtabOffsAfterIndirection + [tmp + vtabOffsOfIndirection]] + // + // + // If relative pointers are also in second level indirection, additional temporary is used: + // tmp1 = vtab + // tmp2 = tmp1 + vtabOffsOfIndirection + vtabOffsAfterIndirection + [tmp1 + vtabOffsOfIndirection] + // result = tmp2 + [tmp2] + // unsigned lclNumTmp = comp->lvaGrabTemp(true DEBUGARG("lclNumTmp")); - comp->lvaTable[lclNumTmp].incRefCnts(comp->compCurBB->getBBWeight(comp), comp); - GenTree* lclvNodeStore = comp->gtNewTempAssign(lclNumTmp, result); - LIR::Range range = LIR::SeqTree(comp, lclvNodeStore); - JITDUMP("result of obtaining pointer to virtual table:\n"); - DISPRANGE(range); - BlockRange().InsertBefore(call, std::move(range)); + unsigned lclNumTmp2 = comp->lvaGrabTemp(true DEBUGARG("lclNumTmp2")); + comp->lvaTable[lclNumTmp2].incRefCnts(comp->compCurBB->getBBWeight(comp), comp); + + GenTree* lclvNodeStore = comp->gtNewTempAssign(lclNumTmp, result); GenTree* tmpTree = comp->gtNewLclvNode(lclNumTmp, result->TypeGet()); tmpTree = Offset(tmpTree, vtabOffsOfIndirection); @@ -4106,7 +4013,22 @@ GenTree* Lowering::LowerVirtualVtableCall(GenTreeCall* call) GenTree* offs = comp->gtNewIconNode(vtabOffsOfIndirection + vtabOffsAfterIndirection, TYP_INT); result = comp->gtNewOperNode(GT_ADD, TYP_I_IMPL, comp->gtNewLclvNode(lclNumTmp, result->TypeGet()), offs); - result = Ind(OffsetByIndex(result, tmpTree)); + GenTree* base = OffsetByIndexWithScale(result, tmpTree, 1); + GenTree* lclvNodeStore2 = comp->gtNewTempAssign(lclNumTmp2, base); + + LIR::Range range = LIR::SeqTree(comp, lclvNodeStore); + JITDUMP("result of obtaining pointer to virtual table:\n"); + DISPRANGE(range); + BlockRange().InsertBefore(call, std::move(range)); + + LIR::Range range2 = LIR::SeqTree(comp, lclvNodeStore2); + JITDUMP("result of obtaining pointer to virtual table 2nd level indirection:\n"); + DISPRANGE(range2); + BlockRange().InsertAfter(lclvNodeStore, std::move(range2)); + + result = Ind(comp->gtNewLclvNode(lclNumTmp2, result->TypeGet())); + result = + comp->gtNewOperNode(GT_ADD, TYP_I_IMPL, result, comp->gtNewLclvNode(lclNumTmp2, result->TypeGet())); } else { @@ -5832,9 +5754,9 @@ void Lowering::ContainCheckNode(GenTree* node) break; case GT_PUTARG_REG: case GT_PUTARG_STK: -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT case GT_PUTARG_SPLIT: -#endif +#endif // FEATURE_ARG_SPLIT // The regNum must have been set by the lowering of the call. assert(node->gtRegNum != REG_NA); break; diff --git a/src/jit/lower.h b/src/jit/lower.h index e98dc082cce9..656e1773245f 100644 --- a/src/jit/lower.h +++ b/src/jit/lower.h @@ -208,6 +208,12 @@ class Lowering : public Phase return new (comp, GT_LEA) GenTreeAddrMode(resultType, base, index, 0, 0); } + GenTree* OffsetByIndexWithScale(GenTree* base, GenTree* index, unsigned scale) + { + var_types resultType = (base->TypeGet() == TYP_REF) ? TYP_BYREF : base->TypeGet(); + return new (comp, GT_LEA) GenTreeAddrMode(resultType, base, index, scale, 0); + } + // Replace the definition of the given use with a lclVar, allocating a new temp // if 'tempNum' is BAD_VAR_NUM. unsigned ReplaceWithLclVar(LIR::Use& use, unsigned tempNum = BAD_VAR_NUM) @@ -355,6 +361,23 @@ class Lowering : public Phase return LIR::AsRange(m_block); } + // Any tracked lclVar accessed by a LCL_FLD or STORE_LCL_FLD should be marked doNotEnregister. + // This method checks, and asserts in the DEBUG case if it is not so marked, + // but in the non-DEBUG case (asserts disabled) set the flag so that we don't generate bad code. + // This ensures that the local's value is valid on-stack as expected for a *LCL_FLD. + void verifyLclFldDoNotEnregister(unsigned lclNum) + { + LclVarDsc* varDsc = &(comp->lvaTable[lclNum]); + // Do a couple of simple checks before setting lvDoNotEnregister. + // This may not cover all cases in 'isRegCandidate()' but we don't want to + // do an expensive check here. For non-candidates it is not harmful to set lvDoNotEnregister. + if (varDsc->lvTracked && !varDsc->lvDoNotEnregister) + { + assert(!m_lsra->isRegCandidate(varDsc)); + comp->lvaSetVarDoNotEnregister(lclNum DEBUG_ARG(Compiler::DNER_LocalField)); + } + } + LinearScan* m_lsra; unsigned vtableCallTemp; // local variable we use as a temp for vtable calls SideEffectSet m_scratchSideEffects; // SideEffectSet used for IsSafeToContainMem and isRMWIndirCandidate diff --git a/src/jit/lowerarmarch.cpp b/src/jit/lowerarmarch.cpp index 47998fef8e23..c46809fe0a1a 100644 --- a/src/jit/lowerarmarch.cpp +++ b/src/jit/lowerarmarch.cpp @@ -90,7 +90,8 @@ bool Lowering::IsContainableImmed(GenTree* parentNode, GenTree* childNode) case GT_CMPXCHG: case GT_LOCKADD: case GT_XADD: - return emitter::emitIns_valid_imm_for_add(immVal, size); + return comp->compSupports(InstructionSet_Atomics) ? false + : emitter::emitIns_valid_imm_for_add(immVal, size); #elif defined(_TARGET_ARM_) return emitter::emitIns_valid_imm_for_add(immVal, flags); #endif @@ -203,6 +204,11 @@ void Lowering::LowerStoreLoc(GenTreeLclVarCommon* storeLoc) } } } + if (storeLoc->OperIs(GT_STORE_LCL_FLD)) + { + // We should only encounter this for lclVars that are lvDoNotEnregister. + verifyLclFldDoNotEnregister(storeLoc->gtLclNum); + } ContainCheckStoreLoc(storeLoc); } diff --git a/src/jit/lowerxarch.cpp b/src/jit/lowerxarch.cpp index fff2ec387de4..327eb2b8ccc7 100644 --- a/src/jit/lowerxarch.cpp +++ b/src/jit/lowerxarch.cpp @@ -94,6 +94,11 @@ void Lowering::LowerStoreLoc(GenTreeLclVarCommon* storeLoc) } } } + if (storeLoc->OperIs(GT_STORE_LCL_FLD)) + { + // We should only encounter this for lclVars that are lvDoNotEnregister. + verifyLclFldDoNotEnregister(storeLoc->gtLclNum); + } ContainCheckStoreLoc(storeLoc); } @@ -1333,7 +1338,7 @@ GenTree* Lowering::PreferredRegOptionalOperand(GenTree* tree) // weight as reg optional. // If either is not tracked, it may be that it was introduced after liveness // was run, in which case we will always prefer op1 (should we use raw refcnt??). - if (v1->lvTracked && v2->lvTracked && (v1->lvRefCntWtd >= v2->lvRefCntWtd)) + if (v1->lvTracked && v2->lvTracked && (v1->lvRefCntWtd() >= v2->lvRefCntWtd())) { preferredOp = op2; } @@ -2381,6 +2386,7 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* containingNode, Ge case NI_AVX_InsertVector128: case NI_AVX_Permute: case NI_AVX_Permute2x128: + case NI_AVX2_Blend: case NI_AVX2_InsertVector128: case NI_AVX2_Permute2x128: case NI_AVX2_ShiftLeftLogical: @@ -2396,8 +2402,69 @@ bool Lowering::IsContainableHWIntrinsicOp(GenTreeHWIntrinsic* containingNode, Ge break; } - case NI_SSE2_Insert: case NI_SSE41_Insert: + { + if (containingNode->gtSIMDBaseType == TYP_FLOAT) + { + assert(supportsSIMDScalarLoads == false); + + GenTree* op1 = containingNode->gtGetOp1(); + GenTree* op2 = containingNode->gtGetOp2(); + GenTree* op3 = nullptr; + + assert(op1->OperIsList()); + assert(containingNode->gtGetOp2() == nullptr); + + GenTreeArgList* argList = op1->AsArgList(); + + op1 = argList->Current(); + argList = argList->Rest(); + + op2 = argList->Current(); + argList = argList->Rest(); + + assert(node == op2); + + op3 = argList->Current(); + + // The upper two bits of the immediate value are ignored if + // op2 comes from memory. In order to support using the upper + // bits, we need to disable containment support if op3 is not + // constant or if the constant is greater than 0x3F (which means + // at least one of the upper two bits is set). + + if (op3->IsCnsIntOrI()) + { + ssize_t ival = op3->AsIntCon()->IconValue(); + assert((ival >= 0) && (ival <= 255)); + + if (ival <= 0x3F) + { + supportsAlignedSIMDLoads = !comp->canUseVexEncoding(); + supportsUnalignedSIMDLoads = !supportsAlignedSIMDLoads; + supportsGeneralLoads = supportsUnalignedSIMDLoads; + + break; + } + } + + assert(supportsAlignedSIMDLoads == false); + assert(supportsUnalignedSIMDLoads == false); + assert(supportsGeneralLoads == false); + } + else + { + assert(supportsAlignedSIMDLoads == false); + assert(supportsUnalignedSIMDLoads == false); + + supportsSIMDScalarLoads = true; + supportsGeneralLoads = supportsSIMDScalarLoads; + } + + break; + } + + case NI_SSE2_Insert: case NI_AVX_CompareScalar: { assert(supportsAlignedSIMDLoads == false); @@ -2563,6 +2630,8 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) case NI_SSE2_ConvertToInt64: case NI_SSE2_ConvertToUInt32: case NI_SSE2_ConvertToUInt64: + case NI_AVX2_ConvertToInt32: + case NI_AVX2_ConvertToUInt32: { if (varTypeIsIntegral(baseType)) { @@ -2612,7 +2681,37 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) { case HW_Category_SimpleSIMD: case HW_Category_SIMDScalar: + case HW_Category_Scalar: { + if (HWIntrinsicInfo::GeneratesMultipleIns(intrinsicId)) + { + switch (intrinsicId) + { + case NI_SSE_CompareLessThanOrderedScalar: + case NI_SSE_CompareLessThanUnorderedScalar: + case NI_SSE_CompareLessThanOrEqualOrderedScalar: + case NI_SSE_CompareLessThanOrEqualUnorderedScalar: + case NI_SSE2_CompareLessThanOrderedScalar: + case NI_SSE2_CompareLessThanUnorderedScalar: + case NI_SSE2_CompareLessThanOrEqualOrderedScalar: + case NI_SSE2_CompareLessThanOrEqualUnorderedScalar: + { + // We need to swap the operands for CompareLessThanOrEqual + node->gtOp1 = op2; + node->gtOp2 = op1; + op2 = op1; + break; + } + + default: + { + // TODO-XArch-CQ: The Compare*OrderedScalar and Compare*UnorderedScalar methods + // are commutative if you also inverse the intrinsic. + break; + } + } + } + bool supportsRegOptional = false; if (IsContainableHWIntrinsicOp(node, op2, &supportsRegOptional)) @@ -2745,9 +2844,7 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) default: { - // TODO-XArch-CQ: Assert that this is unreached after we have ensured the relevant node types are - // handled. - // https://github.com/dotnet/coreclr/issues/16497 + unreached(); break; } } @@ -2864,6 +2961,7 @@ void Lowering::ContainCheckHWIntrinsic(GenTreeHWIntrinsic* node) case NI_AVX_Insert: case NI_AVX_Permute2x128: case NI_AVX_Shuffle: + case NI_AVX2_Blend: case NI_AVX2_Permute2x128: { if (IsContainableHWIntrinsicOp(node, op2, &supportsRegOptional)) diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp index 5d5baea13924..36007b8407ed 100644 --- a/src/jit/lsra.cpp +++ b/src/jit/lsra.cpp @@ -130,13 +130,15 @@ void lsraAssignRegToTree(GenTree* tree, regNumber reg, unsigned regIdx) { tree->gtRegNum = reg; } -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT +#ifdef _TARGET_ARM_ else if (tree->OperIsMultiRegOp()) { assert(regIdx == 1); GenTreeMultiRegOp* mul = tree->AsMultiRegOp(); mul->gtOtherReg = reg; } +#endif // _TARGET_ARM_ else if (tree->OperGet() == GT_COPY) { assert(regIdx == 1); @@ -148,7 +150,7 @@ void lsraAssignRegToTree(GenTree* tree, regNumber reg, unsigned regIdx) GenTreePutArgSplit* putArg = tree->AsPutArgSplit(); putArg->SetRegNumByIdx(reg, regIdx); } -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT else { assert(tree->IsMultiRegCall()); @@ -178,7 +180,7 @@ unsigned LinearScan::getWeight(RefPosition* refPos) // ref position. GenTreeLclVarCommon* lclCommon = treeNode->AsLclVarCommon(); LclVarDsc* varDsc = &(compiler->lvaTable[lclCommon->gtLclNum]); - weight = varDsc->lvRefCntWtd; + weight = varDsc->lvRefCntWtd(); if (refPos->getInterval()->isSpilled) { // Decrease the weight if the interval has already been spilled. @@ -603,11 +605,8 @@ LinearScanInterface* getLinearScanAllocator(Compiler* comp) LinearScan::LinearScan(Compiler* theCompiler) : compiler(theCompiler) -#if MEASURE_MEM_ALLOC - , lsraAllocator(nullptr) -#endif // MEASURE_MEM_ALLOC - , intervals(LinearScanMemoryAllocatorInterval(theCompiler)) - , refPositions(LinearScanMemoryAllocatorRefPosition(theCompiler)) + , intervals(theCompiler->getAllocator(CMK_LSRA_Interval)) + , refPositions(theCompiler->getAllocator(CMK_LSRA_RefPosition)) , listNodePool(theCompiler) { #ifdef DEBUG @@ -867,7 +866,7 @@ void LinearScan::setBlockSequence() // the blocks - but fgBBcount does not appear to be updated when blocks are removed. if (nextBlock == nullptr /* && bbSeqCount != compiler->fgBBcount*/ && !verifiedAllBBs) { - // If we don't encounter all blocks by traversing the regular sucessor links, do a full + // If we don't encounter all blocks by traversing the regular successor links, do a full // traversal of all the blocks, and add them in layout order. // This may include: // - internal-only blocks (in the fgAddCodeList) which may not be in the flow graph @@ -1357,7 +1356,10 @@ void LinearScan::identifyCandidatesExceptionDataflow() bool LinearScan::isRegCandidate(LclVarDsc* varDsc) { - // We shouldn't be called if opt settings do not permit register variables. + if (!enregisterLocalVars) + { + return false; + } assert((compiler->opts.compFlags & CLFLG_REGVAR) != 0); if (!varDsc->lvTracked) @@ -1386,6 +1388,95 @@ bool LinearScan::isRegCandidate(LclVarDsc* varDsc) { return false; } + + // Don't enregister if the ref count is zero. + if (varDsc->lvRefCnt() == 0) + { + varDsc->setLvRefCntWtd(0); + return false; + } + + // Variables that are address-exposed are never enregistered, or tracked. + // A struct may be promoted, and a struct that fits in a register may be fully enregistered. + // Pinned variables may not be tracked (a condition of the GCInfo representation) + // or enregistered, on x86 -- it is believed that we can enregister pinned (more properly, "pinning") + // references when using the general GC encoding. + unsigned lclNum = (unsigned)(varDsc - compiler->lvaTable); + if (varDsc->lvAddrExposed || !varTypeIsEnregisterableStruct(varDsc)) + { +#ifdef DEBUG + Compiler::DoNotEnregisterReason dner = Compiler::DNER_AddrExposed; + if (!varDsc->lvAddrExposed) + { + dner = Compiler::DNER_IsStruct; + } +#endif // DEBUG + compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(dner)); + return false; + } + else if (varDsc->lvPinned) + { + varDsc->lvTracked = 0; +#ifdef JIT32_GCENCODER + compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(Compiler::DNER_PinningRef)); +#endif // JIT32_GCENCODER + return false; + } + + // Are we not optimizing and we have exception handlers? + // if so mark all args and locals as volatile, so that they + // won't ever get enregistered. + // + if (compiler->opts.MinOpts() && compiler->compHndBBtabCount > 0) + { + compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(Compiler::DNER_LiveInOutOfHandler)); + } + + if (varDsc->lvDoNotEnregister) + { + return false; + } + + switch (genActualType(varDsc->TypeGet())) + { +#if CPU_HAS_FP_SUPPORT + case TYP_FLOAT: + case TYP_DOUBLE: + return !compiler->opts.compDbgCode; + +#endif // CPU_HAS_FP_SUPPORT + + case TYP_INT: + case TYP_LONG: + case TYP_REF: + case TYP_BYREF: + break; + +#ifdef FEATURE_SIMD + case TYP_SIMD12: + case TYP_SIMD16: + case TYP_SIMD32: + return !varDsc->lvPromoted; + + // TODO-1stClassStructs: Move TYP_SIMD8 up with the other SIMD types, after handling the param issue + // (passing & returning as TYP_LONG). + case TYP_SIMD8: + return false; +#endif // FEATURE_SIMD + + case TYP_STRUCT: + return false; + + case TYP_UNDEF: + case TYP_UNKNOWN: + noway_assert(!"lvType not set correctly"); + varDsc->lvType = TYP_INT; + return false; + + default: + return false; + } + return true; } @@ -1524,39 +1615,27 @@ void LinearScan::identifyCandidates() { if (varDsc->lvIsParam && !varDsc->lvIsRegArg) { - refCntStkParam += varDsc->lvRefCnt; + refCntStkParam += varDsc->lvRefCnt(); } else if (!isRegCandidate(varDsc) || varDsc->lvDoNotEnregister) { - refCntStk += varDsc->lvRefCnt; + refCntStk += varDsc->lvRefCnt(); if ((varDsc->lvType == TYP_DOUBLE) || ((varTypeIsStruct(varDsc) && varDsc->lvStructDoubleAlign && (compiler->lvaGetPromotionType(varDsc) != Compiler::PROMOTION_TYPE_INDEPENDENT)))) { - refCntWtdStkDbl += varDsc->lvRefCntWtd; + refCntWtdStkDbl += varDsc->lvRefCntWtd(); } } else { - refCntReg += varDsc->lvRefCnt; - refCntWtdReg += varDsc->lvRefCntWtd; + refCntReg += varDsc->lvRefCnt(); + refCntWtdReg += varDsc->lvRefCntWtd(); } } #endif // DOUBLE_ALIGN - /* Track all locals that can be enregistered */ - - if (!isRegCandidate(varDsc)) - { - varDsc->lvLRACandidate = 0; - if (varDsc->lvTracked) - { - localVarIntervals[varDsc->lvVarIndex] = nullptr; - } - continue; - } - - assert(varDsc->lvTracked); + // Start with the assumption that it's a candidate. varDsc->lvLRACandidate = 1; @@ -1564,116 +1643,19 @@ void LinearScan::identifyCandidates() // the same register assignment throughout varDsc->lvRegister = false; - /* If the ref count is zero */ - if (varDsc->lvRefCnt == 0) - { - /* Zero ref count, make this untracked */ - varDsc->lvRefCntWtd = 0; - varDsc->lvLRACandidate = 0; - } - - // Variables that are address-exposed are never enregistered, or tracked. - // A struct may be promoted, and a struct that fits in a register may be fully enregistered. - // Pinned variables may not be tracked (a condition of the GCInfo representation) - // or enregistered, on x86 -- it is believed that we can enregister pinned (more properly, "pinning") - // references when using the general GC encoding. - - if (varDsc->lvAddrExposed || !varTypeIsEnregisterableStruct(varDsc)) + if (!isRegCandidate(varDsc)) { varDsc->lvLRACandidate = 0; -#ifdef DEBUG - Compiler::DoNotEnregisterReason dner = Compiler::DNER_AddrExposed; - if (!varDsc->lvAddrExposed) + if (varDsc->lvTracked) { - dner = Compiler::DNER_IsStruct; + localVarIntervals[varDsc->lvVarIndex] = nullptr; } -#endif // DEBUG - compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(dner)); - } - else if (varDsc->lvPinned) - { - varDsc->lvTracked = 0; -#ifdef JIT32_GCENCODER - compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(Compiler::DNER_PinningRef)); -#endif // JIT32_GCENCODER - } - - // Are we not optimizing and we have exception handlers? - // if so mark all args and locals as volatile, so that they - // won't ever get enregistered. - // - if (compiler->opts.MinOpts() && compiler->compHndBBtabCount > 0) - { - compiler->lvaSetVarDoNotEnregister(lclNum DEBUGARG(Compiler::DNER_LiveInOutOfHandler)); - } - - if (varDsc->lvDoNotEnregister) - { - varDsc->lvLRACandidate = 0; - localVarIntervals[varDsc->lvVarIndex] = nullptr; continue; } - var_types type = genActualType(varDsc->TypeGet()); - - switch (type) - { -#if CPU_HAS_FP_SUPPORT - case TYP_FLOAT: - case TYP_DOUBLE: - if (compiler->opts.compDbgCode) - { - varDsc->lvLRACandidate = 0; - } -#ifdef ARM_SOFTFP - if (varDsc->lvIsParam && varDsc->lvIsRegArg) - { - type = (type == TYP_DOUBLE) ? TYP_LONG : TYP_INT; - } -#endif // ARM_SOFTFP - break; -#endif // CPU_HAS_FP_SUPPORT - - case TYP_INT: - case TYP_LONG: - case TYP_REF: - case TYP_BYREF: - break; - -#ifdef FEATURE_SIMD - case TYP_SIMD12: - case TYP_SIMD16: - case TYP_SIMD32: - if (varDsc->lvPromoted) - { - varDsc->lvLRACandidate = 0; - } - break; - - // TODO-1stClassStructs: Move TYP_SIMD8 up with the other SIMD types, after handling the param issue - // (passing & returning as TYP_LONG). - case TYP_SIMD8: -#endif // FEATURE_SIMD - - case TYP_STRUCT: - { - varDsc->lvLRACandidate = 0; - } - break; - - case TYP_UNDEF: - case TYP_UNKNOWN: - noway_assert(!"lvType not set correctly"); - varDsc->lvType = TYP_INT; - - __fallthrough; - - default: - varDsc->lvLRACandidate = 0; - } - if (varDsc->lvLRACandidate) { + var_types type = genActualType(varDsc->TypeGet()); Interval* newInt = newInterval(type); newInt->setLocalNumber(compiler, lclNum, this); VarSetOps::AddElemD(compiler, registerCandidateVars, varDsc->lvVarIndex); @@ -1700,7 +1682,7 @@ void LinearScan::identifyCandidates() { largeVectorVarCount++; VarSetOps::AddElemD(compiler, largeVectorVars, varDsc->lvVarIndex); - unsigned refCntWtd = varDsc->lvRefCntWtd; + unsigned refCntWtd = varDsc->lvRefCntWtd(); if (refCntWtd >= thresholdLargeVectorRefCntWtd) { VarSetOps::AddElemD(compiler, largeVectorCalleeSaveCandidateVars, varDsc->lvVarIndex); @@ -1711,7 +1693,7 @@ void LinearScan::identifyCandidates() if (regType(type) == FloatRegisterType) { floatVarCount++; - unsigned refCntWtd = varDsc->lvRefCntWtd; + unsigned refCntWtd = varDsc->lvRefCntWtd(); if (varDsc->lvIsRegArg) { // Don't count the initial reference for register params. In those cases, @@ -2702,8 +2684,7 @@ regNumber LinearScan::tryAllocateFreeReg(Interval* currentInterval, RefPosition* { // Don't use the relatedInterval for preferencing if its next reference is not a new definition, // or if it is only related because they are multi-reg targets of the same node. - if (!RefTypeIsDef(nextRelatedRefPosition->refType) || - isMultiRegRelated(nextRelatedRefPosition, refPosition->nodeLocation)) + if (!RefTypeIsDef(nextRelatedRefPosition->refType)) { relatedInterval = nullptr; } @@ -4937,18 +4918,6 @@ bool LinearScan::registerIsFree(regNumber regNum, RegisterType regType) return isFree; } -// isMultiRegRelated: is this RefPosition defining part of a multi-reg value -// at the given location? -// -bool LinearScan::isMultiRegRelated(RefPosition* refPosition, LsraLocation location) -{ -#ifdef FEATURE_MULTIREG_ARGS_OR_RET - return ((refPosition->nodeLocation == location) && refPosition->getInterval()->isMultiReg); -#else - return false; -#endif -} - //------------------------------------------------------------------------ // LinearScan::freeRegister: Make a register available for use // @@ -5254,7 +5223,7 @@ void LinearScan::allocateRegisters() // inserting a store. LclVarDsc* varDsc = currentInterval->getLocalVar(compiler); assert(varDsc != nullptr); - if (refType == RefTypeParamDef && varDsc->lvRefCntWtd <= BB_UNITY_WEIGHT) + if (refType == RefTypeParamDef && varDsc->lvRefCntWtd() <= BB_UNITY_WEIGHT) { INDEBUG(dumpLsraAllocationEvent(LSRA_EVENT_NO_ENTRY_REG_ALLOCATED, currentInterval)); didDump = true; @@ -5605,7 +5574,7 @@ void LinearScan::allocateRegisters() // There MUST be caller-save registers available, because they have all just been killed. // Amd64 Windows: xmm4-xmm5 are guaranteed to be available as xmm0-xmm3 are used for passing args. - // Amd64 Unix: xmm8-xmm15 are guaranteed to be avilable as xmm0-xmm7 are used for passing args. + // Amd64 Unix: xmm8-xmm15 are guaranteed to be available as xmm0-xmm7 are used for passing args. // X86 RyuJIT Windows: xmm4-xmm7 are guanrateed to be available. assert(assignedRegister != REG_NA); @@ -5613,7 +5582,7 @@ void LinearScan::allocateRegisters() // Note: // i) The reason we have to spill is that SaveDef position is allocated after the Kill positions // of the call node are processed. Since callee-trash registers are killed by call node - // we explicity spill and unassign the register. + // we explicitly spill and unassign the register. // ii) These will look a bit backward in the dump, but it's a pain to dump the alloc before the // spill). unassignPhysReg(getRegisterRecord(assignedRegister), currentRefPosition); @@ -5791,7 +5760,7 @@ void LinearScan::allocateRegisters() // Arguments: // reg - register to be updated // interval - interval to be assigned -// regType - regsiter type +// regType - register type // // Return Value: // None @@ -5831,7 +5800,7 @@ void LinearScan::updateAssignedInterval(RegRecord* reg, Interval* interval, Regi // Arguments: // reg - register to be updated // interval - interval to be assigned -// regType - regsiter type +// regType - register type // // Return Value: // None @@ -6370,7 +6339,7 @@ void LinearScan::recordMaxSpill() // only a few types should actually be seen here. JITDUMP("Recording the maximum number of concurrent spills:\n"); #ifdef _TARGET_X86_ - var_types returnType = compiler->tmpNormalizeType(compiler->info.compRetType); + var_types returnType = RegSet::tmpNormalizeType(compiler->info.compRetType); if (needDoubleTmpForFPCall || (returnType == TYP_DOUBLE)) { JITDUMP("Adding a spill temp for moving a double call/return value between xmm reg and x87 stack.\n"); @@ -6384,7 +6353,7 @@ void LinearScan::recordMaxSpill() #endif // _TARGET_X86_ for (int i = 0; i < TYP_COUNT; i++) { - if (var_types(i) != compiler->tmpNormalizeType(var_types(i))) + if (var_types(i) != RegSet::tmpNormalizeType(var_types(i))) { // Only normalized types should have anything in the maxSpill array. // We assume here that if type 'i' does not normalize to itself, then @@ -6394,7 +6363,7 @@ void LinearScan::recordMaxSpill() if (maxSpill[i] != 0) { JITDUMP(" %s: %d\n", varTypeName(var_types(i)), maxSpill[i]); - compiler->tmpPreAllocateTemps(var_types(i), maxSpill[i]); + compiler->codeGen->regSet.tmpPreAllocateTemps(var_types(i), maxSpill[i]); } } JITDUMP("\n"); @@ -6459,11 +6428,12 @@ void LinearScan::updateMaxSpill(RefPosition* refPosition) ReturnTypeDesc* retTypeDesc = treeNode->AsCall()->GetReturnTypeDesc(); typ = retTypeDesc->GetReturnRegType(refPosition->getMultiRegIdx()); } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (treeNode->OperIsPutArgSplit()) { typ = treeNode->AsPutArgSplit()->GetRegType(refPosition->getMultiRegIdx()); } +#if !defined(_TARGET_64BIT_) else if (treeNode->OperIsPutArgReg()) { // For double arg regs, the type is changed to long since they must be passed via `r0-r3`. @@ -6471,12 +6441,13 @@ void LinearScan::updateMaxSpill(RefPosition* refPosition) var_types typNode = treeNode->TypeGet(); typ = (typNode == TYP_LONG) ? TYP_INT : typNode; } -#endif // _TARGET_ARM_ +#endif // !_TARGET_64BIT_ +#endif // FEATURE_ARG_SPLIT else { typ = treeNode->TypeGet(); } - typ = compiler->tmpNormalizeType(typ); + typ = RegSet::tmpNormalizeType(typ); } if (refPosition->spillAfter && !refPosition->reload) @@ -6788,18 +6759,20 @@ void LinearScan::resolveRegisters() GenTreeCall* call = treeNode->AsCall(); call->SetRegSpillFlagByIdx(GTF_SPILL, currentRefPosition->getMultiRegIdx()); } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (treeNode->OperIsPutArgSplit()) { GenTreePutArgSplit* splitArg = treeNode->AsPutArgSplit(); splitArg->SetRegSpillFlagByIdx(GTF_SPILL, currentRefPosition->getMultiRegIdx()); } +#ifdef _TARGET_ARM_ else if (treeNode->OperIsMultiRegOp()) { GenTreeMultiRegOp* multiReg = treeNode->AsMultiRegOp(); multiReg->SetRegSpillFlagByIdx(GTF_SPILL, currentRefPosition->getMultiRegIdx()); } -#endif +#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT } // If the value is reloaded or moved to a different register, we need to insert @@ -6949,7 +6922,7 @@ void LinearScan::resolveRegisters() { // Dead interval varDsc->lvLRACandidate = false; - if (varDsc->lvRefCnt == 0) + if (varDsc->lvRefCnt() == 0) { varDsc->lvOnFrame = false; } @@ -8125,7 +8098,7 @@ void LinearScan::resolveEdge(BasicBlock* fromBlock, if (genIsValidDoubleReg(fromReg)) { // Ensure that either: - // - the Interval targetting fromReg is not double, or + // - the Interval targeting fromReg is not double, or // - the other half of the double is free. Interval* otherInterval = sourceIntervals[source[fromReg]]; regNumber upperHalfReg = REG_NEXT(fromReg); @@ -8612,10 +8585,6 @@ void Interval::dump() { printf(" (constant)"); } - if (isMultiReg) - { - printf(" (multireg)"); - } printf(" RefPositions {"); for (RefPosition* refPosition = this->firstRefPosition; refPosition != nullptr; @@ -8741,6 +8710,10 @@ void LinearScan::dumpNodeInfo(GenTree* node, regMaskTP dstCandidates, int srcCou void LinearScan::dumpDefList() { + if (!VERBOSE) + { + return; + } JITDUMP("DefList: { "); bool first = true; for (RefInfoListNode *listNode = defList.Begin(), *end = defList.End(); listNode != end; @@ -9136,7 +9109,7 @@ void LinearScan::TupleStyleDump(LsraTupleDumpMode mode) printf("\n Use:"); interval->microDump(); printf("(#%d)", currentRefPosition->rpNum); - if (currentRefPosition->isFixedRegRef) + if (currentRefPosition->isFixedRegRef && !interval->isInternal) { assert(genMaxOneBit(currentRefPosition->registerAssignment)); assert(lastFixedRegRefPos != nullptr); diff --git a/src/jit/lsra.h b/src/jit/lsra.h index cc8f1caca89a..eddeee91b459 100644 --- a/src/jit/lsra.h +++ b/src/jit/lsra.h @@ -433,48 +433,10 @@ inline bool RefTypeIsDef(RefType refType) typedef regNumberSmall* VarToRegMap; -template -class ListElementAllocator -{ -private: - template - friend class ListElementAllocator; - - Compiler* m_compiler; - -public: - ListElementAllocator(Compiler* compiler) : m_compiler(compiler) - { - } - - template - ListElementAllocator(const ListElementAllocator& other) : m_compiler(other.m_compiler) - { - } - - ElementType* allocate(size_t count) - { - return reinterpret_cast(m_compiler->compGetMem(sizeof(ElementType) * count, MemKind)); - } - - void deallocate(ElementType* pointer, size_t count) - { - } - - template - struct rebind - { - typedef ListElementAllocator allocator; - }; -}; - -typedef ListElementAllocator LinearScanMemoryAllocatorInterval; -typedef ListElementAllocator LinearScanMemoryAllocatorRefPosition; - -typedef jitstd::list IntervalList; -typedef jitstd::list RefPositionList; -typedef jitstd::list::iterator RefPositionIterator; -typedef jitstd::list::reverse_iterator RefPositionReverseIterator; +typedef jitstd::list IntervalList; +typedef jitstd::list RefPositionList; +typedef jitstd::list::iterator RefPositionIterator; +typedef jitstd::list::reverse_iterator RefPositionReverseIterator; class Referenceable { @@ -787,7 +749,9 @@ class LinearScan : public LinearScanInterface #endif // !UNIX_AMD64_ABI static const regMaskTP LsraLimitSmallFPSet = (RBM_XMM0 | RBM_XMM1 | RBM_XMM2 | RBM_XMM6 | RBM_XMM7); #elif defined(_TARGET_ARM_) - static const regMaskTP LsraLimitSmallIntSet = (RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4); + // On ARM, we may need two registers to set up the target register for a virtual call, so we need + // to have at least the maximum number of arg registers, plus 2. + static const regMaskTP LsraLimitSmallIntSet = (RBM_R0 | RBM_R1 | RBM_R2 | RBM_R3 | RBM_R4 | RBM_R5); static const regMaskTP LsraLimitSmallFPSet = (RBM_F0 | RBM_F1 | RBM_F2 | RBM_F16 | RBM_F17); #elif defined(_TARGET_ARM64_) static const regMaskTP LsraLimitSmallIntSet = (RBM_R0 | RBM_R1 | RBM_R2 | RBM_R19 | RBM_R20); @@ -1067,6 +1031,7 @@ class LinearScan : public LinearScanInterface // Helpers for getKillSetForNode(). regMaskTP getKillSetForStoreInd(GenTreeStoreInd* tree); + regMaskTP getKillSetForShiftRotate(GenTreeOp* tree); regMaskTP getKillSetForMul(GenTreeOp* tree); regMaskTP getKillSetForCall(GenTreeCall* call); regMaskTP getKillSetForModDiv(GenTreeOp* tree); @@ -1092,7 +1057,6 @@ class LinearScan : public LinearScanInterface regMaskTP allSIMDRegs(); regMaskTP internalFloatRegCandidates(); - bool isMultiRegRelated(RefPosition* refPosition, LsraLocation location); bool registerIsFree(regNumber regNum, RegisterType regType); bool registerIsAvailable(RegRecord* physRegRecord, LsraLocation currentLoc, @@ -1397,21 +1361,9 @@ class LinearScan : public LinearScanInterface Compiler* compiler; private: -#if MEASURE_MEM_ALLOC - CompAllocator* lsraAllocator; -#endif - - CompAllocator* getAllocator(Compiler* comp) + CompAllocator getAllocator(Compiler* comp) { -#if MEASURE_MEM_ALLOC - if (lsraAllocator == nullptr) - { - lsraAllocator = new (comp, CMK_LSRA) CompAllocator(comp, CMK_LSRA); - } - return lsraAllocator; -#else - return comp->getAllocator(); -#endif + return comp->getAllocator(CMK_LSRA); } #ifdef DEBUG @@ -1666,9 +1618,9 @@ class LinearScan : public LinearScanInterface #endif // FEATURE_HW_INTRINSICS int BuildPutArgStk(GenTreePutArgStk* argNode); -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT int BuildPutArgSplit(GenTreePutArgSplit* tree); -#endif +#endif // FEATURE_ARG_SPLIT int BuildLclHeap(GenTree* tree); }; @@ -1703,7 +1655,6 @@ class Interval : public Referenceable , isSpecialPutArg(false) , preferCalleeSave(false) , isConstant(false) - , isMultiReg(false) , physReg(REG_COUNT) #ifdef DEBUG , intervalIndex(0) @@ -1774,9 +1725,6 @@ class Interval : public Referenceable // able to reuse a constant that's already in a register. bool isConstant : 1; - // True if this Interval is defined by a node that produces multiple registers. - bool isMultiReg : 1; - // The register to which it is currently assigned. regNumber physReg; diff --git a/src/jit/lsraarm64.cpp b/src/jit/lsraarm64.cpp index 9cc17cacc02b..6fe9d06d4e88 100644 --- a/src/jit/lsraarm64.cpp +++ b/src/jit/lsraarm64.cpp @@ -418,10 +418,18 @@ int LinearScan::BuildNode(GenTree* tree) srcCount = cmpXchgNode->gtOpComparand->isContained() ? 2 : 3; assert(dstCount == 1); - buildInternalIntRegisterDefForNode(tree); + if (!compiler->compSupports(InstructionSet_Atomics)) + { + // For ARMv8 exclusives requires a single internal register + buildInternalIntRegisterDefForNode(tree); + } // For ARMv8 exclusives the lifetime of the addr and data must be extended because // it may be used used multiple during retries + + // For ARMv8.1 atomic cas the lifetime of the addr and data must be extended to prevent + // them being reused as the target register which must be destroyed early + RefPosition* locationUse = BuildUse(tree->gtCmpXchg.gtOpLocation); setDelayFree(locationUse); RefPosition* valueUse = BuildUse(tree->gtCmpXchg.gtOpValue); @@ -429,7 +437,13 @@ int LinearScan::BuildNode(GenTree* tree) if (!cmpXchgNode->gtOpComparand->isContained()) { RefPosition* comparandUse = BuildUse(tree->gtCmpXchg.gtOpComparand); - setDelayFree(comparandUse); + + // For ARMv8 exclusives the lifetime of the comparand must be extended because + // it may be used used multiple during retries + if (!compiler->compSupports(InstructionSet_Atomics)) + { + setDelayFree(comparandUse); + } } // Internals may not collide with target @@ -446,15 +460,16 @@ int LinearScan::BuildNode(GenTree* tree) assert(dstCount == (tree->TypeGet() == TYP_VOID) ? 0 : 1); srcCount = tree->gtGetOp2()->isContained() ? 1 : 2; - // GT_XCHG requires a single internal regiester; the others require two. - buildInternalIntRegisterDefForNode(tree); - if (tree->OperGet() != GT_XCHG) + if (!compiler->compSupports(InstructionSet_Atomics)) { + // GT_XCHG requires a single internal register; the others require two. buildInternalIntRegisterDefForNode(tree); + if (tree->OperGet() != GT_XCHG) + { + buildInternalIntRegisterDefForNode(tree); + } } - // For ARMv8 exclusives the lifetime of the addr and data must be extended because - // it may be used used multiple during retries assert(!tree->gtGetOp1()->isContained()); RefPosition* op1Use = BuildUse(tree->gtGetOp1()); RefPosition* op2Use = nullptr; @@ -463,17 +478,22 @@ int LinearScan::BuildNode(GenTree* tree) op2Use = BuildUse(tree->gtGetOp2()); } - // Internals may not collide with target - if (dstCount == 1) + // For ARMv8 exclusives the lifetime of the addr and data must be extended because + // it may be used used multiple during retries + if (!compiler->compSupports(InstructionSet_Atomics)) { - setDelayFree(op1Use); - if (op2Use != nullptr) + // Internals may not collide with target + if (dstCount == 1) { - setDelayFree(op2Use); + setDelayFree(op1Use); + if (op2Use != nullptr) + { + setDelayFree(op2Use); + } + setInternalRegsDelayFree = true; } - setInternalRegsDelayFree = true; + buildInternalRegisterUses(); } - buildInternalRegisterUses(); if (dstCount == 1) { BuildDef(tree); @@ -481,6 +501,13 @@ int LinearScan::BuildNode(GenTree* tree) } break; +#if FEATURE_ARG_SPLIT + case GT_PUTARG_SPLIT: + srcCount = BuildPutArgSplit(tree->AsPutArgSplit()); + dstCount = tree->AsPutArgSplit()->gtNumRegs; + break; +#endif // FEATURE _SPLIT_ARG + case GT_PUTARG_STK: srcCount = BuildPutArgStk(tree->AsPutArgStk()); break; diff --git a/src/jit/lsraarmarch.cpp b/src/jit/lsraarmarch.cpp index 0afe0e2385f4..87c0991ed518 100644 --- a/src/jit/lsraarmarch.cpp +++ b/src/jit/lsraarmarch.cpp @@ -276,18 +276,18 @@ int LinearScan::BuildCall(GenTreeCall* call) srcCount++; } } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT else if (argNode->OperGet() == GT_PUTARG_SPLIT) { unsigned regCount = argNode->AsPutArgSplit()->gtNumRegs; assert(regCount == curArgTabEntry->numRegs); for (unsigned int i = 0; i < regCount; i++) { - BuildUse(argNode, genRegMask(argNode->gtRegNum), i); + BuildUse(argNode, genRegMask(argNode->AsPutArgSplit()->GetRegNumByIdx(i)), i); } srcCount += regCount; } -#endif +#endif // FEATURE_ARG_SPLIT else { assert(argNode->OperIs(GT_PUTARG_REG)); @@ -332,11 +332,11 @@ int LinearScan::BuildCall(GenTreeCall* call) fgArgTabEntry* curArgTabEntry = compiler->gtArgEntryByNode(call, arg); assert(curArgTabEntry); #endif -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT // PUTARG_SPLIT nodes must be in the gtCallLateArgs list, since they // define registers used by the call. assert(arg->OperGet() != GT_PUTARG_SPLIT); -#endif +#endif // FEATURE_ARG_SPLIT if (arg->gtOper == GT_PUTARG_STK) { assert(curArgTabEntry->regNum == REG_STK); @@ -434,8 +434,7 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* argNode) // We will generate all of the code for the GT_PUTARG_STK and its child node // as one contained operation // - BuildUse(objChild); - srcCount = 1; + srcCount = BuildOperandUses(objChild); } } else @@ -454,7 +453,7 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* argNode) return srcCount; } -#ifdef _TARGET_ARM_ +#if FEATURE_ARG_SPLIT //------------------------------------------------------------------------ // BuildPutArgSplit: Set the NodeInfo for a GT_PUTARG_SPLIT node // @@ -502,25 +501,29 @@ int LinearScan::BuildPutArgSplit(GenTreePutArgSplit* argNode) assert(!node->isContained()); // The only multi-reg nodes we should see are OperIsMultiRegOp() unsigned currentRegCount; +#ifdef _TARGET_ARM_ if (node->OperIsMultiRegOp()) { currentRegCount = node->AsMultiRegOp()->GetRegCount(); } else +#endif // _TARGET_ARM { assert(!node->IsMultiRegNode()); currentRegCount = 1; } - regMaskTP sourceMask = RBM_NONE; - if (sourceRegCount < argNode->gtNumRegs) + // Consume all the registers, setting the appropriate register mask for the ones that + // go into registers. + for (unsigned regIndex = 0; regIndex < currentRegCount; regIndex++) { - for (unsigned regIndex = 0; regIndex < currentRegCount; regIndex++) + regMaskTP sourceMask = RBM_NONE; + if (sourceRegCount < argNode->gtNumRegs) { - sourceMask |= genRegMask((regNumber)((unsigned)argReg + sourceRegCount + regIndex)); + sourceMask = genRegMask((regNumber)((unsigned)argReg + sourceRegCount)); } + sourceRegCount++; + BuildUse(node, sourceMask, regIndex); } - sourceRegCount += currentRegCount; - BuildUse(node, sourceMask); } srcCount += sourceRegCount; assert(putArgChild->isContained()); @@ -551,7 +554,7 @@ int LinearScan::BuildPutArgSplit(GenTreePutArgSplit* argNode) BuildDefs(argNode, dstCount, argMask); return srcCount; } -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT //------------------------------------------------------------------------ // BuildBlockStore: Set the NodeInfo for a block store. diff --git a/src/jit/lsrabuild.cpp b/src/jit/lsrabuild.cpp index ffacd7a5df90..ff746f86ac6f 100644 --- a/src/jit/lsrabuild.cpp +++ b/src/jit/lsrabuild.cpp @@ -83,9 +83,7 @@ RefInfoListNodePool::RefInfoListNodePool(Compiler* compiler, unsigned preallocat { if (preallocate > 0) { - size_t preallocateSize = sizeof(RefInfoListNode) * preallocate; - RefInfoListNode* preallocatedNodes = - static_cast(compiler->compGetMem(preallocateSize, CMK_LSRA)); + RefInfoListNode* preallocatedNodes = compiler->getAllocator(CMK_LSRA).allocate(preallocate); RefInfoListNode* head = preallocatedNodes; head->m_next = nullptr; @@ -119,7 +117,7 @@ RefInfoListNode* RefInfoListNodePool::GetNode(RefPosition* r, GenTree* t, unsign RefInfoListNode* head = m_freeList; if (head == nullptr) { - head = reinterpret_cast(m_compiler->compGetMem(sizeof(RefInfoListNode))); + head = m_compiler->getAllocator(CMK_LSRA).allocate(1); } else { @@ -252,8 +250,8 @@ void LinearScan::resolveConflictingDefAndUse(Interval* interval, RefPosition* de RegRecord* useRegRecord = nullptr; regNumber defReg = REG_NA; regNumber useReg = REG_NA; - bool defRegConflict = false; - bool useRegConflict = false; + bool defRegConflict = ((defRegAssignment & useRegAssignment) == RBM_NONE); + bool useRegConflict = defRegConflict; // If the useRefPosition is a "delayRegFree", we can't change the registerAssignment // on it, or we will fail to ensure that the fixedReg is busy at the time the target @@ -265,7 +263,7 @@ void LinearScan::resolveConflictingDefAndUse(Interval* interval, RefPosition* de { INDEBUG(dumpLsraAllocationEvent(LSRA_EVENT_DEFUSE_FIXED_DELAY_USE)); } - if (defRefPosition->isFixedRegRef) + if (defRefPosition->isFixedRegRef && !defRegConflict) { defReg = defRefPosition->assignedReg(); defRegRecord = getRegisterRecord(defReg); @@ -289,7 +287,7 @@ void LinearScan::resolveConflictingDefAndUse(Interval* interval, RefPosition* de } } } - if (useRefPosition->isFixedRegRef) + if (useRefPosition->isFixedRegRef && !useRegConflict) { useReg = useRefPosition->assignedReg(); useRegRecord = getRegisterRecord(useReg); @@ -403,7 +401,7 @@ void LinearScan::applyCalleeSaveHeuristics(RefPosition* rp) // incorrectly allocate that register. // TODO-CQ: This means that we may often require a copy at the use of this node's result. // This case could be moved to BuildRefPositionsForNode, at the point where the def RefPosition is -// created, causing a RefTypeFixedRef to be added at that location. This, however, results in +// created, causing a RefTypeFixedReg to be added at that location. This, however, results in // more PhysReg RefPositions (a throughput impact), and a large number of diffs that require // further analysis to determine benefit. // See Issue #11274. @@ -518,12 +516,16 @@ RefPosition* LinearScan::newRefPosition( { RefPosition* newRP = newRefPositionRaw(theLocation, theTreeNode, theRefType); - newRP->setReg(getRegisterRecord(reg)); + RegRecord* regRecord = getRegisterRecord(reg); + newRP->setReg(regRecord); newRP->registerAssignment = mask; newRP->setMultiRegIdx(0); newRP->setAllocateIfProfitable(false); + // We can't have two RefPositions on a RegRecord at the same location, unless they are different types. + assert((regRecord->lastRefPosition == nullptr) || (regRecord->lastRefPosition->nodeLocation < theLocation) || + (regRecord->lastRefPosition->refType != theRefType)); associateRefPosWithInterval(newRP); DBEXEC(VERBOSE, newRP->dump()); @@ -581,8 +583,9 @@ RefPosition* LinearScan::newRefPosition(Interval* theInterval, bool insertFixedRef = false; if (isFixedRegister) { - // Insert a RefTypeFixedReg for any normal def or use (not ParamDef or BB) - if (theRefType == RefTypeUse || theRefType == RefTypeDef) + // Insert a RefTypeFixedReg for any normal def or use (not ParamDef or BB), + // but not an internal use (it will already have a FixedRef for the def). + if ((theRefType == RefTypeDef) || ((theRefType == RefTypeUse) && !theInterval->isInternal)) { insertFixedRef = true; } @@ -764,6 +767,28 @@ regMaskTP LinearScan::getKillSetForStoreInd(GenTreeStoreInd* tree) return killMask; } +//------------------------------------------------------------------------ +// getKillSetForShiftRotate: Determine the liveness kill set for a shift or rotate node. +// +// Arguments: +// shiftNode - the shift or rotate node +// +// Return Value: a register mask of the registers killed +// +regMaskTP LinearScan::getKillSetForShiftRotate(GenTreeOp* shiftNode) +{ + regMaskTP killMask = RBM_NONE; +#ifdef _TARGET_XARCH_ + assert(shiftNode->OperIsShiftOrRotate()); + GenTree* shiftBy = shiftNode->gtGetOp2(); + if (!shiftBy->isContained()) + { + killMask = RBM_RCX; + } +#endif // _TARGET_XARCH_ + return killMask; +} + //------------------------------------------------------------------------ // getKillSetForMul: Determine the liveness kill set for a multiply node. // @@ -1008,6 +1033,18 @@ regMaskTP LinearScan::getKillSetForNode(GenTree* tree) regMaskTP killMask = RBM_NONE; switch (tree->OperGet()) { + case GT_LSH: + case GT_RSH: + case GT_RSZ: + case GT_ROL: + case GT_ROR: +#ifdef _TARGET_X86_ + case GT_LSH_HI: + case GT_RSH_LO: +#endif + killMask = getKillSetForShiftRotate(tree->AsOp()); + break; + case GT_MUL: case GT_MULHI: #if !defined(_TARGET_64BIT_) @@ -1897,7 +1934,7 @@ void LinearScan::buildIntervals() // Use lvRefCnt instead of checking bbLiveIn because if it's volatile we // won't have done dataflow on it, but it needs to be marked as live-in so // it will get saved in the prolog. - if (!compiler->compJmpOpUsed && argDsc->lvRefCnt == 0 && !compiler->opts.compDbgCode) + if (!compiler->compJmpOpUsed && argDsc->lvRefCnt() == 0 && !compiler->opts.compDbgCode) { continue; } @@ -1939,7 +1976,7 @@ void LinearScan::buildIntervals() else { // We can overwrite the register (i.e. codegen saves it on entry) - assert(argDsc->lvRefCnt == 0 || !argDsc->lvIsRegArg || argDsc->lvDoNotEnregister || + assert(argDsc->lvRefCnt() == 0 || !argDsc->lvIsRegArg || argDsc->lvDoNotEnregister || !argDsc->lvLRACandidate || (varTypeIsFloating(argDsc->TypeGet()) && compiler->opts.compDbgCode)); } } @@ -2091,7 +2128,11 @@ void LinearScan::buildIntervals() // Note: the visited set is cleared in LinearScan::doLinearScan() markBlockVisited(block); - assert(defList.IsEmpty()); + if (!defList.IsEmpty()) + { + INDEBUG(dumpDefList()); + assert(!"Expected empty defList at end of block"); + } if (enregisterLocalVars) { @@ -2320,6 +2361,12 @@ RefPosition* LinearScan::BuildDef(GenTree* tree, regMaskTP dstCandidates, int mu { assert(!tree->isContained()); RegisterType type = getDefType(tree); + + if (dstCandidates != RBM_NONE) + { + assert((tree->gtRegNum == REG_NA) || (dstCandidates == genRegMask(tree->GetRegByIndex(multiRegIdx)))); + } + #ifdef FEATURE_MULTIREG_ARGS_OR_RET if (tree->TypeGet() == TYP_STRUCT) { @@ -2499,10 +2546,6 @@ RefPosition* LinearScan::BuildUse(GenTree* operand, regMaskTP candidates, int mu Interval* interval; bool regOptional = operand->IsRegOptional(); - if (operand->gtRegNum != REG_NA) - { - candidates = genRegMask(operand->gtRegNum); - } if (isCandidateLocalRef(operand)) { interval = getIntervalForLocalVarNode(operand->AsLclVarCommon()); @@ -2901,7 +2944,7 @@ int LinearScan::BuildSimple(GenTree* tree) assert((kind & GTK_SMPOP) != 0); srcCount = BuildBinaryUses(tree->AsOp()); } - if (tree->IsValue() && !tree->IsUnusedValue()) + if (tree->IsValue()) { BuildDef(tree); } @@ -3067,16 +3110,40 @@ int LinearScan::BuildPutArgReg(GenTreeUnOp* node) assert(node->OperIsPutArgReg()); regNumber argReg = node->gtRegNum; assert(argReg != REG_NA); - bool isSpecialPutArg = false; - int srcCount = 1; + bool isSpecialPutArg = false; + int srcCount = 1; + GenTree* op1 = node->gtGetOp1(); - // Set the register requirements for the node. - regMaskTP argMask = genRegMask(argReg); + // First, handle the GT_OBJ case, which loads into the arg register + // (so we don't set the use to prefer that register for the source address). + if (op1->OperIs(GT_OBJ)) + { + GenTreeObj* obj = op1->AsObj(); + GenTree* addr = obj->Addr(); + unsigned size = obj->gtBlkSize; + assert(size <= TARGET_POINTER_SIZE); + if (addr->OperIsLocalAddr()) + { + // We don't need a source register. + assert(addr->isContained()); + srcCount = 0; + } + else if (!isPow2(size)) + { + // We'll need an internal register to do the odd-size load. + // This can only happen with integer registers. + assert(genIsValidIntReg(argReg)); + buildInternalIntRegisterDefForNode(node); + BuildUse(addr); + buildInternalRegisterUses(); + } + return srcCount; + } // To avoid redundant moves, have the argument operand computed in the // register in which the argument is passed to the call. - GenTree* op1 = node->gtOp1; - RefPosition* use = BuildUse(op1, argMask); + regMaskTP argMask = genRegMask(argReg); + RefPosition* use = BuildUse(op1, argMask); if (supportsSpecialPutArg() && isCandidateLocalRef(op1) && ((op1->gtFlags & GTF_VAR_DEATH) == 0)) { diff --git a/src/jit/lsraxarch.cpp b/src/jit/lsraxarch.cpp index aa4640b81014..1cb407b2f6e1 100644 --- a/src/jit/lsraxarch.cpp +++ b/src/jit/lsraxarch.cpp @@ -964,6 +964,7 @@ int LinearScan::BuildShiftRotate(GenTree* tree) if (!shiftBy->isContained()) { srcCount += BuildDelayFreeUses(shiftBy, RBM_RCX); + buildKillPositionsForNode(tree, currentLoc + 1, RBM_RCX); } BuildDef(tree, dstCandidates); } @@ -972,6 +973,7 @@ int LinearScan::BuildShiftRotate(GenTree* tree) if (!shiftBy->isContained()) { srcCount += BuildOperandUses(shiftBy, RBM_RCX); + buildKillPositionsForNode(tree, currentLoc + 1, RBM_RCX); } } return srcCount; @@ -1460,7 +1462,6 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) { assert(putArgStk->gtOp1->isContained()); -#ifdef _TARGET_X86_ RefPosition* simdTemp = nullptr; RefPosition* intTemp = nullptr; unsigned prevOffset = putArgStk->getArgSize(); @@ -1471,7 +1472,10 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) GenTree* const fieldNode = current->Current(); const var_types fieldType = fieldNode->TypeGet(); const unsigned fieldOffset = current->gtFieldOffset; + +#ifdef _TARGET_X86_ assert(fieldType != TYP_LONG); +#endif // _TARGET_X86_ #if defined(FEATURE_SIMD) // Note that we need to check the GT_FIELD_LIST type, not 'fieldType'. This is because the @@ -1483,6 +1487,7 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) } #endif // defined(FEATURE_SIMD) +#ifdef _TARGET_X86_ if (putArgStk->gtPutArgStkKind == GenTreePutArgStk::Kind::Push) { // We can treat as a slot any field that is stored at a slot boundary, where the previous @@ -1501,6 +1506,7 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) intTemp->registerAssignment &= allByteRegs(); } } +#endif // _TARGET_X86_ if (varTypeIsGC(fieldType)) { @@ -1508,6 +1514,7 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) } prevOffset = fieldOffset; } + for (GenTreeFieldList* current = putArgStk->gtOp1->AsFieldList(); current != nullptr; current = current->Rest()) { GenTree* const fieldNode = current->Current(); @@ -1520,7 +1527,6 @@ int LinearScan::BuildPutArgStk(GenTreePutArgStk* putArgStk) buildInternalRegisterUses(); return srcCount; -#endif // _TARGET_X86_ } GenTree* src = putArgStk->gtOp1; @@ -2380,11 +2386,10 @@ int LinearScan::BuildHWIntrinsic(GenTreeHWIntrinsic* intrinsicTree) } case NI_SSE_ConvertToSingle: - case NI_SSE_StaticCast: case NI_SSE2_ConvertToDouble: case NI_AVX_ExtendToVector256: case NI_AVX_GetLowerHalf: - case NI_AVX_StaticCast: + case NI_AVX2_ConvertToDouble: { assert(numArgs == 1); assert(!isRMW); diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 37bc2f3751ca..53b40904a71b 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -532,7 +532,7 @@ GenTree* Compiler::fgMorphCast(GenTree* tree) /* Just in case new side effects were introduced */ tree->gtFlags |= (oper->gtFlags & GTF_ALL_EFFECT); - if (!gtIsActiveCSE_Candidate(tree)) // tree cannot be a CSE candidate + if (!gtIsActiveCSE_Candidate(tree) && !gtIsActiveCSE_Candidate(oper)) { srcType = oper->TypeGet(); @@ -753,6 +753,7 @@ GenTree* Compiler::fgMorphCast(GenTree* tree) return tree; REMOVE_CAST: + oper->SetVNsFromNode(tree); /* Here we've eliminated the cast, so just return it's operand */ assert(!gtIsActiveCSE_Candidate(tree)); // tree cannot be a CSE candidate @@ -832,19 +833,10 @@ void fgArgTabEntry::Dump() if (regNum != REG_STK) { printf(", %u reg%s:", numRegs, numRegs == 1 ? "" : "s"); - printf(" %s", getRegName(regNum)); -#if defined(UNIX_AMD64_ABI) - if (numRegs > 1) - { - printf(" %s", getRegName(otherRegNum)); - } -#else // !UNIX_AMD64_ABI - // Note that for all other targets, we rely on the fact that arg regs are sequential. - for (unsigned i = 1; i < numRegs; i++) + for (unsigned i = 0; i < numRegs; i++) { - printf(" %s", getRegName((regNumber)(regNum + i))); + printf(" %s", getRegName(regNums[i])); } -#endif // !UNIX_AMD64_ABI } if (numSlots > 0) { @@ -887,6 +879,10 @@ void fgArgTabEntry::Dump() { printf(", isNonStandard"); } + if (isStruct) + { + printf(", isStruct"); + } printf("]\n"); } #endif @@ -1126,29 +1122,44 @@ void fgArgInfo::AddArg(fgArgTabEntry* curArgTabEntry) argCount++; } -fgArgTabEntry* fgArgInfo::AddRegArg( - unsigned argNum, GenTree* node, GenTree* parent, regNumber regNum, unsigned numRegs, unsigned alignment) +fgArgTabEntry* fgArgInfo::AddRegArg(unsigned argNum, + GenTree* node, + GenTree* parent, + regNumber regNum, + unsigned numRegs, + unsigned alignment, + bool isStruct, + bool isVararg /*=false*/) { fgArgTabEntry* curArgTabEntry = new (compiler, CMK_fgArgInfo) fgArgTabEntry; - curArgTabEntry->argNum = argNum; - curArgTabEntry->node = node; - curArgTabEntry->parent = parent; - curArgTabEntry->regNum = regNum; - curArgTabEntry->slotNum = 0; - curArgTabEntry->numRegs = numRegs; - curArgTabEntry->numSlots = 0; - curArgTabEntry->alignment = alignment; - curArgTabEntry->lateArgInx = (unsigned)-1; - curArgTabEntry->tmpNum = (unsigned)-1; - curArgTabEntry->isSplit = false; - curArgTabEntry->isTmp = false; - curArgTabEntry->needTmp = false; - curArgTabEntry->needPlace = false; - curArgTabEntry->processed = false; - curArgTabEntry->isHfaRegArg = false; + // Any additional register numbers are set by the caller. + // This is primarily because on ARM we don't yet know if it + // will be split or if it is a double HFA, so the number of registers + // may actually be less. + curArgTabEntry->setRegNum(0, regNum); + + curArgTabEntry->argNum = argNum; + curArgTabEntry->node = node; + curArgTabEntry->parent = parent; + curArgTabEntry->slotNum = 0; + curArgTabEntry->numRegs = numRegs; + curArgTabEntry->numSlots = 0; + curArgTabEntry->alignment = alignment; + curArgTabEntry->lateArgInx = (unsigned)-1; + curArgTabEntry->tmpNum = (unsigned)-1; + curArgTabEntry->isSplit = false; + curArgTabEntry->isTmp = false; + curArgTabEntry->needTmp = false; + curArgTabEntry->needPlace = false; + curArgTabEntry->processed = false; +#ifdef FEATURE_HFA + curArgTabEntry->_isHfaRegArg = false; +#endif curArgTabEntry->isBackFilled = false; curArgTabEntry->isNonStandard = false; + curArgTabEntry->isStruct = isStruct; + curArgTabEntry->isVararg = isVararg; hasRegArgs = true; AddArg(curArgTabEntry); @@ -1163,19 +1174,21 @@ fgArgTabEntry* fgArgInfo::AddRegArg(unsigned unsigned numRegs, unsigned alignment, const bool isStruct, + const bool isVararg, const regNumber otherRegNum, const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* const structDescPtr) { - fgArgTabEntry* curArgTabEntry = AddRegArg(argNum, node, parent, regNum, numRegs, alignment); + fgArgTabEntry* curArgTabEntry = AddRegArg(argNum, node, parent, regNum, numRegs, alignment, isStruct, isVararg); assert(curArgTabEntry != nullptr); - // The node of the ArgTabEntry could change after remorphing - it could be rewritten to a cpyblk or a - // PlaceHolder node (in case of needed late argument, for example.) - // This requires using of an extra flag. At creation time the state is right, so - // and this assert enforces that. - assert((varTypeIsStruct(node) && isStruct) || (!varTypeIsStruct(node) && !isStruct)); - curArgTabEntry->otherRegNum = otherRegNum; // Second reg for the struct - curArgTabEntry->isStruct = isStruct; // is this a struct arg + curArgTabEntry->isStruct = isStruct; // is this a struct arg + + curArgTabEntry->checkIsStruct(); + assert(numRegs <= 2); + if (numRegs == 2) + { + curArgTabEntry->setRegNum(1, otherRegNum); + } if (isStruct && structDescPtr != nullptr) { @@ -1190,39 +1203,36 @@ fgArgTabEntry* fgArgInfo::AddStkArg(unsigned argNum, GenTree* node, GenTree* parent, unsigned numSlots, - unsigned alignment UNIX_AMD64_ABI_ONLY_ARG(const bool isStruct)) + unsigned alignment, + bool isStruct, + bool isVararg /*=false*/) { fgArgTabEntry* curArgTabEntry = new (compiler, CMK_fgArgInfo) fgArgTabEntry; nextSlotNum = (unsigned)roundUp(nextSlotNum, alignment); -#if defined(UNIX_AMD64_ABI) - // The node of the ArgTabEntry could change after remorphing - it could be rewritten to a cpyblk or a - // PlaceHolder node (in case of needed late argument, for example.) - // This reqires using of an extra flag. At creation time the state is right, so - // and this assert enforces that. - assert((varTypeIsStruct(node) && isStruct) || (!varTypeIsStruct(node) && !isStruct)); - curArgTabEntry->isStruct = isStruct; // is this a struct arg -#endif // defined(UNIX_AMD64_ABI) - - curArgTabEntry->argNum = argNum; - curArgTabEntry->node = node; - curArgTabEntry->parent = parent; - curArgTabEntry->regNum = REG_STK; - curArgTabEntry->slotNum = nextSlotNum; - curArgTabEntry->numRegs = 0; - curArgTabEntry->numSlots = numSlots; - curArgTabEntry->alignment = alignment; - curArgTabEntry->lateArgInx = (unsigned)-1; - curArgTabEntry->tmpNum = (unsigned)-1; - curArgTabEntry->isSplit = false; - curArgTabEntry->isTmp = false; - curArgTabEntry->needTmp = false; - curArgTabEntry->needPlace = false; - curArgTabEntry->processed = false; - curArgTabEntry->isHfaRegArg = false; + curArgTabEntry->setRegNum(0, REG_STK); + curArgTabEntry->argNum = argNum; + curArgTabEntry->node = node; + curArgTabEntry->parent = parent; + curArgTabEntry->slotNum = nextSlotNum; + curArgTabEntry->numRegs = 0; + curArgTabEntry->numSlots = numSlots; + curArgTabEntry->alignment = alignment; + curArgTabEntry->lateArgInx = (unsigned)-1; + curArgTabEntry->tmpNum = (unsigned)-1; + curArgTabEntry->isSplit = false; + curArgTabEntry->isTmp = false; + curArgTabEntry->needTmp = false; + curArgTabEntry->needPlace = false; + curArgTabEntry->processed = false; +#ifdef FEATURE_HFA + curArgTabEntry->_isHfaRegArg = false; +#endif curArgTabEntry->isBackFilled = false; curArgTabEntry->isNonStandard = false; + curArgTabEntry->isStruct = isStruct; + curArgTabEntry->isVararg = isVararg; hasStackArgs = true; AddArg(curArgTabEntry); @@ -1464,13 +1474,13 @@ void fgArgInfo::ArgsComplete() continue; #endif } -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT else if (curArgTabEntry->isSplit) { hasStructRegArg = true; hasStackArgs = true; } -#endif // _TARGET_ARM_ +#endif // FEATURE_ARG_SPLIT else // we have a register argument, next we look for a struct type. { if (varTypeIsStruct(argx) UNIX_AMD64_ABI_ONLY(|| curArgTabEntry->isStruct)) @@ -1590,7 +1600,7 @@ void fgArgInfo::ArgsComplete() { prevArgTabEntry->needPlace = true; } -#if defined(_TARGET_ARM_) +#if FEATURE_ARG_SPLIT else if (prevArgTabEntry->isSplit) { prevArgTabEntry->needPlace = true; @@ -2093,14 +2103,15 @@ void fgArgInfo::Dump(Compiler* compiler) // of the evaluation of arguments. // // Arguments: -// tmpVarNum - the var num which we clone into the newly created temp var. +// curArgTabEntry // // Return Value: // the newly created temp var tree. -GenTree* Compiler::fgMakeTmpArgNode(unsigned tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(const bool passedInRegisters)) +GenTree* Compiler::fgMakeTmpArgNode(fgArgTabEntry* curArgTabEntry) { - LclVarDsc* varDsc = &lvaTable[tmpVarNum]; + unsigned tmpVarNum = curArgTabEntry->tmpNum; + LclVarDsc* varDsc = &lvaTable[tmpVarNum]; assert(varDsc->lvIsTemp); var_types type = varDsc->TypeGet(); @@ -2113,48 +2124,59 @@ GenTree* Compiler::fgMakeTmpArgNode(unsigned tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(c #if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_) || defined(_TARGET_ARM_) -#ifdef UNIX_AMD64_ABI - - arg->gtFlags |= GTF_DONT_CSE; - -#else // !UNIX_AMD64_ABI - // Can this type be passed in a single register? + // Can this type be passed as a primitive type? // If so, the following call will return the corresponding primitive type. - // Otherwise, it will return TYP_UNKNOWN and we will pass by reference. - - bool passedInRegisters = false; - CORINFO_CLASS_HANDLE clsHnd = varDsc->lvVerTypeInfo.GetClassHandle(); - var_types structBaseType = getPrimitiveTypeForStruct(lvaLclExactSize(tmpVarNum), clsHnd); + // Otherwise, it will return TYP_UNKNOWN and we will pass it as a struct type. - if (structBaseType != TYP_UNKNOWN) + bool passedAsPrimitive = false; + if (curArgTabEntry->isSingleRegOrSlot()) { - passedInRegisters = true; - type = structBaseType; + CORINFO_CLASS_HANDLE clsHnd = varDsc->lvVerTypeInfo.GetClassHandle(); + var_types structBaseType = + getPrimitiveTypeForStruct(lvaLclExactSize(tmpVarNum), clsHnd, curArgTabEntry->isVararg); + + if (structBaseType != TYP_UNKNOWN) + { + passedAsPrimitive = true; +#if defined(UNIX_AMD64_ABI) + // TODO-Cleanup: This is inelegant, but eventually we'll track this in the fgArgTabEntry, + // and otherwise we'd have to either modify getPrimitiveTypeForStruct() to take + // a structDesc or call eeGetSystemVAmd64PassStructInRegisterDescriptor yet again. + // + if (genIsValidFloatReg(curArgTabEntry->regNum)) + { + if (structBaseType == TYP_INT) + { + structBaseType = TYP_FLOAT; + } + else + { + assert(structBaseType == TYP_LONG); + structBaseType = TYP_DOUBLE; + } + } +#endif + type = structBaseType; + } } -#endif // !UNIX_AMD64_ABI // If it is passed in registers, don't get the address of the var. Make it a // field instead. It will be loaded in registers with putarg_reg tree in lower. - if (passedInRegisters) + if (passedAsPrimitive) { arg->ChangeOper(GT_LCL_FLD); arg->gtType = type; } else { -#ifdef UNIX_AMD64_ABI - // TODO-Cleanup: Fix this - we should never have an address that is TYP_STRUCT. - var_types addrType = type; -#else var_types addrType = TYP_BYREF; -#endif - arg = gtNewOperNode(GT_ADDR, addrType, arg); - addrNode = arg; + arg = gtNewOperNode(GT_ADDR, addrType, arg); + addrNode = arg; #if FEATURE_MULTIREG_ARGS #ifdef _TARGET_ARM64_ assert(varTypeIsStruct(type)); - if (lvaIsMultiregStruct(varDsc)) + if (lvaIsMultiregStruct(varDsc, curArgTabEntry->isVararg)) { // ToDo-ARM64: Consider using: arg->ChangeOper(GT_LCL_FLD); // as that is how UNIX_AMD64_ABI works. @@ -2170,11 +2192,11 @@ GenTree* Compiler::fgMakeTmpArgNode(unsigned tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(c // values can be pessimizing, so enabling this may require some additional tuning). arg->gtFlags |= GTF_DONT_CSE; } -#elif defined(_TARGET_ARM_) +#else // Always create an Obj of the temp to use it as a call argument. arg = gtNewObjNode(lvaGetStruct(tmpVarNum), arg); arg->gtFlags |= GTF_DONT_CSE; -#endif // _TARGET_ARM_ +#endif // !_TARGET_ARM64_ #endif // FEATURE_MULTIREG_ARGS } @@ -2207,6 +2229,9 @@ GenTree* Compiler::fgMakeTmpArgNode(unsigned tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(c return arg; } +//------------------------------------------------------------------------------ +// EvalArgsToTemps : Create temp assignments and populate the LateArgs list. + void fgArgInfo::EvalArgsToTemps() { assert(argsSorted == true); @@ -2236,14 +2261,10 @@ void fgArgInfo::EvalArgsToTemps() if (curArgTabEntry->needTmp) { - unsigned tmpVarNum; - if (curArgTabEntry->isTmp == true) { // Create a copy of the temp to go into the late argument list - tmpVarNum = curArgTabEntry->tmpNum; - defArg = compiler->fgMakeTmpArgNode( - tmpVarNum UNIX_AMD64_ABI_ONLY_ARG(argTable[curInx]->structDesc.passedInRegisters)); + defArg = compiler->fgMakeTmpArgNode(curArgTabEntry); // mark the original node as a late argument argx->gtFlags |= GTF_LATE_ARG; @@ -2266,7 +2287,7 @@ void fgArgInfo::EvalArgsToTemps() noway_assert(argx->gtType != TYP_STRUCT); #endif - tmpVarNum = compiler->lvaGrabTemp(true DEBUGARG("argument with side effect")); + unsigned tmpVarNum = compiler->lvaGrabTemp(true DEBUGARG("argument with side effect")); if (argx->gtOper == GT_MKREFANY) { // For GT_MKREFANY, typically the actual struct copying does @@ -2317,7 +2338,7 @@ void fgArgInfo::EvalArgsToTemps() // We'll reference this temporary variable just once // when we perform the function call after // setting up this argument. - varDsc->lvRefCnt = 1; + varDsc->setLvRefCnt(1); } var_types lclVarType = genActualType(argx->gtType); @@ -2332,7 +2353,7 @@ void fgArgInfo::EvalArgsToTemps() CORINFO_CLASS_HANDLE clsHnd = compiler->lvaGetStruct(tmpVarNum); unsigned structSize = varDsc->lvExactSize; - scalarType = compiler->getPrimitiveTypeForStruct(structSize, clsHnd); + scalarType = compiler->getPrimitiveTypeForStruct(structSize, clsHnd, curArgTabEntry->isVararg); #endif // _TARGET_ARMARCH_ } @@ -2737,17 +2758,19 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) unsigned nonRegPassedStructSlots = 0; bool reMorphing = call->AreArgsComplete(); bool callHasRetBuffArg = call->HasRetBufArg(); + bool callIsVararg = call->IsVarargs(); -#ifndef _TARGET_X86_ // i.e. _TARGET_AMD64_ or _TARGET_ARM_ - bool callIsVararg = call->IsVarargs(); -#endif - -#ifdef UNIX_AMD64_ABI - // If fgMakeOutgoingStructArgCopy is called and copies are generated, hasStackArgCopy is set - // to make sure to call EvalArgsToTemp. fgMakeOutgoingStructArgCopy just marks the argument - // to need a temp variable, and EvalArgsToTemp actually creates the temp variable node. - bool hasStackArgCopy = false; -#endif +#ifdef _TARGET_UNIX_ + if (callIsVararg) + { + // Currently native varargs is not implemented on non windows targets. + // + // Note that some targets like Arm64 Unix should not need much work as + // the ABI is the same. While other targets may only need small changes + // such as amd64 Unix, which just expects RAX to pass numFPArguments. + NYI("Morphing Vararg call not yet implemented on non Windows targets."); + } +#endif // _TARGET_UNIX_ // Data structure for keeping track of non-standard args. Non-standard args are those that are not passed // following the normal calling convention or in the normal argument registers. We either mark existing @@ -2765,7 +2788,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) ArrayStack args; public: - NonStandardArgs(Compiler* compiler) : args(compiler, 3) // We will have at most 3 non-standard arguments + NonStandardArgs(CompAllocator alloc) : args(alloc, 3) // We will have at most 3 non-standard arguments { } @@ -2852,7 +2875,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) args.IndexRef(index).node = node; } - } nonStandardArgs(this); + } nonStandardArgs(getAllocator(CMK_ArrayStack)); // Count of args. On first morph, this is counted before we've filled in the arg table. // On remorph, we grab it from the arg table. @@ -3123,12 +3146,8 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) assert(varTypeIsGC(call->gtCallObjp->gtType) || (call->gtCallObjp->gtType == TYP_I_IMPL)); /* this is a register argument - put it in the table */ - call->fgArgInfo->AddRegArg(argIndex, argx, nullptr, genMapIntRegArgNumToRegNum(intArgRegNum), 1, 1 -#ifdef UNIX_AMD64_ABI - , - false, REG_STK, nullptr -#endif // UNIX_AMD64_ABI - ); + call->fgArgInfo->AddRegArg(argIndex, argx, nullptr, genMapIntRegArgNumToRegNum(intArgRegNum), 1, 1, false, + callIsVararg UNIX_AMD64_ABI_ONLY_ARG(REG_STK) UNIX_AMD64_ABI_ONLY_ARG(nullptr)); } // this can't be a struct. assert(argx->gtType != TYP_STRUCT); @@ -3235,22 +3254,13 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; #endif // UNIX_AMD64_ABI - bool hasStructArgument = false; // @TODO-ARM64-UNIX: Remove this bool during a future refactoring - // hasMultiregStructArgs is true if there are any structs that are eligible for passing - // in registers; this is true even if it is not actually passed in registers (i.e. because - // previous arguments have used up available argument registers). + // Note that this name is a bit of a misnomer - it indicates that there are struct args + // that occupy more than a single slot that are passed by value (not necessarily in regs). bool hasMultiregStructArgs = false; for (args = call->gtCallArgs; args; args = args->gtOp.gtOp2, argIndex++) { GenTree** parentArgx = &args->gtOp.gtOp1; -#if FEATURE_MULTIREG_ARGS - if (!hasStructArgument) - { - hasStructArgument = varTypeIsStruct(args->gtOp.gtOp1); - } -#endif // FEATURE_MULTIREG_ARGS - // Record the index of any nonStandard arg that we may be processing here, as we are // about to call fgMorphTree on it and fgMorphTree may replace it with a new tree. GenTree* orig_argx = *parentArgx; @@ -3277,25 +3287,8 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) argx->gtType = TYP_I_IMPL; } - bool passUsingFloatRegs; - unsigned argAlign = 1; - // Setup any HFA information about 'argx' - var_types hfaType = GetHfaType(argx); - bool isHfaArg = varTypeIsFloating(hfaType); - unsigned hfaSlots = 0; - - if (isHfaArg) - { - hfaSlots = GetHfaCount(argx); - - // If we have a HFA struct it's possible we transition from a method that originally - // only had integer types to now start having FP types. We have to communicate this - // through this flag since LSRA later on will use this flag to determine whether - // or not to track the FP register set. - // - compFloatingPointUsed = true; - } - + bool passUsingFloatRegs; + unsigned argAlign = 1; unsigned size = 0; CORINFO_CLASS_HANDLE copyBlkClass = nullptr; bool isRegArg = false; @@ -3309,8 +3302,46 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) argEntry = gtArgEntryByArgNum(call, argIndex); } -#ifdef _TARGET_ARM_ + // Setup any HFA information about 'argx' + var_types hfaType = TYP_UNDEF; + bool isHfaArg = false; + unsigned hfaSlots = 0; + +#ifdef FEATURE_HFA + if (reMorphing) + { + isHfaArg = argEntry->isHfaRegArg; + hfaType = argEntry->hfaType; + hfaSlots = argEntry->numRegs; + } + else + { + hfaType = GetHfaType(argx); + if (varTypeIsFloating(hfaType)) + { + isHfaArg = true; + hfaSlots = GetHfaCount(argx); + } + } + +#if defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + // Make sure for vararg methods isHfaArg is not + // true. + isHfaArg = callIsVararg ? false : isHfaArg; +#endif // defined(_TARGET_WINDOWS_) && defined(_TARGET_ARM64_) + + if (isHfaArg) + { + // If we have a HFA struct it's possible we transition from a method that originally + // only had integer types to now start having FP types. We have to communicate this + // through this flag since LSRA later on will use this flag to determine whether + // or not to track the FP register set. + // + compFloatingPointUsed = true; + } +#endif // FEATURE_HFA +#ifdef _TARGET_ARM_ bool passUsingIntRegs; if (reMorphing) { @@ -3401,28 +3432,23 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) var_types structBaseType = TYP_STRUCT; unsigned structSize = 0; - bool isStructArg = varTypeIsStruct(argx); + bool isStructArg; if (reMorphing) { -#if defined(UNIX_AMD64_ABI) - // Get the struct description for the already completed struct argument. - fgArgTabEntry* fgEntryPtr = gtArgEntryByNode(call, argx); - assert(fgEntryPtr != nullptr); - - // As described in few other places, this can happen when the argx was morphed - // into an arg setup node - COPYBLK. The COPYBLK has always a type of void. + assert(argEntry != nullptr); + // Struct arguments may be morphed into a node that is not a struct type. // In such case the fgArgTabEntry keeps track of whether the original node (before morphing) // was a struct and the struct classification. - isStructArg = fgEntryPtr->isStruct; + isStructArg = argEntry->isStruct; +#if defined(UNIX_AMD64_ABI) if (isStructArg) { - structDesc.CopyFrom(fgEntryPtr->structDesc); + structDesc.CopyFrom(argEntry->structDesc); } #endif // defined(UNIX_AMD64_ABI) - assert(argEntry != nullptr); if (argEntry->IsBackFilled()) { isRegArg = true; @@ -3442,6 +3468,13 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) isRegArg = true; assert(argEntry->numRegs > 0); size = argEntry->numRegs + argEntry->numSlots; +#ifdef _TARGET_ARM_ + if (argEntry->isHfaRegArg && (hfaType == TYP_DOUBLE)) + { + assert(!argEntry->isSplit); + size <<= 1; + } +#endif // _TARGET_ARM_ } // This size has now been computed @@ -3456,6 +3489,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // TARGET_POINTER_SIZE stack slots, or the sum of these if the argument is split between the registers and // the stack. // + isStructArg = varTypeIsStruct(argx); if (argx->IsArgPlaceHolderNode() || (!isStructArg)) { #if defined(_TARGET_AMD64_) @@ -3476,7 +3510,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } } #else // !UNIX_AMD64_ABI - size = 1; // On AMD64, all primitives fit in a single (64-bit) 'slot' + size = 1; // On AMD64 Windows, all primitives fit in a single (64-bit) 'slot' #endif // UNIX_AMD64_ABI #elif defined(_TARGET_ARM64_) if (isStructArg) @@ -3560,7 +3594,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) size = 1; } #else - size = 2; + size = 2; #endif } else // We must have a GT_OBJ with a struct type, but the GT_OBJ may be be a child of a GT_COMMA @@ -3596,127 +3630,78 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) structSize = originalSize; structPassingKind howToPassStruct; - structBaseType = getArgTypeForStruct(objClass, &howToPassStruct, originalSize); -#ifdef _TARGET_ARM64_ + structBaseType = getArgTypeForStruct(objClass, &howToPassStruct, callIsVararg, originalSize); + +#if defined(_TARGET_ARM64_) || defined(UNIX_AMD64_ABI) + // For ARM64 or AMD64/UX we can pass non-power-of-2 structs in a register. if ((howToPassStruct == SPK_PrimitiveType) && // Passed in a single register !isPow2(originalSize)) // size is 3,5,6 or 7 bytes { - if (argObj->gtObj.gtOp1->IsVarAddr()) // Is the source a LclVar? - { - // For ARM64 we pass structs that are 3,5,6,7 bytes in size - // we can read 4 or 8 bytes from the LclVar to pass this arg - originalSize = genTypeSize(structBaseType); - } + originalSize = genTypeSize(structBaseType); } -#endif // _TARGET_ARM64_ +#endif // _TARGET_ARM64_ || UNIX_AMD64_ABI -#ifdef UNIX_AMD64_ABI - // On System V OS-es a struct is never passed by reference. - // It is either passed by value on the stack or in registers. - bool passStructInRegisters = false; -#else // !UNIX_AMD64_ABI bool passStructByRef = false; -#endif // !UNIX_AMD64_ABI - // The following if-then-else needs to be carefully refactored. - // Basically the else portion wants to turn a struct load (a GT_OBJ) - // into a GT_IND of the appropriate size. - // It can do this with structs sizes that are 1, 2, 4, or 8 bytes. - // It can't do this when UNIX_AMD64_ABI is defined (Why?) - // TODO-Cleanup: Remove the #ifndef UNIX_AMD64_ABI below. - // It also can't do this if we have a HFA arg, - // unless we have a 1-elem HFA in which case we want to do the optimization. + // Check to see if we can transform this struct load (GT_OBJ) into a GT_IND of the appropriate size. + // That is the else clause of the if statement below. + // When it can do this is platform-dependent: + // - In general, it can be done for power of 2 structs that fit in a single register + // (or, for ARM64 and AMD64/UX, lclVars that are less than pointer size, see above). + // - For ARM and ARM64 it must also be a non-HFA struct, or have a single field. + // - This is irrelevant for X86, since structs are always passed by value on the stack. + // Note that 'howToPassStruct' captures all but the power-of-2 requirement. CLANG_FORMAT_COMMENT_ANCHOR; #ifndef _TARGET_X86_ -#ifndef UNIX_AMD64_ABI // Check for struct argument with size 1, 2, 4 or 8 bytes // As we can optimize these by turning them into a GT_IND of the correct type // // Check for cases that we cannot optimize: - CLANG_FORMAT_COMMENT_ANCHOR; -#ifdef _TARGET_ARM_ - if (((originalSize > TARGET_POINTER_SIZE) && // it is struct that is larger than a pointer - howToPassStruct != SPK_PrimitiveType) || // it is struct that is not one double HFA - !isPow2(originalSize) || // it is not a power of two (1, 2, 4 or 8) - (isHfaArg && (howToPassStruct != SPK_PrimitiveType))) // it is a one element HFA struct -#else // !_TARGET_ARM_ - if ((originalSize > TARGET_POINTER_SIZE) || // it is struct that is larger than a pointer - !isPow2(originalSize) || // it is not a power of two (1, 2, 4 or 8) - (isHfaArg && (hfaSlots != 1))) // it is a one element HFA struct -#endif // !_TARGET_ARM_ -#endif // UNIX_AMD64_ABI + bool canTransformToInd = (howToPassStruct == SPK_PrimitiveType) && isPow2(originalSize); + if (!canTransformToInd) { + GenTree* lclVar = fgIsIndirOfAddrOfLocal(argObj); // Normalize 'size' to the number of pointer sized items // 'size' is the number of register slots that we will use to pass the argument size = roundupSize / TARGET_POINTER_SIZE; #if defined(_TARGET_AMD64_) #ifndef UNIX_AMD64_ABI + // On Windows structs are always copied and passed by reference unless they are + // passed by value in a single register. size = 1; // This must be copied to a temp and passed by address passStructByRef = true; copyBlkClass = objClass; -#else // UNIX_AMD64_ABI - if (!structDesc.passedInRegisters) +#else // UNIX_AMD64_ABI + // On Unix, structs are always passed by value. + // We only need a copy if we have one of the following: + // - We have a lclVar that has been promoted and is passed in registers. + // - The sizes don't match. + // - We have a vector intrinsic. + // TODO-Amd64-Unix-CQ: The first and last case could and should be handled without copies. + + copyBlkClass = NO_CLASS_HANDLE; + if (structDesc.passedInRegisters) { - GenTree* lclVar = fgIsIndirOfAddrOfLocal(argObj); - bool needCpyBlk = false; - if (lclVar != nullptr) - { - // If the struct is promoted to registers, it has to be materialized - // on stack. We may want to support promoted structures in - // codegening pugarg_stk instead of creating a copy here. - LclVarDsc* varDsc = &lvaTable[lclVar->gtLclVarCommon.gtLclNum]; - needCpyBlk = varDsc->lvPromoted; - } - else + if ((lclVar != nullptr) && + (lvaGetPromotionType(lclVar->gtLclVarCommon.gtLclNum) == PROMOTION_TYPE_INDEPENDENT)) { - // If simd16 comes from vector, eeGetSystemVAmd64PassStructInRegisterDescriptor - // sets structDesc.passedInRegisters to be false. - // - // GT_ADDR(GT_SIMD) is not a rationalized IR form and is not handled - // by rationalizer. For now we will let SIMD struct arg to be copied to - // a local. As part of cpblk rewrite, rationalizer will handle GT_ADDR(GT_SIMD) - // - // +--* obj simd16 - // | \--* addr byref - // | | /--* lclVar simd16 V05 loc4 - // | \--* simd simd16 int - - // | \--* lclVar simd16 V08 tmp1 - // - // TODO-Amd64-Unix: The rationalizer can be updated to handle this pattern, - // so that we don't need to generate a copy here. - GenTree* addr = argObj->gtOp.gtOp1; - if (addr->OperGet() == GT_ADDR) - { - GenTree* addrChild = addr->gtOp.gtOp1; - if (addrChild->OperIsSIMDorSimdHWintrinsic()) - { - needCpyBlk = true; - } - } + copyBlkClass = objClass; } - passStructInRegisters = false; - if (needCpyBlk) + else if (originalSize != structSize) { copyBlkClass = objClass; } else { - copyBlkClass = NO_CLASS_HANDLE; + GenTree* addr = argObj->gtGetOp1(); + if (addr->OperIs(GT_ADDR) && addr->gtGetOp1()->OperIs(GT_SIMD, GT_HWIntrinsic)) + { + copyBlkClass = objClass; + } } } - else - { - // The objClass is used to materialize the struct on stack. - // For SystemV, the code below generates copies for struct arguments classified - // as register argument. - // TODO-Amd64-Unix: We don't always need copies for this case. Struct arguments - // can be passed on registers or can be copied directly to outgoing area. - passStructInRegisters = true; - copyBlkClass = objClass; - } - #endif // UNIX_AMD64_ABI #elif defined(_TARGET_ARM64_) if ((size > 2) && !isHfaArg) @@ -3725,13 +3710,16 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) passStructByRef = true; copyBlkClass = objClass; } + else if ((originalSize != structSize) && (lclVar == nullptr)) + { + copyBlkClass = objClass; + } #endif #ifdef _TARGET_ARM_ // If we're passing a promoted struct local var, // we may need to skip some registers due to alignment; record those. - GenTree* lclVar = fgIsIndirOfAddrOfLocal(argObj); - if (lclVar != NULL) + if (lclVar != nullptr) { LclVarDsc* varDsc = &lvaTable[lclVar->gtLclVarCommon.gtLclNum]; if (varDsc->lvPromoted) @@ -3751,9 +3739,6 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } #endif // _TARGET_ARM_ } -#ifndef UNIX_AMD64_ABI - // TODO-Amd64-Unix: Since the else part below is disabled for UNIX_AMD64, copies are always - // generated for struct 1, 2, 4, or 8. else // We have a struct argument with size 1, 2, 4 or 8 bytes { // change our GT_OBJ into a GT_IND of the correct type. @@ -3761,23 +3746,8 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // size. assert(howToPassStruct == SPK_PrimitiveType); - - // ToDo: remove this block as getArgTypeForStruct properly handles turning one element HFAs into - // primitives - if (isHfaArg) - { -#ifdef _TARGET_ARM_ - // If we reach here with an HFA arg it has to be a one element HFA - // If HFA type is double and it has one element, hfaSlot is 2 - assert(hfaSlots == 1 || (hfaSlots == 2 && hfaType == TYP_DOUBLE)); -#else - // If we reach here with an HFA arg it has to be a one element HFA - assert(hfaSlots == 1); -#endif - structBaseType = hfaType; // change the indirection type to a floating point type - } - noway_assert(structBaseType != TYP_UNKNOWN); + assert(originalSize == genTypeSize(structBaseType)); argObj->ChangeOper(GT_IND); @@ -3867,7 +3837,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) argObj->gtType = structBaseType; } assert(varTypeCanReg(argObj->TypeGet()) || - ((copyBlkClass != NO_CLASS_HANDLE) && varTypeIsIntegral(structBaseType))); + ((copyBlkClass != NO_CLASS_HANDLE) && varTypeCanReg(structBaseType))); size = 1; #ifdef _TARGET_ARM_ @@ -3877,17 +3847,11 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } #endif } -#endif // UNIX_AMD64_ABI #endif // not _TARGET_X86_ +#ifndef UNIX_AMD64_ABI // We still have a struct unless we converted the GT_OBJ into a GT_IND above... - if (varTypeIsStruct(structBaseType) && -#if defined(UNIX_AMD64_ABI) - !passStructInRegisters -#else // !defined(UNIX_AMD64_ABI) - !passStructByRef -#endif // !defined(UNIX_AMD64_ABI) - ) + if (varTypeIsStruct(structBaseType) && !passStructByRef) { if (isHfaArg && passUsingFloatRegs) { @@ -3916,6 +3880,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) size = roundupSize / TARGET_POINTER_SIZE; // Normalize size to number of pointer sized items } } +#endif // UNIX_AMD64_ABI } #if defined(_TARGET_64BIT_) @@ -4014,13 +3979,25 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // if (!isRegArg && (size > 1)) { - // We also must update intArgRegNum so that we no longer try to - // allocate any new general purpose registers for args - // - intArgRegNum = maxRegArgs; +#if defined(_TARGET_WINDOWS_) + // Arm64 windows native varargs allows splitting a 16 byte struct between stack + // and the last general purpose register. + if (callIsVararg) + { + // Override the decision and force a split. + isRegArg = isRegArg = (intArgRegNum + (size - 1)) <= maxRegArgs; + } + else +#endif // defined(_TARGET_WINDOWS_) + { + // We also must update intArgRegNum so that we no longer try to + // allocate any new general purpose registers for args + // + intArgRegNum = maxRegArgs; + } } } -#else // not _TARGET_ARM_ or _TARGET_ARM64_ +#else // not _TARGET_ARM_ or _TARGET_ARM64_ #if defined(UNIX_AMD64_ABI) @@ -4183,15 +4160,19 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) else { // This is a register argument - put it in the table - newArgEntry = call->fgArgInfo->AddRegArg(argIndex, argx, args, nextRegNum, size, argAlign -#if defined(UNIX_AMD64_ABI) - , - isStructArg, nextOtherRegNum, &structDesc -#endif // defined(UNIX_AMD64_ABI) - ); + newArgEntry = call->fgArgInfo->AddRegArg(argIndex, argx, args, nextRegNum, size, argAlign, isStructArg, + callIsVararg UNIX_AMD64_ABI_ONLY_ARG(nextOtherRegNum) + UNIX_AMD64_ABI_ONLY_ARG(&structDesc)); + +#ifdef FEATURE_HFA + if (!passUsingFloatRegs) + { + // Note on ARM and ARM64 Windows, an HFA is passed in int regs for varargs + hfaType = TYP_UNDEF; + } + newArgEntry->setHfaType(hfaType, hfaSlots); +#endif // FEATURE_HFA - newArgEntry->SetIsHfaRegArg(passUsingFloatRegs && - isHfaArg); // Note on Arm32 a HFA is passed in int regs for varargs newArgEntry->SetIsBackFilled(isBackFilled); newArgEntry->isNonStandard = isNonStandard; } @@ -4208,12 +4189,28 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) #if defined(UNIX_AMD64_ABI) if (isStructArg) { + // For this case, we've already set the regNums in the argTabEntry intArgRegNum += structIntRegs; fltArgRegNum += structFloatRegs; } else #endif // defined(UNIX_AMD64_ABI) { +#if FEATURE_ARG_SPLIT + // Check for a split (partially enregistered) struct + if (!passUsingFloatRegs && (intArgRegNum + size) > MAX_REG_ARG) + { + // This indicates a partial enregistration of a struct type + assert((isStructArg) || argx->OperIsFieldList() || argx->OperIsCopyBlkOp() || + (argx->gtOper == GT_COMMA && (args->gtFlags & GTF_ASG))); + unsigned numRegsPartial = MAX_REG_ARG - intArgRegNum; + assert((unsigned char)numRegsPartial == numRegsPartial); + call->fgArgInfo->SplitArg(argIndex, numRegsPartial, size - numRegsPartial); + fgPtrArgCntCur += size - numRegsPartial; + } +#endif // FEATURE_ARG_SPLIT + + newArgEntry->SetMultiRegNums(); if (passUsingFloatRegs) { fltArgRegNum += size; @@ -4223,8 +4220,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // we skip the corresponding floating point register argument intArgRegNum = min(intArgRegNum + size, MAX_REG_ARG); #endif // WINDOWS_AMD64_ABI - // There is no partial struct using float registers - // on all supported architectures + // No supported architecture supports partial structs using float registers. assert(fltArgRegNum <= MAX_FLOAT_REG_ARG); } else @@ -4232,22 +4228,9 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // Increment intArgRegNum by 'size' registers intArgRegNum += size; -#if defined(_TARGET_AMD64_) && !defined(UNIX_AMD64_ABI) +#ifdef WINDOWS_AMD64_ABI fltArgRegNum = min(fltArgRegNum + size, MAX_FLOAT_REG_ARG); -#endif // _TARGET_AMD64_ -#ifdef _TARGET_ARM_ - if (intArgRegNum > MAX_REG_ARG) - { - // This indicates a partial enregistration of a struct type - assert((isStructArg) || argx->OperIsFieldList() || argx->OperIsCopyBlkOp() || - (argx->gtOper == GT_COMMA && (args->gtFlags & GTF_ASG))); - unsigned numRegsPartial = size - (intArgRegNum - MAX_REG_ARG); - assert((unsigned char)numRegsPartial == numRegsPartial); - call->fgArgInfo->SplitArg(argIndex, numRegsPartial, size - numRegsPartial); - intArgRegNum = MAX_REG_ARG; - fgPtrArgCntCur += size - numRegsPartial; - } -#endif // _TARGET_ARM_ +#endif // WINDOWS_AMD64_ABI } } } @@ -4266,18 +4249,14 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) else { // This is a stack argument - put it in the table - call->fgArgInfo->AddStkArg(argIndex, argx, args, size, argAlign UNIX_AMD64_ABI_ONLY_ARG(isStructArg)); + call->fgArgInfo->AddStkArg(argIndex, argx, args, size, argAlign, isStructArg, callIsVararg); } } if (copyBlkClass != NO_CLASS_HANDLE) { noway_assert(!reMorphing); - fgMakeOutgoingStructArgCopy(call, args, argIndex, copyBlkClass UNIX_AMD64_ABI_ONLY_ARG(&structDesc)); - -#ifdef UNIX_AMD64_ABI - hasStackArgCopy = true; -#endif + fgMakeOutgoingStructArgCopy(call, args, argIndex, copyBlkClass); } if (argx->gtOper == GT_MKREFANY) @@ -4289,9 +4268,9 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // Build the mkrefany as a GT_FIELD_LIST GenTreeFieldList* fieldList = new (this, GT_FIELD_LIST) - GenTreeFieldList(argx->gtOp.gtOp1, offsetof(CORINFO_RefAny, dataPtr), TYP_BYREF, nullptr); + GenTreeFieldList(argx->gtOp.gtOp1, OFFSETOF__CORINFO_TypedReference__dataPtr, TYP_BYREF, nullptr); (void)new (this, GT_FIELD_LIST) - GenTreeFieldList(argx->gtOp.gtOp2, offsetof(CORINFO_RefAny, type), TYP_I_IMPL, fieldList); + GenTreeFieldList(argx->gtOp.gtOp2, OFFSETOF__CORINFO_TypedReference__type, TYP_I_IMPL, fieldList); fgArgTabEntry* fp = Compiler::gtArgEntryByNode(call, argx); fp->node = fieldList; args->gtOp.gtOp1 = fieldList; @@ -4305,8 +4284,8 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // Build the mkrefany as a comma node: // (tmp.ptr=argx),(tmp.type=handle) - GenTreeLclFld* destPtrSlot = gtNewLclFldNode(tmp, TYP_I_IMPL, offsetof(CORINFO_RefAny, dataPtr)); - GenTreeLclFld* destTypeSlot = gtNewLclFldNode(tmp, TYP_I_IMPL, offsetof(CORINFO_RefAny, type)); + GenTreeLclFld* destPtrSlot = gtNewLclFldNode(tmp, TYP_I_IMPL, OFFSETOF__CORINFO_TypedReference__dataPtr); + GenTreeLclFld* destTypeSlot = gtNewLclFldNode(tmp, TYP_I_IMPL, OFFSETOF__CORINFO_TypedReference__type); destPtrSlot->gtFieldSeq = GetFieldSeqStore()->CreateSingleton(GetRefanyDataField()); destPtrSlot->gtFlags |= GTF_VAR_DEF; destTypeSlot->gtFieldSeq = GetFieldSeqStore()->CreateSingleton(GetRefanyTypeField()); @@ -4471,11 +4450,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) // For UNIX_AMD64, the condition without hasStackArgCopy cannot catch // all cases of fgMakeOutgoingStructArgCopy() being called. hasStackArgCopy // is added to make sure to call EvalArgsToTemp. - if (!reMorphing && (call->fgArgInfo->HasRegArgs() -#ifdef UNIX_AMD64_ABI - || hasStackArgCopy -#endif // UNIX_AMD64_ABI - )) + if (!reMorphing && (call->fgArgInfo->HasRegArgs())) { // This is the first time that we morph this call AND it has register arguments. // Follow into the code below and do the 'defer or eval to temp' analysis. @@ -4491,22 +4466,11 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) } } -#ifdef UNIX_AMD64_ABI - - // Rewrite the struct args to be passed by value on stack or in registers. - fgMorphSystemVStructArgs(call, hasStructArgument); - -#else // !UNIX_AMD64_ABI - - // In the future we can migrate UNIX_AMD64 to use this - // method instead of fgMorphSystemVStructArgs if (hasMultiregStructArgs) { fgMorphMultiregStructArgs(call); } -#endif // UNIX_AMD64_ABI - #ifdef DEBUG if (verbose) { @@ -4519,195 +4483,12 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) #pragma warning(pop) #endif -#ifdef UNIX_AMD64_ABI -// fgMorphSystemVStructArgs: -// Rewrite the struct args to be passed by value on stack or in registers. -// -// args: -// call: The call whose arguments need to be morphed. -// hasStructArgument: Whether this call has struct arguments. -// -void Compiler::fgMorphSystemVStructArgs(GenTreeCall* call, bool hasStructArgument) -{ - unsigned flagsSummary = 0; - - if (hasStructArgument) - { - fgArgInfo* allArgInfo = call->fgArgInfo; - - for (GenTree* args = call->gtCallArgs; args != nullptr; args = args->gtOp.gtOp2) - { - // For late arguments the arg tree that is overridden is in the gtCallLateArgs list. - // For such late args the gtCallArgList contains the setup arg node (evaluating the arg.) - // The tree from the gtCallLateArgs list is passed to the callee. The fgArgEntry node contains the mapping - // between the nodes in both lists. If the arg is not a late arg, the fgArgEntry->node points to itself, - // otherwise points to the list in the late args list. - bool isLateArg = (args->gtOp.gtOp1->gtFlags & GTF_LATE_ARG) != 0; - fgArgTabEntry* fgEntryPtr = gtArgEntryByNode(call, args->gtOp.gtOp1); - assert(fgEntryPtr != nullptr); - GenTree* argx = fgEntryPtr->node; - GenTree* lateList = nullptr; - GenTree* lateNode = nullptr; - - if (isLateArg) - { - for (GenTree* list = call->gtCallLateArgs; list; list = list->MoveNext()) - { - assert(list->OperIsList()); - - GenTree* argNode = list->Current(); - if (argx == argNode) - { - lateList = list; - lateNode = argNode; - break; - } - } - assert(lateList != nullptr && lateNode != nullptr); - } - GenTree* arg = argx; - bool argListCreated = false; - - var_types type = arg->TypeGet(); - - if (varTypeIsStruct(type)) - { - var_types originalType = type; - // If we have already processed the arg... - if (arg->OperGet() == GT_FIELD_LIST && varTypeIsStruct(arg)) - { - continue; - } - - // If already OBJ it is set properly already. - if (arg->OperGet() == GT_OBJ) - { - assert(!fgEntryPtr->structDesc.passedInRegisters); - continue; - } - - assert(arg->OperGet() == GT_LCL_VAR || arg->OperGet() == GT_LCL_FLD || - (arg->OperGet() == GT_ADDR && - (arg->gtOp.gtOp1->OperGet() == GT_LCL_FLD || arg->gtOp.gtOp1->OperGet() == GT_LCL_VAR))); - - GenTreeLclVarCommon* lclCommon = - arg->OperGet() == GT_ADDR ? arg->gtOp.gtOp1->AsLclVarCommon() : arg->AsLclVarCommon(); - if (fgEntryPtr->structDesc.passedInRegisters) - { - if (fgEntryPtr->structDesc.eightByteCount == 1) - { - // Change the type and below the code will change the LclVar to a LCL_FLD - type = GetTypeFromClassificationAndSizes(fgEntryPtr->structDesc.eightByteClassifications[0], - fgEntryPtr->structDesc.eightByteSizes[0]); - } - else if (fgEntryPtr->structDesc.eightByteCount == 2) - { - // Create LCL_FLD for each eightbyte. - argListCreated = true; - - // First eightbyte. - arg->AsLclFld()->gtFieldSeq = FieldSeqStore::NotAField(); - arg->gtType = - GetTypeFromClassificationAndSizes(fgEntryPtr->structDesc.eightByteClassifications[0], - fgEntryPtr->structDesc.eightByteSizes[0]); - GenTreeFieldList* fieldList = - new (this, GT_FIELD_LIST) GenTreeFieldList(arg, 0, originalType, nullptr); - fieldList->gtType = originalType; // Preserve the type. It is a special case. - arg = fieldList; - - // Second eightbyte. - GenTreeLclFld* newLclField = new (this, GT_LCL_FLD) - GenTreeLclFld(GetTypeFromClassificationAndSizes(fgEntryPtr->structDesc - .eightByteClassifications[1], - fgEntryPtr->structDesc.eightByteSizes[1]), - lclCommon->gtLclNum, fgEntryPtr->structDesc.eightByteOffsets[1]); - - fieldList = new (this, GT_FIELD_LIST) GenTreeFieldList(newLclField, 0, originalType, fieldList); - fieldList->gtType = originalType; // Preserve the type. It is a special case. - newLclField->gtFieldSeq = FieldSeqStore::NotAField(); - } - else - { - assert(false && "More than two eightbytes detected for CLR."); // No more than two eightbytes - // for the CLR. - } - } - - // If we didn't change the type of the struct, it means - // its classification doesn't support to be passed directly through a - // register, so we need to pass a pointer to the destination where - // where we copied the struct to. - if (!argListCreated) - { - if (fgEntryPtr->structDesc.passedInRegisters) - { - arg->gtType = type; - } - else - { - // Make sure this is an addr node. - if (arg->OperGet() != GT_ADDR && arg->OperGet() != GT_LCL_VAR_ADDR) - { - arg = gtNewOperNode(GT_ADDR, TYP_I_IMPL, arg); - } - - assert(arg->OperGet() == GT_ADDR || arg->OperGet() == GT_LCL_VAR_ADDR); - - // Create an Obj of the temp to use it as a call argument. - arg = gtNewObjNode(lvaGetStruct(lclCommon->gtLclNum), arg); - } - } - } - - if (argx != arg) - { - bool isLateArg = (args->gtOp.gtOp1->gtFlags & GTF_LATE_ARG) != 0; - fgArgTabEntry* fgEntryPtr = gtArgEntryByNode(call, args->gtOp.gtOp1); - assert(fgEntryPtr != nullptr); - GenTree* argx = fgEntryPtr->node; - GenTree* lateList = nullptr; - GenTree* lateNode = nullptr; - if (isLateArg) - { - for (GenTree* list = call->gtCallLateArgs; list; list = list->MoveNext()) - { - assert(list->OperIsList()); - - GenTree* argNode = list->Current(); - if (argx == argNode) - { - lateList = list; - lateNode = argNode; - break; - } - } - assert(lateList != nullptr && lateNode != nullptr); - } - - fgEntryPtr->node = arg; - if (isLateArg) - { - lateList->gtOp.gtOp1 = arg; - } - else - { - args->gtOp.gtOp1 = arg; - } - } - } - } - - // Update the flags - call->gtFlags |= (flagsSummary & GTF_ALL_EFFECT); -} -#endif // UNIX_AMD64_ABI - //----------------------------------------------------------------------------- // fgMorphMultiregStructArgs: Locate the TYP_STRUCT arguments and // call fgMorphMultiregStructArg on each of them. // // Arguments: -// call: a GenTreeCall node that has one or more TYP_STRUCT arguments +// call : a GenTreeCall node that has one or more TYP_STRUCT arguments\ // // Notes: // We only call fgMorphMultiregStructArg for struct arguments that are not passed as simple types. @@ -4721,19 +4502,11 @@ void Compiler::fgMorphMultiregStructArgs(GenTreeCall* call) unsigned flagsSummary = 0; fgArgInfo* allArgInfo = call->fgArgInfo; - // Currently ARM64/ARM is using this method to morph the MultiReg struct args - // in the future AMD64_UNIX will also use this method - CLANG_FORMAT_COMMENT_ANCHOR; - #ifdef _TARGET_X86_ assert(!"Logic error: no MultiregStructArgs for X86"); #endif -#ifdef _TARGET_AMD64_ -#if defined(UNIX_AMD64_ABI) - NYI_AMD64("fgMorphMultiregStructArgs (UNIX ABI)"); -#else // WINDOWS_AMD64_ABI +#if defined(_TARGET_AMD64_) && !defined(UNIX_AMD64_ABI) assert(!"Logic error: no MultiregStructArgs for Windows X64 ABI"); -#endif // !UNIX_AMD64_ABI #endif for (GenTree* args = call->gtCallArgs; args != nullptr; args = args->gtOp.gtOp2) @@ -4830,7 +4603,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry { assert(varTypeIsStruct(arg->TypeGet())); -#ifndef _TARGET_ARMARCH_ +#if !defined(_TARGET_ARMARCH_) && !defined(UNIX_AMD64_ABI) NYI("fgMorphMultiregStructArg requires implementation for this target"); #endif @@ -4843,7 +4616,6 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry { GenTreeLclVarCommon* lcl = nullptr; - // If already OBJ it is set properly already. if (arg->OperGet() == GT_OBJ) { if (arg->gtGetOp1()->OperIs(GT_ADDR) && arg->gtGetOp1()->gtGetOp1()->OperIs(GT_LCL_VAR)) @@ -4855,7 +4627,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry { assert(arg->OperGet() == GT_LCL_VAR); - // We need to construct a `GT_OBJ` node for the argmuent, + // We need to construct a `GT_OBJ` node for the argument, // so we need to get the address of the lclVar. lcl = arg->AsLclVarCommon(); } @@ -4865,8 +4637,9 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry { arg = fgMorphLclArgToFieldlist(lcl); } - else + else if (arg->TypeGet() == TYP_STRUCT) { + // If this is a non-register struct, it must be referenced from memory. if (!arg->OperIs(GT_OBJ)) { // Create an Obj of the temp to use it as a call argument. @@ -4901,7 +4674,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry GenTree* underlyingTree = op1->gtOp.gtOp1; // Only update to the same type. - if ((underlyingTree->TypeGet() == argValue->TypeGet()) && + if (underlyingTree->OperIs(GT_LCL_VAR) && (underlyingTree->TypeGet() == argValue->TypeGet()) && (objClass == gtGetStructHandleIfPresent(underlyingTree))) { argValue = underlyingTree; @@ -4927,7 +4700,11 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry var_types type[MAX_ARG_REG_COUNT] = {}; // TYP_UNDEF = 0 hfaType = GetHfaType(objClass); // set to float or double if it is an HFA, otherwise TYP_UNDEF - if (varTypeIsFloating(hfaType)) + if (varTypeIsFloating(hfaType) +#if !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + && !fgEntryPtr->isVararg +#endif // !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + ) { elemType = hfaType; elemSize = genTypeSize(elemType); @@ -4940,28 +4717,27 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry } else { -#ifdef _TARGET_ARM64_ - assert(structSize <= 2 * TARGET_POINTER_SIZE); -#elif defined(_TARGET_ARM_) - assert(structSize <= 4 * TARGET_POINTER_SIZE); -#endif - -#ifdef _TARGET_ARM64_ - BYTE gcPtrs[2] = {TYPE_GC_NONE, TYPE_GC_NONE}; - info.compCompHnd->getClassGClayout(objClass, &gcPtrs[0]); - elemCount = 2; - type[0] = getJitGCType(gcPtrs[0]); - type[1] = getJitGCType(gcPtrs[1]); -#elif defined(_TARGET_ARM_) - BYTE gcPtrs[4] = {TYPE_GC_NONE, TYPE_GC_NONE, TYPE_GC_NONE, TYPE_GC_NONE}; - elemCount = (unsigned)roundUp(structSize, TARGET_POINTER_SIZE) / TARGET_POINTER_SIZE; + assert(structSize <= MAX_ARG_REG_COUNT * TARGET_POINTER_SIZE); + BYTE gcPtrs[MAX_ARG_REG_COUNT]; + elemCount = (unsigned)roundUp(structSize, TARGET_POINTER_SIZE) / TARGET_POINTER_SIZE; info.compCompHnd->getClassGClayout(objClass, &gcPtrs[0]); + for (unsigned inx = 0; inx < elemCount; inx++) { - type[inx] = getJitGCType(gcPtrs[inx]); +#ifdef UNIX_AMD64_ABI + if (gcPtrs[inx] == TYPE_GC_NONE) + { + type[inx] = GetTypeFromClassificationAndSizes(fgEntryPtr->structDesc.eightByteClassifications[inx], + fgEntryPtr->structDesc.eightByteSizes[inx]); + } + else +#endif // UNIX_AMD64_ABI + { + type[inx] = getJitGCType(gcPtrs[inx]); + } } -#endif // _TARGET_ARM_ +#ifndef UNIX_AMD64_ABI if ((argValue->OperGet() == GT_LCL_FLD) || (argValue->OperGet() == GT_LCL_VAR)) { elemSize = TARGET_POINTER_SIZE; @@ -4991,18 +4767,20 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry case 2: type[lastElem] = TYP_SHORT; break; -#ifdef _TARGET_ARM64_ +#if defined(_TARGET_ARM64_) || defined(UNIX_AMD64_ABI) case 4: type[lastElem] = TYP_INT; break; -#endif // _TARGET_ARM64_ +#endif // (_TARGET_ARM64_) || (UNIX_AMD64_ABI) default: noway_assert(!"NYI: odd sized struct in fgMorphMultiregStructArg"); break; } } } +#endif // !UNIX_AMD64_ABI } + // We should still have a TYP_STRUCT assert(varTypeIsStruct(argValue->TypeGet())); @@ -5032,8 +4810,13 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry } #endif // DEBUG +#ifndef UNIX_AMD64_ABI // This local variable must match the layout of the 'objClass' type exactly - if (varDsc->lvIsHfa()) + if (varDsc->lvIsHfa() +#if !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + && !fgEntryPtr->isVararg +#endif // !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + ) { // We have a HFA struct noway_assert(elemType == (varDsc->lvHfaTypeIsFloat() ? TYP_FLOAT : TYP_DOUBLE)); @@ -5048,7 +4831,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry } else { -#ifdef _TARGET_ARM64_ +#if defined(_TARGET_ARM64_) // We must have a 16-byte struct (non-HFA) noway_assert(elemCount == 2); #elif defined(_TARGET_ARM_) @@ -5074,11 +4857,16 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry } } } +#endif // !UNIX_AMD64_ABI -#ifdef _TARGET_ARM64_ +#if defined(_TARGET_ARM64_) || defined(UNIX_AMD64_ABI) // Is this LclVar a promoted struct with exactly 2 fields? // TODO-ARM64-CQ: Support struct promoted HFA types here - if (varDsc->lvPromoted && (varDsc->lvFieldCnt == 2) && !varDsc->lvIsHfa()) + if (varDsc->lvPromoted && (varDsc->lvFieldCnt == 2) && (!varDsc->lvIsHfa() +#if !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + && !fgEntryPtr->isVararg +#endif // !defined(_HOST_UNIX_) && defined(_TARGET_ARM64_) + )) { // See if we have two promoted fields that start at offset 0 and 8? unsigned loVarNum = lvaGetFieldLocal(varDsc, 0); @@ -5208,7 +4996,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry LclVarDsc* varDsc = &lvaTable[varNum]; unsigned baseOffset = (argValue->OperGet() == GT_LCL_FLD) ? argValue->gtLclFld.gtLclOffs : 0; - unsigned lastOffset = baseOffset + (elemCount * elemSize); + unsigned lastOffset = baseOffset + structSize; // The allocated size of our LocalVar must be at least as big as lastOffset assert(varDsc->lvSize() >= lastOffset); @@ -5217,13 +5005,18 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry { // alignment of the baseOffset is required noway_assert((baseOffset % TARGET_POINTER_SIZE) == 0); +#ifndef UNIX_AMD64_ABI noway_assert(elemSize == TARGET_POINTER_SIZE); +#endif unsigned baseIndex = baseOffset / TARGET_POINTER_SIZE; const BYTE* gcPtrs = varDsc->lvGcLayout; // Get the GC layout for the local variable for (unsigned inx = 0; (inx < elemCount); inx++) { // The GC information must match what we setup using 'objClass' - noway_assert(type[inx] == getJitGCType(gcPtrs[baseIndex + inx])); + if ((gcPtrs[baseIndex + inx] != TYPE_GC_NONE) || varTypeGCtype(type[inx])) + { + noway_assert(type[inx] == getJitGCType(gcPtrs[baseIndex + inx])); + } } } else // this varDsc contains no GC pointers @@ -5330,7 +5123,7 @@ GenTree* Compiler::fgMorphMultiregStructArg(GenTree* arg, fgArgTabEntry* fgEntry // We need to propagate any GTF_ALL_EFFECT flags from the end of the list back to the beginning. // This is verified in fgDebugCheckFlags(). - ArrayStack stack(this); + ArrayStack stack(getAllocator(CMK_ArrayStack)); GenTree* tree; for (tree = newArg; (tree->gtGetOp2() != nullptr) && tree->gtGetOp2()->OperIsFieldList(); tree = tree->gtGetOp2()) { @@ -5400,19 +5193,19 @@ GenTreeFieldList* Compiler::fgMorphLclArgToFieldlist(GenTreeLclVarCommon* lcl) // Make a copy of a struct variable if necessary, to pass to a callee. // returns: tree that computes address of the outgoing arg -void Compiler::fgMakeOutgoingStructArgCopy( - GenTreeCall* call, - GenTree* args, - unsigned argIndex, - CORINFO_CLASS_HANDLE copyBlkClass - UNIX_AMD64_ABI_ONLY_ARG(const SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR* const structDescPtr)) +void Compiler::fgMakeOutgoingStructArgCopy(GenTreeCall* call, + GenTree* args, + unsigned argIndex, + CORINFO_CLASS_HANDLE copyBlkClass) { GenTree* argx = args->Current(); noway_assert(argx->gtOper != GT_MKREFANY); + fgArgTabEntry* fp = Compiler::gtArgEntryByNode(call, argx); + GenTreeLclVarCommon* lcl = nullptr; + // See if we need to insert a copy at all // Case 1: don't need a copy if it is the last use of a local. We can't determine that all of the time // but if there is only one use and no loops, the use must be last. - GenTreeLclVarCommon* lcl = nullptr; if (argx->OperIsLocal()) { lcl = argx->AsLclVarCommon(); @@ -5431,12 +5224,11 @@ void Compiler::fgMakeOutgoingStructArgCopy( // on the caller's frame. If an argument lives on the caller caller's frame, it may get // overwritten if that frame is reused for the tail call. Therefore, we should always copy // struct parameters if they are passed as arguments to a tail call. - if (!call->IsTailCallViaHelper() && (varDsc->lvRefCnt == 1) && !fgMightHaveLoop()) + if (!call->IsTailCallViaHelper() && (varDsc->lvRefCnt() == 1) && !fgMightHaveLoop()) { - varDsc->lvRefCnt = 0; - args->gtOp.gtOp1 = lcl; - fgArgTabEntry* fp = Compiler::gtArgEntryByNode(call, argx); - fp->node = lcl; + varDsc->setLvRefCnt(0); + args->gtOp.gtOp1 = lcl; + fp->node = lcl; JITDUMP("did not have to make outgoing copy for V%2d", varNum); return; @@ -5479,6 +5271,11 @@ void Compiler::fgMakeOutgoingStructArgCopy( // Here We don't need unsafe value cls check, since the addr of this temp is used only in copyblk. tmp = lvaGrabTemp(true DEBUGARG("by-value struct argument")); lvaSetStruct(tmp, copyBlkClass, false); + if (call->IsVarargs()) + { + lvaSetStructUsedAsVarArg(tmp); + } + fgOutgoingArgTemps->setBit(tmp); } @@ -5523,8 +5320,9 @@ void Compiler::fgMakeOutgoingStructArgCopy( #else // FEATURE_FIXED_OUT_ARGS // Structs are always on the stack, and thus never need temps - // so we have to put the copy and temp all into one expression - GenTree* arg = fgMakeTmpArgNode(tmp UNIX_AMD64_ABI_ONLY_ARG(structDescPtr->passedInRegisters)); + // so we have to put the copy and temp all into one expression. + fp->tmpNum = tmp; + GenTree* arg = fgMakeTmpArgNode(fp); // Change the expression to "(tmp=val),tmp" arg = gtNewOperNode(GT_COMMA, arg->TypeGet(), copyBlk, arg); @@ -5959,19 +5757,19 @@ GenTree* Compiler::fgMorphArrayIndex(GenTree* tree) ssize_t elemOffs; if (tree->gtFlags & GTF_INX_STRING_LAYOUT) { - lenOffs = offsetof(CORINFO_String, stringLen); - elemOffs = offsetof(CORINFO_String, chars); + lenOffs = OFFSETOF__CORINFO_String__stringLen; + elemOffs = OFFSETOF__CORINFO_String__chars; tree->gtFlags &= ~GTF_INX_STRING_LAYOUT; // Clear this flag as it is used for GTF_IND_VOLATILE } else if (tree->gtFlags & GTF_INX_REFARR_LAYOUT) { - lenOffs = offsetof(CORINFO_RefArray, length); + lenOffs = OFFSETOF__CORINFO_Array__length; elemOffs = eeGetEEInfo()->offsetOfObjArrayData; } else // We have a standard array { - lenOffs = offsetof(CORINFO_Array, length); - elemOffs = offsetof(CORINFO_Array, u1Elems); + lenOffs = OFFSETOF__CORINFO_Array__length; + elemOffs = OFFSETOF__CORINFO_Array__data; } // In minopts, we expand GT_INDEX to GT_IND(GT_INDEX_ADDR) in order to minimize the size of the IR. As minopts @@ -7443,6 +7241,10 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee) // that cannot be passed in a register. Note that we don't need to count // non-standard and secret params passed in registers (e.g. R10, R11) since // these won't contribute to out-going arg size. + // For each struct arg, hasMultiByteStackArgs will track if it can be passed in registers. + // If it cannot we will break the loop and not fastTailCall. This is an implementation limitation + // where the callee only is checked for non enregisterable structs. + // It is tracked with https://github.com/dotnet/coreclr/issues/12644. bool hasMultiByteStackArgs = false; bool hasTwoSlotSizedStruct = false; bool hasHfaArg = false; @@ -7477,14 +7279,11 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee) { #if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_) - // hasMultiByteStackArgs will determine if the struct can be passed - // in registers. If it cannot we will break the loop and not - // fastTailCall. This is an implementation limitation - // where the callee only is checked for non enregisterable structs. - // It is tracked with https://github.com/dotnet/coreclr/issues/12644. - unsigned typeSize = 0; - hasMultiByteStackArgs = hasMultiByteStackArgs || - !VarTypeIsMultiByteAndCanEnreg(argx->TypeGet(), objClass, &typeSize, false); + unsigned typeSize = 0; + // We should have already broken out of the loop if we've set hasMultiByteStackArgs to true. + assert(!hasMultiByteStackArgs); + hasMultiByteStackArgs = + !VarTypeIsMultiByteAndCanEnreg(argx->TypeGet(), objClass, &typeSize, false, false); #if defined(UNIX_AMD64_ABI) SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR structDesc; @@ -7519,6 +7318,7 @@ bool Compiler::fgCanFastTailCall(GenTreeCall* callee) else { calleeStackSize += roundUp(typeSize, TARGET_POINTER_SIZE); + hasMultiByteStackArgs = true; } #elif defined(_TARGET_ARM64_) // ARM64 @@ -7814,9 +7614,23 @@ void Compiler::fgMorphTailCall(GenTreeCall* call, void* pfnCopyArgs) /* Now the appropriate vtable slot */ - add = gtNewOperNode(GT_ADD, TYP_I_IMPL, vtbl, gtNewIconNode(vtabOffsAfterIndirection, TYP_I_IMPL)); + add = gtNewOperNode(GT_ADD, TYP_I_IMPL, vtbl, gtNewIconNode(vtabOffsAfterIndirection, TYP_I_IMPL)); + + GenTree* indOffTree = nullptr; + + if (isRelative) + { + indOffTree = impCloneExpr(add, &add, NO_CLASS_HANDLE, (unsigned)CHECK_SPILL_ALL, + nullptr DEBUGARG("virtual table call 2")); + } + vtbl = gtNewOperNode(GT_IND, TYP_I_IMPL, add); + if (isRelative) + { + vtbl = gtNewOperNode(GT_ADD, TYP_I_IMPL, vtbl, indOffTree); + } + // Switch this to a plain indirect call call->gtFlags &= ~GTF_CALL_VIRT_KIND_MASK; assert(!call->IsVirtual()); @@ -8235,6 +8049,12 @@ void Compiler::fgMorphRecursiveFastTailCallIntoLoop(BasicBlock* block, GenTreeCa LclVarDsc* varDsc; for (varNum = 0, varDsc = lvaTable; varNum < lvaCount; varNum++, varDsc++) { +#if FEATURE_FIXED_OUT_ARGS + if (varNum == lvaOutgoingArgSpaceVar) + { + continue; + } +#endif // FEATURE_FIXED_OUT_ARGS if (!varDsc->lvIsParam) { var_types lclType = varDsc->TypeGet(); @@ -9831,9 +9651,6 @@ GenTree* Compiler::fgMorphInitBlock(GenTree* tree) // if (!destDoFldAsg) { -#if CPU_USES_BLOCK_MOVE - compBlkOpUsed = true; -#endif dest = fgMorphBlockOperand(dest, dest->TypeGet(), blockWidth, true); tree->gtOp.gtOp1 = dest; tree->gtFlags |= (dest->gtFlags & GTF_ALL_EFFECT); @@ -10059,7 +9876,7 @@ GenTree* Compiler::fgMorphBlkNode(GenTree* tree, bool isDest) addr = tree; GenTree* effectiveVal = tree->gtEffectiveVal(); - GenTreePtrStack commas(this); + GenTreePtrStack commas(getAllocator(CMK_ArrayStack)); for (GenTree* comma = tree; comma != nullptr && comma->gtOper == GT_COMMA; comma = comma->gtGetOp2()) { commas.Push(comma); @@ -10775,9 +10592,6 @@ GenTree* Compiler::fgMorphCopyBlock(GenTree* tree) if (requiresCopyBlock) { -#if CPU_USES_BLOCK_MOVE - compBlkOpUsed = true; -#endif var_types asgType = dest->TypeGet(); dest = fgMorphBlockOperand(dest, asgType, blockWidth, true /*isDest*/); asg->gtOp.gtOp1 = dest; @@ -12062,6 +11876,9 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) } break; #endif + case GT_LIST: + // Special handling for the arg list. + return fgMorphArgList(tree->AsArgList(), mac); default: break; @@ -12759,11 +12576,11 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) // And then emitter::emitEndCodeGen will assert in the following line: // noway_assert( dsc->lvTracked); // - noway_assert(varDsc->lvRefCnt == 0 || // lvRefCnt may not have been set yet. - varDsc->lvRefCnt == 2 // Or, we assume this tmp should only be used here, - // and it only shows up twice. + noway_assert(varDsc->lvRefCnt() == 0 || // lvRefCnt may not have been set yet. + varDsc->lvRefCnt() == 2 // Or, we assume this tmp should only be used here, + // and it only shows up twice. ); - lvaTable[lclNum].lvRefCnt = 0; + lvaTable[lclNum].setLvRefCnt(0); lvaTable[lclNum].lvaResetSortAgainFlag(this); } @@ -13097,9 +12914,11 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) { noway_assert(varTypeIsIntOrI(tree)); - tree->gtOp.gtOp2 = op2 = gtNewOperNode(GT_NEG, tree->gtType, op2); // The type of the new GT_NEG - // node should be the same - // as the type of the tree, i.e. tree->gtType. + // The type of the new GT_NEG node cannot just be op2->TypeGet(). + // Otherwise we may sign-extend incorrectly in cases where the GT_NEG + // node ends up feeding directly into a cast, for example in + // GT_CAST(GT_SUB(0, s_1.ubyte)) + tree->gtOp.gtOp2 = op2 = gtNewOperNode(GT_NEG, genActualType(op2->TypeGet()), op2); fgMorphTreeDone(op2); oper = GT_ADD; @@ -13325,7 +13144,11 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) // if negative negate (min-int does not need negation) if (mult < 0 && mult != SSIZE_T_MIN) { - tree->gtOp.gtOp1 = op1 = gtNewOperNode(GT_NEG, op1->gtType, op1); + // The type of the new GT_NEG node cannot just be op1->TypeGet(). + // Otherwise we may sign-extend incorrectly in cases where the GT_NEG + // node ends up feeding directly a cast, for example in + // GT_CAST(GT_MUL(-1, s_1.ubyte) + tree->gtOp.gtOp1 = op1 = gtNewOperNode(GT_NEG, genActualType(op1->TypeGet()), op1); fgMorphTreeDone(op1); } @@ -13367,7 +13190,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) // if negative negate (min-int does not need negation) if (mult < 0 && mult != SSIZE_T_MIN) { - tree->gtOp.gtOp1 = op1 = gtNewOperNode(GT_NEG, op1->gtType, op1); + tree->gtOp.gtOp1 = op1 = gtNewOperNode(GT_NEG, genActualType(op1->TypeGet()), op1); fgMorphTreeDone(op1); } @@ -13823,7 +13646,7 @@ GenTree* Compiler::fgMorphSmpOp(GenTree* tree, MorphAddrContext* mac) // Perform the transform ADDR(COMMA(x, ..., z)) == COMMA(x, ..., ADDR(z)). // (Be sure to mark "z" as an l-value...) - GenTreePtrStack commas(this); + GenTreePtrStack commas(getAllocator(CMK_ArrayStack)); for (GenTree* comma = op1; comma != nullptr && comma->gtOper == GT_COMMA; comma = comma->gtGetOp2()) { commas.Push(comma); @@ -17246,10 +17069,6 @@ void Compiler::fgMorph() fgAddInternal(); -#if OPT_BOOL_OPS - fgMultipleNots = false; -#endif - #ifdef DEBUG /* Inliner could add basic blocks. Check that the flowgraph data is up-to-date */ fgDebugCheckBBlist(false, false); @@ -17529,8 +17348,8 @@ Compiler::fgWalkResult Compiler::fgMorphStructField(GenTree* tree, fgWalkData* f // chance, so have to check now. JITDUMP( "Incrementing ref count from %d to %d for V%02d in fgMorphStructField for promoted struct\n", - varDsc->lvRefCnt, varDsc->lvRefCnt + 1, lclNum); - varDsc->lvRefCnt++; + varDsc->lvRefCnt(), varDsc->lvRefCnt() + 1, lclNum); + varDsc->incLvRefCnt(1); } tree->SetOper(GT_LCL_VAR); @@ -17620,8 +17439,8 @@ Compiler::fgWalkResult Compiler::fgMorphStructField(GenTree* tree, fgWalkData* f // lclVars, but here we're about to return SKIP_SUBTREES and rob it of the // chance, so have to check now. JITDUMP("Incrementing ref count from %d to %d for V%02d in fgMorphStructField for normed struct\n", - varDsc->lvRefCnt, varDsc->lvRefCnt + 1, lclNum); - varDsc->lvRefCnt++; + varDsc->lvRefCnt(), varDsc->lvRefCnt() + 1, lclNum); + varDsc->incLvRefCnt(1); } tree->ChangeOper(GT_LCL_VAR); @@ -17763,7 +17582,7 @@ void Compiler::fgMarkImplicitByRefArgs() #if defined(_TARGET_AMD64_) if (size > REGSIZE_BYTES || (size & (size - 1)) != 0) #elif defined(_TARGET_ARM64_) - if ((size > TARGET_POINTER_SIZE) && !lvaIsMultiregStruct(varDsc)) + if ((size > TARGET_POINTER_SIZE) && !lvaIsMultiregStruct(varDsc, this->info.compIsVarArgs)) #endif { // Previously nobody was ever setting lvIsParam and lvIsTemp on the same local @@ -17777,7 +17596,7 @@ void Compiler::fgMarkImplicitByRefArgs() // appearance of implicit-by-ref param so that call arg morphing can do an // optimization for single-use implicit-by-ref params whose single use is as // an outgoing call argument. - varDsc->lvRefCnt = 0; + varDsc->setLvRefCnt(0); } } } @@ -17828,6 +17647,11 @@ void Compiler::fgRetypeImplicitByRefArgs() // promoted struct before rewriting this parameter as a pointer. unsigned newLclNum = lvaGrabTemp(false DEBUGARG("Promoted implicit byref")); lvaSetStruct(newLclNum, lvaGetStruct(lclNum), true); + if (info.compIsVarArgs) + { + lvaSetStructUsedAsVarArg(newLclNum); + } + // Update varDsc since lvaGrabTemp might have re-allocated the var dsc array. varDsc = &lvaTable[lclNum]; @@ -17859,7 +17683,7 @@ void Compiler::fgRetypeImplicitByRefArgs() // parameter if it weren't promoted at all (otherwise the initialization // of the new temp would just be a needless memcpy at method entry). bool undoPromotion = (lvaGetPromotionType(newVarDsc) == PROMOTION_TYPE_DEPENDENT) || - (varDsc->lvRefCnt <= varDsc->lvFieldCnt); + (varDsc->lvRefCnt() <= varDsc->lvFieldCnt); if (!undoPromotion) { @@ -17897,7 +17721,7 @@ void Compiler::fgRetypeImplicitByRefArgs() // to the implicit byref parameter when morphing calls that pass the implicit byref // out as an outgoing argument value, but that doesn't pertain to this field local // which is now a field of a non-arg local. - fieldVarDsc->lvRefCnt = 0; + fieldVarDsc->setLvRefCnt(0); } fieldVarDsc->lvIsParam = false; @@ -18014,12 +17838,12 @@ void Compiler::fgMarkDemotedImplicitByRefArgs() // call morphing could identify single-use implicit byrefs; we're done with // that, and want it to be in its default state of zero when we go to set // real ref counts for all variables. - varDsc->lvRefCnt = 0; + varDsc->setLvRefCnt(0); // The temp struct is now unused; set flags appropriately so that we // won't allocate space for it on the stack. - LclVarDsc* structVarDsc = &lvaTable[structLclNum]; - structVarDsc->lvRefCnt = 0; + LclVarDsc* structVarDsc = &lvaTable[structLclNum]; + structVarDsc->setLvRefCnt(0); structVarDsc->lvAddrExposed = false; #ifdef DEBUG structVarDsc->lvUnusedStruct = true; @@ -18038,7 +17862,7 @@ void Compiler::fgMarkDemotedImplicitByRefArgs() // The field local is now unused; set flags appropriately so that // we won't allocate stack space for it. - fieldVarDsc->lvRefCnt = 0; + fieldVarDsc->setLvRefCnt(0); fieldVarDsc->lvAddrExposed = false; } } @@ -18433,10 +18257,10 @@ Compiler::fgWalkResult Compiler::fgMarkAddrTakenLocalsPreCB(GenTree** pTree, fgW // checks the ref counts for implicit byref params when deciding if it's legal // to elide certain copies of them. LclVarDsc* varDsc = &comp->lvaTable[lclNum]; - JITDUMP("Incrementing ref count from %d to %d for V%02d in fgMorphStructField\n", varDsc->lvRefCnt, - varDsc->lvRefCnt + 1, lclNum); + JITDUMP("Incrementing ref count from %d to %d for V%02d in fgMorphStructField\n", varDsc->lvRefCnt(), + varDsc->lvRefCnt() + 1, lclNum); - varDsc->lvRefCnt++; + varDsc->incLvRefCnt(1); } // This recognizes certain forms, and does all the work. In that case, returns WALK_SKIP_SUBTREES, // else WALK_CONTINUE. We do the same here. @@ -18471,10 +18295,10 @@ Compiler::fgWalkResult Compiler::fgMarkAddrTakenLocalsPreCB(GenTree** pTree, fgW // byref (here during address-exposed analysis); fgMakeOutgoingStructArgCopy // checks the ref counts for implicit byref params when deciding if it's legal // to elide certain copies of them. - JITDUMP("Incrementing ref count from %d to %d for V%02d in fgMorphStructField\n", varDsc->lvRefCnt, - varDsc->lvRefCnt + 1, lclNum); + JITDUMP("Incrementing ref count from %d to %d for V%02d in fgMorphStructField\n", varDsc->lvRefCnt(), + varDsc->lvRefCnt() + 1, lclNum); - varDsc->lvRefCnt++; + varDsc->incLvRefCnt(1); } if (axc == AXC_Addr || axc == AXC_AddrWide) @@ -18719,7 +18543,7 @@ void Compiler::fgMarkAddressExposedLocals() for (stmt = block->bbTreeList; stmt; stmt = stmt->gtNext) { // Call Compiler::fgMarkAddrTakenLocalsCB on each node - AXCStack stk(this); + AXCStack stk(getAllocator(CMK_ArrayStack)); stk.Push(AXC_None); // We start in neither an addr or ind context. fgWalkTree(&stmt->gtStmt.gtStmtExpr, fgMarkAddrTakenLocalsPreCB, fgMarkAddrTakenLocalsPostCB, &stk); } @@ -18925,7 +18749,7 @@ bool Compiler::fgMorphCombineSIMDFieldAssignments(BasicBlock* block, GenTree* st // Since we generated a new address node which didn't exist before, // we should expose this address manually here. - AXCStack stk(this); + AXCStack stk(getAllocator(CMK_ArrayStack)); stk.Push(AXC_None); fgWalkTree(&stmt->gtStmt.gtStmtExpr, fgMarkAddrTakenLocalsPreCB, fgMarkAddrTakenLocalsPostCB, &stk); @@ -19084,3 +18908,64 @@ bool Compiler::fgCheckStmtAfterTailCall() } return nextMorphStmt == nullptr; } + +static const int numberOfTrackedFlags = 5; +static const unsigned trackedFlags[numberOfTrackedFlags] = {GTF_ASG, GTF_CALL, GTF_EXCEPT, GTF_GLOB_REF, + GTF_ORDER_SIDEEFF}; + +//------------------------------------------------------------------------ +// fgMorphArgList: morph argument list tree without recursion. +// +// Arguments: +// args - argument list tree to morph; +// mac - morph address context, used to morph children. +// +// Return Value: +// morphed argument list. +// +GenTreeArgList* Compiler::fgMorphArgList(GenTreeArgList* args, MorphAddrContext* mac) +{ + // Use a non-recursive algorithm that morphs all actual list values, + // memorizes the last node for each effect flag and resets + // them during the second iteration. + assert((trackedFlags[0] | trackedFlags[1] | trackedFlags[2] | trackedFlags[3] | trackedFlags[4]) == GTF_ALL_EFFECT); + + GenTree* memorizedLastNodes[numberOfTrackedFlags] = {nullptr}; + + for (GenTreeArgList* listNode = args; listNode != nullptr; listNode = listNode->Rest()) + { + // Morph actual list values. + GenTree*& arg = listNode->Current(); + arg = fgMorphTree(arg, mac); + + // Remember the last list node with each flag. + for (int i = 0; i < numberOfTrackedFlags; ++i) + { + if ((arg->gtFlags & trackedFlags[i]) != 0) + { + memorizedLastNodes[i] = listNode; + } + } + } + + for (GenTreeArgList* listNode = args; listNode != nullptr; listNode = listNode->Rest()) + { + // Clear all old effects from the list node. + listNode->gtFlags &= ~GTF_ALL_EFFECT; + + // Spread each flag to all list nodes (to the prefix) before the memorized last node. + for (int i = 0; i < numberOfTrackedFlags; ++i) + { + if (memorizedLastNodes[i] != nullptr) + { + listNode->gtFlags |= trackedFlags[i]; + } + if (listNode == memorizedLastNodes[i]) + { + memorizedLastNodes[i] = nullptr; + } + } + } + + return args; +} diff --git a/src/jit/optcse.cpp b/src/jit/optcse.cpp index 019abd67928a..f389aa5beea3 100644 --- a/src/jit/optcse.cpp +++ b/src/jit/optcse.cpp @@ -1327,7 +1327,7 @@ class CSE_Heuristic for (lclNum = 0, varDsc = m_pCompiler->lvaTable; lclNum < m_pCompiler->lvaCount; lclNum++, varDsc++) { - if (varDsc->lvRefCnt == 0) + if (varDsc->lvRefCnt() == 0) { continue; } @@ -1368,7 +1368,7 @@ class CSE_Heuristic // will consider this LclVar as being enregistered. // Now we reduce the remaining regAvailEstimate by // an appropriate amount. - if (varDsc->lvRefCnt <= 2) + if (varDsc->lvRefCnt() <= 2) { // a single use single def LclVar only uses 1 regAvailEstimate -= 1; @@ -1435,22 +1435,22 @@ class CSE_Heuristic { if (CodeOptKind() == Compiler::SMALL_CODE) { - aggressiveRefCnt = varDsc->lvRefCnt + BB_UNITY_WEIGHT; + aggressiveRefCnt = varDsc->lvRefCnt() + BB_UNITY_WEIGHT; } else { - aggressiveRefCnt = varDsc->lvRefCntWtd + BB_UNITY_WEIGHT; + aggressiveRefCnt = varDsc->lvRefCntWtd() + BB_UNITY_WEIGHT; } } if ((moderateRefCnt == 0) && (enregCount > ((CNT_CALLEE_ENREG * 3) + (CNT_CALLEE_TRASH * 2)))) { if (CodeOptKind() == Compiler::SMALL_CODE) { - moderateRefCnt = varDsc->lvRefCnt; + moderateRefCnt = varDsc->lvRefCnt(); } else { - moderateRefCnt = varDsc->lvRefCntWtd; + moderateRefCnt = varDsc->lvRefCntWtd(); } } } @@ -1683,7 +1683,7 @@ class CSE_Heuristic } #endif - // Given a CSE candidate decide whether it passes or fails the profitablity heuristic + // Given a CSE candidate decide whether it passes or fails the profitability heuristic // return true if we believe that it is profitable to promote this candidate to a CSE // bool PromotionCheck(CSE_Candidate* candidate) @@ -1757,7 +1757,7 @@ class CSE_Heuristic unsigned extra_no_cost = 0; // The 'cseRefCnt' is the RefCnt that we will have if we promote this CSE into a new LclVar - // Each CSE Def will contain two Refs and each CSE Use wil have one Ref of this new LclVar + // Each CSE Def will contain two Refs and each CSE Use will have one Ref of this new LclVar unsigned cseRefCnt = (candidate->DefCount() * 2) + candidate->UseCount(); if (CodeOptKind() == Compiler::SMALL_CODE) diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp index 5dbc404cf50c..c99703c8c10b 100644 --- a/src/jit/optimizer.cpp +++ b/src/jit/optimizer.cpp @@ -19,15 +19,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX /*****************************************************************************/ -#if COUNT_RANGECHECKS -/* static */ -unsigned Compiler::optRangeChkRmv = 0; -/* static */ -unsigned Compiler::optRangeChkAll = 0; -#endif - -/*****************************************************************************/ - void Compiler::optInit() { optLoopsMarked = false; @@ -35,6 +26,8 @@ void Compiler::optInit() /* Initialize the # of tracked loops to 0 */ optLoopCount = 0; + optLoopTable = nullptr; + /* Keep track of the number of calls and indirect calls made by this method */ optCallCount = 0; optIndirectCallCount = 0; @@ -1148,20 +1141,29 @@ bool Compiler::optRecordLoop(BasicBlock* head, assert(entry->bbNum <= bottom->bbNum); assert(head->bbNum < top->bbNum || head->bbNum > bottom->bbNum); - // If the new loop contains any existing ones, add it in the right place. unsigned char loopInd = optLoopCount; - for (unsigned char prevPlus1 = optLoopCount; prevPlus1 > 0; prevPlus1--) + + if (optLoopTable == nullptr) { - unsigned char prev = prevPlus1 - 1; - if (optLoopTable[prev].lpContainedBy(first, bottom)) - { - loopInd = prev; - } + assert(loopInd == 0); + optLoopTable = getAllocator(CMK_LoopOpt).allocate(MAX_LOOP_NUM); } - // Move up any loops if necessary. - for (unsigned j = optLoopCount; j > loopInd; j--) + else { - optLoopTable[j] = optLoopTable[j - 1]; + // If the new loop contains any existing ones, add it in the right place. + for (unsigned char prevPlus1 = optLoopCount; prevPlus1 > 0; prevPlus1--) + { + unsigned char prev = prevPlus1 - 1; + if (optLoopTable[prev].lpContainedBy(first, bottom)) + { + loopInd = prev; + } + } + // Move up any loops if necessary. + for (unsigned j = optLoopCount; j > loopInd; j--) + { + optLoopTable[j] = optLoopTable[j - 1]; + } } #ifdef DEBUG @@ -1191,6 +1193,8 @@ bool Compiler::optRecordLoop(BasicBlock* head, optLoopTable[loopInd].lpChild = BasicBlock::NOT_IN_LOOP; optLoopTable[loopInd].lpSibling = BasicBlock::NOT_IN_LOOP; + optLoopTable[loopInd].lpAsgVars = AllVarSetOps::UninitVal(); + optLoopTable[loopInd].lpFlags = 0; // We haven't yet recorded any side effects. @@ -1472,7 +1476,7 @@ class LoopSearch { // Keeping track of which blocks are in the loop requires two block sets since we may add blocks - // as we go but the BlockSet type's max ID doesn't increase to accomodate them. Define a helper + // as we go but the BlockSet type's max ID doesn't increase to accommodate them. Define a helper // struct to make the ensuing code more readable. struct LoopBlockSet { @@ -5778,6 +5782,13 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu case GT_IND: NARROW_IND: + + if ((dstSize > genTypeSize(tree->gtType)) && + (varTypeIsUnsigned(dstt) && !varTypeIsUnsigned(tree->gtType))) + { + return false; + } + /* Simply change the type of the tree */ if (doit && (dstSize <= genTypeSize(tree->gtType))) @@ -5835,9 +5846,11 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu { dstt = genSignedType(dstt); - if (oprSize == dstSize) + if ((oprSize == dstSize) && + ((varTypeIsUnsigned(dstt) == varTypeIsUnsigned(oprt)) || !varTypeIsSmall(dstt))) { - // Same size: change the CAST into a NOP + // Same size and there is no signedness mismatch for small types: change the CAST + // into a NOP tree->ChangeOper(GT_NOP); tree->gtType = dstt; tree->gtOp.gtOp2 = nullptr; @@ -5845,8 +5858,7 @@ bool Compiler::optNarrowTree(GenTree* tree, var_types srct, var_types dstt, Valu } else { - // oprSize is smaller - assert(oprSize < dstSize); + // oprSize is smaller or there is a signedness mismatch for small types // Change the CastToType in the GT_CAST node tree->CastToType() = dstt; @@ -8901,7 +8913,7 @@ void Compiler::optOptimizeBools() B1: brtrue(t1, BX) B2: brtrue(t2, BX) B3: - we wil try to fold it to : + we will try to fold it to : B1: brtrue(t1|t2, BX) B3: */ @@ -9105,7 +9117,7 @@ void Compiler::optOptimizeBools() // The new top level node that we just created does feed directly into // a comparison against zero, so set the GTF_SET_FLAGS bit so that - // we generate an instuction that sets the flags, which allows us + // we generate an instruction that sets the flags, which allows us // to omit the cmp with zero instruction. // Request that the codegen for cmpOp1 sets the condition flags diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp index d80576d97c7c..0c1107c9aa9a 100644 --- a/src/jit/rangecheck.cpp +++ b/src/jit/rangecheck.cpp @@ -23,7 +23,7 @@ RangeCheck::RangeCheck(Compiler* pCompiler) , m_pDefTable(nullptr) #endif , m_pCompiler(pCompiler) - , m_alloc(pCompiler, CMK_RangeCheck) + , m_alloc(pCompiler->getAllocator(CMK_RangeCheck)) , m_nVisitBudget(MAX_VISIT_BUDGET) { } @@ -38,7 +38,7 @@ RangeCheck::RangeMap* RangeCheck::GetRangeMap() { if (m_pRangeMap == nullptr) { - m_pRangeMap = new (&m_alloc) RangeMap(&m_alloc); + m_pRangeMap = new (m_alloc) RangeMap(m_alloc); } return m_pRangeMap; } @@ -48,7 +48,7 @@ RangeCheck::OverflowMap* RangeCheck::GetOverflowMap() { if (m_pOverflowMap == nullptr) { - m_pOverflowMap = new (&m_alloc) OverflowMap(&m_alloc); + m_pOverflowMap = new (m_alloc) OverflowMap(m_alloc); } return m_pOverflowMap; } @@ -256,7 +256,7 @@ void RangeCheck::OptimizeRangeCheck(BasicBlock* block, GenTree* stmt, GenTree* t GetRangeMap()->RemoveAll(); GetOverflowMap()->RemoveAll(); - m_pSearchPath = new (&m_alloc) SearchPath(&m_alloc); + m_pSearchPath = new (m_alloc) SearchPath(m_alloc); // Get the range for this index. Range range = GetRange(block, treeIndex, false DEBUGARG(0)); @@ -517,7 +517,7 @@ void RangeCheck::SetDef(UINT64 hash, Location* loc) { if (m_pDefTable == nullptr) { - m_pDefTable = new (&m_alloc) VarToLocMap(&m_alloc); + m_pDefTable = new (m_alloc) VarToLocMap(m_alloc); } #ifdef DEBUG Location* loc2; @@ -1186,7 +1186,7 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monotonic range = Range(Limit(Limit::keUnknown)); } - GetRangeMap()->Set(expr, new (&m_alloc) Range(range)); + GetRangeMap()->Set(expr, new (m_alloc) Range(range)); m_pSearchPath->Remove(expr); return range; } @@ -1254,7 +1254,7 @@ void RangeCheck::MapStmtDefs(const Location& loc) // To avoid ind(addr) use asgs if (loc.parent->OperIsAssignment()) { - SetDef(HashCode(lclNum, ssaNum), new (&m_alloc) Location(loc)); + SetDef(HashCode(lclNum, ssaNum), new (m_alloc) Location(loc)); } } } @@ -1263,7 +1263,7 @@ void RangeCheck::MapStmtDefs(const Location& loc) { if (loc.parent->OperGet() == GT_ASG) { - SetDef(HashCode(lclNum, ssaNum), new (&m_alloc) Location(loc)); + SetDef(HashCode(lclNum, ssaNum), new (m_alloc) Location(loc)); } } } diff --git a/src/jit/rangecheck.h b/src/jit/rangecheck.h index 8b97308502ef..35372a1d242b 100644 --- a/src/jit/rangecheck.h +++ b/src/jit/rangecheck.h @@ -175,10 +175,10 @@ struct Limit return false; } #ifdef DEBUG - const char* ToString(CompAllocator* alloc) + const char* ToString(CompAllocator alloc) { unsigned size = 64; - char* buf = (char*)alloc->Alloc(size); + char* buf = alloc.allocate(size); switch (type) { case keUndef: @@ -231,10 +231,10 @@ struct Range } #ifdef DEBUG - char* ToString(CompAllocator* alloc) + char* ToString(CompAllocator alloc) { size_t size = 64; - char* buf = (char*)alloc->Alloc(size); + char* buf = alloc.allocate(size); sprintf_s(buf, size, "<%s, %s>", lLimit.ToString(alloc), uLimit.ToString(alloc)); return buf; } diff --git a/src/jit/rationalize.cpp b/src/jit/rationalize.cpp index ad99a27ddf67..89e41679bb63 100644 --- a/src/jit/rationalize.cpp +++ b/src/jit/rationalize.cpp @@ -888,7 +888,7 @@ Compiler::fgWalkResult Rationalizer::RewriteNode(GenTree** useEdge, ArrayStackgtSIMDBaseType); GenTree* address = new (comp, GT_LEA) GenTreeAddrMode(TYP_BYREF, simdNode->gtOp1, simdNode->gtOp2, - baseTypeSize, offsetof(CORINFO_Array, u1Elems)); + baseTypeSize, OFFSETOF__CORINFO_Array__data); GenTree* ind = comp->gtNewOperNode(GT_IND, simdType, address); BlockRange().InsertBefore(simdNode, address, ind); diff --git a/src/jit/regalloc.cpp b/src/jit/regalloc.cpp index aa3d0f43bff9..f80c81bbe18a 100644 --- a/src/jit/regalloc.cpp +++ b/src/jit/regalloc.cpp @@ -295,7 +295,7 @@ void Compiler::raMarkStkVars() goto NOT_STK; } /* Unused variables typically don't get any frame space */ - else if (varDsc->lvRefCnt == 0) + else if (varDsc->lvRefCnt() == 0) { bool needSlot = false; @@ -344,7 +344,7 @@ void Compiler::raMarkStkVars() if (lvaTypeIsGC(lclNum)) { - varDsc->lvRefCnt = 1; + varDsc->setLvRefCnt(1); } if (!varDsc->lvIsParam) @@ -404,7 +404,7 @@ void Compiler::raMarkStkVars() // It must be in a register, on frame, or have zero references. - noway_assert(varDsc->lvIsInReg() || varDsc->lvOnFrame || varDsc->lvRefCnt == 0); + noway_assert(varDsc->lvIsInReg() || varDsc->lvOnFrame || varDsc->lvRefCnt() == 0); // We can't have both lvRegister and lvOnFrame noway_assert(!varDsc->lvRegister || !varDsc->lvOnFrame); @@ -424,7 +424,7 @@ void Compiler::raMarkStkVars() { if (!varDsc->lvPromoted && !varDsc->lvIsStructField) { - noway_assert(varDsc->lvRefCnt == 0 && !varDsc->lvRegister && !varDsc->lvOnFrame); + noway_assert(varDsc->lvRefCnt() == 0 && !varDsc->lvRegister && !varDsc->lvOnFrame); } } #endif diff --git a/src/jit/regset.cpp b/src/jit/regset.cpp index 2bec96f1937a..81887cc94e87 100644 --- a/src/jit/regset.cpp +++ b/src/jit/regset.cpp @@ -95,6 +95,11 @@ void RegSet::verifyRegistersUsed(regMaskTP regMask) return; } + if (regMask == RBM_NONE) + { + return; + } + // TODO-Cleanup: we need to identify the places where the registers // are not marked as used when this is called. rsSetRegsModified(regMask); @@ -320,7 +325,7 @@ void RegSet::rsSpillTree(regNumber reg, GenTree* tree, unsigned regIdx /* =0 */) treeType = tree->TypeGet(); } - var_types tempType = Compiler::tmpNormalizeType(treeType); + var_types tempType = RegSet::tmpNormalizeType(treeType); regMaskTP mask; bool floatSpill = false; @@ -385,7 +390,7 @@ void RegSet::rsSpillTree(regNumber reg, GenTree* tree, unsigned regIdx /* =0 */) SpillDsc* spill = SpillDsc::alloc(m_rsCompiler, this, tempType); // Grab a temp to store the spilled value - TempDsc* temp = m_rsCompiler->tmpGetTemp(tempType); + TempDsc* temp = tmpGetTemp(tempType); spill->spillTemp = temp; tempType = temp->tdTempType(); @@ -459,7 +464,7 @@ void RegSet::rsSpillFPStack(GenTreeCall* call) /* Grab a temp to store the spilled value */ - spill->spillTemp = temp = m_rsCompiler->tmpGetTemp(treeType); + spill->spillTemp = temp = tmpGetTemp(treeType); /* Remember what it is we have spilled */ @@ -597,7 +602,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */ -void Compiler::tmpInit() +void RegSet::tmpInit() { tmpCount = 0; tmpSize = 0; @@ -610,7 +615,7 @@ void Compiler::tmpInit() } /* static */ -var_types Compiler::tmpNormalizeType(var_types type) +var_types RegSet::tmpNormalizeType(var_types type) { type = genActualType(type); @@ -633,7 +638,7 @@ var_types Compiler::tmpNormalizeType(var_types type) * the garbage collector). */ -TempDsc* Compiler::tmpGetTemp(var_types type) +TempDsc* RegSet::tmpGetTemp(var_types type) { type = tmpNormalizeType(type); unsigned size = genTypeSize(type); @@ -671,7 +676,7 @@ TempDsc* Compiler::tmpGetTemp(var_types type) noway_assert(temp != nullptr); #ifdef DEBUG - if (verbose) + if (m_rsCompiler->verbose) { printf("%s temp #%u, slot %u, size = %u\n", isNewTemp ? "created" : "reused", -temp->tdTempNum(), slot, temp->tdTempSize()); @@ -695,7 +700,7 @@ TempDsc* Compiler::tmpGetTemp(var_types type) * has been preallocated, it is a fatal error. */ -void Compiler::tmpPreAllocateTemps(var_types type, unsigned count) +void RegSet::tmpPreAllocateTemps(var_types type, unsigned count) { assert(type == tmpNormalizeType(type)); unsigned size = genTypeSize(type); @@ -723,10 +728,10 @@ void Compiler::tmpPreAllocateTemps(var_types type, unsigned count) } #endif // _TARGET_ARM_ - TempDsc* temp = new (this, CMK_Unknown) TempDsc(-((int)tmpCount), size, type); + TempDsc* temp = new (m_rsCompiler, CMK_Unknown) TempDsc(-((int)tmpCount), size, type); #ifdef DEBUG - if (verbose) + if (m_rsCompiler->verbose) { printf("pre-allocated temp #%u, slot %u, size = %u\n", -temp->tdTempNum(), slot, temp->tdTempSize()); } @@ -743,7 +748,7 @@ void Compiler::tmpPreAllocateTemps(var_types type, unsigned count) * Release the given temp. */ -void Compiler::tmpRlsTemp(TempDsc* temp) +void RegSet::tmpRlsTemp(TempDsc* temp) { assert(temp != nullptr); @@ -754,7 +759,7 @@ void Compiler::tmpRlsTemp(TempDsc* temp) slot = tmpSlot(temp->tdTempSize()); #ifdef DEBUG - if (verbose) + if (m_rsCompiler->verbose) { printf("release temp #%u, slot %u, size = %u\n", -temp->tdTempNum(), slot, temp->tdTempSize()); } @@ -793,7 +798,7 @@ void Compiler::tmpRlsTemp(TempDsc* temp) * * When looking for temps on the "used" list, this can be used any time. */ -TempDsc* Compiler::tmpFindNum(int tnum, TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const +TempDsc* RegSet::tmpFindNum(int tnum, TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const { assert(tnum < 0); // temp numbers are negative @@ -813,7 +818,7 @@ TempDsc* Compiler::tmpFindNum(int tnum, TEMP_USAGE_TYPE usageType /* = TEMP_USAG * A helper function is used to iterate over all the temps. */ -TempDsc* Compiler::tmpListBeg(TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const +TempDsc* RegSet::tmpListBeg(TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const { TempDsc* const* tmpLists; if (usageType == TEMP_USAGE_FREE) @@ -840,7 +845,7 @@ TempDsc* Compiler::tmpListBeg(TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) * Used with tmpListBeg() to iterate over the list of temps. */ -TempDsc* Compiler::tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const +TempDsc* RegSet::tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType /* = TEMP_USAGE_FREE */) const { assert(curTemp != nullptr); @@ -879,7 +884,7 @@ TempDsc* Compiler::tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType /* = T /***************************************************************************** * Return 'true' if all allocated temps are free (not in use). */ -bool Compiler::tmpAllFree() const +bool RegSet::tmpAllFree() const { // The 'tmpGetCount' should equal the number of things in the 'tmpUsed' lists. This is a convenient place // to assert that. @@ -1060,7 +1065,7 @@ RegSet::SpillDsc* RegSet::SpillDsc::alloc(Compiler* pComp, RegSet* regSet, var_t } else { - spill = (RegSet::SpillDsc*)pComp->compGetMem(sizeof(SpillDsc)); + spill = pComp->getAllocator().allocate(1); } return spill; } @@ -1088,7 +1093,7 @@ void RegSet::SpillDsc::freeDsc(RegSet* regSet, RegSet::SpillDsc* spillDsc) void RegSet::rsSpillChk() { // All grabbed temps should have been released - assert(m_rsCompiler->tmpGetCount == 0); + assert(tmpGetCount == 0); for (regNumber reg = REG_FIRST; reg < REG_COUNT; reg = REG_NEXT(reg)) { diff --git a/src/jit/regset.h b/src/jit/regset.h index 88889d946dc5..469178dce473 100644 --- a/src/jit/regset.h +++ b/src/jit/regset.h @@ -172,6 +172,62 @@ class RegSet TempDsc* rsUnspillInPlace(GenTree* tree, regNumber oldReg, unsigned regIdx = 0); void rsMarkSpill(GenTree* tree, regNumber reg); + +public: + void tmpInit(); + + enum TEMP_USAGE_TYPE + { + TEMP_USAGE_FREE, + TEMP_USAGE_USED + }; + + static var_types tmpNormalizeType(var_types type); + TempDsc* tmpGetTemp(var_types type); // get temp for the given type + void tmpRlsTemp(TempDsc* temp); + TempDsc* tmpFindNum(int temp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; + + void tmpEnd(); + TempDsc* tmpListBeg(TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; + TempDsc* tmpListNxt(TempDsc* curTemp, TEMP_USAGE_TYPE usageType = TEMP_USAGE_FREE) const; + void tmpDone(); + +#ifdef DEBUG + bool tmpAllFree() const; +#endif // DEBUG + + void tmpPreAllocateTemps(var_types type, unsigned count); + + unsigned tmpGetTotalSize() + { + return tmpSize; + } + +private: + unsigned tmpCount; // Number of temps + unsigned tmpSize; // Size of all the temps +#ifdef DEBUG + // Used by RegSet::rsSpillChk() + unsigned tmpGetCount; // Temps which haven't been released yet +#endif + static unsigned tmpSlot(unsigned size); // which slot in tmpFree[] or tmpUsed[] to use + + enum TEMP_CONSTANTS : unsigned + { +#if defined(FEATURE_SIMD) +#if defined(_TARGET_XARCH_) + TEMP_MAX_SIZE = YMM_REGSIZE_BYTES, +#elif defined(_TARGET_ARM64_) + TEMP_MAX_SIZE = FP_REGSIZE_BYTES, +#endif // defined(_TARGET_XARCH_) || defined(_TARGET_ARM64_) +#else // !FEATURE_SIMD + TEMP_MAX_SIZE = sizeof(double), +#endif // !FEATURE_SIMD + TEMP_SLOT_COUNT = (TEMP_MAX_SIZE / sizeof(int)) + }; + + TempDsc* tmpFree[TEMP_MAX_SIZE / sizeof(int)]; + TempDsc* tmpUsed[TEMP_MAX_SIZE / sizeof(int)]; }; #endif // _REGSET_H diff --git a/src/jit/scopeinfo.cpp b/src/jit/scopeinfo.cpp index 5a3f704cfce0..ddb5e8ce016b 100644 --- a/src/jit/scopeinfo.cpp +++ b/src/jit/scopeinfo.cpp @@ -160,7 +160,7 @@ CodeGen::siScope* CodeGen::siNewScope(unsigned LVnum, unsigned varNum) siEndTrackedScope(varIndex); } - siScope* newScope = (siScope*)compiler->compGetMem(sizeof(*newScope), CMK_SiScope); + siScope* newScope = compiler->getAllocator(CMK_SiScope).allocate(1); newScope->scStartLoc.CaptureLocation(getEmitter()); assert(newScope->scStartLoc.Valid()); @@ -377,19 +377,27 @@ void CodeGen::siInit() if (compiler->info.compVarScopesCount == 0) { - return; + siLatestTrackedScopes = nullptr; } - + else + { #if FEATURE_EH_FUNCLETS - siInFuncletRegion = false; + siInFuncletRegion = false; #endif // FEATURE_EH_FUNCLETS - for (unsigned i = 0; i < lclMAX_TRACKED; i++) - { - siLatestTrackedScopes[i] = nullptr; - } + unsigned scopeCount = compiler->lvaTrackedCount; - compiler->compResetScopeLists(); + if (scopeCount == 0) + { + siLatestTrackedScopes = nullptr; + } + else + { + siLatestTrackedScopes = new (compiler->getAllocator(CMK_SiScope)) siScope* [scopeCount] {}; + } + + compiler->compResetScopeLists(); + } } /***************************************************************************** @@ -467,7 +475,7 @@ void CodeGen::siBeginBlock(BasicBlock* block) // So we need to check if this tracked variable is actually used. if (!compiler->lvaTable[varNum].lvIsInReg() && !compiler->lvaTable[varNum].lvOnFrame) { - assert(compiler->lvaTable[varNum].lvRefCnt == 0); + assert(compiler->lvaTable[varNum].lvRefCnt() == 0); continue; } @@ -669,8 +677,6 @@ void CodeGen::siUpdate() LclVarDsc* lclVar = &compiler->lvaTable[lclNum]; assert(lclVar->lvTracked); #endif - - siScope* scope = siLatestTrackedScopes[varIndex]; siEndTrackedScope(varIndex); } @@ -825,7 +831,7 @@ void CodeGen::siDispOpenScopes() CodeGen::psiScope* CodeGen::psiNewPrologScope(unsigned LVnum, unsigned slotNum) { - psiScope* newScope = (psiScope*)compiler->compGetMem(sizeof(*newScope), CMK_SiScope); + psiScope* newScope = compiler->getAllocator(CMK_SiScope).allocate(1); newScope->scStartLoc.CaptureLocation(getEmitter()); assert(newScope->scStartLoc.Valid()); diff --git a/src/jit/sideeffects.cpp b/src/jit/sideeffects.cpp index 931ee6f8f4da..6821ab5297b7 100644 --- a/src/jit/sideeffects.cpp +++ b/src/jit/sideeffects.cpp @@ -165,7 +165,7 @@ AliasSet::NodeInfo::NodeInfo(Compiler* compiler, GenTree* node) isWrite = true; node = node->gtGetOp1(); } - else if (node->OperIsStore() || node->OperIsAtomicOp()) + else if (node->OperIsStore()) { isWrite = true; } diff --git a/src/jit/simd.cpp b/src/jit/simd.cpp index c45aa8982efa..224c340720fd 100644 --- a/src/jit/simd.cpp +++ b/src/jit/simd.cpp @@ -122,6 +122,26 @@ int Compiler::getSIMDTypeAlignment(var_types simdType) var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, unsigned* sizeBytes /*= nullptr */) { assert(featureSIMD); + + if (m_simdHandleCache == nullptr) + { + if (impInlineInfo == nullptr) + { + m_simdHandleCache = new (this, CMK_Generic) SIMDHandlesCache(); + } + else + { + // Steal the inliner compiler's cache (create it if not available). + + if (impInlineInfo->InlineRoot->m_simdHandleCache == nullptr) + { + impInlineInfo->InlineRoot->m_simdHandleCache = new (this, CMK_Generic) SIMDHandlesCache(); + } + + m_simdHandleCache = impInlineInfo->InlineRoot->m_simdHandleCache; + } + } + if (typeHnd == nullptr) { return TYP_UNKNOWN; @@ -136,77 +156,77 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u { // The most likely to be used type handles are looked up first followed by // less likely to be used type handles - if (typeHnd == SIMDFloatHandle) + if (typeHnd == m_simdHandleCache->SIMDFloatHandle) { simdBaseType = TYP_FLOAT; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDIntHandle) + else if (typeHnd == m_simdHandleCache->SIMDIntHandle) { simdBaseType = TYP_INT; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDVector2Handle) + else if (typeHnd == m_simdHandleCache->SIMDVector2Handle) { simdBaseType = TYP_FLOAT; size = 2 * genTypeSize(TYP_FLOAT); assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); JITDUMP(" Known type Vector2\n"); } - else if (typeHnd == SIMDVector3Handle) + else if (typeHnd == m_simdHandleCache->SIMDVector3Handle) { simdBaseType = TYP_FLOAT; size = 3 * genTypeSize(TYP_FLOAT); assert(size == info.compCompHnd->getClassSize(typeHnd)); JITDUMP(" Known type Vector3\n"); } - else if (typeHnd == SIMDVector4Handle) + else if (typeHnd == m_simdHandleCache->SIMDVector4Handle) { simdBaseType = TYP_FLOAT; size = 4 * genTypeSize(TYP_FLOAT); assert(size == roundUp(info.compCompHnd->getClassSize(typeHnd), TARGET_POINTER_SIZE)); JITDUMP(" Known type Vector4\n"); } - else if (typeHnd == SIMDVectorHandle) + else if (typeHnd == m_simdHandleCache->SIMDVectorHandle) { JITDUMP(" Known type Vector\n"); } - else if (typeHnd == SIMDUShortHandle) + else if (typeHnd == m_simdHandleCache->SIMDUShortHandle) { simdBaseType = TYP_USHORT; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDUByteHandle) + else if (typeHnd == m_simdHandleCache->SIMDUByteHandle) { simdBaseType = TYP_UBYTE; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDDoubleHandle) + else if (typeHnd == m_simdHandleCache->SIMDDoubleHandle) { simdBaseType = TYP_DOUBLE; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDLongHandle) + else if (typeHnd == m_simdHandleCache->SIMDLongHandle) { simdBaseType = TYP_LONG; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDShortHandle) + else if (typeHnd == m_simdHandleCache->SIMDShortHandle) { simdBaseType = TYP_SHORT; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDByteHandle) + else if (typeHnd == m_simdHandleCache->SIMDByteHandle) { simdBaseType = TYP_BYTE; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDUIntHandle) + else if (typeHnd == m_simdHandleCache->SIMDUIntHandle) { simdBaseType = TYP_UINT; JITDUMP(" Known type SIMD Vector\n"); } - else if (typeHnd == SIMDULongHandle) + else if (typeHnd == m_simdHandleCache->SIMDULongHandle) { simdBaseType = TYP_ULONG; JITDUMP(" Known type SIMD Vector\n"); @@ -232,62 +252,62 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u { if (wcsncmp(&(className[25]), W("System.Single"), 13) == 0) { - SIMDFloatHandle = typeHnd; - simdBaseType = TYP_FLOAT; + m_simdHandleCache->SIMDFloatHandle = typeHnd; + simdBaseType = TYP_FLOAT; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.Int32"), 12) == 0) { - SIMDIntHandle = typeHnd; - simdBaseType = TYP_INT; + m_simdHandleCache->SIMDIntHandle = typeHnd; + simdBaseType = TYP_INT; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.UInt16"), 13) == 0) { - SIMDUShortHandle = typeHnd; - simdBaseType = TYP_USHORT; + m_simdHandleCache->SIMDUShortHandle = typeHnd; + simdBaseType = TYP_USHORT; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.Byte"), 11) == 0) { - SIMDUByteHandle = typeHnd; - simdBaseType = TYP_UBYTE; + m_simdHandleCache->SIMDUByteHandle = typeHnd; + simdBaseType = TYP_UBYTE; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.Double"), 13) == 0) { - SIMDDoubleHandle = typeHnd; - simdBaseType = TYP_DOUBLE; + m_simdHandleCache->SIMDDoubleHandle = typeHnd; + simdBaseType = TYP_DOUBLE; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.Int64"), 12) == 0) { - SIMDLongHandle = typeHnd; - simdBaseType = TYP_LONG; + m_simdHandleCache->SIMDLongHandle = typeHnd; + simdBaseType = TYP_LONG; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.Int16"), 12) == 0) { - SIMDShortHandle = typeHnd; - simdBaseType = TYP_SHORT; + m_simdHandleCache->SIMDShortHandle = typeHnd; + simdBaseType = TYP_SHORT; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.SByte"), 12) == 0) { - SIMDByteHandle = typeHnd; - simdBaseType = TYP_BYTE; + m_simdHandleCache->SIMDByteHandle = typeHnd; + simdBaseType = TYP_BYTE; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.UInt32"), 13) == 0) { - SIMDUIntHandle = typeHnd; - simdBaseType = TYP_UINT; + m_simdHandleCache->SIMDUIntHandle = typeHnd; + simdBaseType = TYP_UINT; JITDUMP(" Found type SIMD Vector\n"); } else if (wcsncmp(&(className[25]), W("System.UInt64"), 13) == 0) { - SIMDULongHandle = typeHnd; - simdBaseType = TYP_ULONG; + m_simdHandleCache->SIMDULongHandle = typeHnd; + simdBaseType = TYP_ULONG; JITDUMP(" Found type SIMD Vector\n"); } else @@ -297,7 +317,7 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u } else if (wcsncmp(&(className[16]), W("Vector2"), 8) == 0) { - SIMDVector2Handle = typeHnd; + m_simdHandleCache->SIMDVector2Handle = typeHnd; simdBaseType = TYP_FLOAT; size = 2 * genTypeSize(TYP_FLOAT); @@ -306,7 +326,7 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u } else if (wcsncmp(&(className[16]), W("Vector3"), 8) == 0) { - SIMDVector3Handle = typeHnd; + m_simdHandleCache->SIMDVector3Handle = typeHnd; simdBaseType = TYP_FLOAT; size = 3 * genTypeSize(TYP_FLOAT); @@ -315,7 +335,7 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u } else if (wcsncmp(&(className[16]), W("Vector4"), 8) == 0) { - SIMDVector4Handle = typeHnd; + m_simdHandleCache->SIMDVector4Handle = typeHnd; simdBaseType = TYP_FLOAT; size = 4 * genTypeSize(TYP_FLOAT); @@ -324,7 +344,7 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u } else if (wcsncmp(&(className[16]), W("Vector"), 6) == 0) { - SIMDVectorHandle = typeHnd; + m_simdHandleCache->SIMDVectorHandle = typeHnd; JITDUMP(" Found type Vector\n"); } else @@ -357,67 +377,67 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u static_assert_no_msg(YMM_REGSIZE_BYTES == Vector256SizeBytes); static_assert_no_msg(XMM_REGSIZE_BYTES == Vector128SizeBytes); - if (typeHnd == Vector256FloatHandle) + if (typeHnd == m_simdHandleCache->Vector256FloatHandle) { simdBaseType = TYP_FLOAT; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256DoubleHandle) + else if (typeHnd == m_simdHandleCache->Vector256DoubleHandle) { simdBaseType = TYP_DOUBLE; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256IntHandle) + else if (typeHnd == m_simdHandleCache->Vector256IntHandle) { simdBaseType = TYP_INT; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256UIntHandle) + else if (typeHnd == m_simdHandleCache->Vector256UIntHandle) { simdBaseType = TYP_UINT; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256ShortHandle) + else if (typeHnd == m_simdHandleCache->Vector256ShortHandle) { simdBaseType = TYP_SHORT; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256UShortHandle) + else if (typeHnd == m_simdHandleCache->Vector256UShortHandle) { simdBaseType = TYP_USHORT; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256ByteHandle) + else if (typeHnd == m_simdHandleCache->Vector256ByteHandle) { simdBaseType = TYP_BYTE; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256UByteHandle) + else if (typeHnd == m_simdHandleCache->Vector256UByteHandle) { simdBaseType = TYP_UBYTE; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256LongHandle) + else if (typeHnd == m_simdHandleCache->Vector256LongHandle) { simdBaseType = TYP_LONG; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256ULongHandle) + else if (typeHnd == m_simdHandleCache->Vector256ULongHandle) { simdBaseType = TYP_ULONG; size = Vector256SizeBytes; JITDUMP(" Known type Vector256\n"); } - else if (typeHnd == Vector256FloatHandle) + else if (typeHnd == m_simdHandleCache->Vector256FloatHandle) { simdBaseType = TYP_FLOAT; size = Vector256SizeBytes; @@ -425,92 +445,92 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u } else #endif // defined(_TARGET_XARCH) - if (typeHnd == Vector128DoubleHandle) + if (typeHnd == m_simdHandleCache->Vector128DoubleHandle) { simdBaseType = TYP_DOUBLE; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128IntHandle) + else if (typeHnd == m_simdHandleCache->Vector128IntHandle) { simdBaseType = TYP_INT; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128UIntHandle) + else if (typeHnd == m_simdHandleCache->Vector128UIntHandle) { simdBaseType = TYP_UINT; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128ShortHandle) + else if (typeHnd == m_simdHandleCache->Vector128ShortHandle) { simdBaseType = TYP_SHORT; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128UShortHandle) + else if (typeHnd == m_simdHandleCache->Vector128UShortHandle) { simdBaseType = TYP_USHORT; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128ByteHandle) + else if (typeHnd == m_simdHandleCache->Vector128ByteHandle) { simdBaseType = TYP_BYTE; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128UByteHandle) + else if (typeHnd == m_simdHandleCache->Vector128UByteHandle) { simdBaseType = TYP_UBYTE; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128LongHandle) + else if (typeHnd == m_simdHandleCache->Vector128LongHandle) { simdBaseType = TYP_LONG; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } - else if (typeHnd == Vector128ULongHandle) + else if (typeHnd == m_simdHandleCache->Vector128ULongHandle) { simdBaseType = TYP_ULONG; size = Vector128SizeBytes; JITDUMP(" Known type Vector128\n"); } #if defined(_TARGET_ARM64_) - else if (typeHnd == Vector64IntHandle) + else if (typeHnd == m_simdHandleCache->Vector64IntHandle) { simdBaseType = TYP_INT; size = Vector64SizeBytes; JITDUMP(" Known type Vector64\n"); } - else if (typeHnd == Vector64UIntHandle) + else if (typeHnd == m_simdHandleCache->Vector64UIntHandle) { simdBaseType = TYP_UINT; size = Vector64SizeBytes; JITDUMP(" Known type Vector64\n"); } - else if (typeHnd == Vector64ShortHandle) + else if (typeHnd == m_simdHandleCache->Vector64ShortHandle) { simdBaseType = TYP_SHORT; size = Vector64SizeBytes; JITDUMP(" Known type Vector64\n"); } - else if (typeHnd == Vector64UShortHandle) + else if (typeHnd == m_simdHandleCache->Vector64UShortHandle) { simdBaseType = TYP_USHORT; size = Vector64SizeBytes; JITDUMP(" Known type Vector64\n"); } - else if (typeHnd == Vector64ByteHandle) + else if (typeHnd == m_simdHandleCache->Vector64ByteHandle) { simdBaseType = TYP_BYTE; size = Vector64SizeBytes; JITDUMP(" Known type Vector64\n"); } - else if (typeHnd == Vector64UByteHandle) + else if (typeHnd == m_simdHandleCache->Vector64UByteHandle) { simdBaseType = TYP_UBYTE; size = Vector64SizeBytes; @@ -539,53 +559,53 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u switch (type) { case CORINFO_TYPE_FLOAT: - Vector256FloatHandle = typeHnd; - simdBaseType = TYP_FLOAT; + m_simdHandleCache->Vector256FloatHandle = typeHnd; + simdBaseType = TYP_FLOAT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_DOUBLE: - Vector256DoubleHandle = typeHnd; - simdBaseType = TYP_DOUBLE; + m_simdHandleCache->Vector256DoubleHandle = typeHnd; + simdBaseType = TYP_DOUBLE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_INT: - Vector256IntHandle = typeHnd; - simdBaseType = TYP_INT; + m_simdHandleCache->Vector256IntHandle = typeHnd; + simdBaseType = TYP_INT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_UINT: - Vector256UIntHandle = typeHnd; - simdBaseType = TYP_UINT; + m_simdHandleCache->Vector256UIntHandle = typeHnd; + simdBaseType = TYP_UINT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_SHORT: - Vector256ShortHandle = typeHnd; - simdBaseType = TYP_SHORT; + m_simdHandleCache->Vector256ShortHandle = typeHnd; + simdBaseType = TYP_SHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_USHORT: - Vector256UShortHandle = typeHnd; - simdBaseType = TYP_USHORT; + m_simdHandleCache->Vector256UShortHandle = typeHnd; + simdBaseType = TYP_USHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_LONG: - Vector256LongHandle = typeHnd; - simdBaseType = TYP_LONG; + m_simdHandleCache->Vector256LongHandle = typeHnd; + simdBaseType = TYP_LONG; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_ULONG: - Vector256ULongHandle = typeHnd; - simdBaseType = TYP_ULONG; + m_simdHandleCache->Vector256ULongHandle = typeHnd; + simdBaseType = TYP_ULONG; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_UBYTE: - Vector256UByteHandle = typeHnd; - simdBaseType = TYP_UBYTE; + m_simdHandleCache->Vector256UByteHandle = typeHnd; + simdBaseType = TYP_UBYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; case CORINFO_TYPE_BYTE: - Vector256ByteHandle = typeHnd; - simdBaseType = TYP_BYTE; + m_simdHandleCache->Vector256ByteHandle = typeHnd; + simdBaseType = TYP_BYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector256\n"); break; @@ -601,53 +621,53 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u switch (type) { case CORINFO_TYPE_FLOAT: - Vector128FloatHandle = typeHnd; - simdBaseType = TYP_FLOAT; + m_simdHandleCache->Vector128FloatHandle = typeHnd; + simdBaseType = TYP_FLOAT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_DOUBLE: - Vector128DoubleHandle = typeHnd; - simdBaseType = TYP_DOUBLE; + m_simdHandleCache->Vector128DoubleHandle = typeHnd; + simdBaseType = TYP_DOUBLE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_INT: - Vector128IntHandle = typeHnd; - simdBaseType = TYP_INT; + m_simdHandleCache->Vector128IntHandle = typeHnd; + simdBaseType = TYP_INT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_UINT: - Vector128UIntHandle = typeHnd; - simdBaseType = TYP_UINT; + m_simdHandleCache->Vector128UIntHandle = typeHnd; + simdBaseType = TYP_UINT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_SHORT: - Vector128ShortHandle = typeHnd; - simdBaseType = TYP_SHORT; + m_simdHandleCache->Vector128ShortHandle = typeHnd; + simdBaseType = TYP_SHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_USHORT: - Vector128UShortHandle = typeHnd; - simdBaseType = TYP_USHORT; + m_simdHandleCache->Vector128UShortHandle = typeHnd; + simdBaseType = TYP_USHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_LONG: - Vector128LongHandle = typeHnd; - simdBaseType = TYP_LONG; + m_simdHandleCache->Vector128LongHandle = typeHnd; + simdBaseType = TYP_LONG; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_ULONG: - Vector128ULongHandle = typeHnd; - simdBaseType = TYP_ULONG; + m_simdHandleCache->Vector128ULongHandle = typeHnd; + simdBaseType = TYP_ULONG; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_UBYTE: - Vector128UByteHandle = typeHnd; - simdBaseType = TYP_UBYTE; + m_simdHandleCache->Vector128UByteHandle = typeHnd; + simdBaseType = TYP_UBYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; case CORINFO_TYPE_BYTE: - Vector128ByteHandle = typeHnd; - simdBaseType = TYP_BYTE; + m_simdHandleCache->Vector128ByteHandle = typeHnd; + simdBaseType = TYP_BYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector128\n"); break; @@ -662,38 +682,38 @@ var_types Compiler::getBaseTypeAndSizeOfSIMDType(CORINFO_CLASS_HANDLE typeHnd, u switch (type) { case CORINFO_TYPE_FLOAT: - Vector64FloatHandle = typeHnd; - simdBaseType = TYP_FLOAT; + m_simdHandleCache->Vector64FloatHandle = typeHnd; + simdBaseType = TYP_FLOAT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_INT: - Vector64IntHandle = typeHnd; - simdBaseType = TYP_INT; + m_simdHandleCache->Vector64IntHandle = typeHnd; + simdBaseType = TYP_INT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_UINT: - Vector64UIntHandle = typeHnd; - simdBaseType = TYP_UINT; + m_simdHandleCache->Vector64UIntHandle = typeHnd; + simdBaseType = TYP_UINT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_SHORT: - Vector64ShortHandle = typeHnd; - simdBaseType = TYP_SHORT; + m_simdHandleCache->Vector64ShortHandle = typeHnd; + simdBaseType = TYP_SHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_USHORT: - Vector64UShortHandle = typeHnd; - simdBaseType = TYP_USHORT; + m_simdHandleCache->Vector64UShortHandle = typeHnd; + simdBaseType = TYP_USHORT; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_UBYTE: - Vector64UByteHandle = typeHnd; - simdBaseType = TYP_UBYTE; + m_simdHandleCache->Vector64UByteHandle = typeHnd; + simdBaseType = TYP_UBYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; case CORINFO_TYPE_BYTE: - Vector64ByteHandle = typeHnd; - simdBaseType = TYP_BYTE; + m_simdHandleCache->Vector64ByteHandle = typeHnd; + simdBaseType = TYP_BYTE; JITDUMP(" Found type Hardware Intrinsic SIMD Vector64\n"); break; @@ -762,7 +782,7 @@ const SIMDIntrinsicInfo* Compiler::getSIMDIntrinsicInfo(CORINFO_CLASS_HANDLE* in CORINFO_CLASS_HANDLE typeHnd = *inOutTypeHnd; *baseType = getBaseTypeAndSizeOfSIMDType(typeHnd, sizeBytes); - if (typeHnd == SIMDVectorHandle) + if (typeHnd == m_simdHandleCache->SIMDVectorHandle) { // All of the supported intrinsics on this static class take a first argument that's a vector, // which determines the baseType. @@ -846,22 +866,22 @@ const SIMDIntrinsicInfo* Compiler::getSIMDIntrinsicInfo(CORINFO_CLASS_HANDLE* in { if (i == SIMDIntrinsicInitN) { - if (*argCount == 3 && typeHnd == SIMDVector2Handle) + if (*argCount == 3 && typeHnd == m_simdHandleCache->SIMDVector2Handle) { expectedArgCnt = 3; } - else if (*argCount == 4 && typeHnd == SIMDVector3Handle) + else if (*argCount == 4 && typeHnd == m_simdHandleCache->SIMDVector3Handle) { expectedArgCnt = 4; } - else if (*argCount == 5 && typeHnd == SIMDVector4Handle) + else if (*argCount == 5 && typeHnd == m_simdHandleCache->SIMDVector4Handle) { expectedArgCnt = 5; } } else if (i == SIMDIntrinsicInitFixed) { - if (*argCount == 4 && typeHnd == SIMDVector4Handle) + if (*argCount == 4 && typeHnd == m_simdHandleCache->SIMDVector4Handle) { expectedArgCnt = 4; } @@ -997,12 +1017,15 @@ const SIMDIntrinsicInfo* Compiler::getSIMDIntrinsicInfo(CORINFO_CLASS_HANDLE* in // Arguments: // type - the type of value that the caller expects to be popped off the stack. // expectAddr - if true indicates we are expecting type stack entry to be a TYP_BYREF. +// structType - the class handle to use when normalizing if it is not the same as the stack entry class handle; +// this can happen for certain scenarios, such as folding away a static cast, where we want the +// value popped to have the type that would have been returned. // // Notes: // If the popped value is a struct, and the expected type is a simd type, it will be set // to that type, otherwise it will assert if the type being popped is not the expected type. -GenTree* Compiler::impSIMDPopStack(var_types type, bool expectAddr) +GenTree* Compiler::impSIMDPopStack(var_types type, bool expectAddr, CORINFO_CLASS_HANDLE structType) { StackEntry se = impPopStack(); typeInfo ti = se.seTypeInfo; @@ -1046,8 +1069,13 @@ GenTree* Compiler::impSIMDPopStack(var_types type, bool expectAddr) if (varTypeIsStruct(tree) && ((tree->OperGet() == GT_RET_EXPR) || (tree->OperGet() == GT_CALL) || isParam)) { assert(ti.IsType(TI_STRUCT)); - CORINFO_CLASS_HANDLE structType = ti.GetClassHandleForValueClass(); - tree = impNormStructVal(tree, structType, (unsigned)CHECK_SPILL_ALL); + + if (structType == nullptr) + { + structType = ti.GetClassHandleForValueClass(); + } + + tree = impNormStructVal(tree, structType, (unsigned)CHECK_SPILL_ALL); } // Now set the type of the tree to the specialized SIMD struct type, if applicable. @@ -2200,11 +2228,11 @@ GenTree* Compiler::createAddressNodeForSIMDInit(GenTree* tree, unsigned simdSize // = indexVal + arrayElementsCount - 1 unsigned arrayElementsCount = simdSize / genTypeSize(baseType); checkIndexExpr = new (this, GT_CNS_INT) GenTreeIntCon(TYP_INT, indexVal + arrayElementsCount - 1); - GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, arrayRef, (int)offsetof(CORINFO_Array, length)); + GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, arrayRef, (int)OFFSETOF__CORINFO_Array__length); GenTreeBoundsChk* arrBndsChk = new (this, GT_ARR_BOUNDS_CHECK) GenTreeBoundsChk(GT_ARR_BOUNDS_CHECK, TYP_VOID, checkIndexExpr, arrLen, SCK_RNGCHK_FAIL); - offset += offsetof(CORINFO_Array, u1Elems); + offset += OFFSETOF__CORINFO_Array__data; byrefNode = gtNewOperNode(GT_COMMA, arrayRef->TypeGet(), arrBndsChk, gtCloneExpr(arrayRef)); } else @@ -2631,7 +2659,7 @@ GenTree* Compiler::impSIMDIntrinsic(OPCODE opcode, } GenTreeArrLen* arrLen = - gtNewArrLen(TYP_INT, arrayRefForArgRngChk, (int)offsetof(CORINFO_Array, length)); + gtNewArrLen(TYP_INT, arrayRefForArgRngChk, (int)OFFSETOF__CORINFO_Array__length); argRngChk = new (this, GT_ARR_BOUNDS_CHECK) GenTreeBoundsChk(GT_ARR_BOUNDS_CHECK, TYP_VOID, index, arrLen, op3CheckKind); // Now, clone op3 to create another node for the argChk @@ -2651,7 +2679,7 @@ GenTree* Compiler::impSIMDIntrinsic(OPCODE opcode, { op2CheckKind = SCK_ARG_EXCPN; } - GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, arrayRefForArgChk, (int)offsetof(CORINFO_Array, length)); + GenTreeArrLen* arrLen = gtNewArrLen(TYP_INT, arrayRefForArgChk, (int)OFFSETOF__CORINFO_Array__length); GenTreeBoundsChk* argChk = new (this, GT_ARR_BOUNDS_CHECK) GenTreeBoundsChk(GT_ARR_BOUNDS_CHECK, TYP_VOID, checkIndexExpr, arrLen, op2CheckKind); @@ -2681,7 +2709,7 @@ GenTree* Compiler::impSIMDIntrinsic(OPCODE opcode, // TODO-Cleanup: Though it happens to just work fine front-end phases are not aware of GT_LEA node. // Therefore, convert these to use GT_ADDR . copyBlkDst = new (this, GT_LEA) - GenTreeAddrMode(TYP_BYREF, op2, op3, genTypeSize(baseType), offsetof(CORINFO_Array, u1Elems)); + GenTreeAddrMode(TYP_BYREF, op2, op3, genTypeSize(baseType), OFFSETOF__CORINFO_Array__data); doCopyBlk = true; } } diff --git a/src/jit/simdcodegenxarch.cpp b/src/jit/simdcodegenxarch.cpp index 6f40010e9ace..c0ecf25cb758 100644 --- a/src/jit/simdcodegenxarch.cpp +++ b/src/jit/simdcodegenxarch.cpp @@ -3091,7 +3091,7 @@ void CodeGen::genSIMDIntrinsicUpperRestore(GenTreeSIMD* simdNode) //------------------------------------------------------------------------ // genSIMDIntrinsic: Generate code for a SIMD Intrinsic. This is the main -// routine which in turn calls apropriate genSIMDIntrinsicXXX() routine. +// routine which in turn calls appropriate genSIMDIntrinsicXXX() routine. // // Arguments: // simdNode - The GT_SIMD node diff --git a/src/jit/smallhash.h b/src/jit/smallhash.h index 65c5eeda65ed..5900d286b602 100644 --- a/src/jit/smallhash.h +++ b/src/jit/smallhash.h @@ -5,11 +5,6 @@ #ifndef _SMALLHASHTABLE_H_ #define _SMALLHASHTABLE_H_ -// Since compiler depends on valuenum which depends on smallhash, forward declare -// a wrapper for comp->compGetMem here (implemented in compiler.hpp) that can be used below. -class Compiler; -void* compGetMem(Compiler* comp, size_t sz); - // genLog2 is defined in compiler.hpp unsigned genLog2(unsigned value); @@ -109,7 +104,7 @@ struct HashTableInfo // TKey - The type of the table's keys. // TValue - The type of the table's values. // TKeyInfo - A type that conforms to the HashTableInfo concept. -template > +template , typename TAllocator = CompAllocator> class HashTableBase { friend class KeyValuePair; @@ -151,10 +146,10 @@ class HashTableBase }; private: - Compiler* m_compiler; // The compiler context to use for allocations. - Bucket* m_buckets; // The bucket array. - unsigned m_numBuckets; // The number of buckets in the bucket array. - unsigned m_numFullBuckets; // The number of occupied buckets. + TAllocator m_alloc; // The memory allocator. + Bucket* m_buckets; // The bucket array. + unsigned m_numBuckets; // The number of buckets in the bucket array. + unsigned m_numFullBuckets; // The number of occupied buckets. //------------------------------------------------------------------------ // HashTableBase::Insert: inserts a key-value pair into a bucket array. @@ -302,11 +297,8 @@ class HashTableBase Bucket* currentBuckets = m_buckets; unsigned newNumBuckets = m_numBuckets == 0 ? InitialNumBuckets : m_numBuckets * 2; - size_t allocSize = sizeof(Bucket) * newNumBuckets; - assert((sizeof(Bucket) * m_numBuckets) < allocSize); - - auto* newBuckets = reinterpret_cast(compGetMem(m_compiler, allocSize)); - memset(newBuckets, 0, allocSize); + Bucket* newBuckets = m_alloc.template allocate(newNumBuckets); + memset(newBuckets, 0, sizeof(Bucket) * newNumBuckets); for (unsigned currentIndex = 0; currentIndex < m_numBuckets; currentIndex++) { @@ -326,11 +318,9 @@ class HashTableBase } protected: - HashTableBase(Compiler* compiler, Bucket* buckets, unsigned numBuckets) - : m_compiler(compiler), m_buckets(buckets), m_numBuckets(numBuckets), m_numFullBuckets(0) + HashTableBase(TAllocator alloc, Bucket* buckets, unsigned numBuckets) + : m_alloc(alloc), m_buckets(buckets), m_numBuckets(numBuckets), m_numFullBuckets(0) { - assert(compiler != nullptr); - if (numBuckets > 0) { assert((numBuckets & (numBuckets - 1)) == 0); // Size must be a power of 2 @@ -599,10 +589,10 @@ class HashTableBase //------------------------------------------------------------------------ // HashTable: a simple subclass of `HashTableBase` that always uses heap // storage for its bucket array. -template > -class HashTable final : public HashTableBase +template , typename TAllocator = CompAllocator> +class HashTable final : public HashTableBase { - typedef HashTableBase TBase; + typedef HashTableBase TBase; static unsigned RoundUp(unsigned initialSize) { @@ -610,15 +600,12 @@ class HashTable final : public HashTableBase } public: - HashTable(Compiler* compiler) : TBase(compiler, nullptr, 0) + HashTable(TAllocator alloc) : TBase(alloc, nullptr, 0) { } - HashTable(Compiler* compiler, unsigned initialSize) - : TBase(compiler, - reinterpret_cast( - compGetMem(compiler, RoundUp(initialSize) * sizeof(typename TBase::Bucket))), - RoundUp(initialSize)) + HashTable(TAllocator alloc, unsigned initialSize) + : TBase(alloc, alloc.template allocate(RoundUp(initialSize)), RoundUp(initialSize)) { } }; @@ -630,10 +617,14 @@ class HashTable final : public HashTableBase // the map at any given time falls below a certain // threshold. Switches to heap storage once the initial // inline storage is exhausted. -template > -class SmallHashTable final : public HashTableBase +template , + typename TAllocator = CompAllocator> +class SmallHashTable final : public HashTableBase { - typedef HashTableBase TBase; + typedef HashTableBase TBase; enum : unsigned { @@ -643,7 +634,7 @@ class SmallHashTable final : public HashTableBase typename TBase::Bucket m_inlineBuckets[RoundedNumInlineBuckets]; public: - SmallHashTable(Compiler* compiler) : TBase(compiler, m_inlineBuckets, RoundedNumInlineBuckets) + SmallHashTable(TAllocator alloc) : TBase(alloc, m_inlineBuckets, RoundedNumInlineBuckets) { } }; diff --git a/src/jit/ssabuilder.cpp b/src/jit/ssabuilder.cpp index 9845aa98fe67..fbd7d90e345c 100644 --- a/src/jit/ssabuilder.cpp +++ b/src/jit/ssabuilder.cpp @@ -134,7 +134,7 @@ void Compiler::fgResetForSsa() */ SsaBuilder::SsaBuilder(Compiler* pCompiler) : m_pCompiler(pCompiler) - , m_allocator(pCompiler, CMK_SSA) + , m_allocator(pCompiler->getAllocator(CMK_SSA)) , m_visitedTraits(0, pCompiler) // at this point we do not know the size, SetupBBRoot can add a block #ifdef SSA_FEATURE_DOMARR , m_pDomPreOrder(nullptr) @@ -193,8 +193,7 @@ int SsaBuilder::TopologicalSort(BasicBlock** postOrder, int count) BasicBlock* block = comp->fgFirstBB; BitVecOps::AddElemD(&m_visitedTraits, m_visited, block->bbNum); - ArrayStack blocks(comp); - + ArrayStack blocks(m_allocator); blocks.Emplace(comp, block); DumpBlockAndSuccessors(comp, block); @@ -538,7 +537,7 @@ void SsaBuilder::ComputeDominanceFrontiers(BasicBlock** postOrder, int count, Bl { DBG_SSA_JITDUMP(" Adding BB%02u to dom frontier of pred dom BB%02u.\n", block->bbNum, b1->bbNum); - BlkVector& b1DF = *mapDF->Emplace(b1, &m_allocator); + BlkVector& b1DF = *mapDF->Emplace(b1, m_allocator); // It's possible to encounter the same DF multiple times, ensure that we don't add duplicates. if (b1DF.empty() || (b1DF.back() != block)) { @@ -692,12 +691,12 @@ void SsaBuilder::InsertPhiFunctions(BasicBlock** postOrder, int count) EndPhase(PHASE_BUILD_SSA_LIVENESS); // Compute dominance frontier. - BlkToBlkVectorMap mapDF(&m_allocator); + BlkToBlkVectorMap mapDF(m_allocator); ComputeDominanceFrontiers(postOrder, count, &mapDF); EndPhase(PHASE_BUILD_SSA_DF); // Use the same IDF vector for all blocks to avoid unnecessary memory allocations - BlkVector blockIDF(&m_allocator); + BlkVector blockIDF(m_allocator); JITDUMP("Inserting phi functions:\n"); @@ -1614,7 +1613,7 @@ void SsaBuilder::RenameVariables(BlkToBlkVectorMap* domTree, SsaRenameState* pRe }; typedef jitstd::vector BlockWorkStack; - BlockWorkStack* blocksToDo = new (&m_allocator) BlockWorkStack(&m_allocator); + BlockWorkStack* blocksToDo = new (m_allocator) BlockWorkStack(m_allocator); blocksToDo->push_back(BlockWork(m_pCompiler->fgFirstBB)); // Probably have to include other roots of dom tree. while (blocksToDo->size() != 0) @@ -1739,7 +1738,7 @@ void SsaBuilder::Build() if (blockCount > DEFAULT_MIN_OPTS_BB_COUNT) { - postOrder = new (&m_allocator) BasicBlock*[blockCount]; + postOrder = new (m_allocator) BasicBlock*[blockCount]; } else { @@ -1758,7 +1757,7 @@ void SsaBuilder::Build() ComputeImmediateDom(postOrder, count); // Compute the dominator tree. - BlkToBlkVectorMap* domTree = new (&m_allocator) BlkToBlkVectorMap(&m_allocator); + BlkToBlkVectorMap* domTree = new (m_allocator) BlkToBlkVectorMap(m_allocator); ComputeDominators(postOrder, count, domTree); EndPhase(PHASE_BUILD_SSA_DOMS); @@ -1766,8 +1765,8 @@ void SsaBuilder::Build() InsertPhiFunctions(postOrder, count); // Rename local variables and collect UD information for each ssa var. - SsaRenameState* pRenameState = new (&m_allocator) - SsaRenameState(&m_allocator, m_pCompiler->lvaCount, m_pCompiler->byrefStatesMatchGcHeapStates); + SsaRenameState* pRenameState = + new (m_allocator) SsaRenameState(m_allocator, m_pCompiler->lvaCount, m_pCompiler->byrefStatesMatchGcHeapStates); RenameVariables(domTree, pRenameState); EndPhase(PHASE_BUILD_SSA_RENAME); diff --git a/src/jit/ssarenamestate.cpp b/src/jit/ssarenamestate.cpp index 4ccac05a4843..9ec07701995d 100644 --- a/src/jit/ssarenamestate.cpp +++ b/src/jit/ssarenamestate.cpp @@ -28,9 +28,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX * * @params alloc The allocator class used to allocate jitstd data. */ -SsaRenameState::SsaRenameState(const jitstd::allocator& alloc, - unsigned lvaCount, - bool byrefStatesMatchGcHeapStates) +SsaRenameState::SsaRenameState(CompAllocator alloc, unsigned lvaCount, bool byrefStatesMatchGcHeapStates) : counts(nullptr) , stacks(nullptr) , definedLocs(alloc) @@ -51,7 +49,7 @@ void SsaRenameState::EnsureCounts() { if (counts == nullptr) { - counts = jitstd::utility::allocate(m_alloc, lvaCount); + counts = m_alloc.allocate(lvaCount); for (unsigned i = 0; i < lvaCount; ++i) { counts[i] = SsaConfig::FIRST_SSA_NUM; @@ -68,7 +66,7 @@ void SsaRenameState::EnsureStacks() { if (stacks == nullptr) { - stacks = jitstd::utility::allocate(m_alloc, lvaCount); + stacks = m_alloc.allocate(lvaCount); for (unsigned i = 0; i < lvaCount; ++i) { stacks[i] = nullptr; @@ -141,7 +139,7 @@ void SsaRenameState::Push(BasicBlock* bb, unsigned lclNum, unsigned count) if (stack == nullptr) { DBG_SSA_JITDUMP("\tCreating a new stack\n"); - stack = stacks[lclNum] = new (jitstd::utility::allocate(m_alloc), jitstd::placement_t()) Stack(m_alloc); + stack = stacks[lclNum] = new (m_alloc) Stack(m_alloc); } if (stack->empty() || stack->back().m_bb != bb) diff --git a/src/jit/ssarenamestate.h b/src/jit/ssarenamestate.h index a8496b638639..a17b572aad9d 100644 --- a/src/jit/ssarenamestate.h +++ b/src/jit/ssarenamestate.h @@ -101,7 +101,7 @@ struct SsaRenameState typedef unsigned* Counts; typedef jitstd::list DefStack; - SsaRenameState(const jitstd::allocator& allocator, unsigned lvaCount, bool byrefStatesMatchGcHeapStates); + SsaRenameState(CompAllocator allocator, unsigned lvaCount, bool byrefStatesMatchGcHeapStates); void EnsureCounts(); void EnsureStacks(); @@ -182,7 +182,7 @@ struct SsaRenameState unsigned lvaCount; // Allocator to allocate stacks. - jitstd::allocator m_alloc; + CompAllocator m_alloc; // Indicates whether GcHeap and ByrefExposed use the same state. bool byrefStatesMatchGcHeapStates; diff --git a/src/jit/stacklevelsetter.cpp b/src/jit/stacklevelsetter.cpp index b0b6324f86aa..393eb25daf5a 100644 --- a/src/jit/stacklevelsetter.cpp +++ b/src/jit/stacklevelsetter.cpp @@ -13,8 +13,8 @@ StackLevelSetter::StackLevelSetter(Compiler* compiler) : Phase(compiler, "StackLevelSetter", PHASE_STACK_LEVEL_SETTER) , currentStackLevel(0) , maxStackLevel(0) - , memAllocator(compiler, CMK_fgArgInfoPtrArr) - , putArgNumSlots(&memAllocator) + , memAllocator(compiler->getAllocator(CMK_fgArgInfoPtrArr)) + , putArgNumSlots(memAllocator) #if !FEATURE_FIXED_OUT_ARGS , framePointerRequired(compiler->codeGen->isFramePointerRequired()) , throwHelperBlocksUsed(comp->fgUseThrowHelperBlocks() && comp->compUsesThrowHelper) diff --git a/src/jit/target.h b/src/jit/target.h index c374b0dbd736..9771f9a5d96a 100644 --- a/src/jit/target.h +++ b/src/jit/target.h @@ -225,7 +225,6 @@ typedef unsigned char regNumberSmall; #define CPU_HAS_FP_SUPPORT 1 #define ROUND_FLOAT 1 // round intermed float expression results #define CPU_HAS_BYTE_REGS 1 - #define CPU_USES_BLOCK_MOVE 1 // TODO-CQ: Fine tune the following xxBlk threshold values: @@ -513,7 +512,6 @@ typedef unsigned char regNumberSmall; #define CPU_HAS_FP_SUPPORT 1 #define ROUND_FLOAT 0 // Do not round intermed float expression results #define CPU_HAS_BYTE_REGS 0 - #define CPU_USES_BLOCK_MOVE 1 #define CPBLK_MOVS_LIMIT 16 // When generating code for CpBlk, this is the buffer size // threshold to stop generating rep movs and switch to the helper call. @@ -918,7 +916,6 @@ typedef unsigned char regNumberSmall; #define CPU_HAS_FP_SUPPORT 1 #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. @@ -1219,7 +1216,6 @@ typedef unsigned char regNumberSmall; #define CPU_HAS_FP_SUPPORT 1 #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 64 // Upper bound to let the code generator to loop unroll CpBlk. #define INITBLK_UNROLL_LIMIT 64 // Upper bound to let the code generator to loop unroll InitBlk. diff --git a/src/jit/unwind.cpp b/src/jit/unwind.cpp index 1f090b20b696..db120c5b3bcc 100644 --- a/src/jit/unwind.cpp +++ b/src/jit/unwind.cpp @@ -160,12 +160,6 @@ void Compiler::unwindPushPopCFI(regNumber reg) } } -template -inline static T* allocate_any(jitstd::allocator& alloc, size_t count = 5) -{ - return jitstd::allocator(alloc).allocate(count); -} - typedef jitstd::vector CFICodeVector; void Compiler::unwindBegPrologCFI() @@ -185,9 +179,7 @@ void Compiler::unwindBegPrologCFI() unwindGetFuncLocations(func, false, &func->coldStartLoc, &func->coldEndLoc); } - jitstd::allocator allocator(getAllocator()); - - func->cfiCodes = new (allocate_any(allocator), jitstd::placement_t()) CFICodeVector(allocator); + func->cfiCodes = new (getAllocator()) CFICodeVector(getAllocator()); #endif // FEATURE_EH_FUNCLETS } diff --git a/src/jit/utils.cpp b/src/jit/utils.cpp index a2016b805944..2b120dd347d7 100644 --- a/src/jit/utils.cpp +++ b/src/jit/utils.cpp @@ -953,7 +953,7 @@ FixedBitVect* FixedBitVect::bitVectInit(UINT size, Compiler* comp) assert(bitVectMemSize * bitChunkSize() >= size); - bv = (FixedBitVect*)comp->compGetMem(sizeof(FixedBitVect) + bitVectMemSize, CMK_FixedBitVect); + bv = (FixedBitVect*)comp->getAllocator(CMK_FixedBitVect).allocate(sizeof(FixedBitVect) + bitVectMemSize); memset(bv->bitVect, 0, bitVectMemSize); bv->bitVectSize = size; @@ -1491,10 +1491,8 @@ void HelperCallProperties::init() // MyAssembly;mscorlib;System // MyAssembly;mscorlib System -AssemblyNamesList2::AssemblyNamesList2(const wchar_t* list, HostAllocator* alloc) : m_alloc(alloc) +AssemblyNamesList2::AssemblyNamesList2(const wchar_t* list, HostAllocator alloc) : m_alloc(alloc) { - assert(m_alloc != nullptr); - WCHAR prevChar = '?'; // dummy LPWSTR nameStart = nullptr; // start of the name currently being processed. nullptr if no current name AssemblyName** ppPrevLink = &m_pNames; @@ -1561,8 +1559,8 @@ AssemblyNamesList2::~AssemblyNamesList2() AssemblyName* cur = pName; pName = pName->m_next; - m_alloc->Free(cur->m_assemblyName); - m_alloc->Free(cur); + m_alloc.deallocate(cur->m_assemblyName); + m_alloc.deallocate(cur); } } @@ -2032,7 +2030,7 @@ const SignedMagic* TryGetSignedMagic(int64_t divisor) // // Notes: // This code is previously from UTC where it notes it was taken from -// _The_PowerPC_Compiler_Writer's_Guide_, pages 57-58. The paper is is based on +// _The_PowerPC_Compiler_Writer's_Guide_, pages 57-58. The paper is based on // is "Division by invariant integers using multiplication" by Torbjorn Granlund // and Peter L. Montgomery in PLDI 94 diff --git a/src/jit/utils.h b/src/jit/utils.h index 8dadabb3bc1d..fb6e3459ee80 100644 --- a/src/jit/utils.h +++ b/src/jit/utils.h @@ -539,12 +539,12 @@ class AssemblyNamesList2 AssemblyName* m_next; }; - AssemblyName* m_pNames; // List of names - HostAllocator* m_alloc; // HostAllocator to use in this class + AssemblyName* m_pNames; // List of names + HostAllocator m_alloc; // HostAllocator to use in this class public: // Take a Unicode string list of assembly names, parse it, and store it. - AssemblyNamesList2(const wchar_t* list, __in HostAllocator* alloc); + AssemblyNamesList2(const wchar_t* list, HostAllocator alloc); ~AssemblyNamesList2(); diff --git a/src/jit/valuenum.cpp b/src/jit/valuenum.cpp index 6bf8429abee8..a65a8787f0e4 100644 --- a/src/jit/valuenum.cpp +++ b/src/jit/valuenum.cpp @@ -50,7 +50,7 @@ VNFunc GetVNFuncForOper(genTreeOps oper, bool isUnsigned) } } -ValueNumStore::ValueNumStore(Compiler* comp, CompAllocator* alloc) +ValueNumStore::ValueNumStore(Compiler* comp, CompAllocator alloc) : m_pComp(comp) , m_alloc(alloc) , @@ -60,7 +60,7 @@ ValueNumStore::ValueNumStore(Compiler* comp, CompAllocator* alloc) #endif m_nextChunkBase(0) , m_fixedPointMapSels(alloc, 8) - , m_checkedBoundVNs(comp) + , m_checkedBoundVNs(alloc) , m_chunks(alloc, 8) , m_intCnsMap(nullptr) , m_longCnsMap(nullptr) @@ -672,7 +672,7 @@ bool ValueNumStore::IsSharedStatic(ValueNum vn) return GetVNFunc(vn, &funcAttr) && (s_vnfOpAttribs[funcAttr.m_func] & VNFOA_SharedStatic) != 0; } -ValueNumStore::Chunk::Chunk(CompAllocator* alloc, +ValueNumStore::Chunk::Chunk(CompAllocator alloc, ValueNum* pNextBaseVN, var_types typ, ChunkExtraAttribs attribs, @@ -2568,49 +2568,41 @@ ValueNum ValueNumStore::VNApplySelectorsTypeCheck(ValueNum elem, var_types indTy if (indType != elemTyp) { - bool isConstant = IsVNConstant(elem); - if (isConstant && (elemTyp == genActualType(indType))) + // We are trying to read from an 'elem' of type 'elemType' using 'indType' read + + size_t elemTypSize = (elemTyp == TYP_STRUCT) ? elemStructSize : genTypeSize(elemTyp); + size_t indTypeSize = genTypeSize(indType); + + if ((indType == TYP_REF) && (varTypeIsStruct(elemTyp))) { - // (i.e. We recorded a constant of TYP_INT for a TYP_BYTE field) + // indType is TYP_REF and elemTyp is TYP_STRUCT + // + // We have a pointer to a static that is a Boxed Struct + // + return elem; } - else + else if (indTypeSize > elemTypSize) { - // We are trying to read from an 'elem' of type 'elemType' using 'indType' read - - size_t elemTypSize = (elemTyp == TYP_STRUCT) ? elemStructSize : genTypeSize(elemTyp); - size_t indTypeSize = genTypeSize(indType); + // Reading beyong the end of 'elem' - if ((indType == TYP_REF) && (varTypeIsStruct(elemTyp))) - { - // indType is TYP_REF and elemTyp is TYP_STRUCT - // - // We have a pointer to a static that is a Boxed Struct - // - return elem; - } - else if (indTypeSize > elemTypSize) - { - // Reading beyong the end of 'elem' - - // return a new unique value number - elem = VNForExpr(nullptr, indType); - JITDUMP(" *** Mismatched types in VNApplySelectorsTypeCheck (reading beyond the end)\n"); - } - else if (varTypeIsStruct(indType)) - { - // indType is TYP_STRUCT + // return a new unique value number + elem = VNForExpr(nullptr, indType); + JITDUMP(" *** Mismatched types in VNApplySelectorsTypeCheck (reading beyond the end)\n"); + } + else if (varTypeIsStruct(indType)) + { + // indType is TYP_STRUCT - // return a new unique value number - elem = VNForExpr(nullptr, indType); - JITDUMP(" *** Mismatched types in VNApplySelectorsTypeCheck (indType is TYP_STRUCT)\n"); - } - else - { - // We are trying to read an 'elem' of type 'elemType' using 'indType' read + // return a new unique value number + elem = VNForExpr(nullptr, indType); + JITDUMP(" *** Mismatched types in VNApplySelectorsTypeCheck (indType is TYP_STRUCT)\n"); + } + else + { + // We are trying to read an 'elem' of type 'elemType' using 'indType' read - // insert a cast of elem to 'indType' - elem = VNForCast(elem, indType, elemTyp); - } + // insert a cast of elem to 'indType' + elem = VNForCast(elem, indType, elemTyp); } } return elem; @@ -4546,8 +4538,8 @@ void Compiler::fgValueNumber() assert(fgVNPassesCompleted > 0 || vnStore == nullptr); if (fgVNPassesCompleted == 0) { - CompAllocator* allocator = new (this, CMK_ValueNumber) CompAllocator(this, CMK_ValueNumber); - vnStore = new (this, CMK_ValueNumber) ValueNumStore(this, allocator); + CompAllocator allocator(getAllocator(CMK_ValueNumber)); + vnStore = new (allocator) ValueNumStore(this, allocator); } else { @@ -5782,7 +5774,7 @@ void Compiler::fgValueNumberTree(GenTree* tree, bool evalAsgLhsInd) // TODO-Review: For the short term, we have a workaround for copyblk/initblk. Those that use // addrSpillTemp will have a statement like "addrSpillTemp = addr(local)." If we previously decided // that this block operation defines the local, we will have labeled the "local" node as a DEF - // This flag propogates to the "local" on the RHS. So we'll assume that this is correct, + // This flag propagates to the "local" on the RHS. So we'll assume that this is correct, // and treat it as a def (to a new, unique VN). else if ((lcl->gtFlags & GTF_VAR_DEF) != 0) { @@ -7041,13 +7033,18 @@ void Compiler::fgValueNumberTree(GenTree* tree, bool evalAsgLhsInd) break; case GT_NULLCHECK: + { // Explicit null check. - tree->gtVNPair = - vnStore->VNPWithExc(ValueNumPair(ValueNumStore::VNForVoid(), ValueNumStore::VNForVoid()), - vnStore->VNPExcSetSingleton( - vnStore->VNPairForFunc(TYP_REF, VNF_NullPtrExc, - tree->gtOp.gtOp1->gtVNPair))); - break; + // Handle case where operand tree also may cause exceptions. + ValueNumPair excSet = vnStore->VNPExcSetSingleton( + vnStore->VNPairForFunc(TYP_REF, VNF_NullPtrExc, + vnStore->VNPNormVal(tree->gtOp.gtOp1->gtVNPair))); + ValueNumPair excSetBoth = + vnStore->VNPExcSetUnion(excSet, vnStore->VNPExcVal(tree->gtOp.gtOp1->gtVNPair)); + + tree->gtVNPair = vnStore->VNPWithExc(vnStore->VNPForVoid(), excSetBoth); + } + break; case GT_LOCKADD: // Binop case GT_XADD: // Binop diff --git a/src/jit/valuenum.h b/src/jit/valuenum.h index a8aabef5b1c3..b0c1580462fb 100644 --- a/src/jit/valuenum.h +++ b/src/jit/valuenum.h @@ -103,7 +103,7 @@ class ValueNumStore class VNMap : public JitHashTable { public: - VNMap(CompAllocator* alloc) : JitHashTable(alloc) + VNMap(CompAllocator alloc) : JitHashTable(alloc) { } ~VNMap() @@ -128,7 +128,7 @@ class ValueNumStore Compiler* m_pComp; // For allocations. (Other things?) - CompAllocator* m_alloc; + CompAllocator m_alloc; // TODO-Cleanup: should transform "attribs" into a struct with bit fields. That would be simpler... @@ -237,7 +237,7 @@ class ValueNumStore static void InitValueNumStoreStatics(); // Initialize an empty ValueNumStore. - ValueNumStore(Compiler* comp, CompAllocator* allocator); + ValueNumStore(Compiler* comp, CompAllocator allocator); // Returns "true" iff "vnf" (which may have been created by a cast from an integral value) represents // a legal value number function. @@ -916,7 +916,7 @@ class ValueNumStore // Initialize a chunk, starting at "*baseVN", for the given "typ", "attribs", and "loopNum" (using "alloc" for // allocations). // (Increments "*baseVN" by ChunkSize.) - Chunk(CompAllocator* alloc, + Chunk(CompAllocator alloc, ValueNum* baseVN, var_types typ, ChunkExtraAttribs attribs, diff --git a/src/md/inc/verifylayouts.h b/src/md/inc/verifylayouts.h index 035b52d3ec3c..8ac45a73932d 100644 --- a/src/md/inc/verifylayouts.h +++ b/src/md/inc/verifylayouts.h @@ -65,21 +65,21 @@ // class VerifyLayoutsMD // { // -// static const expected_offset_of_first_field_in_CMiniMdRW = 208; -// static const actual_offset_of_first_field_in_CMiniMdRW = +// static const int expected_offset_of_first_field_in_CMiniMdRW = 208; +// static const int actual_offset_of_first_field_in_CMiniMdRW = // 208; -// static const offset_of_field_after_CMiniMdRW_m_Schema = +// static const int offset_of_field_after_CMiniMdRW_m_Schema = // 312; -// static const offset_of_field_after_CMiniMdRW_m_Tables = +// static const int offset_of_field_after_CMiniMdRW_m_Tables = // 316; // ... many more lines like this covering all fields in all marked up types ... // // -// static const alignment_of_first_field_in_CMiniMdRW = +// static const int alignment_of_first_field_in_CMiniMdRW = // 4; -// static const alignment_of_field_after_CMiniMdRW_m_Schema = +// static const int alignment_of_field_after_CMiniMdRW_m_Schema = // 8; -// static const alignment_of_field_after_CMiniMdRW_m_Tables = +// static const int alignment_of_field_after_CMiniMdRW_m_Tables = // 8; // ... many more lines like this cover all fields in all marked up types ... // @@ -123,16 +123,16 @@ class VerifyLayoutsMD #define END_TYPE(typeName, typeAlign) END_TYPE_ESCAPED(typeName, typeName, typeAlign) #define BEGIN_TYPE_ESCAPED(typeName, typeNameEscaped, initialFieldOffset) \ - static const expected_offset_of_first_field_in_##typeNameEscaped## = initialFieldOffset; \ - static const actual_offset_of_first_field_in_##typeNameEscaped## = + static const int expected_offset_of_first_field_in_##typeNameEscaped## = initialFieldOffset; \ + static const int actual_offset_of_first_field_in_##typeNameEscaped## = #define ALIGN_FIELD_ESCAPED(typeName, typeNameEscaped, fieldName, fieldSize, fieldAlign) \ offsetof(IGNORE_COMMAS(typeName), fieldName); \ - static const offset_of_field_after_##typeNameEscaped##_##fieldName = + static const int offset_of_field_after_##typeNameEscaped##_##fieldName = #define BITFIELD(typeName, fieldName, fieldOffset, fieldSize) \ fieldOffset; \ - static const offset_of_field_after_##typeName##_##fieldName = + static const int offset_of_field_after_##typeName##_##fieldName = #define END_TYPE_ESCAPED(typeName, typeNameEscaped, typeAlignentSize) \ sizeof(typeName); @@ -145,13 +145,13 @@ class VerifyLayoutsMD #undef BITFIELD #define BEGIN_TYPE_ESCAPED(typeName, escapedTypeName, initialFieldOffset) \ - static const alignment_of_first_field_in_##escapedTypeName = + static const int alignment_of_first_field_in_##escapedTypeName = #define ALIGN_FIELD_ESCAPED(typeName, escapedTypeName, fieldName, fieldSize, fieldAlign) \ fieldAlign; \ - static const alignment_of_field_after_##escapedTypeName##_##fieldName = + static const int alignment_of_field_after_##escapedTypeName##_##fieldName = #define BITFIELD(typeName, fieldName, fieldOffset, fieldSize) \ fieldSize; \ - static const alignment_of_field_after_##typeName##_##fieldName = + static const int alignment_of_field_after_##typeName##_##fieldName = #define END_TYPE_ESCAPED(typeName, escapedTypeName, typeAlignmentSize) \ typeAlignmentSize; diff --git a/src/pal/inc/pal.h b/src/pal/inc/pal.h index f89798ceab80..98d0ae2f11e9 100644 --- a/src/pal/inc/pal.h +++ b/src/pal/inc/pal.h @@ -873,7 +873,13 @@ SetFileAttributesW( #define SetFileAttributes SetFileAttributesA #endif -typedef LPVOID LPOVERLAPPED; // diff from winbase.h +typedef struct _OVERLAPPED { + ULONG_PTR Internal; + ULONG_PTR InternalHigh; + DWORD Offset; + DWORD OffsetHigh; + HANDLE hEvent; +} OVERLAPPED, *LPOVERLAPPED; PALIMPORT BOOL @@ -5024,6 +5030,16 @@ PALAPI PAL_SetTerminationRequestHandler( IN PTERMINATION_REQUEST_HANDLER terminationRequestHandler); +PALIMPORT +VOID +PALAPI +PAL_CatchHardwareExceptionHolderEnter(); + +PALIMPORT +VOID +PALAPI +PAL_CatchHardwareExceptionHolderExit(); + // // This holder is used to indicate that a hardware // exception should be raised as a C++ exception @@ -5032,9 +5048,15 @@ PAL_SetTerminationRequestHandler( class CatchHardwareExceptionHolder { public: - CatchHardwareExceptionHolder(); + CatchHardwareExceptionHolder() + { + PAL_CatchHardwareExceptionHolderEnter(); + } - ~CatchHardwareExceptionHolder(); + ~CatchHardwareExceptionHolder() + { + PAL_CatchHardwareExceptionHolderExit(); + } static bool IsEnabled(); }; @@ -5052,6 +5074,13 @@ class CatchHardwareExceptionHolder #ifdef FEATURE_PAL_SXS +class NativeExceptionHolderBase; + +PALIMPORT +NativeExceptionHolderBase ** +PALAPI +PAL_GetNativeExceptionHolderHead(); + extern "C++" { // @@ -5070,9 +5099,22 @@ class NativeExceptionHolderBase NativeExceptionHolderBase *m_next; protected: - NativeExceptionHolderBase(); + NativeExceptionHolderBase() + { + m_head = nullptr; + m_next = nullptr; + } - ~NativeExceptionHolderBase(); + ~NativeExceptionHolderBase() + { + // Only destroy if Push was called + if (m_head != nullptr) + { + *m_head = m_next; + m_head = nullptr; + m_next = nullptr; + } + } public: // Calls the holder's filter handler. @@ -5081,7 +5123,13 @@ class NativeExceptionHolderBase // Adds the holder to the "stack" of holders. This is done explicitly instead // of in the constructor was to avoid the mess of move constructors combined // with return value optimization (in CreateHolder). - void Push(); + void Push() + { + NativeExceptionHolderBase **head = PAL_GetNativeExceptionHolderHead(); + m_head = head; + m_next = *head; + *head = this; + } // Given the currentHolder and locals stack range find the next holder starting with this one // To find the first holder, pass nullptr as the currentHolder. diff --git a/src/pal/inc/rt/palrt.h b/src/pal/inc/rt/palrt.h index 1360a81c4325..e262b0dd9551 100644 --- a/src/pal/inc/rt/palrt.h +++ b/src/pal/inc/rt/palrt.h @@ -1273,7 +1273,7 @@ interface IMoniker; typedef VOID (WINAPI *LPOVERLAPPED_COMPLETION_ROUTINE)( DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, - LPVOID lpOverlapped); + LPOVERLAPPED lpOverlapped); // // Debug APIs diff --git a/src/pal/prebuilt/corerror/mscorurt.rc b/src/pal/prebuilt/corerror/mscorurt.rc index 28da8f91ce6e..35b26618a15d 100644 --- a/src/pal/prebuilt/corerror/mscorurt.rc +++ b/src/pal/prebuilt/corerror/mscorurt.rc @@ -5,180 +5,64 @@ STRINGTABLE DISCARDABLE BEGIN MSG_FOR_URT_HR(CORDBG_S_AT_END_OF_STACK) "The stack walk has reached the end of the stack. There are no more frames to walk." - MSG_FOR_URT_HR(CEE_E_ENTRYPOINT) "Invalid entrypoint information." MSG_FOR_URT_HR(CEE_E_CVTRES_NOT_FOUND) "cvtres.exe not found." - MSG_FOR_URT_HR(MSEE_E_LOADLIBFAILED) "Failed to delayload a library." - MSG_FOR_URT_HR(MSEE_E_GETPROCFAILED) "Failed to get dll entrypoint." - MSG_FOR_URT_HR(MSEE_E_MULTCOPIESLOADED) "Multiple copies of mscoree.dll have been loaded into the same process." MSG_FOR_URT_HR(COR_E_TYPEUNLOADED) "Type has been unloaded." MSG_FOR_URT_HR(COR_E_APPDOMAINUNLOADED) "Attempted to access an unloaded appdomain." MSG_FOR_URT_HR(COR_E_CANNOTUNLOADAPPDOMAIN) "Error while unloading appdomain." MSG_FOR_URT_HR(MSEE_E_ASSEMBLYLOADINPROGRESS) "Assembly is still being loaded." - MSG_FOR_URT_HR(MSEE_E_CANNOTCREATEAPPDOMAIN) "Attempt to create appdomain failed." MSG_FOR_URT_HR(COR_E_ASSEMBLYEXPECTED) "The module was expected to contain an assembly manifest." MSG_FOR_URT_HR(COR_E_FIXUPSINEXE) "Attempt to load an unverifiable executable with fixups (IAT with more than 2 sections or a TLS section.)" - MSG_FOR_URT_HR(COR_E_NO_LOADLIBRARY_ALLOWED) "Attempt to LoadLibrary a managed image in an improper way (only assemblies with EAT area allowed)." MSG_FOR_URT_HR(COR_E_NEWER_RUNTIME) "This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded." - MSG_FOR_URT_HR(COR_E_CANNOT_SET_POLICY) "Cannot set security policy under MultiDomain after non-GAC assemblies have been loaded in appdomain." - MSG_FOR_URT_HR(COR_E_CANNOT_SPECIFY_EVIDENCE) "Cannot specify assembly evidence under MultiDomain after non-GAC assemblies with default evidence have been loaded in appdomain." MSG_FOR_URT_HR(COR_E_MULTIMODULEASSEMBLIESDIALLOWED) "The module cannot be loaded because only single file assemblies are supported." MSG_FOR_URT_HR(HOST_E_DEADLOCK) "Host detected a deadlock on a blocking operation." - MSG_FOR_URT_HR(HOST_E_INTERRUPTED) "Host interrupted a wait." MSG_FOR_URT_HR(HOST_E_INVALIDOPERATION) "Invalid operation." MSG_FOR_URT_HR(HOST_E_CLRNOTAVAILABLE) "CLR has been disabled due to unrecoverable error." - MSG_FOR_URT_HR(HOST_E_TIMEOUT) "A wait has timed out." - MSG_FOR_URT_HR(HOST_E_NOT_OWNER) "The leave operation has been attempted on a synchronization primitive that is not owned by the current thread." - MSG_FOR_URT_HR(HOST_E_ABANDONED) "An event has been abandoned." MSG_FOR_URT_HR(HOST_E_EXITPROCESS_THREADABORT) "Process exited due to ThreadAbort escalation." MSG_FOR_URT_HR(HOST_E_EXITPROCESS_ADUNLOAD) "Process exited due to AD Unload escalation." MSG_FOR_URT_HR(HOST_E_EXITPROCESS_TIMEOUT) "Process exited due to Timeout escalation." MSG_FOR_URT_HR(HOST_E_EXITPROCESS_OUTOFMEMORY) "Process exited due to OutOfMemory escalation." - MSG_FOR_URT_HR(HOST_E_EXITPROCESS_STACKOVERFLOW) "Process exited due to StackOverflow escalation." MSG_FOR_URT_HR(COR_E_MODULE_HASH_CHECK_FAILED) "The check of the module's hash failed." MSG_FOR_URT_HR(FUSION_E_REF_DEF_MISMATCH) "The located assembly's manifest definition does not match the assembly reference." MSG_FOR_URT_HR(FUSION_E_INVALID_PRIVATE_ASM_LOCATION) "The private assembly was located outside the appbase directory." MSG_FOR_URT_HR(FUSION_E_ASM_MODULE_MISSING) "A module specified in the manifest was not found." - MSG_FOR_URT_HR(FUSION_E_UNEXPECTED_MODULE_FOUND) "Modules which are not in the manifest were streamed in." MSG_FOR_URT_HR(FUSION_E_PRIVATE_ASM_DISALLOWED) "A strongly-named assembly is required." MSG_FOR_URT_HR(FUSION_E_SIGNATURE_CHECK_FAILED) "Strong name signature could not be verified. The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key." - MSG_FOR_URT_HR(FUSION_E_DATABASE_ERROR) "An unexpected error was encountered in the Assembly Cache database." MSG_FOR_URT_HR(FUSION_E_INVALID_NAME) "The given assembly name or codebase was invalid." MSG_FOR_URT_HR(FUSION_E_CODE_DOWNLOAD_DISABLED) "HTTP download of assemblies has been disabled for this appdomain." - MSG_FOR_URT_HR(FUSION_E_UNINSTALL_DISALLOWED) "Uninstall of given assembly is not allowed." - MSG_FOR_URT_HR(CLR_E_APP_CONFIG_NOT_ALLOWED_IN_APPX_PROCESS) "Application configuration file not allowed in AppX process." MSG_FOR_URT_HR(FUSION_E_HOST_GAC_ASM_MISMATCH) "Assembly in host store has a different signature than assembly in GAC." MSG_FOR_URT_HR(FUSION_E_LOADFROM_BLOCKED) "LoadFrom(), LoadFile(), Load(byte[]) and LoadModule() have been disabled by the host." MSG_FOR_URT_HR(FUSION_E_CACHEFILE_FAILED) "Failed to add file to AppDomain cache." MSG_FOR_URT_HR(FUSION_E_APP_DOMAIN_LOCKED) "The requested assembly version conflicts with what is already bound in the app domain or specified in the manifest." MSG_FOR_URT_HR(FUSION_E_CONFIGURATION_ERROR) "The requested assembly name was neither found in the GAC nor in the manifest or the manifest's specified location is wrong." MSG_FOR_URT_HR(FUSION_E_MANIFEST_PARSE_ERROR) "Unexpected error while parsing the specified manifest." - MSG_FOR_URT_HR(FUSION_E_INVALID_ASSEMBLY_REFERENCE) "The given assembly name is invalid because a processor architecture is specified." - MSG_FOR_URT_HR(COR_E_ASSEMBLY_NOT_EXPECTED) "The module was expected to not contain an assembly manifest." MSG_FOR_URT_HR(COR_E_LOADING_REFERENCE_ASSEMBLY) "Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context." MSG_FOR_URT_HR(COR_E_NI_AND_RUNTIME_VERSION_MISMATCH) "The native image could not be loaded, because it was generated for use by a different version of the runtime." MSG_FOR_URT_HR(COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY) "Contract Windows Runtime assemblies cannot be loaded for execution. Make sure your application only contains non-contract Windows Runtime assemblies." MSG_FOR_URT_HR(CLDB_E_FILE_BADREAD) "Error occurred during a read." MSG_FOR_URT_HR(CLDB_E_FILE_BADWRITE) "Error occurred during a write." - MSG_FOR_URT_HR(CLDB_E_FILE_READONLY) "File is read only." - MSG_FOR_URT_HR(CLDB_E_NAME_ERROR) "Ill-formed name." - MSG_FOR_URT_HR(CLDB_E_TRUNCATION) "Data value was truncated." MSG_FOR_URT_HR(CLDB_E_FILE_OLDVER) "Old version error." - MSG_FOR_URT_HR(CLDB_E_RELOCATED) "A shared memory open failed to open at the originally assigned memory address." MSG_FOR_URT_HR(CLDB_E_SMDUPLICATE) "Create of shared memory failed. A memory mapping of the same name already exists." MSG_FOR_URT_HR(CLDB_E_NO_DATA) "No .CLB data in the memory or stream." - MSG_FOR_URT_HR(CLDB_E_READONLY) "Database is read only." MSG_FOR_URT_HR(CLDB_E_INCOMPATIBLE) "Importing scope is not compatible with the emitting scope." MSG_FOR_URT_HR(CLDB_E_FILE_CORRUPT) "File is corrupt." - MSG_FOR_URT_HR(CLDB_E_SCHEMA_VERNOTFOUND) "Required version of schema not found." MSG_FOR_URT_HR(CLDB_E_BADUPDATEMODE) "Cannot open a incrementally build scope for full update." - MSG_FOR_URT_HR(CLDB_E_INDEX_NONULLKEYS) "Null value not allowed in unique index or primary key." - MSG_FOR_URT_HR(CLDB_E_INDEX_DUPLICATE) "Index has been duplicated." - MSG_FOR_URT_HR(CLDB_E_INDEX_BADTYPE) "The columns data type is not allowed in an index." MSG_FOR_URT_HR(CLDB_E_INDEX_NOTFOUND) "Index not found." MSG_FOR_URT_HR(CLDB_E_RECORD_NOTFOUND) "Record not found on lookup." - MSG_FOR_URT_HR(CLDB_E_RECORD_OVERFLOW) "Too many records were returned for criteria." - MSG_FOR_URT_HR(CLDB_E_RECORD_DUPLICATE) "Record is a duplicate." - MSG_FOR_URT_HR(CLDB_E_RECORD_PKREQUIRED) "Primary key value is required." - MSG_FOR_URT_HR(CLDB_E_RECORD_DELETED) "Record is valid but deleted." MSG_FOR_URT_HR(CLDB_E_RECORD_OUTOFORDER) "Record is emitted out of order." - MSG_FOR_URT_HR(CLDB_E_COLUMN_OVERFLOW) "Data too large." - MSG_FOR_URT_HR(CLDB_E_COLUMN_READONLY) "Column cannot be changed." - MSG_FOR_URT_HR(CLDB_E_COLUMN_SPECIALCOL) "Too many RID or primary key columns, 1 is max." - MSG_FOR_URT_HR(CLDB_E_COLUMN_PKNONULLS) "Primary key column may not allow the null value." - MSG_FOR_URT_HR(CLDB_E_TABLE_CANTDROP) "Attempted auto-drop of table while open." - MSG_FOR_URT_HR(CLDB_E_OBJECT_NOTFOUND) "Object not found in the database." - MSG_FOR_URT_HR(CLDB_E_OBJECT_COLNOTFOUND) "Column not found." - MSG_FOR_URT_HR(CLDB_E_VECTOR_BADINDEX) "Invalid index." MSG_FOR_URT_HR(CLDB_E_TOO_BIG) "A blob or string was too big." MSG_FOR_URT_HR(META_E_INVALID_TOKEN_TYPE) "A token of the wrong type passed to a metadata function." - MSG_FOR_URT_HR(TLBX_E_INVALID_TYPEINFO) "Typelib import: Invalid type, not converted." - MSG_FOR_URT_HR(TLBX_E_INVALID_TYPEINFO_UNNAMED) "Typelib import: Invalid type, not converted - name unknown." - MSG_FOR_URT_HR(TLBX_E_CTX_NESTED) "Typelib export: TLBX_E_CTX_NESTED" - MSG_FOR_URT_HR(TLBX_E_ERROR_MESSAGE) "Typelib export: General error. See IError info for more information." - MSG_FOR_URT_HR(TLBX_E_CANT_SAVE) "Typelib export: SaveAllChanges() failed." - MSG_FOR_URT_HR(TLBX_W_LIBNOTREGISTERED) "Typelib export: Type library is not registered." - MSG_FOR_URT_HR(TLBX_E_CANTLOADLIBRARY) "Typelib export: Type library could not be loaded." - MSG_FOR_URT_HR(TLBX_E_BAD_VT_TYPE) "Typelib import: Invalid vartype, not converted." - MSG_FOR_URT_HR(TLBX_E_NO_MSCOREE_TLB) "Typelib export: Could not load mscoree.tlb." - MSG_FOR_URT_HR(TLBX_E_BAD_MSCOREE_TLB) "Typelib export: Could not get a required typeinfo from mscoree.tlb." - MSG_FOR_URT_HR(TLBX_E_TLB_EXCEPTION) "Typelib import: Fault reading a typelib." - MSG_FOR_URT_HR(TLBX_E_MULTIPLE_LCIDS) "Typelib import: Multiple [lcid] parameters on a method." - MSG_FOR_URT_HR(TLBX_E_AMBIGUOUS_RETURN) "Typelib import: Duplicate or ambiguous return types." - MSG_FOR_URT_HR(TLBX_E_DUPLICATE_TYPE_NAME) "Typelib import: Duplicate name (due to user-defined name)." - MSG_FOR_URT_HR(TLBX_I_NONSEQUENTIALSTRUCT) "Typelib export: Cannot convert non-sequential structs." - MSG_FOR_URT_HR(TLBX_I_RESOLVEREFFAILED) "Typelib import: The resolve ref call failed." - MSG_FOR_URT_HR(TLBX_E_ASANY) "Typelib export: Encountered AsAny - ignored." - MSG_FOR_URT_HR(TLBX_E_INVALIDLCIDPARAM) "Typelib export: Encountered an [lcid] attribute set to an invalid parameter." - MSG_FOR_URT_HR(TLBX_E_LCIDONDISPONLYITF) "Typelib export: Encountered an [lcid] attribute on a pure dispatch interface." - MSG_FOR_URT_HR(TLBX_E_NONPUBLIC_FIELD) "Typelib export: Non-public field in public struct." - MSG_FOR_URT_HR(TLBX_E_BAD_NAMES) "Typelib export: Bad names list." - MSG_FOR_URT_HR(TLBX_E_GENERICINST_SIGNATURE) "TypeLib export: generic type instance in signature." - MSG_FOR_URT_HR(TLBX_E_GENERICPAR_SIGNATURE) "TypeLib export: generic type parameter in signature." - MSG_FOR_URT_HR(META_E_DUPLICATE) "Attempted to define an object that already exists." - MSG_FOR_URT_HR(META_E_GUID_REQUIRED) "A guid was not provided where one was required." - MSG_FOR_URT_HR(META_E_TYPEDEF_MISMATCH) "Merge: an import typedef matched ns.name, but not version and guid." - MSG_FOR_URT_HR(META_E_MERGE_COLLISION) "Merge: conflict between import and emit." - MSG_FOR_URT_HR(TLBX_E_NO_SAFEHANDLE_ARRAYS) "TypeLib export: Detected array of SafeHandles." - MSG_FOR_URT_HR(META_E_METHD_NOT_FOUND) "Merge: Class already in emit scope, but member not found." - MSG_FOR_URT_HR(META_E_FIELD_NOT_FOUND) "Merge: Class already in emit scope, but member not found." - MSG_FOR_URT_HR(META_E_PARAM_MISMATCH) "Merge: Parameter information mismatched." MSG_FOR_URT_HR(META_E_BADMETADATA) "Merge: Inconsistency in meta data import scope." - MSG_FOR_URT_HR(META_E_INTFCEIMPL_NOT_FOUND) "Merge: Class already in emit scope, but interfaceimpl not found." - MSG_FOR_URT_HR(TLBX_E_NO_CRITICALHANDLE_ARRAYS) "TypeLib export: Detected array of CriticalHandles." - MSG_FOR_URT_HR(META_E_CLASS_LAYOUT_INCONSISTENT) "Merge: Duplicate classes have inconsistent class layout information." - MSG_FOR_URT_HR(META_E_FIELD_MARSHAL_NOT_FOUND) "Merge: Field is duplicated but no matching FieldMarshal information." - MSG_FOR_URT_HR(META_E_EVENT_NOT_FOUND) "Merge: Method is duplicated but no matching event info." - MSG_FOR_URT_HR(META_E_PROP_NOT_FOUND) "Merge: Method is duplicated but no matching property info." MSG_FOR_URT_HR(META_E_BAD_SIGNATURE) "Bad binary signature." MSG_FOR_URT_HR(META_E_BAD_INPUT_PARAMETER) "Bad input parameters." - MSG_FOR_URT_HR(META_E_METHDIMPL_INCONSISTENT) "Merge: duplicated methods have inconsistent ImplFlags." - MSG_FOR_URT_HR(META_E_MD_INCONSISTENCY) "Merge: Inconsistency in meta data." MSG_FOR_URT_HR(META_E_CANNOTRESOLVETYPEREF) "Cannot resolve typeref." MSG_FOR_URT_HR(META_E_STRINGSPACE_FULL) "No logical space left to create more user strings." - MSG_FOR_URT_HR(META_E_UNEXPECTED_REMAP) "Unexpected TokenRemap." MSG_FOR_URT_HR(META_E_HAS_UNMARKALL) "Unmark all has been called already." MSG_FOR_URT_HR(META_E_MUST_CALL_UNMARKALL) "Must call UnmarkAll first before marking." - MSG_FOR_URT_HR(META_E_GENERICPARAM_INCONSISTENT) "Merge: duplicated types or methods have inconsistent GenericParams." - MSG_FOR_URT_HR(META_E_EVENT_COUNTS) "Merge: different event counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_PROPERTY_COUNTS) "Merge: different property counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_TYPEDEF_MISSING) "Merge: An input scope has a TypeRef which does not have a matching TypeDef." - MSG_FOR_URT_HR(TLBX_E_CANT_LOAD_MODULE) "TypeLib export: cannot open the module to export." - MSG_FOR_URT_HR(TLBX_E_CANT_LOAD_CLASS) "TypeLib export: cannot load a class." - MSG_FOR_URT_HR(TLBX_E_NULL_MODULE) "TypeLib export: the hModule of a loaded class is 0; cannot export it." - MSG_FOR_URT_HR(TLBX_E_NO_CLSID_KEY) "TypeLib export: no CLSID or Interface subkey to HKCR." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_EXPORT) "TypeLib export: attempted to export an Assembly imported from a TLB." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_IMPORT) "TypeLib import: attempted to import a TLB exported from an Assembly." - MSG_FOR_URT_HR(TLBX_E_BAD_NATIVETYPE) "TypeLib export: bad Native type in method signature." - MSG_FOR_URT_HR(TLBX_E_BAD_VTABLE) "TypeLib import: non-increasing vtable (duplicate slots)." - MSG_FOR_URT_HR(TLBX_E_CRM_NON_STATIC) "TypeLib export: the COM register method is non static." - MSG_FOR_URT_HR(TLBX_E_CRM_INVALID_SIG) "TypeLib export: the specified COM register method does not have the correct signature." - MSG_FOR_URT_HR(TLBX_E_CLASS_LOAD_EXCEPTION) "TypeLib export: cannot load CLR type." - MSG_FOR_URT_HR(TLBX_E_UNKNOWN_SIGNATURE) "TypeLib export: unknown element in signature." - MSG_FOR_URT_HR(TLBX_E_REFERENCED_TYPELIB) "TypeLib import: reference to an external typelib." - MSG_FOR_URT_HR(TLBX_E_INVALID_NAMESPACE) "TypeLib import: an imported typelib has an invalid namespace name." - MSG_FOR_URT_HR(TLBX_E_LAYOUT_ERROR) "Typelib export: an error on Layout()" - MSG_FOR_URT_HR(TLBX_E_NOTIUNKNOWN) "Typelib import: Interface not derived from IUnknown." - MSG_FOR_URT_HR(TLBX_E_NONVISIBLEVALUECLASS) "Typelib export: Non COM visible value type in method signature." - MSG_FOR_URT_HR(TLBX_E_LPTSTR_NOT_ALLOWED) "Typelib export: Types which contain the native type NATIVE_TYPE_LPTSTR are not allowed to be exported to COM." - MSG_FOR_URT_HR(TLBX_E_AUTO_CS_NOT_ALLOWED) "Typelib export: Types with a charset of auto are not allowed to be exported to COM." - MSG_FOR_URT_HR(TLBX_E_ENUM_VALUE_INVALID) "Typelib export: The enum value is not legal for a typelib." - MSG_FOR_URT_HR(TLBX_E_DUPLICATE_IID) "Typelib export: Duplicate IID." - MSG_FOR_URT_HR(TLBX_E_NO_NESTED_ARRAYS) "Typelib export: detected nested arrays." - MSG_FOR_URT_HR(TLBX_E_PARAM_ERROR_NAMED) "Typelib import: parameter type could not be converted." - MSG_FOR_URT_HR(TLBX_E_PARAM_ERROR_UNNAMED) "Typelib import: parameter type could not be converted - parameter name unknown." - MSG_FOR_URT_HR(TLBX_E_AGNOST_SIGNATURE) "TypeLib export: size agnostic element in signature." - MSG_FOR_URT_HR(TLBX_E_CONVERT_FAIL) "TypeLib export: exporter failed." - MSG_FOR_URT_HR(TLBX_W_DUAL_NOT_DISPATCH) "Typelib import: [dual] interface not derived from IDispatch." - MSG_FOR_URT_HR(TLBX_E_BAD_SIGNATURE) "Typelib export: bad signature." - MSG_FOR_URT_HR(TLBX_E_ARRAY_NEEDS_NT_FIXED) "Typelib export: non-fixed or non-safearray array in struct." - MSG_FOR_URT_HR(TLBX_E_CLASS_NEEDS_NT_INTF) "Typelib export: non-interface class in struct." MSG_FOR_URT_HR(META_E_CA_INVALID_TARGET) "Known custom attribute on invalid target." MSG_FOR_URT_HR(META_E_CA_INVALID_VALUE) "Known custom attribute had invalid value." MSG_FOR_URT_HR(META_E_CA_INVALID_BLOB) "Known custom attribute blob has bad format." MSG_FOR_URT_HR(META_E_CA_REPEATED_ARG) "Known custom attribute blob has repeated named argument." MSG_FOR_URT_HR(META_E_CA_UNKNOWN_ARGUMENT) "Known custom attribute named argument not recognized." - MSG_FOR_URT_HR(META_E_CA_VARIANT_NYI) "Known attribute named argument does not support variant." - MSG_FOR_URT_HR(META_E_CA_ARRAY_NYI) "Known attribute named argument does not support array." MSG_FOR_URT_HR(META_E_CA_UNEXPECTED_TYPE) "Known attribute parser found unexpected type." MSG_FOR_URT_HR(META_E_CA_INVALID_ARGTYPE) "Known attribute parser only handles fields, not properties." MSG_FOR_URT_HR(META_E_CA_INVALID_ARG_FOR_TYPE) "Known attribute parser found an argument that is invalid for the object it is applied to." @@ -186,73 +70,17 @@ BEGIN MSG_FOR_URT_HR(META_E_CA_INVALID_MARSHALAS_FIELDS) "The MarshalAs attribute has fields set that are not valid for the specified unmanaged type." MSG_FOR_URT_HR(META_E_CA_NT_FIELDONLY) "The specified unmanaged type is only valid on fields." MSG_FOR_URT_HR(META_E_CA_NEGATIVE_PARAMINDEX) "The parameter index cannot be negative." - MSG_FOR_URT_HR(META_E_CA_NEGATIVE_MULTIPLIER) "The multiplier cannot be negative." MSG_FOR_URT_HR(META_E_CA_NEGATIVE_CONSTSIZE) "The constant size cannot be negative." MSG_FOR_URT_HR(META_E_CA_FIXEDSTR_SIZE_REQUIRED) "A fixed string requires a size." MSG_FOR_URT_HR(META_E_CA_CUSTMARSH_TYPE_REQUIRED) "A custom marshaler requires the custom marshaler type." - MSG_FOR_URT_HR(META_E_CA_FILENAME_REQUIRED) "A DllImport attribute requires a filename." - MSG_FOR_URT_HR(TLBX_W_NO_PROPS_IN_EVENTS) "TypeLib import: Detected properties in a source dispinterface." MSG_FOR_URT_HR(META_E_NOT_IN_ENC_MODE) "SaveDelta was called without being in EnC mode." - MSG_FOR_URT_HR(META_E_METHOD_COUNTS) "Merge: different method counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_FIELD_COUNTS) "Merge: different field counts in import and emit scopes." - MSG_FOR_URT_HR(META_E_PARAM_COUNTS) "Merge: different parameter counts in import and emit scopes." - MSG_FOR_URT_HR(TLBX_E_TYPED_REF) "TypeLib export: Exporting a TypedReference." - MSG_FOR_URT_HR(TLBX_E_BITNESS_MISMATCH) "TypeLib export: bitness of assembly does not match bitness of output type library." MSG_FOR_URT_HR(META_E_CA_BAD_FRIENDS_ARGS) "InternalsVisibleTo can't have a version, culture, or processor architecture." MSG_FOR_URT_HR(VLDTR_E_RID_OUTOFRANGE) "Rid is out of range." - MSG_FOR_URT_HR(VLDTR_E_CDTKN_OUTOFRANGE) "Coded token type is out of range." - MSG_FOR_URT_HR(VLDTR_E_CDRID_OUTOFRANGE) "Coded rid is out of range." MSG_FOR_URT_HR(VLDTR_E_STRING_INVALID) "String offset is invalid." MSG_FOR_URT_HR(VLDTR_E_GUID_INVALID) "GUID offset is invalid." MSG_FOR_URT_HR(VLDTR_E_BLOB_INVALID) "Blob offset if invalid." - MSG_FOR_URT_HR(VLDTR_E_MOD_MULTI) "Multiple module records found." - MSG_FOR_URT_HR(VLDTR_E_MOD_NULLMVID) "Module has null MVID." - MSG_FOR_URT_HR(VLDTR_E_TR_NAMENULL) "TypeRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TR_DUP) "TypeRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_TD_NAMENULL) "TypeDef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TD_DUPNAME) "TypeDef has a duplicate based on name+namespace." - MSG_FOR_URT_HR(VLDTR_E_TD_DUPGUID) "TypeDef has a duplicate based on GUID." - MSG_FOR_URT_HR(VLDTR_E_TD_NOTIFACEOBJEXTNULL) "TypeDef that is not an Interface and not System.Object extends nil parent." - MSG_FOR_URT_HR(VLDTR_E_TD_OBJEXTENDSNONNULL) "System.Object extends a non-nil parent." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSSEALED) "TypeDef extends sealed class." - MSG_FOR_URT_HR(VLDTR_E_TD_DLTNORTSPCL) "TypeDef is Deleted but not marked with RTSpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_RTSPCLNOTDLT) "TypeDef is marked RTSpecialName, but is not a Deleted record." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLPRIV) "MethodImpl's Decl is private." - MSG_FOR_URT_HR(VLDTR_E_AS_BADNAME) "Assembly [Ref] name has path and/or extension." - MSG_FOR_URT_HR(VLDTR_E_FILE_SYSNAME) "File has a system name (con, com, aux, etc.)." - MSG_FOR_URT_HR(VLDTR_E_MI_BODYSTATIC) "MethodImpl's body is static." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACENOTABS) "TypeDef is marked Interface but not Abstract." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACEPARNOTNIL) "TypeDef is marked Interface but parent is not Nil." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACEGUIDNULL) "TypeDef is marked Interface but GUID is NULL." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLFINAL) "TMethodImpl's Decl is final." - MSG_FOR_URT_HR(VLDTR_E_TD_VTNOTSEAL) "TypeDef is marked ValueType but not marked Sealed." - MSG_FOR_URT_HR(VLDTR_E_PD_BADFLAGS) "Parameter has extra bits in flags." - MSG_FOR_URT_HR(VLDTR_E_IFACE_DUP) "InterfaceImpl has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MR_NAMENULL) "MemberRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MR_VTBLNAME) "MemberRef has an invalid name, _VtblGap*." - MSG_FOR_URT_HR(VLDTR_E_MR_DELNAME) "MemberRef has an invalid name, _Deleted*." - MSG_FOR_URT_HR(VLDTR_E_MR_PARNIL) "MemberRef parent Nil in a PE file." MSG_FOR_URT_HR(VLDTR_E_MR_BADCALLINGCONV) "MemberRef has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MR_NOTVARARG) "MemberRef has Method parent but calling convention is not VARARG." - MSG_FOR_URT_HR(VLDTR_E_MR_NAMEDIFF) "MemberRef name different from parent MethodDef." - MSG_FOR_URT_HR(VLDTR_E_MR_SIGDIFF) "MemberRef signature different from parent MethodDef." - MSG_FOR_URT_HR(VLDTR_E_MR_DUP) "MemberRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_CL_TDAUTO) "ClassLayout parent TypeDef is marked AutoLayout." - MSG_FOR_URT_HR(VLDTR_E_CL_BADPCKSZ) "ClassLayout has bad PackingSize." - MSG_FOR_URT_HR(VLDTR_E_CL_DUP) "ClassLayout has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FL_BADOFFSET) "FieldLayout2 has bad offset." - MSG_FOR_URT_HR(VLDTR_E_FL_TDNIL) "FieldLayout2 has field with nil parent." - MSG_FOR_URT_HR(VLDTR_E_FL_NOCL) "FieldLayout2 has no ClassLayout record." - MSG_FOR_URT_HR(VLDTR_E_FL_TDNOTEXPLCT) "FieldLayout2 parent TypeDef is not marked with ExplicitLayout." - MSG_FOR_URT_HR(VLDTR_E_FL_FLDSTATIC) "FieldLayout2 has field marked Static." - MSG_FOR_URT_HR(VLDTR_E_FL_DUP) "FieldLayout2 has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MODREF_NAMENULL) "ModuleRef name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MODREF_DUP) "ModuleRef has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_TR_BADSCOPE) "TypeRef has a bad resolution scope." - MSG_FOR_URT_HR(VLDTR_E_TD_NESTEDNOENCL) "TypeDef marked nested has no encloser." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTTRRES) "TypeDef extends a TypeRef which resolves to a TypeDef in the same module." MSG_FOR_URT_HR(VLDTR_E_SIGNULL) "Signature specified is zero-sized." - MSG_FOR_URT_HR(VLDTR_E_SIGNODATA) "Signature does not have enough data at specified byte." MSG_FOR_URT_HR(VLDTR_E_MD_BADCALLINGCONV) "Method signature has invalid calling convention." MSG_FOR_URT_HR(VLDTR_E_MD_THISSTATIC) "Method is marked static but has HASTHIS/EXPLICITTHIS set on the calling convention." MSG_FOR_URT_HR(VLDTR_E_MD_NOTTHISNOTSTATIC) "Method is not marked static but is not HASTHIS or EXPLICITTHIS." @@ -268,187 +96,13 @@ BEGIN MSG_FOR_URT_HR(VLDTR_E_SIG_MISSNLBND) "Signature is missing count of lower bounds." MSG_FOR_URT_HR(VLDTR_E_SIG_MISSLBND) "Signature is missing a lower bound." MSG_FOR_URT_HR(VLDTR_E_SIG_BADELTYPE) "Signature has bad element type." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSVASIZE) "Signature has value array missing size." - MSG_FOR_URT_HR(VLDTR_E_FD_BADCALLINGCONV) "Field signature has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MD_NAMENULL) "Method name is NULL." - MSG_FOR_URT_HR(VLDTR_E_MD_PARNIL) "Method has parent NIL." - MSG_FOR_URT_HR(VLDTR_E_MD_DUP) "Method has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FD_NAMENULL) "Field name is NULL." - MSG_FOR_URT_HR(VLDTR_E_FD_PARNIL) "Field parent is Nil." - MSG_FOR_URT_HR(VLDTR_E_FD_DUP) "Field has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_AS_MULTI) "Multiple Assembly records found." - MSG_FOR_URT_HR(VLDTR_E_AS_NAMENULL) "Assembly name is NULL." - MSG_FOR_URT_HR(VLDTR_E_SIG_TOKTYPEMISMATCH) "E_T_VALUETYPE or E_T_CLASS." - MSG_FOR_URT_HR(VLDTR_E_CL_TDINTF) "Class layout on an Interface." - MSG_FOR_URT_HR(VLDTR_E_ASOS_OSPLTFRMIDINVAL) "AssemblyOS platform ID invalid." - MSG_FOR_URT_HR(VLDTR_E_AR_NAMENULL) "AssemblyRef name is NULL." MSG_FOR_URT_HR(VLDTR_E_TD_ENCLNOTNESTED) "TypeDef not nested has encloser." - MSG_FOR_URT_HR(VLDTR_E_AROS_OSPLTFRMIDINVAL) "AssemblyRefOS has invalid platform ID." - MSG_FOR_URT_HR(VLDTR_E_FILE_NAMENULL) "File name is NULL." - MSG_FOR_URT_HR(VLDTR_E_CT_NAMENULL) "ExportedType name is NULL." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSCHILD) "TypeDef extends its own child." - MSG_FOR_URT_HR(VLDTR_E_MAR_NAMENULL) "ManifestResource name is NULL." - MSG_FOR_URT_HR(VLDTR_E_FILE_DUP) "File has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_FILE_NAMEFULLQLFD) "File name is fully qualified." - MSG_FOR_URT_HR(VLDTR_E_CT_DUP) "ExportedType has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MAR_DUP) "ManifestResource has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_MAR_NOTPUBPRIV) "ManifestResource is neither Public nor Private." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOVALUE) "Enum has no value__ field." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALSTATIC) "Enum's value__ field is static." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALNOTSN) "Enum's value__ field is not SpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDNOTST) "Enum's field is not static." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDNOTLIT) "Enum's field is not literal." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOLITFLDS) "Enum has no literal fields." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDSIGMISMATCH) "Enum's field signature does not match value__ signature." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMVALNOT1ST) "Enum's value__ field is not first." - MSG_FOR_URT_HR(VLDTR_E_FD_NOTVALUERTSN) "Field is RTSpecialName but name is not value__." - MSG_FOR_URT_HR(VLDTR_E_FD_VALUEPARNOTENUM) "Field value__ in not Enum class." - MSG_FOR_URT_HR(VLDTR_E_FD_INSTINIFACE) "Instance field in interface." - MSG_FOR_URT_HR(VLDTR_E_FD_NOTPUBINIFACE) "Non-public field in interface." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALNOTPUBPRIVSC) "Global field or method is neither Public nor PrivateScope." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALNOTSTATIC) "Global field or method is not static." - MSG_FOR_URT_HR(VLDTR_E_FD_GLOBALNORVA) "Global field has no RVA." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORZERORVA) ".ctor or .cctor has zero RVA." - MSG_FOR_URT_HR(VLDTR_E_FD_MARKEDNOMARSHAL) "Field is marked marshaled but has no marshaling record." - MSG_FOR_URT_HR(VLDTR_E_FD_MARSHALNOTMARKED) "Field has marshaling record but is not marked marshaled." - MSG_FOR_URT_HR(VLDTR_E_FD_MARKEDNODEFLT) "Field is marked HasDefault but has no const value." - MSG_FOR_URT_HR(VLDTR_E_FD_DEFLTNOTMARKED) "Field has const value record but is not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_FMD_MARKEDNOSECUR) "Field or method is marked HasSecurity but has no security record." - MSG_FOR_URT_HR(VLDTR_E_FMD_SECURNOTMARKED) "Field or method has security record but is not marked HasSecurity." MSG_FOR_URT_HR(VLDTR_E_FMD_PINVOKENOTSTATIC) "Field or method is PInvoke but is not marked Static." - MSG_FOR_URT_HR(VLDTR_E_FMD_MARKEDNOPINVOKE) "Field or method is marked PInvoke but has no ImplMap." - MSG_FOR_URT_HR(VLDTR_E_FMD_PINVOKENOTMARKED) "Field or method has ImplMap but is not marked PInvoke." - MSG_FOR_URT_HR(VLDTR_E_FMD_BADIMPLMAP) "Field or method has invalid ImplMap." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADMODREF) "ImplMap has invalid ModuleRef." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADMEMBER) "ImplMap has invalid MemberForwarded." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADIMPORTNAME) "ImplMap has invalid ImportName." - MSG_FOR_URT_HR(VLDTR_E_IMAP_BADCALLCONV) "ImplMap has invalid call conv." - MSG_FOR_URT_HR(VLDTR_E_FMD_BADACCESSFLAG) "Field or method has invalid access flag." - MSG_FOR_URT_HR(VLDTR_E_FD_INITONLYANDLITERAL) "Field is InitOnly and Literal." - MSG_FOR_URT_HR(VLDTR_E_FD_LITERALNOTSTATIC) "Field is Literal but not Static." - MSG_FOR_URT_HR(VLDTR_E_FMD_RTSNNOTSN) "Field or method is RTSpec.Name but not Spec.Name." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTPARNOTABST) "Method is abstract, parent is not." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTSTATABSTININTF) "Method not static or abstract in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTPUBININTF) "Method not public in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORININTF) ".ctor in interface." - MSG_FOR_URT_HR(VLDTR_E_MD_GLOBALCTORCCTOR) "global .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORSTATIC) "static .ctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORNOTSNRTSN) ".ctor or .cctor not marked SpecialName or RTSpecialName." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORVIRT) "virtual .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORABST) "abstract .ctor or .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORNOTSTATIC) "instance .cctor." - MSG_FOR_URT_HR(VLDTR_E_MD_ZERORVA) "RVA set to zero, but method not abstract or pinvoke or runtime, or reverse." - MSG_FOR_URT_HR(VLDTR_E_MD_FINNOTVIRT) "Method is final and not virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_STATANDFINORVIRT) "Method is static and final or virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDFINAL) "Method is abstract and final." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDIMPL) "Method is abstract and implemented." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTANDPINVOKE) "Method is abstract and pinvoke." - MSG_FOR_URT_HR(VLDTR_E_MD_ABSTNOTVIRT) "Method is abstract and not virtual." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTABSTNOTIMPL) "Method is not abstract and not implemented." - MSG_FOR_URT_HR(VLDTR_E_MD_NOTABSTBADFLAGSRVA) "Method is not abstract and not (non-zero RVA or PInvoke or runtime)." - MSG_FOR_URT_HR(VLDTR_E_MD_PRIVSCOPENORVA) "Method is PrivateScope and has RVA set to zero." - MSG_FOR_URT_HR(VLDTR_E_MD_GLOBALABSTORVIRT) "Global method is abstract or virtual." - MSG_FOR_URT_HR(VLDTR_E_SIG_LONGFORM) "Signature uses long form." - MSG_FOR_URT_HR(VLDTR_E_MD_MULTIPLESEMANTICS) "Method has multiple semantics (warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_INVALIDSEMANTICS) "Method has invalid semantics (not event or property.)" - MSG_FOR_URT_HR(VLDTR_E_MD_SEMANTICSNOTEXIST) "Method has semantics association that does not exist." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLNOTVIRT) "MethodImpl's Decl is not virtual." - MSG_FOR_URT_HR(VLDTR_E_FMD_GLOBALITEM) "Global field or method (warning, CLS)." - MSG_FOR_URT_HR(VLDTR_E_MD_MULTSEMANTICFLAGS) "Method has multiple semantic flags set." - MSG_FOR_URT_HR(VLDTR_E_MD_NOSEMANTICFLAGS) "Method has no semantic flags set." - MSG_FOR_URT_HR(VLDTR_E_FD_FLDINIFACE) "Field in Interface (warning, CLS)." - MSG_FOR_URT_HR(VLDTR_E_AS_HASHALGID) "Unrecognized Hash Alg ID (warning)." - MSG_FOR_URT_HR(VLDTR_E_AS_PROCID) "Unrecognized Processor ID in Assembly(warning)." - MSG_FOR_URT_HR(VLDTR_E_AR_PROCID) "Unrecognized Processor ID in AssemblyRef(warning)." - MSG_FOR_URT_HR(VLDTR_E_CN_PARENTRANGE) "Constant: parent token out of range." - MSG_FOR_URT_HR(VLDTR_E_AS_BADFLAGS) "Invalid flags in Assembly." - MSG_FOR_URT_HR(VLDTR_E_TR_HASTYPEDEF) "There is TypeDef with same name as TypeRef (warning)." - MSG_FOR_URT_HR(VLDTR_E_IFACE_BADIMPL) "In InterfaceImpl, the implementing token is not TypeDef." - MSG_FOR_URT_HR(VLDTR_E_IFACE_BADIFACE) "In InterfaceImpl, the implemented token is not TypeDef or TypeRef." - MSG_FOR_URT_HR(VLDTR_E_TD_SECURNOTMARKED) "TypeDef has security record but it is not marked HasSecurity." - MSG_FOR_URT_HR(VLDTR_E_TD_MARKEDNOSECUR) "TypeDef marked HasSecurity but has no security record." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORHASARGS) ".cctor has arguments." - MSG_FOR_URT_HR(VLDTR_E_CT_BADIMPL) "ExportedType has invalid Implementation." - MSG_FOR_URT_HR(VLDTR_E_MI_ALIENBODY) "MethodImpl has body from other class." - MSG_FOR_URT_HR(VLDTR_E_MD_CCTORCALLCONV) ".cctor has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MI_BADCLASS) "MethodImpl has invalid Class token." - MSG_FOR_URT_HR(VLDTR_E_MI_CLASSISINTF) "MethodImpl declared in Interface." - MSG_FOR_URT_HR(VLDTR_E_MI_BADDECL) "MethodImpl has invalid MethodDeclaration token." - MSG_FOR_URT_HR(VLDTR_E_MI_BADBODY) "MethodImpl has invalid MethodBody token." - MSG_FOR_URT_HR(VLDTR_E_MI_DUP) "MethodImpl has duplicate." - MSG_FOR_URT_HR(VLDTR_E_FD_BADPARENT) "Bad field parent." - MSG_FOR_URT_HR(VLDTR_E_MD_PARAMOUTOFSEQ) "Parameter out of sequence (warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_PARASEQTOOBIG) "Parameter's sequence number exceeds number of arguments." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARKEDNOMARSHAL) "Parameter marked HasMarshal, has no marshaling info." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARSHALNOTMARKED) "Parameter has marshaling info, not marked HasMarshal." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMMARKEDNODEFLT) "Parameter marked HasDefault, has no const value." - MSG_FOR_URT_HR(VLDTR_E_MD_PARMDEFLTNOTMARKED) "Parameter has const value, not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_PR_BADSCOPE) "Property has invalid scope." - MSG_FOR_URT_HR(VLDTR_E_PR_NONAME) "Property has no name." - MSG_FOR_URT_HR(VLDTR_E_PR_NOSIG) "Property has no signature." - MSG_FOR_URT_HR(VLDTR_E_PR_DUP) "Property has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_PR_BADCALLINGCONV) "Property has bad calling convention." - MSG_FOR_URT_HR(VLDTR_E_PR_MARKEDNODEFLT) "Property marked HasDefault, has no const value." - MSG_FOR_URT_HR(VLDTR_E_PR_DEFLTNOTMARKED) "Property has const value, not marked HasDefault." - MSG_FOR_URT_HR(VLDTR_E_PR_BADSEMANTICS) "Property has method that is neither a Setter nor a Getter." - MSG_FOR_URT_HR(VLDTR_E_PR_BADMETHOD) "Property has method with invalid token." - MSG_FOR_URT_HR(VLDTR_E_PR_ALIENMETHOD) "Property has method from another class." - MSG_FOR_URT_HR(VLDTR_E_CN_BLOBNOTNULL) "Const has non-null blob when it should not." - MSG_FOR_URT_HR(VLDTR_E_CN_BLOBNULL) "Const has null value blob." - MSG_FOR_URT_HR(VLDTR_E_EV_BADSCOPE) "Event has invalid scope." - MSG_FOR_URT_HR(VLDTR_E_EV_NONAME) "Event has no name." - MSG_FOR_URT_HR(VLDTR_E_EV_DUP) "Event has a duplicate." - MSG_FOR_URT_HR(VLDTR_E_EV_BADEVTYPE) "Event has invalid EventType." - MSG_FOR_URT_HR(VLDTR_E_EV_EVTYPENOTCLASS) "Event's EventType is not a class." - MSG_FOR_URT_HR(VLDTR_E_EV_BADSEMANTICS) "Event has method not (AddOn,RemoveOn,Fire,Other)." - MSG_FOR_URT_HR(VLDTR_E_EV_BADMETHOD) "Event has method with invalid token." - MSG_FOR_URT_HR(VLDTR_E_EV_ALIENMETHOD) "Event has method from another class." - MSG_FOR_URT_HR(VLDTR_E_EV_NOADDON) "Event has no AddOn method." - MSG_FOR_URT_HR(VLDTR_E_EV_NOREMOVEON) "Event has no RemoveOn method." - MSG_FOR_URT_HR(VLDTR_E_CT_DUPTDNAME) "ExportedType has same name as TypeDef." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADOFFSET) "MRes refers to non-PE file with non-zero offset." - MSG_FOR_URT_HR(VLDTR_E_DS_BADOWNER) "Declarative security has invalid owner token." - MSG_FOR_URT_HR(VLDTR_E_DS_BADFLAGS) "Declarative security has invalid action flags." - MSG_FOR_URT_HR(VLDTR_E_DS_NOBLOB) "Declarative security has no permission blob." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADIMPL) "Manifest resource has invalid Implementation." - MSG_FOR_URT_HR(VLDTR_E_MR_VARARGCALLINGCONV) "MemberRef has VARARG calling conv. (CLS warning)." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORNOTVOID) ".ctor or .cctor returns something other than void." - MSG_FOR_URT_HR(VLDTR_E_EV_FIRENOTVOID) "Fire method returns something other than void." - MSG_FOR_URT_HR(VLDTR_E_AS_BADLOCALE) "Invalid locale." - MSG_FOR_URT_HR(VLDTR_E_CN_PARENTTYPE) "Constant has parent of invalid type." MSG_FOR_URT_HR(VLDTR_E_SIG_SENTINMETHODDEF) "E_T_SENTINEL in MethodDef signature." MSG_FOR_URT_HR(VLDTR_E_SIG_SENTMUSTVARARG) "E_T_SENTINEL <=> VARARG." MSG_FOR_URT_HR(VLDTR_E_SIG_MULTSENTINELS) "Multiple E_T_SENTINELs." - MSG_FOR_URT_HR(VLDTR_E_SIG_LASTSENTINEL) "E_T_SENTINEL not followed by type." MSG_FOR_URT_HR(VLDTR_E_SIG_MISSARG) "Signature missing argument." MSG_FOR_URT_HR(VLDTR_E_SIG_BYREFINFIELD) "Field of ByRef type." - MSG_FOR_URT_HR(VLDTR_E_MD_SYNCMETHODINVTYPE) "Synchronized method in value class." - MSG_FOR_URT_HR(VLDTR_E_TD_NAMETOOLONG) "TypeDef name too long." - MSG_FOR_URT_HR(VLDTR_E_AS_PROCDUP) "Duplicate Assembly Processor." - MSG_FOR_URT_HR(VLDTR_E_ASOS_DUP) "Duplicate Assembly OS (ID+ver.major+ver.minor)." - MSG_FOR_URT_HR(VLDTR_E_MAR_BADFLAGS) "Manifest Resource has bad flags." - MSG_FOR_URT_HR(VLDTR_E_CT_NOTYPEDEFID) "ExportedType has nil TypeDefId." - MSG_FOR_URT_HR(VLDTR_E_FILE_BADFLAGS) "File has bad flags." - MSG_FOR_URT_HR(VLDTR_E_FILE_NULLHASH) "File has no hash blob." - MSG_FOR_URT_HR(VLDTR_E_MOD_NONAME) "Module has no name." - MSG_FOR_URT_HR(VLDTR_E_MOD_NAMEFULLQLFD) "Module has fully-qualified name." - MSG_FOR_URT_HR(VLDTR_E_TD_RTSPCLNOTSPCL) "TypeDef is tdRTSpecialName but not tdSpecialName." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSIFACE) "TypeDef extends interface." - MSG_FOR_URT_HR(VLDTR_E_MD_CTORPINVOKE) ".ctor or .cctor is PInvokeImpl." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSENUMNOTCLASS) "System.Enum is not a class." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSENUMNOTEXTVTYPE) "System.Enum extends not System.ValueType." - MSG_FOR_URT_HR(VLDTR_E_MI_SIGMISMATCH) "MethodImpl's Decl and Body signatures mismatch." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASMETHODS) "TypeDef extends System.Enum but has methods." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMIMPLIFACE) "TypeDef extends System.Enum but implements an interface." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASPROP) "TypeDef extends System.Enum but has a property." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMHASEVENT) "TypeDef extends System.Enum but has an event." - MSG_FOR_URT_HR(VLDTR_E_TD_BADMETHODLST) "TypeDef has MethodList > Nmethods+1." - MSG_FOR_URT_HR(VLDTR_E_TD_BADFIELDLST) "TypeDef has FieldList > Nfields+1." - MSG_FOR_URT_HR(VLDTR_E_CN_BADTYPE) "Constant has wrong type." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMNOINSTFLD) "Enum has no instance fields." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMMULINSTFLD) "Enum has multiple instance fields." - MSG_FOR_URT_HR(VLDTR_E_INTERRUPTED) "Validator has been interrupted by the VEHandler." - MSG_FOR_URT_HR(VLDTR_E_NOTINIT) "Validator failed to initialize correctly." MSG_FOR_URT_HR(CORDBG_E_UNRECOVERABLE_ERROR) "Unrecoverable API error." MSG_FOR_URT_HR(CORDBG_E_PROCESS_TERMINATED) "Process was terminated." MSG_FOR_URT_HR(CORDBG_E_PROCESS_NOT_SYNCHRONIZED) "Process not synchronized." @@ -457,7 +111,6 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_BAD_REFERENCE_VALUE) "A reference value was found to be bad during dereferencing." MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_AVAILABLE) "A field in a class is not available, because the runtime optimized it away." MSG_FOR_URT_HR(CORDBG_E_NON_NATIVE_FRAME) "'Native-frame-only' operation on non-native frame." - MSG_FOR_URT_HR(CORDBG_E_NONCONTINUABLE_EXCEPTION) "Cannot Continue on non-continuable exception." MSG_FOR_URT_HR(CORDBG_E_CODE_NOT_AVAILABLE) "The code is currently unavailable." MSG_FOR_URT_HR(CORDBG_E_FUNCTION_NOT_IL) "Attempt to get a ICorDebugFunction for a function that is not IL." MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_INTO_FINALLY) "SetIP is not possible because SetIP would move EIP from outside of an exception handling finally clause to a point inside of one." @@ -468,16 +121,11 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_FUNC_EVAL_BAD_START_POINT) "Func eval cannot work. Bad starting point." MSG_FOR_URT_HR(CORDBG_E_INVALID_OBJECT) "This object value is no longer valid." MSG_FOR_URT_HR(CORDBG_E_FUNC_EVAL_NOT_COMPLETE) "CordbEval::GetResult called before func eval has finished." - MSG_FOR_URT_HR(CORDBG_E_INPROC_NOT_IMPL) "The in-process version of the debugging API does not support this function." MSG_FOR_URT_HR(CORDBG_E_STATIC_VAR_NOT_AVAILABLE) "A static variable is not available because it has not been initialized yet." - MSG_FOR_URT_HR(CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS) "Cannot copy a VC with object refs in it." MSG_FOR_URT_HR(CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER) "SetIP cannot leave or enter a filter." MSG_FOR_URT_HR(CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE) "JIT settings for ZAP modules cannot be changed." MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64) "SetIP is not possible because it would move EIP from within a finally clause to a point outside of one on WIN64 platforms." MSG_FOR_URT_HR(CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64) "SetIP is not possible because it would move EIP from within a catch clause to a point outside of one on WIN64 platforms." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_CONN_RESET) "The remote device closed the connection." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE) "The connection was closed due to a keep-alive failure." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR) "Generic error that the device connection has been broken with no chance for recovery." MSG_FOR_URT_HR(CORDBG_E_CANT_SET_TO_JMC) "Cannot use JMC on this code (likely wrong JIT settings)." MSG_FOR_URT_HR(CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME) "Internal frame markers have no associated context." MSG_FOR_URT_HR(CORDBG_E_NOT_CHILD_FRAME) "The current frame is not a child frame." @@ -488,32 +136,21 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_DEBUGGER_ALREADY_ATTACHED) "This process has already been attached." MSG_FOR_URT_HR(CORDBG_E_SUPERFLOUS_CONTINUE) "Returned from a call to Continue that was not matched with a stopping event." MSG_FOR_URT_HR(CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME) "Cannot perfrom SetValue on non-leaf frames." - MSG_FOR_URT_HR(CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE) "When doing Edit and Continue, some JITs do not allow increasing the maximum level to which exception handling can be nested." MSG_FOR_URT_HR(CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED) "Tried to do Edit and Continue on a module that was not started in Edit and Continue mode." MSG_FOR_URT_HR(CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION) "SetIP cannot be done on any exception." MSG_FOR_URT_HR(CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL) "The 'variable' does not exist because it is a literal optimized away by the compiler." MSG_FOR_URT_HR(CORDBG_E_PROCESS_DETACHED) "Process has been detached." - MSG_FOR_URT_HR(CORDBG_E_ENC_METHOD_SIG_CHANGED) "Not allowed to change the signature of an existing method." - MSG_FOR_URT_HR(CORDBG_E_ENC_METHOD_NO_LOCAL_SIG) "Cannot get the local signature for the method." MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS) "Adding a field to a value or layout class is prohibited." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_CHANGE_FIELD) "Cannot change field after adding." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER) "Only support addition of private members." MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_STATIC) "GetStaticFieldValue called on a non-static field." MSG_FOR_URT_HR(CORDBG_E_FIELD_NOT_INSTANCE) "Returned if someone tries to call GetStaticFieldValue on a non-instance field." - MSG_FOR_URT_HR(CORDBG_E_ENC_ZAPPED_WITHOUT_ENC) "If a zap file was created without the Edit and Continue flag set, then we cannot do Edit and Continue on it, no matter what." - MSG_FOR_URT_HR(CORDBG_E_ENC_BAD_METHOD_INFO) "Lacking information about method." MSG_FOR_URT_HR(CORDBG_E_ENC_JIT_CANT_UPDATE) "The JIT is unable to update the method." - MSG_FOR_URT_HR(CORDBG_E_ENC_MISSING_CLASS) "An internal structure about the class is missing." MSG_FOR_URT_HR(CORDBG_E_ENC_INTERNAL_ERROR) "Internal Runtime Error while doing Edit-and-Continue." MSG_FOR_URT_HR(CORDBG_E_ENC_HANGING_FIELD) "The field was added via Edit and Continue after the class was loaded." MSG_FOR_URT_HR(CORDBG_E_MODULE_NOT_LOADED) "Module not loaded." - MSG_FOR_URT_HR(CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS) "Not allowed to change base class." MSG_FOR_URT_HR(CORDBG_E_UNABLE_TO_SET_BREAKPOINT) "Cannot set a breakpoint here." MSG_FOR_URT_HR(CORDBG_E_DEBUGGING_NOT_POSSIBLE) "Debugging is not possible due to an incompatibility within the CLR implementation." MSG_FOR_URT_HR(CORDBG_E_KERNEL_DEBUGGER_ENABLED) "A kernel debugger is enabled on the system. User-mode debugging will trap to the kernel debugger." MSG_FOR_URT_HR(CORDBG_E_KERNEL_DEBUGGER_PRESENT) "A kernel debugger is present on the system. User-mode debugging will trap to the kernel debugger." - MSG_FOR_URT_HR(CORDBG_E_HELPER_THREAD_DEAD) "The debugger's internal helper thread is dead." - MSG_FOR_URT_HR(CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE) "Not allowed to change interface inheritance." MSG_FOR_URT_HR(CORDBG_E_INCOMPATIBLE_PROTOCOL) "The debugger's protocol is incompatible with the debuggee." MSG_FOR_URT_HR(CORDBG_E_TOO_MANY_PROCESSES) "The debugger can only handle a finite number of debuggees." MSG_FOR_URT_HR(CORDBG_E_INTEROP_NOT_SUPPORTED) "Interop debugging is not supported." @@ -521,88 +158,27 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_OBJECT_NEUTERED) "Object is in a zombie state." MSG_FOR_URT_HR(CORPROF_E_FUNCTION_NOT_COMPILED) "Function not yet compiled." MSG_FOR_URT_HR(CORPROF_E_DATAINCOMPLETE) "The ID is not fully loaded/defined yet." - MSG_FOR_URT_HR(CORPROF_E_NOT_REJITABLE_METHODS) "The Module is not configured for updateable methods." - MSG_FOR_URT_HR(CORPROF_E_CANNOT_UPDATE_METHOD) "The Method could not be updated for re-JIT." MSG_FOR_URT_HR(CORPROF_E_FUNCTION_NOT_IL) "The Method has no associated IL." MSG_FOR_URT_HR(CORPROF_E_NOT_MANAGED_THREAD) "The thread has never run managed code before." MSG_FOR_URT_HR(CORPROF_E_CALL_ONLY_FROM_INIT) "The function may only be called during profiler initialization." - MSG_FOR_URT_HR(CORPROF_E_INPROC_NOT_ENABLED) "In-process debugging must be enabled during initialization." - MSG_FOR_URT_HR(CORPROF_E_JITMAPS_NOT_ENABLED) "Cannot get a JIT map becuase they are not enabled." - MSG_FOR_URT_HR(CORPROF_E_INPROC_ALREADY_BEGUN) "BeginInprocDebugging already called." - MSG_FOR_URT_HR(CORPROF_E_INPROC_NOT_AVAILABLE) "In-process debugging not allowed at this point." MSG_FOR_URT_HR(CORPROF_E_NOT_YET_AVAILABLE) "Requested information is not yet available." MSG_FOR_URT_HR(CORPROF_E_TYPE_IS_PARAMETERIZED) "The given type is a generic and cannot be used with this method." MSG_FOR_URT_HR(CORPROF_E_FUNCTION_IS_PARAMETERIZED) "The given function is a generic and cannot be used with this method." - MSG_FOR_URT_HR(SECURITY_E_XML_TO_ASN_ENCODING) "Failed to convert XML to ASN." MSG_FOR_URT_HR(SECURITY_E_INCOMPATIBLE_SHARE) "Loading this assembly would produce a different grant set from other instances." MSG_FOR_URT_HR(SECURITY_E_UNVERIFIABLE) "Unverifiable code failed policy check." MSG_FOR_URT_HR(SECURITY_E_INCOMPATIBLE_EVIDENCE) "Assembly already loaded without additional security evidence." - MSG_FOR_URT_HR(CORSEC_E_DECODE_SET) "Failure decoding permission set." - MSG_FOR_URT_HR(CORSEC_E_ENCODE_SET) "Failure encoding permission set." - MSG_FOR_URT_HR(CORSEC_E_UNSUPPORTED_FORMAT) "Unrecognized encoding format." - MSG_FOR_URT_HR(CORSEC_E_CRYPTOAPI_CALL_FAILED) "StrongName APIs not supported on system." - MSG_FOR_URT_HR(CORSEC_E_NO_SUITABLE_CSP) "StrongName APIs could not locate a matching CSP." - MSG_FOR_URT_HR(CORSEC_E_INVALID_ATTR) "Invalid security custom attribute." MSG_FOR_URT_HR(CORSEC_E_POLICY_EXCEPTION) "PolicyException thrown." MSG_FOR_URT_HR(CORSEC_E_MIN_GRANT_FAIL) "Failed to grant minimum permission requests." MSG_FOR_URT_HR(CORSEC_E_NO_EXEC_PERM) "Failed to grant permission to execute." MSG_FOR_URT_HR(CORSEC_E_XMLSYNTAX) "XML Syntax error." MSG_FOR_URT_HR(CORSEC_E_INVALID_STRONGNAME) "Strong name validation failed." MSG_FOR_URT_HR(CORSEC_E_MISSING_STRONGNAME) "Assembly is not strong named." - MSG_FOR_URT_HR(CORSEC_E_CONTAINER_NOT_FOUND) "Strong name key container not found." MSG_FOR_URT_HR(CORSEC_E_INVALID_IMAGE_FORMAT) "Invalid assembly file format." MSG_FOR_URT_HR(CORSEC_E_INVALID_PUBLICKEY) "Invalid assembly public key." MSG_FOR_URT_HR(CORSEC_E_SIGNATURE_MISMATCH) "Signature size mismatch." - MSG_FOR_URT_HR(SN_E_PUBLICKEY_MISMATCH) "Public key of assembly did not match signing public key." - MSG_FOR_URT_HR(CORSEC_E_INVALID_SIGNATUREKEY) "Invalid signature public key specified in AssemblySignatureKeyAttribute." - MSG_FOR_URT_HR(CORSEC_E_INVALID_COUNTERSIGNATURE) "Invalid countersignature specified in AssemblySignatureKeyAttribute." MSG_FOR_URT_HR(CORSEC_E_CRYPTO) "Failure during Cryptographic operation." MSG_FOR_URT_HR(CORSEC_E_CRYPTO_UNEX_OPER) "Unexpected Cryptographic operation." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ATTRIBUTE) "Generic problem with a custom attribute." - MSG_FOR_URT_HR(CORSECATTR_E_MISSING_CONSTRUCTOR) "Missing a required constructor." - MSG_FOR_URT_HR(CORSECATTR_E_FAILED_TO_CREATE_PERM) "Unable to create a permission for this attribute." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION_ASM) "SecurityAction type invalid on assembly." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION_OTHER) "SecurityAction type invalid on types and methods." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_PARENT) "Security custom attribute attached to invalid parent." - MSG_FOR_URT_HR(CORSECATTR_E_TRUNCATED) "Bad custom attribute serialized blob." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_VERSION) "Bad custom attribute serialized blob version." MSG_FOR_URT_HR(CORSECATTR_E_BAD_ACTION) "Invalid security action code." - MSG_FOR_URT_HR(CORSECATTR_E_NO_SELF_REF) "CA reference to CA definition in same assembly." - MSG_FOR_URT_HR(CORSECATTR_E_BAD_NONCAS) "Use of non-CAS permission with invalid action." - MSG_FOR_URT_HR(CORSECATTR_E_ASSEMBLY_LOAD_FAILED) "Failed to load assembly containing CA (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX) "Failed to load assembly containing CA (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_TYPE_LOAD_FAILED) "Failed to load CA type (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_TYPE_LOAD_FAILED_EX) "Failed to load CA type (or required CA type)." - MSG_FOR_URT_HR(CORSECATTR_E_ABSTRACT) "CA type is abstract." - MSG_FOR_URT_HR(CORSECATTR_E_UNSUPPORTED_TYPE) "Security custom attributes do not support array or Type fields and properties." - MSG_FOR_URT_HR(CORSECATTR_E_UNSUPPORTED_ENUM_TYPE) "Unsupported base type for enum field or property." - MSG_FOR_URT_HR(CORSECATTR_E_NO_FIELD) "Could not find a CA field." - MSG_FOR_URT_HR(CORSECATTR_E_NO_PROPERTY) "Could not find a CA property." - MSG_FOR_URT_HR(CORSECATTR_E_EXCEPTION) "Unexpected exception." - MSG_FOR_URT_HR(CORSECATTR_E_EXCEPTION_HR) "Unexpected exception." - MSG_FOR_URT_HR(ISS_E_ISOSTORE) "IsolatedStorage operation failed." - MSG_FOR_URT_HR(ISS_E_OPEN_STORE_FILE) "Unable to open the store." - MSG_FOR_URT_HR(ISS_E_OPEN_FILE_MAPPING) "Unable to create store file mapping." - MSG_FOR_URT_HR(ISS_E_MAP_VIEW_OF_FILE) "Unable to map the store file." - MSG_FOR_URT_HR(ISS_E_GET_FILE_SIZE) "Unable to determine store file size." - MSG_FOR_URT_HR(ISS_E_CREATE_MUTEX) "Unable to create mutex." - MSG_FOR_URT_HR(ISS_E_LOCK_FAILED) "Unable to lock the store." - MSG_FOR_URT_HR(ISS_E_FILE_WRITE) "File Write failed." - MSG_FOR_URT_HR(ISS_E_SET_FILE_POINTER) "Cannot set file pointer." - MSG_FOR_URT_HR(ISS_E_CREATE_DIR) "Unable to create the store directory." - MSG_FOR_URT_HR(ISS_E_STORE_NOT_OPEN) "Store must be open for this operation." - MSG_FOR_URT_HR(ISS_E_CORRUPTED_STORE_FILE) "Store file is corrupt." - MSG_FOR_URT_HR(ISS_E_STORE_VERSION) "Store version is not supported." - MSG_FOR_URT_HR(ISS_E_FILE_NOT_MAPPED) "Store file is not mapped." - MSG_FOR_URT_HR(ISS_E_BLOCK_SIZE_TOO_SMALL) "Block size is too small." - MSG_FOR_URT_HR(ISS_E_ALLOC_TOO_LARGE) "Allocation size is too large." - MSG_FOR_URT_HR(ISS_E_USAGE_WILL_EXCEED_QUOTA) "Allowed quota is fully used." - MSG_FOR_URT_HR(ISS_E_TABLE_ROW_NOT_FOUND) "Row not found." - MSG_FOR_URT_HR(ISS_E_DEPRECATE) "Unable to deprecate old store." - MSG_FOR_URT_HR(ISS_E_CALLER) "Unable to determine the caller." - MSG_FOR_URT_HR(ISS_E_PATH_LENGTH) "Path length is too long." - MSG_FOR_URT_HR(ISS_E_MACHINE) "Machine Store is not supported." - MSG_FOR_URT_HR(ISS_E_MACHINE_DACL) "The DACL for the machine store is incorrect or could not be created." MSG_FOR_URT_HR(COR_E_EXCEPTION) "General Exception" MSG_FOR_URT_HR(COR_E_SYSTEM) "System.Exception" MSG_FOR_URT_HR(COR_E_ARGUMENTOUTOFRANGE) "An argument was out of its legal range." @@ -614,11 +190,8 @@ BEGIN MSG_FOR_URT_HR(COR_E_INDEXOUTOFRANGE) "Array subscript out of range." MSG_FOR_URT_HR(COR_E_INVALIDOPERATION) "An operation is not legal in the current state." MSG_FOR_URT_HR(COR_E_SECURITY) "An error relating to security occurred." - MSG_FOR_URT_HR(COR_E_REMOTING) "An error relating to remoting occurred." MSG_FOR_URT_HR(COR_E_SERIALIZATION) "An error relating to serialization occurred." MSG_FOR_URT_HR(COR_E_VERIFICATION) "A verification failure has occurred." - MSG_FOR_URT_HR(COR_E_SERVER) "An error relating to remoting occurred." - MSG_FOR_URT_HR(COR_E_SERVICEDCOMPONENT) "An error relating to ServicedComponent occurred." MSG_FOR_URT_HR(COR_E_METHODACCESS) "Access to this method is denied." MSG_FOR_URT_HR(COR_E_MISSINGFIELD) "Field does not exist." MSG_FOR_URT_HR(COR_E_MISSINGMEMBER) "Member does not exist." @@ -653,12 +226,10 @@ BEGIN MSG_FOR_URT_HR(COR_E_PLATFORMNOTSUPPORTED) "Operation is not supported on this platform." MSG_FOR_URT_HR(COR_E_INVALIDPROGRAM) "Invalid IL or CLR metadata." MSG_FOR_URT_HR(COR_E_OPERATIONCANCELED) "The operation was cancelled." - MSG_FOR_URT_HR(COR_E_DEVICESNOTSUPPORTED) "Devices not supported." MSG_FOR_URT_HR(COR_E_DATAMISALIGNED) "A datatype misalignment was detected in a load or store instruction." MSG_FOR_URT_HR(COR_E_CODECONTRACTFAILED) "A managed code contract (ie, precondition, postcondition, invariant, or assert) failed." MSG_FOR_URT_HR(COR_E_TYPEACCESS) "Access to this type is denied." MSG_FOR_URT_HR(COR_E_ACCESSING_CCW) "Fail to access a CCW because the corresponding managed object is already collected." - MSG_FOR_URT_HR(COR_E_MAXMETHODSIZE) "A method in this assembly is greater than the maximum allowed method size." MSG_FOR_URT_HR(COR_E_KEYNOTFOUND) "The given key was not present in the dictionary." MSG_FOR_URT_HR(COR_E_INSUFFICIENTEXECUTIONSTACK) "Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space." MSG_FOR_URT_HR(COR_E_APPLICATION) "Application exception" @@ -674,305 +245,15 @@ BEGIN MSG_FOR_URT_HR(COR_E_HOSTPROTECTION) "The host has forbidden this operation." MSG_FOR_URT_HR(COR_E_ILLEGAL_REENTRANCY) "Attempted to call into managed code when executing inside a low level extensibility point." MSG_FOR_URT_HR(CLR_E_SHIM_RUNTIMELOAD) "Failed to load the runtime." - MSG_FOR_URT_HR(CLR_E_SHIM_RUNTIMEEXPORT) "Failed to find a required export in the runtime." - MSG_FOR_URT_HR(CLR_E_SHIM_INSTALLROOT) "Install root is not defined." - MSG_FOR_URT_HR(CLR_E_SHIM_INSTALLCOMP) "Expected component of the runtime is not available." MSG_FOR_URT_HR(CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND) "A runtime has already been bound for legacy activation policy use." - MSG_FOR_URT_HR(CLR_E_SHIM_SHUTDOWNINPROGRESS) "The operation is invalid because the process may be shutting down." - MSG_FOR_URT_HR(VER_E_UNKNOWN_OPCODE) "Unknown opcode." - MSG_FOR_URT_HR(VER_E_SIG_CALLCONV) "Unknown calling convention." - MSG_FOR_URT_HR(VER_E_SIG_ELEMTYPE) "Unknown ELEMENT_TYPE." - MSG_FOR_URT_HR(VER_E_RET_SIG) "[return sig]" MSG_FOR_URT_HR(VER_E_FIELD_SIG) "[field sig]" - MSG_FOR_URT_HR(VER_E_OPEN_DLGT_PROT_ACC) "Protected method access through an open instance delegate is not verifiable." - MSG_FOR_URT_HR(VER_E_INTERNAL) "Internal error." - MSG_FOR_URT_HR(VER_E_STACK_TOO_LARGE) "Stack is too large." - MSG_FOR_URT_HR(VER_E_ARRAY_NAME_LONG) "Array name is too long." - MSG_FOR_URT_HR(VER_E_FALLTHRU) "fall through end of the method without returning" - MSG_FOR_URT_HR(VER_E_TRY_GTEQ_END) "try start >= try end" - MSG_FOR_URT_HR(VER_E_TRYEND_GT_CS) "try end > code size" - MSG_FOR_URT_HR(VER_E_HND_GTEQ_END) "handler start >= handler end" - MSG_FOR_URT_HR(VER_E_HNDEND_GT_CS) "handler end > code size" - MSG_FOR_URT_HR(VER_E_TRY_START) "Try starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_HND_START) "Handler starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_TRY_OVERLAP) "Try block overlap with another block." - MSG_FOR_URT_HR(VER_E_TRY_EQ_HND_FIL) "Try and filter/handler blocks are equivalent." - MSG_FOR_URT_HR(VER_E_TRY_SHARE_FIN_FAL) "Shared try has finally or fault handler." - MSG_FOR_URT_HR(VER_E_HND_OVERLAP) "Handler block overlaps with another block." - MSG_FOR_URT_HR(VER_E_HND_EQ) "Handler block is the same as another block." - MSG_FOR_URT_HR(VER_E_FIL_OVERLAP) "Filter block overlaps with another block." - MSG_FOR_URT_HR(VER_E_FIL_EQ) "Filter block is the same as another block." - MSG_FOR_URT_HR(VER_E_FIL_CONT_TRY) "Filter contains try." - MSG_FOR_URT_HR(VER_E_FIL_CONT_HND) "Filter contains handler." - MSG_FOR_URT_HR(VER_E_FIL_CONT_FIL) "Nested filters." - MSG_FOR_URT_HR(VER_E_FIL_GTEQ_CS) "filter >= code size" - MSG_FOR_URT_HR(VER_E_FIL_START) "Filter starts in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_FALLTHRU_EXCEP) "fallthru the end of an exception block" - MSG_FOR_URT_HR(VER_E_FALLTHRU_INTO_HND) "fallthru into an exception handler" - MSG_FOR_URT_HR(VER_E_FALLTHRU_INTO_FIL) "fallthru into an exception filter" - MSG_FOR_URT_HR(VER_E_LEAVE) "Leave from outside a try or catch block." - MSG_FOR_URT_HR(VER_E_RETHROW) "Rethrow from outside a catch handler." - MSG_FOR_URT_HR(VER_E_ENDFINALLY) "Endfinally from outside a finally handler" - MSG_FOR_URT_HR(VER_E_ENDFILTER) "Endfilter from outside an exception filter block" - MSG_FOR_URT_HR(VER_E_ENDFILTER_MISSING) "Missing Endfilter." - MSG_FOR_URT_HR(VER_E_BR_INTO_TRY) "Branch into try block." - MSG_FOR_URT_HR(VER_E_BR_INTO_HND) "Branch into exception handler block." - MSG_FOR_URT_HR(VER_E_BR_INTO_FIL) "Branch into exception filter block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_TRY) "Branch out of try block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_HND) "Branch out of exception handler block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_FIL) "Branch out of exception filter block." - MSG_FOR_URT_HR(VER_E_BR_OUTOF_FIN) "Branch out of finally block." - MSG_FOR_URT_HR(VER_E_RET_FROM_TRY) "Return out of try block." - MSG_FOR_URT_HR(VER_E_RET_FROM_HND) "Return out of exception handler block." - MSG_FOR_URT_HR(VER_E_RET_FROM_FIL) "Return out of exception filter block." - MSG_FOR_URT_HR(VER_E_BAD_JMP_TARGET) "jmp / exception into the middle of an instruction." - MSG_FOR_URT_HR(VER_E_PATH_LOC) "Non-compatible types depending on path." - MSG_FOR_URT_HR(VER_E_PATH_THIS) "Init state for this differs depending on path." - MSG_FOR_URT_HR(VER_E_PATH_STACK) "Non-compatible types on stack depending on path." - MSG_FOR_URT_HR(VER_E_PATH_STACK_DEPTH) "Stack depth differs depending on path." - MSG_FOR_URT_HR(VER_E_THIS) "Instance variable (this) missing." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_EXCEP) "Uninitialized this on entering a try block." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_STORE) "Store into this when it is uninitialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_RET) "Return from .ctor when this is uninitialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_V_RET) "Return from .ctor before all fields are initialized." - MSG_FOR_URT_HR(VER_E_THIS_UNINIT_BR) "Branch back when this is uninitialized." - MSG_FOR_URT_HR(VER_E_LDFTN_CTOR) "ldftn and ldvirtftn not allowed on .ctor." - MSG_FOR_URT_HR(VER_E_STACK_NOT_EQ) "Non-compatible types on the stack." - MSG_FOR_URT_HR(VER_E_STACK_UNEXPECTED) "Unexpected type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_EXCEPTION) "Missing stack slot for exception." - MSG_FOR_URT_HR(VER_E_STACK_OVERFLOW) "Stack overflow." - MSG_FOR_URT_HR(VER_E_STACK_UNDERFLOW) "Stack underflow." - MSG_FOR_URT_HR(VER_E_STACK_EMPTY) "Stack empty." - MSG_FOR_URT_HR(VER_E_STACK_UNINIT) "Uninitialized item on stack." - MSG_FOR_URT_HR(VER_E_STACK_I_I4_I8) "Expected I, I4, or I8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_R_R4_R8) "Expected R, R4, or R8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NO_R_I8) "unexpected R, R4, R8, or I8 on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NUMERIC) "Expected numeric type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_OBJREF) "Expected an ObjRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_P_OBJREF) "Expected address of an ObjRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_BYREF) "Expected ByRef on the stack." - MSG_FOR_URT_HR(VER_E_STACK_METHOD) "Expected pointer to function on the stack." - MSG_FOR_URT_HR(VER_E_STACK_ARRAY_SD) "Expected single dimension array on the stack." - MSG_FOR_URT_HR(VER_E_STACK_VALCLASS) "Expected value type instance on the stack." - MSG_FOR_URT_HR(VER_E_STACK_P_VALCLASS) "Expected address of value type on the stack." - MSG_FOR_URT_HR(VER_E_STACK_NO_VALCLASS) "Unexpected value type instance on the stack." - MSG_FOR_URT_HR(VER_E_LOC_DEAD) "Local variable is unusable at this point." - MSG_FOR_URT_HR(VER_E_LOC_NUM) "Unrecognized local variable number." - MSG_FOR_URT_HR(VER_E_ARG_NUM) "Unrecognized argument number." - MSG_FOR_URT_HR(VER_E_TOKEN_RESOLVE) "Unable to resolve token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE) "Unable to resolve type of the token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_MEMBER) "Expected memberRef, memberDef or methodSpec token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_FIELD) "Expected memberRef or fieldDef token." - MSG_FOR_URT_HR(VER_E_TOKEN_TYPE_SIG) "Expected signature token." - MSG_FOR_URT_HR(VER_E_UNVERIFIABLE) "Instruction cannot be verified." - MSG_FOR_URT_HR(VER_E_LDSTR_OPERAND) "Operand does not point to a valid string ref." - MSG_FOR_URT_HR(VER_E_RET_PTR_TO_STACK) "Return type is ByRef, TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_RET_VOID) "Stack must be empty on return from a void function." - MSG_FOR_URT_HR(VER_E_RET_MISSING) "Return value missing on the stack." - MSG_FOR_URT_HR(VER_E_RET_EMPTY) "Stack must contain only the return value." - MSG_FOR_URT_HR(VER_E_RET_UNINIT) "Return uninitialized data." - MSG_FOR_URT_HR(VER_E_ARRAY_ACCESS) "Illegal array access." - MSG_FOR_URT_HR(VER_E_ARRAY_V_STORE) "Store non Object type into Object array." - MSG_FOR_URT_HR(VER_E_ARRAY_SD) "Expected single dimension array." - MSG_FOR_URT_HR(VER_E_ARRAY_SD_PTR) "Expected single dimension array of pointer types." - MSG_FOR_URT_HR(VER_E_ARRAY_FIELD) "Array field access is denied." - MSG_FOR_URT_HR(VER_E_ARGLIST) "Allowed only in vararg methods." - MSG_FOR_URT_HR(VER_E_VALCLASS) "Value type expected." - MSG_FOR_URT_HR(VER_E_METHOD_ACCESS) "Method is not visible." - MSG_FOR_URT_HR(VER_E_FIELD_ACCESS) "Field is not visible." - MSG_FOR_URT_HR(VER_E_DEAD) "Item is unusable at this point." - MSG_FOR_URT_HR(VER_E_FIELD_STATIC) "Expected static field." - MSG_FOR_URT_HR(VER_E_FIELD_NO_STATIC) "Expected non-static field." - MSG_FOR_URT_HR(VER_E_ADDR) "Address of not allowed for this item." - MSG_FOR_URT_HR(VER_E_ADDR_BYREF) "Address of not allowed for ByRef." - MSG_FOR_URT_HR(VER_E_ADDR_LITERAL) "Address of not allowed for literal field." - MSG_FOR_URT_HR(VER_E_INITONLY) "Cannot change initonly field outside its .ctor." - MSG_FOR_URT_HR(VER_E_THROW) "Cannot throw this object." - MSG_FOR_URT_HR(VER_E_CALLVIRT_VALCLASS) "Callvirt on a value type method." - MSG_FOR_URT_HR(VER_E_CALL_SIG) "Call signature mismatch." - MSG_FOR_URT_HR(VER_E_CALL_STATIC) "Static function expected." - MSG_FOR_URT_HR(VER_E_CTOR) ".ctor expected." - MSG_FOR_URT_HR(VER_E_CTOR_VIRT) "Cannot use callvirt on .ctor." - MSG_FOR_URT_HR(VER_E_CTOR_OR_SUPER) "Only super::ctor or typeof(this)::ctor allowed here." - MSG_FOR_URT_HR(VER_E_CTOR_MUL_INIT) "Possible call to .ctor more than once." - MSG_FOR_URT_HR(VER_E_SIG) "Unrecognized signature." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY) "Cannot resolve Array type." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_PTR) "Array of ELEMENT_TYPE_PTR." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_BYREF) "Array of ELEMENT_TYPE_BYREF or ELEMENT_TYPE_TYPEDBYREF." - MSG_FOR_URT_HR(VER_E_SIG_ELEM_PTR) "ELEMENT_TYPE_PTR cannot be verified." - MSG_FOR_URT_HR(VER_E_SIG_VARARG) "Unexpected vararg." - MSG_FOR_URT_HR(VER_E_SIG_VOID) "Unexpected Void." - MSG_FOR_URT_HR(VER_E_SIG_BYREF_BYREF) "ByRef of ByRef" - MSG_FOR_URT_HR(VER_E_CODE_SIZE_ZERO) "Code size is zero." - MSG_FOR_URT_HR(VER_E_BAD_VARARG) "Unrecognized use of vararg." - MSG_FOR_URT_HR(VER_E_TAIL_CALL) "Missing call, callvirt or calli." - MSG_FOR_URT_HR(VER_E_TAIL_BYREF) "Cannot pass ByRef to a tail call." - MSG_FOR_URT_HR(VER_E_TAIL_RET) "Missing ret." - MSG_FOR_URT_HR(VER_E_TAIL_RET_VOID) "Void ret type expected for tail call." - MSG_FOR_URT_HR(VER_E_TAIL_RET_TYPE) "Tail call return type not compatible." - MSG_FOR_URT_HR(VER_E_TAIL_STACK_EMPTY) "Stack not empty after tail call." - MSG_FOR_URT_HR(VER_E_METHOD_END) "Method ends in the middle of an instruction." - MSG_FOR_URT_HR(VER_E_BAD_BRANCH) "Branch out of the method." - MSG_FOR_URT_HR(VER_E_FIN_OVERLAP) "Finally handler blocks overlap." - MSG_FOR_URT_HR(VER_E_LEXICAL_NESTING) "Lexical nesting." - MSG_FOR_URT_HR(VER_E_VOLATILE) "Missing ldsfld, stsfld, ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - MSG_FOR_URT_HR(VER_E_UNALIGNED) "Missing ldind, stind, ldfld, stfld, ldobj, stobj, initblk or cpblk." - MSG_FOR_URT_HR(VER_E_INNERMOST_FIRST) "Innermost exception blocks should be declared first." - MSG_FOR_URT_HR(VER_E_CALLI_VIRTUAL) "Calli not allowed on virtual methods." - MSG_FOR_URT_HR(VER_E_CALL_ABSTRACT) "Call not allowed on abstract methods." - MSG_FOR_URT_HR(VER_E_STACK_UNEXP_ARRAY) "Unexpected array type on the stack." - MSG_FOR_URT_HR(VER_E_NOT_IN_GC_HEAP) "Value type with NotInGCHeap attribute being created on the GC heap." - MSG_FOR_URT_HR(VER_E_TRY_N_EMPTY_STACK) "Attempt to enter a try block with nonempty stack." - MSG_FOR_URT_HR(VER_E_DLGT_CTOR) "Unrecognized arguments for delegate .ctor." - MSG_FOR_URT_HR(VER_E_DLGT_BB) "Delegate .ctor not allowed at the start of a basic block when the function pointer argument is a virtual method." - MSG_FOR_URT_HR(VER_E_DLGT_PATTERN) "Dup, ldvirtftn, newobj delegate::.ctor() pattern expected (in the same basic block)." - MSG_FOR_URT_HR(VER_E_DLGT_LDFTN) "Ldftn or ldvirtftn instruction required before call to a delegate .ctor." - MSG_FOR_URT_HR(VER_E_FTN_ABSTRACT) "Attempt to load address of an abstract method." - MSG_FOR_URT_HR(VER_E_SIG_C_VC) "ELEMENT_TYPE_CLASS ValueClass in signature." - MSG_FOR_URT_HR(VER_E_SIG_VC_C) "ELEMENT_TYPE_VALUETYPE non-ValueClass in signature." - MSG_FOR_URT_HR(VER_E_BOX_PTR_TO_STACK) "Box operation on TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_SIG_BYREF_TB_AH) "ByRef of TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_SIG_ARRAY_TB_AH) "Array of TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_ENDFILTER_STACK) "Stack not empty when leaving an exception filter." - MSG_FOR_URT_HR(VER_E_DLGT_SIG_I) "Unrecognized delegate .ctor signature; expected I." - MSG_FOR_URT_HR(VER_E_DLGT_SIG_O) "Unrecognized delegate .ctor signature; expected Object." - MSG_FOR_URT_HR(VER_E_RA_PTR_TO_STACK) "Mkrefany on TypedReference, ArgHandle, or ArgIterator." - MSG_FOR_URT_HR(VER_E_CATCH_VALUE_TYPE) "Value type not allowed as catch type." - MSG_FOR_URT_HR(VER_E_CATCH_BYREF) "ByRef not allowed as catch type." - MSG_FOR_URT_HR(VER_E_FIL_PRECEED_HND) "filter block should immediately precede handler block" - MSG_FOR_URT_HR(VER_E_LDVIRTFTN_STATIC) "ldvirtftn on static" - MSG_FOR_URT_HR(VER_E_CALLVIRT_STATIC) "callvirt on static" - MSG_FOR_URT_HR(VER_E_INITLOCALS) "initlocals must be set for verifiable methods with one or more local variables." - MSG_FOR_URT_HR(VER_E_BR_TO_EXCEPTION) "branch or leave to the beginning of a catch/filter handler" - MSG_FOR_URT_HR(VER_E_CALL_CTOR) "Call to .ctor only allowed to initialize this pointer from within a .ctor. Try newobj." - MSG_FOR_URT_HR(VER_E_VALCLASS_OBJREF_VAR) "Value type, ObjRef type or variable type expected." - MSG_FOR_URT_HR(VER_E_STACK_P_VALCLASS_OBJREF_VAR) "Expected address of value type, ObjRef type or variable type on the stack." - MSG_FOR_URT_HR(VER_E_SIG_VAR_PARAM) "Unrecognized type parameter of enclosing class." - MSG_FOR_URT_HR(VER_E_SIG_MVAR_PARAM) "Unrecognized type parameter of enclosing method." - MSG_FOR_URT_HR(VER_E_SIG_VAR_ARG) "Unrecognized type argument of referenced class instantiation." - MSG_FOR_URT_HR(VER_E_SIG_MVAR_ARG) "Unrecognized type argument of referenced method instantiation." - MSG_FOR_URT_HR(VER_E_SIG_GENERICINST) "Cannot resolve generic type." - MSG_FOR_URT_HR(VER_E_SIG_METHOD_INST) "Method instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_SIG_METHOD_PARENT_INST) "Method parent instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_SIG_FIELD_PARENT_INST) "Field parent instantiation contains non boxable type arguments." - MSG_FOR_URT_HR(VER_E_CALLCONV_NOT_GENERICINST) "Unrecognized calling convention for an instantiated generic method." - MSG_FOR_URT_HR(VER_E_TOKEN_BAD_METHOD_SPEC) "Unrecognized generic method in method instantiation." - MSG_FOR_URT_HR(VER_E_BAD_READONLY_PREFIX) "Missing ldelema or call following readonly. prefix." - MSG_FOR_URT_HR(VER_E_BAD_CONSTRAINED_PREFIX) "Missing callvirt following constrained. prefix." MSG_FOR_URT_HR(VER_E_CIRCULAR_VAR_CONSTRAINTS) "Method parent has circular class type parameter constraints." MSG_FOR_URT_HR(VER_E_CIRCULAR_MVAR_CONSTRAINTS) "Method has circular method type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_METHOD_INST) "Method instantiation has unsatisfied method type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_METHOD_PARENT_INST) "Method parent instantiation has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_FIELD_PARENT_INST) "Field parent instantiation has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_UNSATISFIED_BOX_OPERAND) "Type operand of box instruction has unsatisfied class type parameter constraints." - MSG_FOR_URT_HR(VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS) "The 'this' argument to a constrained call must have ByRef type." - MSG_FOR_URT_HR(VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE) "The operand to a constrained prefix instruction must be a type parameter." - MSG_FOR_URT_HR(VER_E_READONLY_UNEXPECTED_CALLEE) "The readonly prefix may only be applied to calls to array methods returning ByRefs." - MSG_FOR_URT_HR(VER_E_READONLY_ILLEGAL_WRITE) "Illegal write to readonly ByRef." - MSG_FOR_URT_HR(VER_E_READONLY_IN_MKREFANY) "A readonly ByRef cannot be used with mkrefany." - MSG_FOR_URT_HR(VER_E_UNALIGNED_ALIGNMENT) "Alignment specified for 'unaligned' prefix must be 1, 2, or 4." - MSG_FOR_URT_HR(VER_E_TAILCALL_INSIDE_EH) "The tail.call (or calli or callvirt) instruction cannot be used to transfer control out of a try, filter, catch, or finally block." - MSG_FOR_URT_HR(VER_E_BACKWARD_BRANCH) "Stack height at all points must be determinable in a single forward scan of IL." - MSG_FOR_URT_HR(VER_E_CALL_TO_VTYPE_BASE) "Call to base type of valuetype." - MSG_FOR_URT_HR(VER_E_NEWOBJ_OF_ABSTRACT_CLASS) "Cannot construct an instance of abstract class." - MSG_FOR_URT_HR(VER_E_UNMANAGED_POINTER) "Unmanaged pointers are not a verifiable type." - MSG_FOR_URT_HR(VER_E_LDFTN_NON_FINAL_VIRTUAL) "Cannot LDFTN a non-final virtual method." - MSG_FOR_URT_HR(VER_E_FIELD_OVERLAP) "Accessing type with overlapping fields." - MSG_FOR_URT_HR(VER_E_THIS_MISMATCH) "The 'this' parameter to the call must be the calling method's 'this' parameter." - MSG_FOR_URT_HR(VER_E_STACK_I_I4) "Expected I4 on the stack." - MSG_FOR_URT_HR(VER_E_BAD_PE) "Unverifiable PE Header/native stub." - MSG_FOR_URT_HR(VER_E_BAD_MD) "Unrecognized metadata, unable to verify IL." - MSG_FOR_URT_HR(VER_E_BAD_APPDOMAIN) "Unrecognized appdomain pointer." - MSG_FOR_URT_HR(VER_E_TYPELOAD) "Type load failed." - MSG_FOR_URT_HR(VER_E_PE_LOAD) "Module load failed." - MSG_FOR_URT_HR(VER_E_WRITE_RVA_STATIC) "Cannot modify an imaged based (RVA) static" - MSG_FOR_URT_HR(VER_E_INITIALIZE_ARRAY_MISSING_TOKEN) "Ldtoken instruction required before call to System.Runtime.CompilerServices.InitializeArray." - MSG_FOR_URT_HR(VLDTR_E_IFACE_NOTIFACE) "Interface in InterfaceImpl is not marked tdInterface." - MSG_FOR_URT_HR(VLDTR_E_FD_RVAHASNORVA) "Field marked fdHasFieldRVA but has no RVA record." - MSG_FOR_URT_HR(VLDTR_E_FD_RVAHASZERORVA) "Field marked fdHasFieldRVA has RVA set to zero." - MSG_FOR_URT_HR(VLDTR_E_MD_RVAANDIMPLMAP) "Method has both non-zero RVA and ImplMap." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTRAFLAGS) "TypeDef has extraneous bits in flags." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTENDSITSELF) "TypeDef extends itself." - MSG_FOR_URT_HR(VLDTR_E_TD_SYSVTNOTEXTOBJ) "System.ValueType does not extend System.Object." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTTYPESPEC) "Class extends TypeSpec (warning)." - MSG_FOR_URT_HR(VLDTR_E_TD_VTNOSIZE) "Value Class has zero size." - MSG_FOR_URT_HR(VLDTR_E_TD_IFACESEALED) "Interface is sealed." - MSG_FOR_URT_HR(VLDTR_E_NC_BADNESTED) "Bad 'nested' token in NestedClass." - MSG_FOR_URT_HR(VLDTR_E_NC_BADENCLOSER) "Bad 'enclosing' token in NestedClass." - MSG_FOR_URT_HR(VLDTR_E_NC_DUP) "Duplicate NestedClass record." - MSG_FOR_URT_HR(VLDTR_E_NC_DUPENCLOSER) "Duplicate NestedClass with different encloser." - MSG_FOR_URT_HR(VLDTR_E_FRVA_ZERORVA) "RVA set to zero in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_BADFIELD) "Invalid field token in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_DUPRVA) "Duplicate RVA in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_FRVA_DUPFIELD) "Duplicate field in FieldRVA record." - MSG_FOR_URT_HR(VLDTR_E_EP_BADTOKEN) "Bad token as entry point in CLR header." - MSG_FOR_URT_HR(VLDTR_E_EP_INSTANCE) "Entry point in CLR header is a token of instance method." - MSG_FOR_URT_HR(VLDTR_E_TD_ENUMFLDBADTYPE) "Enum has non-integral underlying type." - MSG_FOR_URT_HR(VLDTR_E_MD_BADRVA) "Method has bogus RVA." - MSG_FOR_URT_HR(VLDTR_E_FD_LITERALNODEFAULT) "Literal field has no const value." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHNOTIMPL) "Class implementing an interface does not implement one of methods." - MSG_FOR_URT_HR(VLDTR_E_CA_BADPARENT) "CA has invalid owner." - MSG_FOR_URT_HR(VLDTR_E_CA_BADTYPE) "CA has invalid type." - MSG_FOR_URT_HR(VLDTR_E_CA_NOTCTOR) "CA type is not .ctor." - MSG_FOR_URT_HR(VLDTR_E_CA_BADSIG) "CA type has bad signature." - MSG_FOR_URT_HR(VLDTR_E_CA_NOSIG) "CA type has no signature." - MSG_FOR_URT_HR(VLDTR_E_CA_BADPROLOG) "CA blob has bad prolog (not 0x01 0x00)." - MSG_FOR_URT_HR(VLDTR_E_MD_BADLOCALSIGTOK) "Method has invalid LocalSig token." - MSG_FOR_URT_HR(VLDTR_E_MD_BADHEADER) "Method has invalid header." - MSG_FOR_URT_HR(VLDTR_E_EP_TOOMANYARGS) "Entry point has more than one argument." - MSG_FOR_URT_HR(VLDTR_E_EP_BADRET) "Entry point has bad return type." - MSG_FOR_URT_HR(VLDTR_E_EP_BADARG) "Entry point has bad argument." MSG_FOR_URT_HR(VLDTR_E_SIG_BADVOID) "Illegal 'void' in signature." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHMULTIMPL) "Multiple implementation of method." - MSG_FOR_URT_HR(VLDTR_E_GP_NAMENULL) "GenericParam name is NULL." - MSG_FOR_URT_HR(VLDTR_E_GP_OWNERNIL) "GenericParam has nil owner." - MSG_FOR_URT_HR(VLDTR_E_GP_DUPNAME) "GenericParam has duplicate by owner and name." - MSG_FOR_URT_HR(VLDTR_E_GP_DUPNUMBER) "GenericParam has duplicate by owner and number." - MSG_FOR_URT_HR(VLDTR_E_GP_NONSEQ_BY_OWNER) "GenericParam is non sequential by owner." - MSG_FOR_URT_HR(VLDTR_E_GP_NONSEQ_BY_NUMBER) "GenericParam is non sequential by number." - MSG_FOR_URT_HR(VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR) "GenericParam has variance but its owner is not an interface or delegate." MSG_FOR_URT_HR(VLDTR_E_GP_ILLEGAL_VARIANT_MVAR) "GenericParam is a method type parameter and must be non-variant." - MSG_FOR_URT_HR(VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS) "GenericParam has illegal value for variance flags." - MSG_FOR_URT_HR(VLDTR_E_GP_REFANDVALUETYPE) "GenericParam has incompatible special constraints reference type and valuetype." - MSG_FOR_URT_HR(VLDTR_E_GPC_OWNERNIL) "GenericParamConstraint has nil owner." - MSG_FOR_URT_HR(VLDTR_E_GPC_DUP) "GenericParamConstraint has duplicate by owner and constraint." - MSG_FOR_URT_HR(VLDTR_E_GPC_NONCONTIGUOUS) "GenericParamConstraint is non-contiguous with preceeding constraints for same owner." - MSG_FOR_URT_HR(VLDTR_E_MS_METHODNIL) "MethodSpec has nil method." - MSG_FOR_URT_HR(VLDTR_E_MS_DUP) "MethodSpec has duplicate based on method and instantiation." - MSG_FOR_URT_HR(VLDTR_E_MS_BADCALLINGCONV) "MethodSpec signature has invalid calling convention." - MSG_FOR_URT_HR(VLDTR_E_MS_MISSARITY) "MethodSpec signature is missing arity specification." - MSG_FOR_URT_HR(VLDTR_E_MS_MISSARG) "MethodSpec signature is missing type argument." - MSG_FOR_URT_HR(VLDTR_E_MS_ARITYMISMATCH) "MethodSpec arity of generic method and instantiation do not match." - MSG_FOR_URT_HR(VLDTR_E_MS_METHODNOTGENERIC) "MethodSpec method is not generic." - MSG_FOR_URT_HR(VLDTR_E_SIG_MISSARITY) "Signature missing arity of instantiated generic type." - MSG_FOR_URT_HR(VLDTR_E_SIG_ARITYMISMATCH) "Signature has generic type of arity instantiated at different arity." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_CCTOR) "Method cannot be both generic and a class constructor." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_CTOR) "Method cannot be both generic and an instance constructor." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_IMPORT) "Method cannot be both generic and defined on an imported type." - MSG_FOR_URT_HR(VLDTR_E_MD_GENERIC_BADCALLCONV) "Method cannot be both generic and have non-default calling convention." - MSG_FOR_URT_HR(VLDTR_E_EP_GENERIC_METHOD) "Entry point in CLR header is the token for a generic method." - MSG_FOR_URT_HR(VLDTR_E_MD_MISSARITY) "Method signature is generic but is missing its arity." - MSG_FOR_URT_HR(VLDTR_E_MD_ARITYZERO) "Method signature is generic but its arity is zero." - MSG_FOR_URT_HR(VLDTR_E_SIG_ARITYZERO) "Signature has generic type instantiated at arity 0." - MSG_FOR_URT_HR(VLDTR_E_MS_ARITYZERO) "MethodSpec signature has arity 0." - MSG_FOR_URT_HR(VLDTR_E_MD_GPMISMATCH) "MethodDef signature has arity n but owns m GenericParams." - MSG_FOR_URT_HR(VLDTR_E_EP_GENERIC_TYPE) "Entry point in CLR header is the token for a method in a generic type." - MSG_FOR_URT_HR(VLDTR_E_MI_DECLNOTGENERIC) "MethodImpl overrides non-generic method with generic method." - MSG_FOR_URT_HR(VLDTR_E_MI_IMPLNOTGENERIC) "MethodImpl overrides non-generic method with generic method." - MSG_FOR_URT_HR(VLDTR_E_MI_ARITYMISMATCH) "MethodImpl overrides generic method of arity n with generic method of arity m." - MSG_FOR_URT_HR(VLDTR_E_TD_EXTBADTYPESPEC) "TypeDef extends a TypeSpec that is not an instantiated type." - MSG_FOR_URT_HR(VLDTR_E_SIG_BYREFINST) "Signature has type instantiated at ByRef at offset i." - MSG_FOR_URT_HR(VLDTR_E_MS_BYREFINST) "Signature has type instantiated at ByRef at offset i." - MSG_FOR_URT_HR(VLDTR_E_TS_EMPTY) "TypeSpec has empty signature." - MSG_FOR_URT_HR(VLDTR_E_TS_HASSENTINALS) "TypeSpec has signature containing one or more sentinels." - MSG_FOR_URT_HR(VLDTR_E_TD_GENERICHASEXPLAYOUT) "TypeDef is generic but has explicit layout." - MSG_FOR_URT_HR(VLDTR_E_SIG_BADTOKTYPE) "Signature has token following ELEMENT_TYPE_CLASS (_VALUETYPE) that is not a TypeDef or TypeRef." - MSG_FOR_URT_HR(VLDTR_E_IFACE_METHNOTIMPLTHISMOD) "Warning: Class does not implement interface method in this module." - MSG_FOR_URT_HR(TLBX_E_CIRCULAR_EXPORT2) "TypeLib export: attempted to export an Assembly imported from a TLB." MSG_FOR_URT_HR(CORDBG_E_THREAD_NOT_SCHEDULED) "Thread is not scheduled. Thus we may not have OSThreadId, handle, or context." MSG_FOR_URT_HR(CORDBG_E_HANDLE_HAS_BEEN_DISPOSED) "Handle has been disposed." MSG_FOR_URT_HR(CORDBG_E_NONINTERCEPTABLE_EXCEPTION) "Cannot intercept this exception." - MSG_FOR_URT_HR(CORDBG_E_CANT_UNWIND_ABOVE_CALLBACK) "When intercepting an exception, cannot intercept above the current frame." MSG_FOR_URT_HR(CORDBG_E_INTERCEPT_FRAME_ALREADY_SET) "The intercept frame for this exception has already been set." MSG_FOR_URT_HR(CORDBG_E_NO_NATIVE_PATCH_AT_ADDR) "There is no native patch at the given address." MSG_FOR_URT_HR(CORDBG_E_MUST_BE_INTEROP_DEBUGGING) "This API is only allowed when interop debugging." @@ -980,11 +261,8 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_TIMEOUT) "A wait timed out, likely an indication of deadlock." MSG_FOR_URT_HR(CORDBG_E_CANT_CALL_ON_THIS_THREAD) "Cannot use the API on this thread." MSG_FOR_URT_HR(CORDBG_E_ENC_INFOLESS_METHOD) "Method was not JIT'd in EnC mode." - MSG_FOR_URT_HR(CORDBG_E_ENC_NESTED_HANLDERS) "Frame cannot be updated due to change in max nesting of handlers." MSG_FOR_URT_HR(CORDBG_E_ENC_IN_FUNCLET) "Method is in a callable handler/filter. Cannot increase stack." - MSG_FOR_URT_HR(CORDBG_E_ENC_LOCALLOC) "Frame cannot be updated due to localloc." MSG_FOR_URT_HR(CORDBG_E_ENC_EDIT_NOT_SUPPORTED) "Attempt to perform unsupported edit." - MSG_FOR_URT_HR(CORDBG_E_FEABORT_DELAYED_UNTIL_THREAD_RESUMED) "Attempt to func eval abort on a suspended thread." MSG_FOR_URT_HR(CORDBG_E_NOTREADY) "The LS is not in a good spot to perform the requested operation." MSG_FOR_URT_HR(CORDBG_E_CANNOT_RESOLVE_ASSEMBLY) "We failed to resolve assembly given an AssemblyRef token. Assembly may be not loaded yet or not a valid token." MSG_FOR_URT_HR(CORDBG_E_MUST_BE_IN_LOAD_MODULE) "Must be in context of LoadModule callback to perform requested operation." @@ -1002,7 +280,6 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_PROLOG) "The operation failed because the thread is in the prolog." MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_NATIVE_CODE) "The operation failed because the thread is in native code." MSG_FOR_URT_HR(CORDBG_E_ILLEGAL_IN_OPTIMIZED_CODE) "The operation failed because the thread is in optimized code." - MSG_FOR_URT_HR(CORDBG_E_MINIDUMP_UNSUPPORTED) "The information requested is not supported by minidumps." MSG_FOR_URT_HR(CORDBG_E_APPDOMAIN_MISMATCH) "A supplied object or type belongs to the wrong AppDomain." MSG_FOR_URT_HR(CORDBG_E_CONTEXT_UNVAILABLE) "The thread's context is not available." MSG_FOR_URT_HR(CORDBG_E_UNCOMPATIBLE_PLATFORMS) "The operation failed because debuggee and debugger are on incompatible platforms." @@ -1018,12 +295,6 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_MODULE_LOADED_FROM_DISK) "Symbols are not supplied for modules loaded from disk." MSG_FOR_URT_HR(CORDBG_E_SYMBOLS_NOT_AVAILABLE) "The application did not supply symbols when it loaded or created this module, or they are not yet available." MSG_FOR_URT_HR(CORDBG_E_DEBUG_COMPONENT_MISSING) "A debug component is not installed." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_MISMATCHED_CERTS) "Connection authentication failed due to mismatched certificates." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_NETWORK_FAILURE) "Connection failed due to a miscellaneous network error." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_NO_LISTENER) "Connection failed due to no endpoint at remote machine (no proxy configured?)." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_UNKNOWN_TARGET) "Connection failed due to inability to locate remote machine." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_INVALID_CONFIG) "Local debugger configuration was missing or invalid." - MSG_FOR_URT_HR(CORDBG_E_REMOTE_MISMATCHED_PROTOCOLS) "Connection failed due to protocol version mismatch between local and remote components." MSG_FOR_URT_HR(CORDBG_E_LIBRARY_PROVIDER_ERROR) "The ICLRDebuggingLibraryProvider callback returned an error or did not provide a valid handle." MSG_FOR_URT_HR(CORDBG_E_NOT_CLR) "The module at the base address indicated was not recognized as a CLR" MSG_FOR_URT_HR(CORDBG_E_MISSING_DATA_TARGET_INTERFACE) "The provided data target does not implement the required interfaces for this version of the runtime" @@ -1038,37 +309,10 @@ BEGIN MSG_FOR_URT_HR(CORDBG_E_UNSUPPORTED) "The specified action is unsupported by this version of the runtime." MSG_FOR_URT_HR(CORDBG_E_MISSING_DEBUGGER_EXPORTS) "The debuggee memory space does not have the expected debugging export table." MSG_FOR_URT_HR(CORDBG_E_DATA_TARGET_ERROR) "Failure when calling a data target method." - MSG_FOR_URT_HR(CORDBG_E_CODE_HAS_NO_METADATA) "Couldn't find metadata for the given executable code." - MSG_FOR_URT_HR(CORDBG_E_CODE_UNRECOGNIZED) "Given executable code is not managed." MSG_FOR_URT_HR(CORDBG_E_NO_IMAGE_AVAILABLE) "Couldn't find a native image." - MSG_FOR_URT_HR(CORDBG_E_TYPE_NOT_FOUND) "The type doesn't exist in the given module." - MSG_FOR_URT_HR(CORDBG_E_VTABLE_HAS_NO_METADATA) "Couldn't find metadata for the given vtable." - MSG_FOR_URT_HR(CORDBG_E_NO_GENERIC_INFO) "Couldn't find any generics information." - MSG_FOR_URT_HR(PEFMT_E_NO_CONTENTS) "File is empty." - MSG_FOR_URT_HR(PEFMT_E_NO_NTHEADERS) "File has no NT headers." MSG_FOR_URT_HR(PEFMT_E_64BIT) "File is PE32+." - MSG_FOR_URT_HR(PEFMT_E_NO_CORHEADER) "File has no COR header." - MSG_FOR_URT_HR(PEFMT_E_NOT_ILONLY) "Flag IL_ONLY not set." - MSG_FOR_URT_HR(PEFMT_E_IMPORT_DLLS) "Bad import DLLs." - MSG_FOR_URT_HR(PEFMT_E_EXE_NOENTRYPOINT) "EXE file has no mgd entry point." - MSG_FOR_URT_HR(PEFMT_E_BASE_RELOCS) "Bad base relocations." - MSG_FOR_URT_HR(PEFMT_E_ENTRYPOINT) "Bad managed entry point." - MSG_FOR_URT_HR(PEFMT_E_ZERO_SIZEOFCODE) "OptHeader.SizeOfCode is set to zero." - MSG_FOR_URT_HR(PEFMT_E_BAD_CORHEADER) "File has invalid COR header." MSG_FOR_URT_HR(PEFMT_E_32BIT) "File is PE32" - MSG_FOR_URT_HR(CLR_OPTSVC_E_CONTROLLER_INTERRUPT) "The operation was interrupted by the CLR Optimization Service controller." - MSG_FOR_URT_HR(NGEN_FAILED_GET_DEPENDENCIES) "Failed to get dependencies for assembly." - MSG_FOR_URT_HR(NGEN_FAILED_NATIVE_IMAGE_DELETE) "Failed to delete native image." - MSG_FOR_URT_HR(NGEN_E_TOO_MANY_INTERFACES) "Module contains too many interfaces to successfully compile all methods." - MSG_FOR_URT_HR(NGEN_E_OLDER_RUNTIME) "Requested runtime does not support side-by-side NGen." - MSG_FOR_URT_HR(NGEN_E_WORKER_UNEXPECTED_EXIT) "Worker exited unexpectedly during startup" - MSG_FOR_URT_HR(NGEN_E_WORKER_UNEXPECTED_SYNC) "Failed to synchronize with worker during startup" MSG_FOR_URT_HR(NGEN_E_SYS_ASM_NI_MISSING) "NGen cannot proceed because Mscorlib.dll does not have a native image" - MSG_FOR_URT_HR(NGEN_E_EXE_MACHINE_TYPE_MISMATCH) "The image file is not compatible with the version of Ngen you're running. Use 32bit Ngen for 32bit assemblies, and 64bit Ngen for 64bit assemblies." - MSG_FOR_URT_HR(NGEN_E_ASSEMBLY_EXCLUSION_FILE_PARSE_ERROR) "There was an error parsing the NGen assembly exclusion Xml file." - MSG_FOR_URT_HR(NGEN_E_HARDBOUND_DEPENDENCY_MISSING) "A hardbound dependent native image is missing." - MSG_FOR_URT_HR(NGEN_E_NOT_RUNNING_IN_EXPECTED_PACKAGE) "NGen is not running in expected package." - MSG_FOR_URT_HR(NGEN_E_FILE_NOT_ASSEMBLY) "The image being compiled is not a .NET assembly" MSG_FOR_URT_HR(CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW) "The bound assembly has a version that is lower than that of the request." MSG_FOR_URT_HR(CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH) "The assembly version has a public key token that does not match that of the request." MSG_FOR_URT_HR(CLR_E_BIND_IMAGE_UNAVAILABLE) "The requested image was not found or is unavailable." diff --git a/src/pal/prebuilt/inc/corerror.h b/src/pal/prebuilt/inc/corerror.h index d4d449529752..237cd40aa6a4 100644 --- a/src/pal/prebuilt/inc/corerror.h +++ b/src/pal/prebuilt/inc/corerror.h @@ -24,221 +24,72 @@ #endif #define CLDB_S_TRUNCATION SMAKEHR(0x1106) -#define CLDB_S_NULL SMAKEHR(0x1109) -#define CLDB_S_INDEX_TABLESCANREQUIRED SMAKEHR(0x1125) -#define TLBX_I_TYPEINFO_IMPORTED SMAKEHR(0x116c) -#define TLBX_I_PIA_REGISTERED_FOR_TLB SMAKEHR(0x116d) -#define TLBX_I_AGNOSTIC_ASSEMBLY SMAKEHR(0x116e) -#define TLBX_I_USEIUNKNOWN SMAKEHR(0x116f) -#define TLBX_I_UNCONVERTABLE_ARGS SMAKEHR(0x1170) -#define TLBX_I_UNCONVERTABLE_FIELD SMAKEHR(0x1171) -#define TLBX_W_WARNING_MESSAGE SMAKEHR(0x1173) -#define TLBX_W_ASSEMBLY_HAS_EMBEDDED_TLB SMAKEHR(0x1174) -#define TLBX_W_CROSS_COMPILE_NO_REFS SMAKEHR(0x1175) -#define TLBX_W_PURE_CROSS_COMPILE SMAKEHR(0x1176) -#define TLBX_I_TYPE_EXPORTED SMAKEHR(0x1179) -#define TLBX_I_DUPLICATE_DISPID SMAKEHR(0x117a) -#define TLBX_I_REF_TYPE_AS_STRUCT SMAKEHR(0x117c) -#define TLBX_I_GENERIC_TYPE SMAKEHR(0x117f) -#define TLBX_W_NON_INTEGRAL_CA_TYPE SMAKEHR(0x1184) -#define TLBX_W_IENUM_CA_ON_IUNK SMAKEHR(0x1185) -#define META_S_PARAM_MISMATCH SMAKEHR(0x1189) #define META_S_DUPLICATE SMAKEHR(0x1197) -#define TLBX_S_REFERENCED_TYPELIB SMAKEHR(0x11ac) -#define TLBX_S_NOSTDINTERFACE SMAKEHR(0x11b3) -#define TLBX_S_DUPLICATE_DISPID SMAKEHR(0x11b4) -#define TLBX_W_ENUM_VALUE_TOOBIG SMAKEHR(0x11d5) -#define TLBX_W_EXPORTING_AUTO_LAYOUT SMAKEHR(0x11d9) -#define TLBX_W_DEFAULT_INTF_NOT_VISIBLE SMAKEHR(0x11db) -#define TLBX_W_BAD_SAFEARRAYFIELD_NO_ELEMENTVT SMAKEHR(0x11de) -#define TLBX_W_LAYOUTCLASS_AS_INTERFACE SMAKEHR(0x11df) -#define TLBX_I_GENERIC_BASE_TYPE SMAKEHR(0x11e0) -#define VLDTR_S_WRN SMAKEHR(0x1200) -#define VLDTR_S_ERR SMAKEHR(0x1201) -#define VLDTR_S_WRNERR SMAKEHR(0x1202) #define CORDBG_S_BAD_START_SEQUENCE_POINT SMAKEHR(0x130b) #define CORDBG_S_BAD_END_SEQUENCE_POINT SMAKEHR(0x130c) -#define CORDBG_S_INSUFFICIENT_INFO_FOR_SET_IP SMAKEHR(0x130d) #define CORDBG_S_FUNC_EVAL_HAS_NO_RESULT SMAKEHR(0x1316) #define CORDBG_S_VALUE_POINTS_TO_VOID SMAKEHR(0x1317) #define CORDBG_S_FUNC_EVAL_ABORTED SMAKEHR(0x1319) #define CORDBG_S_AT_END_OF_STACK SMAKEHR(0x1324) #define CORDBG_S_NOT_ALL_BITS_SET SMAKEHR(0x1c13) -#define CEE_E_ENTRYPOINT EMAKEHR(0x1000) #define CEE_E_CVTRES_NOT_FOUND EMAKEHR(0x1001) -#define MSEE_E_LOADLIBFAILED EMAKEHR(0x1010) -#define MSEE_E_GETPROCFAILED EMAKEHR(0x1011) -#define MSEE_E_MULTCOPIESLOADED EMAKEHR(0x1012) #define COR_E_TYPEUNLOADED EMAKEHR(0x1013) #define COR_E_APPDOMAINUNLOADED EMAKEHR(0x1014) #define COR_E_CANNOTUNLOADAPPDOMAIN EMAKEHR(0x1015) #define MSEE_E_ASSEMBLYLOADINPROGRESS EMAKEHR(0x1016) -#define MSEE_E_CANNOTCREATEAPPDOMAIN EMAKEHR(0x1017) #define COR_E_ASSEMBLYEXPECTED EMAKEHR(0x1018) #define COR_E_FIXUPSINEXE EMAKEHR(0x1019) -#define COR_E_NO_LOADLIBRARY_ALLOWED EMAKEHR(0x101a) #define COR_E_NEWER_RUNTIME EMAKEHR(0x101b) -#define COR_E_CANNOT_SET_POLICY EMAKEHR(0x101c) -#define COR_E_CANNOT_SPECIFY_EVIDENCE EMAKEHR(0x101d) #define COR_E_MULTIMODULEASSEMBLIESDIALLOWED EMAKEHR(0x101e) #define HOST_E_DEADLOCK EMAKEHR(0x1020) -#define HOST_E_INTERRUPTED EMAKEHR(0x1021) #define HOST_E_INVALIDOPERATION EMAKEHR(0x1022) #define HOST_E_CLRNOTAVAILABLE EMAKEHR(0x1023) -#define HOST_E_TIMEOUT EMAKEHR(0x1024) -#define HOST_E_NOT_OWNER EMAKEHR(0x1025) -#define HOST_E_ABANDONED EMAKEHR(0x1026) #define HOST_E_EXITPROCESS_THREADABORT EMAKEHR(0x1027) #define HOST_E_EXITPROCESS_ADUNLOAD EMAKEHR(0x1028) #define HOST_E_EXITPROCESS_TIMEOUT EMAKEHR(0x1029) #define HOST_E_EXITPROCESS_OUTOFMEMORY EMAKEHR(0x102a) -#define HOST_E_EXITPROCESS_STACKOVERFLOW EMAKEHR(0x102b) #define COR_E_MODULE_HASH_CHECK_FAILED EMAKEHR(0x1039) #define FUSION_E_REF_DEF_MISMATCH EMAKEHR(0x1040) #define FUSION_E_INVALID_PRIVATE_ASM_LOCATION EMAKEHR(0x1041) #define FUSION_E_ASM_MODULE_MISSING EMAKEHR(0x1042) -#define FUSION_E_UNEXPECTED_MODULE_FOUND EMAKEHR(0x1043) #define FUSION_E_PRIVATE_ASM_DISALLOWED EMAKEHR(0x1044) #define FUSION_E_SIGNATURE_CHECK_FAILED EMAKEHR(0x1045) -#define FUSION_E_DATABASE_ERROR EMAKEHR(0x1046) #define FUSION_E_INVALID_NAME EMAKEHR(0x1047) #define FUSION_E_CODE_DOWNLOAD_DISABLED EMAKEHR(0x1048) -#define FUSION_E_UNINSTALL_DISALLOWED EMAKEHR(0x1049) -#define CLR_E_APP_CONFIG_NOT_ALLOWED_IN_APPX_PROCESS EMAKEHR(0x104a) #define FUSION_E_HOST_GAC_ASM_MISMATCH EMAKEHR(0x1050) #define FUSION_E_LOADFROM_BLOCKED EMAKEHR(0x1051) #define FUSION_E_CACHEFILE_FAILED EMAKEHR(0x1052) #define FUSION_E_APP_DOMAIN_LOCKED EMAKEHR(0x1053) #define FUSION_E_CONFIGURATION_ERROR EMAKEHR(0x1054) #define FUSION_E_MANIFEST_PARSE_ERROR EMAKEHR(0x1055) -#define FUSION_E_INVALID_ASSEMBLY_REFERENCE EMAKEHR(0x1056) -#define COR_E_ASSEMBLY_NOT_EXPECTED EMAKEHR(0x1057) #define COR_E_LOADING_REFERENCE_ASSEMBLY EMAKEHR(0x1058) #define COR_E_NI_AND_RUNTIME_VERSION_MISMATCH EMAKEHR(0x1059) #define COR_E_LOADING_WINMD_REFERENCE_ASSEMBLY EMAKEHR(0x1069) #define CLDB_E_FILE_BADREAD EMAKEHR(0x1100) #define CLDB_E_FILE_BADWRITE EMAKEHR(0x1101) -#define CLDB_E_FILE_READONLY EMAKEHR(0x1103) -#define CLDB_E_NAME_ERROR EMAKEHR(0x1105) -#define CLDB_E_TRUNCATION EMAKEHR(0x1106) #define CLDB_E_FILE_OLDVER EMAKEHR(0x1107) -#define CLDB_E_RELOCATED EMAKEHR(0x1108) #define CLDB_E_SMDUPLICATE EMAKEHR(0x110a) #define CLDB_E_NO_DATA EMAKEHR(0x110b) -#define CLDB_E_READONLY EMAKEHR(0x110c) #define CLDB_E_INCOMPATIBLE EMAKEHR(0x110d) #define CLDB_E_FILE_CORRUPT EMAKEHR(0x110e) -#define CLDB_E_SCHEMA_VERNOTFOUND EMAKEHR(0x110f) #define CLDB_E_BADUPDATEMODE EMAKEHR(0x1110) -#define CLDB_E_INDEX_NONULLKEYS EMAKEHR(0x1121) -#define CLDB_E_INDEX_DUPLICATE EMAKEHR(0x1122) -#define CLDB_E_INDEX_BADTYPE EMAKEHR(0x1123) #define CLDB_E_INDEX_NOTFOUND EMAKEHR(0x1124) #define CLDB_E_RECORD_NOTFOUND EMAKEHR(0x1130) -#define CLDB_E_RECORD_OVERFLOW EMAKEHR(0x1131) -#define CLDB_E_RECORD_DUPLICATE EMAKEHR(0x1132) -#define CLDB_E_RECORD_PKREQUIRED EMAKEHR(0x1133) -#define CLDB_E_RECORD_DELETED EMAKEHR(0x1134) #define CLDB_E_RECORD_OUTOFORDER EMAKEHR(0x1135) -#define CLDB_E_COLUMN_OVERFLOW EMAKEHR(0x1140) -#define CLDB_E_COLUMN_READONLY EMAKEHR(0x1141) -#define CLDB_E_COLUMN_SPECIALCOL EMAKEHR(0x1142) -#define CLDB_E_COLUMN_PKNONULLS EMAKEHR(0x1143) -#define CLDB_E_TABLE_CANTDROP EMAKEHR(0x1150) -#define CLDB_E_OBJECT_NOTFOUND EMAKEHR(0x1151) -#define CLDB_E_OBJECT_COLNOTFOUND EMAKEHR(0x1152) -#define CLDB_E_VECTOR_BADINDEX EMAKEHR(0x1153) #define CLDB_E_TOO_BIG EMAKEHR(0x1154) #define META_E_INVALID_TOKEN_TYPE EMAKEHR(0x115f) -#define TLBX_E_INVALID_TYPEINFO EMAKEHR(0x1160) -#define TLBX_E_INVALID_TYPEINFO_UNNAMED EMAKEHR(0x1161) -#define TLBX_E_CTX_NESTED EMAKEHR(0x1162) -#define TLBX_E_ERROR_MESSAGE EMAKEHR(0x1163) -#define TLBX_E_CANT_SAVE EMAKEHR(0x1164) -#define TLBX_W_LIBNOTREGISTERED EMAKEHR(0x1165) -#define TLBX_E_CANTLOADLIBRARY EMAKEHR(0x1166) -#define TLBX_E_BAD_VT_TYPE EMAKEHR(0x1167) -#define TLBX_E_NO_MSCOREE_TLB EMAKEHR(0x1168) -#define TLBX_E_BAD_MSCOREE_TLB EMAKEHR(0x1169) -#define TLBX_E_TLB_EXCEPTION EMAKEHR(0x116a) -#define TLBX_E_MULTIPLE_LCIDS EMAKEHR(0x116b) -#define TLBX_E_AMBIGUOUS_RETURN EMAKEHR(0x116d) -#define TLBX_E_DUPLICATE_TYPE_NAME EMAKEHR(0x116e) -#define TLBX_I_NONSEQUENTIALSTRUCT EMAKEHR(0x1172) -#define TLBX_I_RESOLVEREFFAILED EMAKEHR(0x1174) -#define TLBX_E_ASANY EMAKEHR(0x1175) -#define TLBX_E_INVALIDLCIDPARAM EMAKEHR(0x1176) -#define TLBX_E_LCIDONDISPONLYITF EMAKEHR(0x1177) -#define TLBX_E_NONPUBLIC_FIELD EMAKEHR(0x1178) -#define TLBX_E_BAD_NAMES EMAKEHR(0x117b) -#define TLBX_E_GENERICINST_SIGNATURE EMAKEHR(0x117d) -#define TLBX_E_GENERICPAR_SIGNATURE EMAKEHR(0x117e) -#define META_E_DUPLICATE EMAKEHR(0x1180) -#define META_E_GUID_REQUIRED EMAKEHR(0x1181) -#define META_E_TYPEDEF_MISMATCH EMAKEHR(0x1182) -#define META_E_MERGE_COLLISION EMAKEHR(0x1183) -#define TLBX_E_NO_SAFEHANDLE_ARRAYS EMAKEHR(0x1186) -#define META_E_METHD_NOT_FOUND EMAKEHR(0x1187) -#define META_E_FIELD_NOT_FOUND EMAKEHR(0x1188) -#define META_E_PARAM_MISMATCH EMAKEHR(0x1189) #define META_E_BADMETADATA EMAKEHR(0x118a) -#define META_E_INTFCEIMPL_NOT_FOUND EMAKEHR(0x118b) -#define TLBX_E_NO_CRITICALHANDLE_ARRAYS EMAKEHR(0x118c) -#define META_E_CLASS_LAYOUT_INCONSISTENT EMAKEHR(0x118d) -#define META_E_FIELD_MARSHAL_NOT_FOUND EMAKEHR(0x118e) -#define META_E_METHODSEM_NOT_FOUND EMAKEHR(0x118f) -#define META_E_EVENT_NOT_FOUND EMAKEHR(0x1190) -#define META_E_PROP_NOT_FOUND EMAKEHR(0x1191) #define META_E_BAD_SIGNATURE EMAKEHR(0x1192) #define META_E_BAD_INPUT_PARAMETER EMAKEHR(0x1193) -#define META_E_METHDIMPL_INCONSISTENT EMAKEHR(0x1194) -#define META_E_MD_INCONSISTENCY EMAKEHR(0x1195) #define META_E_CANNOTRESOLVETYPEREF EMAKEHR(0x1196) #define META_E_STRINGSPACE_FULL EMAKEHR(0x1198) -#define META_E_UNEXPECTED_REMAP EMAKEHR(0x1199) #define META_E_HAS_UNMARKALL EMAKEHR(0x119a) #define META_E_MUST_CALL_UNMARKALL EMAKEHR(0x119b) -#define META_E_GENERICPARAM_INCONSISTENT EMAKEHR(0x119c) -#define META_E_EVENT_COUNTS EMAKEHR(0x119d) -#define META_E_PROPERTY_COUNTS EMAKEHR(0x119e) -#define META_E_TYPEDEF_MISSING EMAKEHR(0x119f) -#define TLBX_E_CANT_LOAD_MODULE EMAKEHR(0x11a0) -#define TLBX_E_CANT_LOAD_CLASS EMAKEHR(0x11a1) -#define TLBX_E_NULL_MODULE EMAKEHR(0x11a2) -#define TLBX_E_NO_CLSID_KEY EMAKEHR(0x11a3) -#define TLBX_E_CIRCULAR_EXPORT EMAKEHR(0x11a4) -#define TLBX_E_CIRCULAR_IMPORT EMAKEHR(0x11a5) -#define TLBX_E_BAD_NATIVETYPE EMAKEHR(0x11a6) -#define TLBX_E_BAD_VTABLE EMAKEHR(0x11a7) -#define TLBX_E_CRM_NON_STATIC EMAKEHR(0x11a8) -#define TLBX_E_CRM_INVALID_SIG EMAKEHR(0x11a9) -#define TLBX_E_CLASS_LOAD_EXCEPTION EMAKEHR(0x11aa) -#define TLBX_E_UNKNOWN_SIGNATURE EMAKEHR(0x11ab) -#define TLBX_E_REFERENCED_TYPELIB EMAKEHR(0x11ac) -#define TLBX_E_INVALID_NAMESPACE EMAKEHR(0x11ad) -#define TLBX_E_LAYOUT_ERROR EMAKEHR(0x11ae) -#define TLBX_E_NOTIUNKNOWN EMAKEHR(0x11af) -#define TLBX_E_NONVISIBLEVALUECLASS EMAKEHR(0x11b0) -#define TLBX_E_LPTSTR_NOT_ALLOWED EMAKEHR(0x11b1) -#define TLBX_E_AUTO_CS_NOT_ALLOWED EMAKEHR(0x11b2) -#define TLBX_E_ENUM_VALUE_INVALID EMAKEHR(0x11b5) -#define TLBX_E_DUPLICATE_IID EMAKEHR(0x11b6) -#define TLBX_E_NO_NESTED_ARRAYS EMAKEHR(0x11b7) -#define TLBX_E_PARAM_ERROR_NAMED EMAKEHR(0x11b8) -#define TLBX_E_PARAM_ERROR_UNNAMED EMAKEHR(0x11b9) -#define TLBX_E_AGNOST_SIGNATURE EMAKEHR(0x11ba) -#define TLBX_E_CONVERT_FAIL EMAKEHR(0x11bb) -#define TLBX_W_DUAL_NOT_DISPATCH EMAKEHR(0x11bc) -#define TLBX_E_BAD_SIGNATURE EMAKEHR(0x11bd) -#define TLBX_E_ARRAY_NEEDS_NT_FIXED EMAKEHR(0x11be) -#define TLBX_E_CLASS_NEEDS_NT_INTF EMAKEHR(0x11bf) #define META_E_CA_INVALID_TARGET EMAKEHR(0x11c0) #define META_E_CA_INVALID_VALUE EMAKEHR(0x11c1) #define META_E_CA_INVALID_BLOB EMAKEHR(0x11c2) #define META_E_CA_REPEATED_ARG EMAKEHR(0x11c3) #define META_E_CA_UNKNOWN_ARGUMENT EMAKEHR(0x11c4) -#define META_E_CA_VARIANT_NYI EMAKEHR(0x11c5) -#define META_E_CA_ARRAY_NYI EMAKEHR(0x11c6) #define META_E_CA_UNEXPECTED_TYPE EMAKEHR(0x11c7) #define META_E_CA_INVALID_ARGTYPE EMAKEHR(0x11c8) #define META_E_CA_INVALID_ARG_FOR_TYPE EMAKEHR(0x11c9) @@ -246,77 +97,18 @@ #define META_E_CA_INVALID_MARSHALAS_FIELDS EMAKEHR(0x11cb) #define META_E_CA_NT_FIELDONLY EMAKEHR(0x11cc) #define META_E_CA_NEGATIVE_PARAMINDEX EMAKEHR(0x11cd) -#define META_E_CA_NEGATIVE_MULTIPLIER EMAKEHR(0x11ce) #define META_E_CA_NEGATIVE_CONSTSIZE EMAKEHR(0x11cf) #define META_E_CA_FIXEDSTR_SIZE_REQUIRED EMAKEHR(0x11d0) #define META_E_CA_CUSTMARSH_TYPE_REQUIRED EMAKEHR(0x11d1) -#define META_E_CA_FILENAME_REQUIRED EMAKEHR(0x11d2) -#define TLBX_W_NO_PROPS_IN_EVENTS EMAKEHR(0x11d3) #define META_E_NOT_IN_ENC_MODE EMAKEHR(0x11d4) -#define META_E_METHOD_COUNTS EMAKEHR(0x11d6) -#define META_E_FIELD_COUNTS EMAKEHR(0x11d7) -#define META_E_PARAM_COUNTS EMAKEHR(0x11d8) -#define TLBX_E_TYPED_REF EMAKEHR(0x11da) -#define TLBX_E_BITNESS_MISMATCH EMAKEHR(0x11e1) -#define TLBX_E_EVENT_WITH_NEWENUM EMAKEHR(0x11e2) -#define TLBX_E_PROPGET_WITHOUT_RETURN EMAKEHR(0x11e3) -#define META_E_MISMATCHED_VISIBLITY EMAKEHR(0x11e4) #define META_E_CA_BAD_FRIENDS_ARGS EMAKEHR(0x11e5) #define META_E_CA_FRIENDS_SN_REQUIRED EMAKEHR(0x11e6) #define VLDTR_E_RID_OUTOFRANGE EMAKEHR(0x1203) -#define VLDTR_E_CDTKN_OUTOFRANGE EMAKEHR(0x1204) -#define VLDTR_E_CDRID_OUTOFRANGE EMAKEHR(0x1205) #define VLDTR_E_STRING_INVALID EMAKEHR(0x1206) #define VLDTR_E_GUID_INVALID EMAKEHR(0x1207) #define VLDTR_E_BLOB_INVALID EMAKEHR(0x1208) -#define VLDTR_E_MOD_MULTI EMAKEHR(0x1209) -#define VLDTR_E_MOD_NULLMVID EMAKEHR(0x120a) -#define VLDTR_E_TR_NAMENULL EMAKEHR(0x120b) -#define VLDTR_E_TR_DUP EMAKEHR(0x120c) -#define VLDTR_E_TD_NAMENULL EMAKEHR(0x120d) -#define VLDTR_E_TD_DUPNAME EMAKEHR(0x120e) -#define VLDTR_E_TD_DUPGUID EMAKEHR(0x120f) -#define VLDTR_E_TD_NOTIFACEOBJEXTNULL EMAKEHR(0x1210) -#define VLDTR_E_TD_OBJEXTENDSNONNULL EMAKEHR(0x1211) -#define VLDTR_E_TD_EXTENDSSEALED EMAKEHR(0x1212) -#define VLDTR_E_TD_DLTNORTSPCL EMAKEHR(0x1213) -#define VLDTR_E_TD_RTSPCLNOTDLT EMAKEHR(0x1214) -#define VLDTR_E_MI_DECLPRIV EMAKEHR(0x1215) -#define VLDTR_E_AS_BADNAME EMAKEHR(0x1216) -#define VLDTR_E_FILE_SYSNAME EMAKEHR(0x1217) -#define VLDTR_E_MI_BODYSTATIC EMAKEHR(0x1218) -#define VLDTR_E_TD_IFACENOTABS EMAKEHR(0x1219) -#define VLDTR_E_TD_IFACEPARNOTNIL EMAKEHR(0x121a) -#define VLDTR_E_TD_IFACEGUIDNULL EMAKEHR(0x121b) -#define VLDTR_E_MI_DECLFINAL EMAKEHR(0x121c) -#define VLDTR_E_TD_VTNOTSEAL EMAKEHR(0x121d) -#define VLDTR_E_PD_BADFLAGS EMAKEHR(0x121e) -#define VLDTR_E_IFACE_DUP EMAKEHR(0x121f) -#define VLDTR_E_MR_NAMENULL EMAKEHR(0x1220) -#define VLDTR_E_MR_VTBLNAME EMAKEHR(0x1221) -#define VLDTR_E_MR_DELNAME EMAKEHR(0x1222) -#define VLDTR_E_MR_PARNIL EMAKEHR(0x1223) #define VLDTR_E_MR_BADCALLINGCONV EMAKEHR(0x1224) -#define VLDTR_E_MR_NOTVARARG EMAKEHR(0x1225) -#define VLDTR_E_MR_NAMEDIFF EMAKEHR(0x1226) -#define VLDTR_E_MR_SIGDIFF EMAKEHR(0x1227) -#define VLDTR_E_MR_DUP EMAKEHR(0x1228) -#define VLDTR_E_CL_TDAUTO EMAKEHR(0x1229) -#define VLDTR_E_CL_BADPCKSZ EMAKEHR(0x122a) -#define VLDTR_E_CL_DUP EMAKEHR(0x122b) -#define VLDTR_E_FL_BADOFFSET EMAKEHR(0x122c) -#define VLDTR_E_FL_TDNIL EMAKEHR(0x122d) -#define VLDTR_E_FL_NOCL EMAKEHR(0x122e) -#define VLDTR_E_FL_TDNOTEXPLCT EMAKEHR(0x122f) -#define VLDTR_E_FL_FLDSTATIC EMAKEHR(0x1230) -#define VLDTR_E_FL_DUP EMAKEHR(0x1231) -#define VLDTR_E_MODREF_NAMENULL EMAKEHR(0x1232) -#define VLDTR_E_MODREF_DUP EMAKEHR(0x1233) -#define VLDTR_E_TR_BADSCOPE EMAKEHR(0x1234) -#define VLDTR_E_TD_NESTEDNOENCL EMAKEHR(0x1235) -#define VLDTR_E_TD_EXTTRRES EMAKEHR(0x1236) #define VLDTR_E_SIGNULL EMAKEHR(0x1237) -#define VLDTR_E_SIGNODATA EMAKEHR(0x1238) #define VLDTR_E_MD_BADCALLINGCONV EMAKEHR(0x1239) #define VLDTR_E_MD_THISSTATIC EMAKEHR(0x123a) #define VLDTR_E_MD_NOTTHISNOTSTATIC EMAKEHR(0x123b) @@ -332,187 +124,13 @@ #define VLDTR_E_SIG_MISSNLBND EMAKEHR(0x1245) #define VLDTR_E_SIG_MISSLBND EMAKEHR(0x1246) #define VLDTR_E_SIG_BADELTYPE EMAKEHR(0x1247) -#define VLDTR_E_SIG_MISSVASIZE EMAKEHR(0x1248) -#define VLDTR_E_FD_BADCALLINGCONV EMAKEHR(0x1249) -#define VLDTR_E_MD_NAMENULL EMAKEHR(0x124a) -#define VLDTR_E_MD_PARNIL EMAKEHR(0x124b) -#define VLDTR_E_MD_DUP EMAKEHR(0x124c) -#define VLDTR_E_FD_NAMENULL EMAKEHR(0x124d) -#define VLDTR_E_FD_PARNIL EMAKEHR(0x124e) -#define VLDTR_E_FD_DUP EMAKEHR(0x124f) -#define VLDTR_E_AS_MULTI EMAKEHR(0x1250) -#define VLDTR_E_AS_NAMENULL EMAKEHR(0x1251) -#define VLDTR_E_SIG_TOKTYPEMISMATCH EMAKEHR(0x1252) -#define VLDTR_E_CL_TDINTF EMAKEHR(0x1253) -#define VLDTR_E_ASOS_OSPLTFRMIDINVAL EMAKEHR(0x1254) -#define VLDTR_E_AR_NAMENULL EMAKEHR(0x1255) #define VLDTR_E_TD_ENCLNOTNESTED EMAKEHR(0x1256) -#define VLDTR_E_AROS_OSPLTFRMIDINVAL EMAKEHR(0x1257) -#define VLDTR_E_FILE_NAMENULL EMAKEHR(0x1258) -#define VLDTR_E_CT_NAMENULL EMAKEHR(0x1259) -#define VLDTR_E_TD_EXTENDSCHILD EMAKEHR(0x125a) -#define VLDTR_E_MAR_NAMENULL EMAKEHR(0x125b) -#define VLDTR_E_FILE_DUP EMAKEHR(0x125c) -#define VLDTR_E_FILE_NAMEFULLQLFD EMAKEHR(0x125d) -#define VLDTR_E_CT_DUP EMAKEHR(0x125e) -#define VLDTR_E_MAR_DUP EMAKEHR(0x125f) -#define VLDTR_E_MAR_NOTPUBPRIV EMAKEHR(0x1260) -#define VLDTR_E_TD_ENUMNOVALUE EMAKEHR(0x1261) -#define VLDTR_E_TD_ENUMVALSTATIC EMAKEHR(0x1262) -#define VLDTR_E_TD_ENUMVALNOTSN EMAKEHR(0x1263) -#define VLDTR_E_TD_ENUMFLDNOTST EMAKEHR(0x1264) -#define VLDTR_E_TD_ENUMFLDNOTLIT EMAKEHR(0x1265) -#define VLDTR_E_TD_ENUMNOLITFLDS EMAKEHR(0x1266) -#define VLDTR_E_TD_ENUMFLDSIGMISMATCH EMAKEHR(0x1267) -#define VLDTR_E_TD_ENUMVALNOT1ST EMAKEHR(0x1268) -#define VLDTR_E_FD_NOTVALUERTSN EMAKEHR(0x1269) -#define VLDTR_E_FD_VALUEPARNOTENUM EMAKEHR(0x126a) -#define VLDTR_E_FD_INSTINIFACE EMAKEHR(0x126b) -#define VLDTR_E_FD_NOTPUBINIFACE EMAKEHR(0x126c) -#define VLDTR_E_FMD_GLOBALNOTPUBPRIVSC EMAKEHR(0x126d) -#define VLDTR_E_FMD_GLOBALNOTSTATIC EMAKEHR(0x126e) -#define VLDTR_E_FD_GLOBALNORVA EMAKEHR(0x126f) -#define VLDTR_E_MD_CTORZERORVA EMAKEHR(0x1270) -#define VLDTR_E_FD_MARKEDNOMARSHAL EMAKEHR(0x1271) -#define VLDTR_E_FD_MARSHALNOTMARKED EMAKEHR(0x1272) -#define VLDTR_E_FD_MARKEDNODEFLT EMAKEHR(0x1273) -#define VLDTR_E_FD_DEFLTNOTMARKED EMAKEHR(0x1274) -#define VLDTR_E_FMD_MARKEDNOSECUR EMAKEHR(0x1275) -#define VLDTR_E_FMD_SECURNOTMARKED EMAKEHR(0x1276) #define VLDTR_E_FMD_PINVOKENOTSTATIC EMAKEHR(0x1277) -#define VLDTR_E_FMD_MARKEDNOPINVOKE EMAKEHR(0x1278) -#define VLDTR_E_FMD_PINVOKENOTMARKED EMAKEHR(0x1279) -#define VLDTR_E_FMD_BADIMPLMAP EMAKEHR(0x127a) -#define VLDTR_E_IMAP_BADMODREF EMAKEHR(0x127b) -#define VLDTR_E_IMAP_BADMEMBER EMAKEHR(0x127c) -#define VLDTR_E_IMAP_BADIMPORTNAME EMAKEHR(0x127d) -#define VLDTR_E_IMAP_BADCALLCONV EMAKEHR(0x127e) -#define VLDTR_E_FMD_BADACCESSFLAG EMAKEHR(0x127f) -#define VLDTR_E_FD_INITONLYANDLITERAL EMAKEHR(0x1280) -#define VLDTR_E_FD_LITERALNOTSTATIC EMAKEHR(0x1281) -#define VLDTR_E_FMD_RTSNNOTSN EMAKEHR(0x1282) -#define VLDTR_E_MD_ABSTPARNOTABST EMAKEHR(0x1283) -#define VLDTR_E_MD_NOTSTATABSTININTF EMAKEHR(0x1284) -#define VLDTR_E_MD_NOTPUBININTF EMAKEHR(0x1285) -#define VLDTR_E_MD_CTORININTF EMAKEHR(0x1286) -#define VLDTR_E_MD_GLOBALCTORCCTOR EMAKEHR(0x1287) -#define VLDTR_E_MD_CTORSTATIC EMAKEHR(0x1288) -#define VLDTR_E_MD_CTORNOTSNRTSN EMAKEHR(0x1289) -#define VLDTR_E_MD_CTORVIRT EMAKEHR(0x128a) -#define VLDTR_E_MD_CTORABST EMAKEHR(0x128b) -#define VLDTR_E_MD_CCTORNOTSTATIC EMAKEHR(0x128c) -#define VLDTR_E_MD_ZERORVA EMAKEHR(0x128d) -#define VLDTR_E_MD_FINNOTVIRT EMAKEHR(0x128e) -#define VLDTR_E_MD_STATANDFINORVIRT EMAKEHR(0x128f) -#define VLDTR_E_MD_ABSTANDFINAL EMAKEHR(0x1290) -#define VLDTR_E_MD_ABSTANDIMPL EMAKEHR(0x1291) -#define VLDTR_E_MD_ABSTANDPINVOKE EMAKEHR(0x1292) -#define VLDTR_E_MD_ABSTNOTVIRT EMAKEHR(0x1293) -#define VLDTR_E_MD_NOTABSTNOTIMPL EMAKEHR(0x1294) -#define VLDTR_E_MD_NOTABSTBADFLAGSRVA EMAKEHR(0x1295) -#define VLDTR_E_MD_PRIVSCOPENORVA EMAKEHR(0x1296) -#define VLDTR_E_MD_GLOBALABSTORVIRT EMAKEHR(0x1297) -#define VLDTR_E_SIG_LONGFORM EMAKEHR(0x1298) -#define VLDTR_E_MD_MULTIPLESEMANTICS EMAKEHR(0x1299) -#define VLDTR_E_MD_INVALIDSEMANTICS EMAKEHR(0x129a) -#define VLDTR_E_MD_SEMANTICSNOTEXIST EMAKEHR(0x129b) -#define VLDTR_E_MI_DECLNOTVIRT EMAKEHR(0x129c) -#define VLDTR_E_FMD_GLOBALITEM EMAKEHR(0x129d) -#define VLDTR_E_MD_MULTSEMANTICFLAGS EMAKEHR(0x129e) -#define VLDTR_E_MD_NOSEMANTICFLAGS EMAKEHR(0x129f) -#define VLDTR_E_FD_FLDINIFACE EMAKEHR(0x12a0) -#define VLDTR_E_AS_HASHALGID EMAKEHR(0x12a1) -#define VLDTR_E_AS_PROCID EMAKEHR(0x12a2) -#define VLDTR_E_AR_PROCID EMAKEHR(0x12a3) -#define VLDTR_E_CN_PARENTRANGE EMAKEHR(0x12a4) -#define VLDTR_E_AS_BADFLAGS EMAKEHR(0x12a5) -#define VLDTR_E_TR_HASTYPEDEF EMAKEHR(0x12a6) -#define VLDTR_E_IFACE_BADIMPL EMAKEHR(0x12a7) -#define VLDTR_E_IFACE_BADIFACE EMAKEHR(0x12a8) -#define VLDTR_E_TD_SECURNOTMARKED EMAKEHR(0x12a9) -#define VLDTR_E_TD_MARKEDNOSECUR EMAKEHR(0x12aa) -#define VLDTR_E_MD_CCTORHASARGS EMAKEHR(0x12ab) -#define VLDTR_E_CT_BADIMPL EMAKEHR(0x12ac) -#define VLDTR_E_MI_ALIENBODY EMAKEHR(0x12ad) -#define VLDTR_E_MD_CCTORCALLCONV EMAKEHR(0x12ae) -#define VLDTR_E_MI_BADCLASS EMAKEHR(0x12af) -#define VLDTR_E_MI_CLASSISINTF EMAKEHR(0x12b0) -#define VLDTR_E_MI_BADDECL EMAKEHR(0x12b1) -#define VLDTR_E_MI_BADBODY EMAKEHR(0x12b2) -#define VLDTR_E_MI_DUP EMAKEHR(0x12b3) -#define VLDTR_E_FD_BADPARENT EMAKEHR(0x12b4) -#define VLDTR_E_MD_PARAMOUTOFSEQ EMAKEHR(0x12b5) -#define VLDTR_E_MD_PARASEQTOOBIG EMAKEHR(0x12b6) -#define VLDTR_E_MD_PARMMARKEDNOMARSHAL EMAKEHR(0x12b7) -#define VLDTR_E_MD_PARMMARSHALNOTMARKED EMAKEHR(0x12b8) -#define VLDTR_E_MD_PARMMARKEDNODEFLT EMAKEHR(0x12ba) -#define VLDTR_E_MD_PARMDEFLTNOTMARKED EMAKEHR(0x12bb) -#define VLDTR_E_PR_BADSCOPE EMAKEHR(0x12bc) -#define VLDTR_E_PR_NONAME EMAKEHR(0x12bd) -#define VLDTR_E_PR_NOSIG EMAKEHR(0x12be) -#define VLDTR_E_PR_DUP EMAKEHR(0x12bf) -#define VLDTR_E_PR_BADCALLINGCONV EMAKEHR(0x12c0) -#define VLDTR_E_PR_MARKEDNODEFLT EMAKEHR(0x12c1) -#define VLDTR_E_PR_DEFLTNOTMARKED EMAKEHR(0x12c2) -#define VLDTR_E_PR_BADSEMANTICS EMAKEHR(0x12c3) -#define VLDTR_E_PR_BADMETHOD EMAKEHR(0x12c4) -#define VLDTR_E_PR_ALIENMETHOD EMAKEHR(0x12c5) -#define VLDTR_E_CN_BLOBNOTNULL EMAKEHR(0x12c6) -#define VLDTR_E_CN_BLOBNULL EMAKEHR(0x12c7) -#define VLDTR_E_EV_BADSCOPE EMAKEHR(0x12c8) -#define VLDTR_E_EV_NONAME EMAKEHR(0x12ca) -#define VLDTR_E_EV_DUP EMAKEHR(0x12cb) -#define VLDTR_E_EV_BADEVTYPE EMAKEHR(0x12cc) -#define VLDTR_E_EV_EVTYPENOTCLASS EMAKEHR(0x12cd) -#define VLDTR_E_EV_BADSEMANTICS EMAKEHR(0x12ce) -#define VLDTR_E_EV_BADMETHOD EMAKEHR(0x12cf) -#define VLDTR_E_EV_ALIENMETHOD EMAKEHR(0x12d0) -#define VLDTR_E_EV_NOADDON EMAKEHR(0x12d1) -#define VLDTR_E_EV_NOREMOVEON EMAKEHR(0x12d2) -#define VLDTR_E_CT_DUPTDNAME EMAKEHR(0x12d3) -#define VLDTR_E_MAR_BADOFFSET EMAKEHR(0x12d4) -#define VLDTR_E_DS_BADOWNER EMAKEHR(0x12d5) -#define VLDTR_E_DS_BADFLAGS EMAKEHR(0x12d6) -#define VLDTR_E_DS_NOBLOB EMAKEHR(0x12d7) -#define VLDTR_E_MAR_BADIMPL EMAKEHR(0x12d8) -#define VLDTR_E_MR_VARARGCALLINGCONV EMAKEHR(0x12da) -#define VLDTR_E_MD_CTORNOTVOID EMAKEHR(0x12db) -#define VLDTR_E_EV_FIRENOTVOID EMAKEHR(0x12dc) -#define VLDTR_E_AS_BADLOCALE EMAKEHR(0x12dd) -#define VLDTR_E_CN_PARENTTYPE EMAKEHR(0x12de) #define VLDTR_E_SIG_SENTINMETHODDEF EMAKEHR(0x12df) #define VLDTR_E_SIG_SENTMUSTVARARG EMAKEHR(0x12e0) #define VLDTR_E_SIG_MULTSENTINELS EMAKEHR(0x12e1) -#define VLDTR_E_SIG_LASTSENTINEL EMAKEHR(0x12e2) #define VLDTR_E_SIG_MISSARG EMAKEHR(0x12e3) #define VLDTR_E_SIG_BYREFINFIELD EMAKEHR(0x12e4) -#define VLDTR_E_MD_SYNCMETHODINVTYPE EMAKEHR(0x12e5) -#define VLDTR_E_TD_NAMETOOLONG EMAKEHR(0x12e6) -#define VLDTR_E_AS_PROCDUP EMAKEHR(0x12e7) -#define VLDTR_E_ASOS_DUP EMAKEHR(0x12e8) -#define VLDTR_E_MAR_BADFLAGS EMAKEHR(0x12e9) -#define VLDTR_E_CT_NOTYPEDEFID EMAKEHR(0x12ea) -#define VLDTR_E_FILE_BADFLAGS EMAKEHR(0x12eb) -#define VLDTR_E_FILE_NULLHASH EMAKEHR(0x12ec) -#define VLDTR_E_MOD_NONAME EMAKEHR(0x12ed) -#define VLDTR_E_MOD_NAMEFULLQLFD EMAKEHR(0x12ee) -#define VLDTR_E_TD_RTSPCLNOTSPCL EMAKEHR(0x12ef) -#define VLDTR_E_TD_EXTENDSIFACE EMAKEHR(0x12f0) -#define VLDTR_E_MD_CTORPINVOKE EMAKEHR(0x12f1) -#define VLDTR_E_TD_SYSENUMNOTCLASS EMAKEHR(0x12f2) -#define VLDTR_E_TD_SYSENUMNOTEXTVTYPE EMAKEHR(0x12f3) -#define VLDTR_E_MI_SIGMISMATCH EMAKEHR(0x12f4) -#define VLDTR_E_TD_ENUMHASMETHODS EMAKEHR(0x12f5) -#define VLDTR_E_TD_ENUMIMPLIFACE EMAKEHR(0x12f6) -#define VLDTR_E_TD_ENUMHASPROP EMAKEHR(0x12f7) -#define VLDTR_E_TD_ENUMHASEVENT EMAKEHR(0x12f8) -#define VLDTR_E_TD_BADMETHODLST EMAKEHR(0x12f9) -#define VLDTR_E_TD_BADFIELDLST EMAKEHR(0x12fa) -#define VLDTR_E_CN_BADTYPE EMAKEHR(0x12fb) -#define VLDTR_E_TD_ENUMNOINSTFLD EMAKEHR(0x12fc) -#define VLDTR_E_TD_ENUMMULINSTFLD EMAKEHR(0x12fd) -#define VLDTR_E_INTERRUPTED EMAKEHR(0x12fe) -#define VLDTR_E_NOTINIT EMAKEHR(0x12ff) #define CORDBG_E_UNRECOVERABLE_ERROR EMAKEHR(0x1300) #define CORDBG_E_PROCESS_TERMINATED EMAKEHR(0x1301) #define CORDBG_E_PROCESS_NOT_SYNCHRONIZED EMAKEHR(0x1302) @@ -521,7 +139,6 @@ #define CORDBG_E_BAD_REFERENCE_VALUE EMAKEHR(0x1305) #define CORDBG_E_FIELD_NOT_AVAILABLE EMAKEHR(0x1306) #define CORDBG_E_NON_NATIVE_FRAME EMAKEHR(0x1307) -#define CORDBG_E_NONCONTINUABLE_EXCEPTION EMAKEHR(0x1308) #define CORDBG_E_CODE_NOT_AVAILABLE EMAKEHR(0x1309) #define CORDBG_E_FUNCTION_NOT_IL EMAKEHR(0x130a) #define CORDBG_E_CANT_SET_IP_INTO_FINALLY EMAKEHR(0x130e) @@ -532,16 +149,11 @@ #define CORDBG_E_FUNC_EVAL_BAD_START_POINT EMAKEHR(0x1313) #define CORDBG_E_INVALID_OBJECT EMAKEHR(0x1314) #define CORDBG_E_FUNC_EVAL_NOT_COMPLETE EMAKEHR(0x1315) -#define CORDBG_E_INPROC_NOT_IMPL EMAKEHR(0x1318) #define CORDBG_E_STATIC_VAR_NOT_AVAILABLE EMAKEHR(0x131a) -#define CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS EMAKEHR(0x131b) #define CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER EMAKEHR(0x131c) #define CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE EMAKEHR(0x131d) #define CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY_ON_WIN64 EMAKEHR(0x131e) #define CORDBG_E_CANT_SET_IP_OUT_OF_CATCH_ON_WIN64 EMAKEHR(0x131f) -#define CORDBG_E_REMOTE_CONNECTION_CONN_RESET EMAKEHR(0x1320) -#define CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE EMAKEHR(0x1321) -#define CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR EMAKEHR(0x1322) #define CORDBG_E_CANT_SET_TO_JMC EMAKEHR(0x1323) #define CORDBG_E_NO_CONTEXT_FOR_INTERNAL_FRAME EMAKEHR(0x1325) #define CORDBG_E_NOT_CHILD_FRAME EMAKEHR(0x1326) @@ -552,32 +164,21 @@ #define CORDBG_E_DEBUGGER_ALREADY_ATTACHED EMAKEHR(0x132e) #define CORDBG_E_SUPERFLOUS_CONTINUE EMAKEHR(0x132f) #define CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME EMAKEHR(0x1330) -#define CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE EMAKEHR(0x1331) #define CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED EMAKEHR(0x1332) #define CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION EMAKEHR(0x1333) #define CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL EMAKEHR(0x1334) #define CORDBG_E_PROCESS_DETACHED EMAKEHR(0x1335) -#define CORDBG_E_ENC_METHOD_SIG_CHANGED EMAKEHR(0x1336) -#define CORDBG_E_ENC_METHOD_NO_LOCAL_SIG EMAKEHR(0x1337) #define CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS EMAKEHR(0x1338) -#define CORDBG_E_ENC_CANT_CHANGE_FIELD EMAKEHR(0x1339) -#define CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER EMAKEHR(0x133a) #define CORDBG_E_FIELD_NOT_STATIC EMAKEHR(0x133b) #define CORDBG_E_FIELD_NOT_INSTANCE EMAKEHR(0x133c) -#define CORDBG_E_ENC_ZAPPED_WITHOUT_ENC EMAKEHR(0x133d) -#define CORDBG_E_ENC_BAD_METHOD_INFO EMAKEHR(0x133e) #define CORDBG_E_ENC_JIT_CANT_UPDATE EMAKEHR(0x133f) -#define CORDBG_E_ENC_MISSING_CLASS EMAKEHR(0x1340) #define CORDBG_E_ENC_INTERNAL_ERROR EMAKEHR(0x1341) #define CORDBG_E_ENC_HANGING_FIELD EMAKEHR(0x1342) #define CORDBG_E_MODULE_NOT_LOADED EMAKEHR(0x1343) -#define CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS EMAKEHR(0x1344) #define CORDBG_E_UNABLE_TO_SET_BREAKPOINT EMAKEHR(0x1345) #define CORDBG_E_DEBUGGING_NOT_POSSIBLE EMAKEHR(0x1346) #define CORDBG_E_KERNEL_DEBUGGER_ENABLED EMAKEHR(0x1347) #define CORDBG_E_KERNEL_DEBUGGER_PRESENT EMAKEHR(0x1348) -#define CORDBG_E_HELPER_THREAD_DEAD EMAKEHR(0x1349) -#define CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE EMAKEHR(0x134a) #define CORDBG_E_INCOMPATIBLE_PROTOCOL EMAKEHR(0x134b) #define CORDBG_E_TOO_MANY_PROCESSES EMAKEHR(0x134c) #define CORDBG_E_INTEROP_NOT_SUPPORTED EMAKEHR(0x134d) @@ -585,15 +186,9 @@ #define CORDBG_E_OBJECT_NEUTERED EMAKEHR(0x134f) #define CORPROF_E_FUNCTION_NOT_COMPILED EMAKEHR(0x1350) #define CORPROF_E_DATAINCOMPLETE EMAKEHR(0x1351) -#define CORPROF_E_NOT_REJITABLE_METHODS EMAKEHR(0x1352) -#define CORPROF_E_CANNOT_UPDATE_METHOD EMAKEHR(0x1353) #define CORPROF_E_FUNCTION_NOT_IL EMAKEHR(0x1354) #define CORPROF_E_NOT_MANAGED_THREAD EMAKEHR(0x1355) #define CORPROF_E_CALL_ONLY_FROM_INIT EMAKEHR(0x1356) -#define CORPROF_E_INPROC_NOT_ENABLED EMAKEHR(0x1357) -#define CORPROF_E_JITMAPS_NOT_ENABLED EMAKEHR(0x1358) -#define CORPROF_E_INPROC_ALREADY_BEGUN EMAKEHR(0x1359) -#define CORPROF_E_INPROC_NOT_AVAILABLE EMAKEHR(0x135a) #define CORPROF_E_NOT_YET_AVAILABLE EMAKEHR(0x135b) #define CORPROF_E_TYPE_IS_PARAMETERIZED EMAKEHR(0x135c) #define CORPROF_E_FUNCTION_IS_PARAMETERIZED EMAKEHR(0x135d) @@ -622,91 +217,29 @@ #define CORPROF_E_INCONSISTENT_WITH_FLAGS EMAKEHR(0x1374) #define CORPROF_E_PROFILER_CANCEL_ACTIVATION EMAKEHR(0x1375) #define CORPROF_E_CONCURRENT_GC_NOT_PROFILABLE EMAKEHR(0x1376) -#define CORPROF_E_INCONSISTENT_FLAGS_WITH_HOST_PROTECTION_SETTING EMAKEHR(0x1377) #define CORPROF_E_DEBUGGING_DISABLED EMAKEHR(0x1378) #define CORPROF_E_TIMEOUT_WAITING_FOR_CONCURRENT_GC EMAKEHR(0x1379) #define CORPROF_E_MODULE_IS_DYNAMIC EMAKEHR(0x137a) #define CORPROF_E_CALLBACK4_REQUIRED EMAKEHR(0x137b) #define CORPROF_E_REJIT_NOT_ENABLED EMAKEHR(0x137c) -#define CORPROF_E_ACTIVE_REJIT_REQUEST_NOT_FOUND EMAKEHR(0x137d) #define CORPROF_E_FUNCTION_IS_COLLECTIBLE EMAKEHR(0x137e) -#define CORPROF_E_REJIT_REQUIRES_DISABLE_NGEN EMAKEHR(0x137f) #define CORPROF_E_CALLBACK6_REQUIRED EMAKEHR(0x1380) #define CORPROF_E_CALLBACK7_REQUIRED EMAKEHR(0x1382) -#define SECURITY_E_XML_TO_ASN_ENCODING EMAKEHR(0x1400) #define SECURITY_E_INCOMPATIBLE_SHARE EMAKEHR(0x1401) #define SECURITY_E_UNVERIFIABLE EMAKEHR(0x1402) #define SECURITY_E_INCOMPATIBLE_EVIDENCE EMAKEHR(0x1403) -#define CORSEC_E_DECODE_SET EMAKEHR(0x1410) -#define CORSEC_E_ENCODE_SET EMAKEHR(0x1411) -#define CORSEC_E_UNSUPPORTED_FORMAT EMAKEHR(0x1412) -#define SN_CRYPTOAPI_CALL_FAILED EMAKEHR(0x1413) -#define CORSEC_E_CRYPTOAPI_CALL_FAILED EMAKEHR(0x1413) -#define SN_NO_SUITABLE_CSP EMAKEHR(0x1414) -#define CORSEC_E_NO_SUITABLE_CSP EMAKEHR(0x1414) -#define CORSEC_E_INVALID_ATTR EMAKEHR(0x1415) #define CORSEC_E_POLICY_EXCEPTION EMAKEHR(0x1416) #define CORSEC_E_MIN_GRANT_FAIL EMAKEHR(0x1417) #define CORSEC_E_NO_EXEC_PERM EMAKEHR(0x1418) #define CORSEC_E_XMLSYNTAX EMAKEHR(0x1419) #define CORSEC_E_INVALID_STRONGNAME EMAKEHR(0x141a) #define CORSEC_E_MISSING_STRONGNAME EMAKEHR(0x141b) -#define CORSEC_E_CONTAINER_NOT_FOUND EMAKEHR(0x141c) #define CORSEC_E_INVALID_IMAGE_FORMAT EMAKEHR(0x141d) #define CORSEC_E_INVALID_PUBLICKEY EMAKEHR(0x141e) #define CORSEC_E_SIGNATURE_MISMATCH EMAKEHR(0x1420) -#define SN_E_PUBLICKEY_MISMATCH EMAKEHR(0x1421) -#define CORSEC_E_INVALID_SIGNATUREKEY EMAKEHR(0x1422) -#define CORSEC_E_INVALID_COUNTERSIGNATURE EMAKEHR(0x1423) #define CORSEC_E_CRYPTO EMAKEHR(0x1430) #define CORSEC_E_CRYPTO_UNEX_OPER EMAKEHR(0x1431) -#define CORSECATTR_E_BAD_ATTRIBUTE EMAKEHR(0x143a) -#define CORSECATTR_E_MISSING_CONSTRUCTOR EMAKEHR(0x143b) -#define CORSECATTR_E_FAILED_TO_CREATE_PERM EMAKEHR(0x143c) -#define CORSECATTR_E_BAD_ACTION_ASM EMAKEHR(0x143d) -#define CORSECATTR_E_BAD_ACTION_OTHER EMAKEHR(0x143e) -#define CORSECATTR_E_BAD_PARENT EMAKEHR(0x143f) -#define CORSECATTR_E_TRUNCATED EMAKEHR(0x1440) -#define CORSECATTR_E_BAD_VERSION EMAKEHR(0x1441) #define CORSECATTR_E_BAD_ACTION EMAKEHR(0x1442) -#define CORSECATTR_E_NO_SELF_REF EMAKEHR(0x1443) -#define CORSECATTR_E_BAD_NONCAS EMAKEHR(0x1444) -#define CORSECATTR_E_ASSEMBLY_LOAD_FAILED EMAKEHR(0x1445) -#define CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX EMAKEHR(0x1446) -#define CORSECATTR_E_TYPE_LOAD_FAILED EMAKEHR(0x1447) -#define CORSECATTR_E_TYPE_LOAD_FAILED_EX EMAKEHR(0x1448) -#define CORSECATTR_E_ABSTRACT EMAKEHR(0x1449) -#define CORSECATTR_E_UNSUPPORTED_TYPE EMAKEHR(0x144a) -#define CORSECATTR_E_UNSUPPORTED_ENUM_TYPE EMAKEHR(0x144b) -#define CORSECATTR_E_NO_FIELD EMAKEHR(0x144c) -#define CORSECATTR_E_NO_PROPERTY EMAKEHR(0x144d) -#define CORSECATTR_E_EXCEPTION EMAKEHR(0x144e) -#define CORSECATTR_E_EXCEPTION_HR EMAKEHR(0x144f) -#define ISS_E_ISOSTORE_START EMAKEHR(0x1450) -#define ISS_E_ISOSTORE EMAKEHR(0x1450) -#define ISS_E_OPEN_STORE_FILE EMAKEHR(0x1460) -#define ISS_E_OPEN_FILE_MAPPING EMAKEHR(0x1461) -#define ISS_E_MAP_VIEW_OF_FILE EMAKEHR(0x1462) -#define ISS_E_GET_FILE_SIZE EMAKEHR(0x1463) -#define ISS_E_CREATE_MUTEX EMAKEHR(0x1464) -#define ISS_E_LOCK_FAILED EMAKEHR(0x1465) -#define ISS_E_FILE_WRITE EMAKEHR(0x1466) -#define ISS_E_SET_FILE_POINTER EMAKEHR(0x1467) -#define ISS_E_CREATE_DIR EMAKEHR(0x1468) -#define ISS_E_STORE_NOT_OPEN EMAKEHR(0x1469) -#define ISS_E_CORRUPTED_STORE_FILE EMAKEHR(0x1480) -#define ISS_E_STORE_VERSION EMAKEHR(0x1481) -#define ISS_E_FILE_NOT_MAPPED EMAKEHR(0x1482) -#define ISS_E_BLOCK_SIZE_TOO_SMALL EMAKEHR(0x1483) -#define ISS_E_ALLOC_TOO_LARGE EMAKEHR(0x1484) -#define ISS_E_USAGE_WILL_EXCEED_QUOTA EMAKEHR(0x1485) -#define ISS_E_TABLE_ROW_NOT_FOUND EMAKEHR(0x1486) -#define ISS_E_DEPRECATE EMAKEHR(0x14a0) -#define ISS_E_CALLER EMAKEHR(0x14a1) -#define ISS_E_PATH_LENGTH EMAKEHR(0x14a2) -#define ISS_E_MACHINE EMAKEHR(0x14a3) -#define ISS_E_MACHINE_DACL EMAKEHR(0x14a4) -#define ISS_E_ISOSTORE_END EMAKEHR(0x14ff) #define COR_E_EXCEPTION EMAKEHR(0x1500) #define COR_E_SYSTEM EMAKEHR(0x1501) #define COR_E_ARGUMENTOUTOFRANGE EMAKEHR(0x1502) @@ -718,11 +251,8 @@ #define COR_E_INDEXOUTOFRANGE EMAKEHR(0x1508) #define COR_E_INVALIDOPERATION EMAKEHR(0x1509) #define COR_E_SECURITY EMAKEHR(0x150a) -#define COR_E_REMOTING EMAKEHR(0x150b) #define COR_E_SERIALIZATION EMAKEHR(0x150c) #define COR_E_VERIFICATION EMAKEHR(0x150d) -#define COR_E_SERVER EMAKEHR(0x150e) -#define COR_E_SERVICEDCOMPONENT EMAKEHR(0x150f) #define COR_E_METHODACCESS EMAKEHR(0x1510) #define COR_E_MISSINGFIELD EMAKEHR(0x1511) #define COR_E_MISSINGMEMBER EMAKEHR(0x1512) @@ -760,12 +290,10 @@ #define COR_E_OPERATIONCANCELED EMAKEHR(0x153b) #define COR_E_INSUFFICIENTMEMORY EMAKEHR(0x153d) #define COR_E_RUNTIMEWRAPPED EMAKEHR(0x153e) -#define COR_E_DEVICESNOTSUPPORTED EMAKEHR(0x1540) #define COR_E_DATAMISALIGNED EMAKEHR(0x1541) #define COR_E_CODECONTRACTFAILED EMAKEHR(0x1542) #define COR_E_TYPEACCESS EMAKEHR(0x1543) #define COR_E_ACCESSING_CCW EMAKEHR(0x1544) -#define COR_E_MAXMETHODSIZE EMAKEHR(0x1545) #define COR_E_KEYNOTFOUND EMAKEHR(0x1577) #define COR_E_INSUFFICIENTEXECUTIONSTACK EMAKEHR(0x1578) #define COR_E_APPLICATION EMAKEHR(0x1600) @@ -781,347 +309,16 @@ #define COR_E_HOSTPROTECTION EMAKEHR(0x1640) #define COR_E_ILLEGAL_REENTRANCY EMAKEHR(0x1641) #define CLR_E_SHIM_RUNTIMELOAD EMAKEHR(0x1700) -#define CLR_E_SHIM_RUNTIMEEXPORT EMAKEHR(0x1701) -#define CLR_E_SHIM_INSTALLROOT EMAKEHR(0x1702) -#define CLR_E_SHIM_INSTALLCOMP EMAKEHR(0x1703) #define CLR_E_SHIM_LEGACYRUNTIMEALREADYBOUND EMAKEHR(0x1704) -#define CLR_E_SHIM_SHUTDOWNINPROGRESS EMAKEHR(0x1705) -#define VER_E_HRESULT EMAKEHR(0x1801) -#define VER_E_OFFSET EMAKEHR(0x1802) -#define VER_E_OPCODE EMAKEHR(0x1803) -#define VER_E_OPERAND EMAKEHR(0x1804) -#define VER_E_TOKEN EMAKEHR(0x1805) -#define VER_E_EXCEPT EMAKEHR(0x1806) -#define VER_E_STACK_SLOT EMAKEHR(0x1807) -#define VER_E_LOC EMAKEHR(0x1808) -#define VER_E_ARG EMAKEHR(0x1809) -#define VER_E_FOUND EMAKEHR(0x180a) -#define VER_E_EXPECTED EMAKEHR(0x180b) -#define VER_E_LOC_BYNAME EMAKEHR(0x180c) -#define VER_E_UNKNOWN_OPCODE EMAKEHR(0x1810) -#define VER_E_SIG_CALLCONV EMAKEHR(0x1811) -#define VER_E_SIG_ELEMTYPE EMAKEHR(0x1812) -#define VER_E_RET_SIG EMAKEHR(0x1814) #define VER_E_FIELD_SIG EMAKEHR(0x1815) -#define VER_E_OPEN_DLGT_PROT_ACC EMAKEHR(0x1816) -#define VER_E_INTERNAL EMAKEHR(0x1818) -#define VER_E_STACK_TOO_LARGE EMAKEHR(0x1819) -#define VER_E_ARRAY_NAME_LONG EMAKEHR(0x181a) -#define VER_E_FALLTHRU EMAKEHR(0x1820) -#define VER_E_TRY_GTEQ_END EMAKEHR(0x1821) -#define VER_E_TRYEND_GT_CS EMAKEHR(0x1822) -#define VER_E_HND_GTEQ_END EMAKEHR(0x1823) -#define VER_E_HNDEND_GT_CS EMAKEHR(0x1824) -#define VER_E_FLT_GTEQ_CS EMAKEHR(0x1825) -#define VER_E_TRY_START EMAKEHR(0x1826) -#define VER_E_HND_START EMAKEHR(0x1827) -#define VER_E_FLT_START EMAKEHR(0x1828) -#define VER_E_TRY_OVERLAP EMAKEHR(0x1829) -#define VER_E_TRY_EQ_HND_FIL EMAKEHR(0x182a) -#define VER_E_TRY_SHARE_FIN_FAL EMAKEHR(0x182b) -#define VER_E_HND_OVERLAP EMAKEHR(0x182c) -#define VER_E_HND_EQ EMAKEHR(0x182d) -#define VER_E_FIL_OVERLAP EMAKEHR(0x182e) -#define VER_E_FIL_EQ EMAKEHR(0x182f) -#define VER_E_FIL_CONT_TRY EMAKEHR(0x1830) -#define VER_E_FIL_CONT_HND EMAKEHR(0x1831) -#define VER_E_FIL_CONT_FIL EMAKEHR(0x1832) -#define VER_E_FIL_GTEQ_CS EMAKEHR(0x1833) -#define VER_E_FIL_START EMAKEHR(0x1834) -#define VER_E_FALLTHRU_EXCEP EMAKEHR(0x1835) -#define VER_E_FALLTHRU_INTO_HND EMAKEHR(0x1836) -#define VER_E_FALLTHRU_INTO_FIL EMAKEHR(0x1837) -#define VER_E_LEAVE EMAKEHR(0x1838) -#define VER_E_RETHROW EMAKEHR(0x1839) -#define VER_E_ENDFINALLY EMAKEHR(0x183a) -#define VER_E_ENDFILTER EMAKEHR(0x183b) -#define VER_E_ENDFILTER_MISSING EMAKEHR(0x183c) -#define VER_E_BR_INTO_TRY EMAKEHR(0x183d) -#define VER_E_BR_INTO_HND EMAKEHR(0x183e) -#define VER_E_BR_INTO_FIL EMAKEHR(0x183f) -#define VER_E_BR_OUTOF_TRY EMAKEHR(0x1840) -#define VER_E_BR_OUTOF_HND EMAKEHR(0x1841) -#define VER_E_BR_OUTOF_FIL EMAKEHR(0x1842) -#define VER_E_BR_OUTOF_FIN EMAKEHR(0x1843) -#define VER_E_RET_FROM_TRY EMAKEHR(0x1844) -#define VER_E_RET_FROM_HND EMAKEHR(0x1845) -#define VER_E_RET_FROM_FIL EMAKEHR(0x1846) -#define VER_E_BAD_JMP_TARGET EMAKEHR(0x1847) -#define VER_E_PATH_LOC EMAKEHR(0x1848) -#define VER_E_PATH_THIS EMAKEHR(0x1849) -#define VER_E_PATH_STACK EMAKEHR(0x184a) -#define VER_E_PATH_STACK_DEPTH EMAKEHR(0x184b) -#define VER_E_THIS EMAKEHR(0x184c) -#define VER_E_THIS_UNINIT_EXCEP EMAKEHR(0x184d) -#define VER_E_THIS_UNINIT_STORE EMAKEHR(0x184e) -#define VER_E_THIS_UNINIT_RET EMAKEHR(0x184f) -#define VER_E_THIS_UNINIT_V_RET EMAKEHR(0x1850) -#define VER_E_THIS_UNINIT_BR EMAKEHR(0x1851) -#define VER_E_LDFTN_CTOR EMAKEHR(0x1852) -#define VER_E_STACK_NOT_EQ EMAKEHR(0x1853) -#define VER_E_STACK_UNEXPECTED EMAKEHR(0x1854) -#define VER_E_STACK_EXCEPTION EMAKEHR(0x1855) -#define VER_E_STACK_OVERFLOW EMAKEHR(0x1856) -#define VER_E_STACK_UNDERFLOW EMAKEHR(0x1857) -#define VER_E_STACK_EMPTY EMAKEHR(0x1858) -#define VER_E_STACK_UNINIT EMAKEHR(0x1859) -#define VER_E_STACK_I_I4_I8 EMAKEHR(0x185a) -#define VER_E_STACK_R_R4_R8 EMAKEHR(0x185b) -#define VER_E_STACK_NO_R_I8 EMAKEHR(0x185c) -#define VER_E_STACK_NUMERIC EMAKEHR(0x185d) -#define VER_E_STACK_OBJREF EMAKEHR(0x185e) -#define VER_E_STACK_P_OBJREF EMAKEHR(0x185f) -#define VER_E_STACK_BYREF EMAKEHR(0x1860) -#define VER_E_STACK_METHOD EMAKEHR(0x1861) -#define VER_E_STACK_ARRAY_SD EMAKEHR(0x1862) -#define VER_E_STACK_VALCLASS EMAKEHR(0x1863) -#define VER_E_STACK_P_VALCLASS EMAKEHR(0x1864) -#define VER_E_STACK_NO_VALCLASS EMAKEHR(0x1865) -#define VER_E_LOC_DEAD EMAKEHR(0x1866) -#define VER_E_LOC_NUM EMAKEHR(0x1867) -#define VER_E_ARG_NUM EMAKEHR(0x1868) -#define VER_E_TOKEN_RESOLVE EMAKEHR(0x1869) -#define VER_E_TOKEN_TYPE EMAKEHR(0x186a) -#define VER_E_TOKEN_TYPE_MEMBER EMAKEHR(0x186b) -#define VER_E_TOKEN_TYPE_FIELD EMAKEHR(0x186c) -#define VER_E_TOKEN_TYPE_SIG EMAKEHR(0x186d) -#define VER_E_UNVERIFIABLE EMAKEHR(0x186e) -#define VER_E_LDSTR_OPERAND EMAKEHR(0x186f) -#define VER_E_RET_PTR_TO_STACK EMAKEHR(0x1870) -#define VER_E_RET_VOID EMAKEHR(0x1871) -#define VER_E_RET_MISSING EMAKEHR(0x1872) -#define VER_E_RET_EMPTY EMAKEHR(0x1873) -#define VER_E_RET_UNINIT EMAKEHR(0x1874) -#define VER_E_ARRAY_ACCESS EMAKEHR(0x1875) -#define VER_E_ARRAY_V_STORE EMAKEHR(0x1876) -#define VER_E_ARRAY_SD EMAKEHR(0x1877) -#define VER_E_ARRAY_SD_PTR EMAKEHR(0x1878) -#define VER_E_ARRAY_FIELD EMAKEHR(0x1879) -#define VER_E_ARGLIST EMAKEHR(0x187a) -#define VER_E_VALCLASS EMAKEHR(0x187b) -#define VER_E_METHOD_ACCESS EMAKEHR(0x187c) -#define VER_E_FIELD_ACCESS EMAKEHR(0x187d) -#define VER_E_DEAD EMAKEHR(0x187e) -#define VER_E_FIELD_STATIC EMAKEHR(0x187f) -#define VER_E_FIELD_NO_STATIC EMAKEHR(0x1880) -#define VER_E_ADDR EMAKEHR(0x1881) -#define VER_E_ADDR_BYREF EMAKEHR(0x1882) -#define VER_E_ADDR_LITERAL EMAKEHR(0x1883) -#define VER_E_INITONLY EMAKEHR(0x1884) -#define VER_E_THROW EMAKEHR(0x1885) -#define VER_E_CALLVIRT_VALCLASS EMAKEHR(0x1886) -#define VER_E_CALL_SIG EMAKEHR(0x1887) -#define VER_E_CALL_STATIC EMAKEHR(0x1888) -#define VER_E_CTOR EMAKEHR(0x1889) -#define VER_E_CTOR_VIRT EMAKEHR(0x188a) -#define VER_E_CTOR_OR_SUPER EMAKEHR(0x188b) -#define VER_E_CTOR_MUL_INIT EMAKEHR(0x188c) -#define VER_E_SIG EMAKEHR(0x188d) -#define VER_E_SIG_ARRAY EMAKEHR(0x188e) -#define VER_E_SIG_ARRAY_PTR EMAKEHR(0x188f) -#define VER_E_SIG_ARRAY_BYREF EMAKEHR(0x1890) -#define VER_E_SIG_ELEM_PTR EMAKEHR(0x1891) -#define VER_E_SIG_VARARG EMAKEHR(0x1892) -#define VER_E_SIG_VOID EMAKEHR(0x1893) -#define VER_E_SIG_BYREF_BYREF EMAKEHR(0x1894) -#define VER_E_CODE_SIZE_ZERO EMAKEHR(0x1896) -#define VER_E_BAD_VARARG EMAKEHR(0x1897) -#define VER_E_TAIL_CALL EMAKEHR(0x1898) -#define VER_E_TAIL_BYREF EMAKEHR(0x1899) -#define VER_E_TAIL_RET EMAKEHR(0x189a) -#define VER_E_TAIL_RET_VOID EMAKEHR(0x189b) -#define VER_E_TAIL_RET_TYPE EMAKEHR(0x189c) -#define VER_E_TAIL_STACK_EMPTY EMAKEHR(0x189d) -#define VER_E_METHOD_END EMAKEHR(0x189e) -#define VER_E_BAD_BRANCH EMAKEHR(0x189f) -#define VER_E_FIN_OVERLAP EMAKEHR(0x18a0) -#define VER_E_LEXICAL_NESTING EMAKEHR(0x18a1) -#define VER_E_VOLATILE EMAKEHR(0x18a2) -#define VER_E_UNALIGNED EMAKEHR(0x18a3) -#define VER_E_INNERMOST_FIRST EMAKEHR(0x18a4) -#define VER_E_CALLI_VIRTUAL EMAKEHR(0x18a5) -#define VER_E_CALL_ABSTRACT EMAKEHR(0x18a6) -#define VER_E_STACK_UNEXP_ARRAY EMAKEHR(0x18a7) -#define VER_E_NOT_IN_GC_HEAP EMAKEHR(0x18a8) -#define VER_E_TRY_N_EMPTY_STACK EMAKEHR(0x18a9) -#define VER_E_DLGT_CTOR EMAKEHR(0x18aa) -#define VER_E_DLGT_BB EMAKEHR(0x18ab) -#define VER_E_DLGT_PATTERN EMAKEHR(0x18ac) -#define VER_E_DLGT_LDFTN EMAKEHR(0x18ad) -#define VER_E_FTN_ABSTRACT EMAKEHR(0x18ae) -#define VER_E_SIG_C_VC EMAKEHR(0x18af) -#define VER_E_SIG_VC_C EMAKEHR(0x18b0) -#define VER_E_BOX_PTR_TO_STACK EMAKEHR(0x18b1) -#define VER_E_SIG_BYREF_TB_AH EMAKEHR(0x18b2) -#define VER_E_SIG_ARRAY_TB_AH EMAKEHR(0x18b3) -#define VER_E_ENDFILTER_STACK EMAKEHR(0x18b4) -#define VER_E_DLGT_SIG_I EMAKEHR(0x18b5) -#define VER_E_DLGT_SIG_O EMAKEHR(0x18b6) -#define VER_E_RA_PTR_TO_STACK EMAKEHR(0x18b7) -#define VER_E_CATCH_VALUE_TYPE EMAKEHR(0x18b8) -#define VER_E_CATCH_BYREF EMAKEHR(0x18b9) -#define VER_E_FIL_PRECEED_HND EMAKEHR(0x18ba) -#define VER_E_LDVIRTFTN_STATIC EMAKEHR(0x18bb) -#define VER_E_CALLVIRT_STATIC EMAKEHR(0x18bc) -#define VER_E_INITLOCALS EMAKEHR(0x18bd) -#define VER_E_BR_TO_EXCEPTION EMAKEHR(0x18be) -#define VER_E_CALL_CTOR EMAKEHR(0x18bf) -#define VER_E_VALCLASS_OBJREF_VAR EMAKEHR(0x18c0) -#define VER_E_STACK_P_VALCLASS_OBJREF_VAR EMAKEHR(0x18c1) -#define VER_E_SIG_VAR_PARAM EMAKEHR(0x18c2) -#define VER_E_SIG_MVAR_PARAM EMAKEHR(0x18c3) -#define VER_E_SIG_VAR_ARG EMAKEHR(0x18c4) -#define VER_E_SIG_MVAR_ARG EMAKEHR(0x18c5) -#define VER_E_SIG_GENERICINST EMAKEHR(0x18c6) -#define VER_E_SIG_METHOD_INST EMAKEHR(0x18c7) -#define VER_E_SIG_METHOD_PARENT_INST EMAKEHR(0x18c8) -#define VER_E_SIG_FIELD_PARENT_INST EMAKEHR(0x18c9) -#define VER_E_CALLCONV_NOT_GENERICINST EMAKEHR(0x18ca) -#define VER_E_TOKEN_BAD_METHOD_SPEC EMAKEHR(0x18cb) -#define VER_E_BAD_READONLY_PREFIX EMAKEHR(0x18cc) -#define VER_E_BAD_CONSTRAINED_PREFIX EMAKEHR(0x18cd) #define VER_E_CIRCULAR_VAR_CONSTRAINTS EMAKEHR(0x18ce) #define VER_E_CIRCULAR_MVAR_CONSTRAINTS EMAKEHR(0x18cf) -#define VER_E_UNSATISFIED_METHOD_INST EMAKEHR(0x18d0) -#define VER_E_UNSATISFIED_METHOD_PARENT_INST EMAKEHR(0x18d1) -#define VER_E_UNSATISFIED_FIELD_PARENT_INST EMAKEHR(0x18d2) -#define VER_E_UNSATISFIED_BOX_OPERAND EMAKEHR(0x18d3) -#define VER_E_CONSTRAINED_CALL_WITH_NON_BYREF_THIS EMAKEHR(0x18d4) -#define VER_E_CONSTRAINED_OF_NON_VARIABLE_TYPE EMAKEHR(0x18d5) -#define VER_E_READONLY_UNEXPECTED_CALLEE EMAKEHR(0x18d6) -#define VER_E_READONLY_ILLEGAL_WRITE EMAKEHR(0x18d7) -#define VER_E_READONLY_IN_MKREFANY EMAKEHR(0x18d8) -#define VER_E_UNALIGNED_ALIGNMENT EMAKEHR(0x18d9) -#define VER_E_TAILCALL_INSIDE_EH EMAKEHR(0x18da) -#define VER_E_BACKWARD_BRANCH EMAKEHR(0x18db) -#define VER_E_CALL_TO_VTYPE_BASE EMAKEHR(0x18dc) -#define VER_E_NEWOBJ_OF_ABSTRACT_CLASS EMAKEHR(0x18dd) -#define VER_E_UNMANAGED_POINTER EMAKEHR(0x18de) -#define VER_E_LDFTN_NON_FINAL_VIRTUAL EMAKEHR(0x18df) -#define VER_E_FIELD_OVERLAP EMAKEHR(0x18e0) -#define VER_E_THIS_MISMATCH EMAKEHR(0x18e1) -#define VER_E_STACK_I_I4 EMAKEHR(0x18e2) -#define VER_E_BAD_PE EMAKEHR(0x18f0) -#define VER_E_BAD_MD EMAKEHR(0x18f1) -#define VER_E_BAD_APPDOMAIN EMAKEHR(0x18f2) -#define VER_E_TYPELOAD EMAKEHR(0x18f3) -#define VER_E_PE_LOAD EMAKEHR(0x18f4) -#define VER_E_WRITE_RVA_STATIC EMAKEHR(0x18f5) -#define VER_E_INITIALIZE_ARRAY_MISSING_TOKEN EMAKEHR(0x18f6) -#define COR_E_SqlException EMAKEHR(0x1904) #define COR_E_Data EMAKEHR(0x1920) -#define COR_E_DataDeletedRowInaccessible EMAKEHR(0x1921) -#define COR_E_DataDuplicateName EMAKEHR(0x1922) -#define COR_E_DataInRowChangingEvent EMAKEHR(0x1923) -#define COR_E_DataInvalidConstraint EMAKEHR(0x1924) -#define COR_E_DataMissingPrimaryKey EMAKEHR(0x1925) -#define COR_E_DataNoNullAllowed EMAKEHR(0x1926) -#define COR_E_DataReadOnly EMAKEHR(0x1927) -#define COR_E_DataRowNotInTable EMAKEHR(0x1928) -#define COR_E_DataVersionNotFound EMAKEHR(0x1929) -#define COR_E_DataConstraint EMAKEHR(0x192a) -#define COR_E_StrongTyping EMAKEHR(0x192b) -#define COR_E_SqlType EMAKEHR(0x1930) -#define COR_E_SqlNullValue EMAKEHR(0x1931) -#define COR_E_SqlTruncate EMAKEHR(0x1932) -#define COR_E_AdapterMapping EMAKEHR(0x1933) -#define COR_E_DataAdapter EMAKEHR(0x1934) -#define COR_E_DBConcurrency EMAKEHR(0x1935) -#define COR_E_OperationAborted EMAKEHR(0x1936) -#define COR_E_InvalidUdt EMAKEHR(0x1937) -#define COR_E_OdbcException EMAKEHR(0x1937) -#define COR_E_OracleException EMAKEHR(0x1938) -#define COR_E_Xml EMAKEHR(0x1940) -#define COR_E_XmlSchema EMAKEHR(0x1941) -#define COR_E_XmlXslt EMAKEHR(0x1942) -#define COR_E_XmlXPath EMAKEHR(0x1943) -#define COR_E_XmlQuery EMAKEHR(0x1944) -#define VLDTR_E_IFACE_NOTIFACE EMAKEHR(0x1b00) -#define VLDTR_E_FD_RVAHASNORVA EMAKEHR(0x1b01) -#define VLDTR_E_FD_RVAHASZERORVA EMAKEHR(0x1b02) -#define VLDTR_E_MD_RVAANDIMPLMAP EMAKEHR(0x1b03) -#define VLDTR_E_TD_EXTRAFLAGS EMAKEHR(0x1b04) -#define VLDTR_E_TD_EXTENDSITSELF EMAKEHR(0x1b05) -#define VLDTR_E_TD_SYSVTNOTEXTOBJ EMAKEHR(0x1b06) -#define VLDTR_E_TD_EXTTYPESPEC EMAKEHR(0x1b07) -#define VLDTR_E_TD_VTNOSIZE EMAKEHR(0x1b09) -#define VLDTR_E_TD_IFACESEALED EMAKEHR(0x1b0a) -#define VLDTR_E_NC_BADNESTED EMAKEHR(0x1b0b) -#define VLDTR_E_NC_BADENCLOSER EMAKEHR(0x1b0c) -#define VLDTR_E_NC_DUP EMAKEHR(0x1b0d) -#define VLDTR_E_NC_DUPENCLOSER EMAKEHR(0x1b0e) -#define VLDTR_E_FRVA_ZERORVA EMAKEHR(0x1b0f) -#define VLDTR_E_FRVA_BADFIELD EMAKEHR(0x1b10) -#define VLDTR_E_FRVA_DUPRVA EMAKEHR(0x1b11) -#define VLDTR_E_FRVA_DUPFIELD EMAKEHR(0x1b12) -#define VLDTR_E_EP_BADTOKEN EMAKEHR(0x1b13) -#define VLDTR_E_EP_INSTANCE EMAKEHR(0x1b14) -#define VLDTR_E_TD_ENUMFLDBADTYPE EMAKEHR(0x1b15) -#define VLDTR_E_MD_BADRVA EMAKEHR(0x1b16) -#define VLDTR_E_FD_LITERALNODEFAULT EMAKEHR(0x1b17) -#define VLDTR_E_IFACE_METHNOTIMPL EMAKEHR(0x1b18) -#define VLDTR_E_CA_BADPARENT EMAKEHR(0x1b19) -#define VLDTR_E_CA_BADTYPE EMAKEHR(0x1b1a) -#define VLDTR_E_CA_NOTCTOR EMAKEHR(0x1b1b) -#define VLDTR_E_CA_BADSIG EMAKEHR(0x1b1c) -#define VLDTR_E_CA_NOSIG EMAKEHR(0x1b1d) -#define VLDTR_E_CA_BADPROLOG EMAKEHR(0x1b1e) -#define VLDTR_E_MD_BADLOCALSIGTOK EMAKEHR(0x1b1f) -#define VLDTR_E_MD_BADHEADER EMAKEHR(0x1b20) -#define VLDTR_E_EP_TOOMANYARGS EMAKEHR(0x1b21) -#define VLDTR_E_EP_BADRET EMAKEHR(0x1b22) -#define VLDTR_E_EP_BADARG EMAKEHR(0x1b23) #define VLDTR_E_SIG_BADVOID EMAKEHR(0x1b24) -#define VLDTR_E_IFACE_METHMULTIMPL EMAKEHR(0x1b25) -#define VLDTR_E_GP_NAMENULL EMAKEHR(0x1b26) -#define VLDTR_E_GP_OWNERNIL EMAKEHR(0x1b27) -#define VLDTR_E_GP_DUPNAME EMAKEHR(0x1b28) -#define VLDTR_E_GP_DUPNUMBER EMAKEHR(0x1b29) -#define VLDTR_E_GP_NONSEQ_BY_OWNER EMAKEHR(0x1b2a) -#define VLDTR_E_GP_NONSEQ_BY_NUMBER EMAKEHR(0x1b2b) -#define VLDTR_E_GP_UNEXPECTED_OWNER_FOR_VARIANT_VAR EMAKEHR(0x1b2c) #define VLDTR_E_GP_ILLEGAL_VARIANT_MVAR EMAKEHR(0x1b2d) -#define VLDTR_E_GP_ILLEGAL_VARIANCE_FLAGS EMAKEHR(0x1b2e) -#define VLDTR_E_GP_REFANDVALUETYPE EMAKEHR(0x1b2f) -#define VLDTR_E_GPC_OWNERNIL EMAKEHR(0x1b30) -#define VLDTR_E_GPC_DUP EMAKEHR(0x1b31) -#define VLDTR_E_GPC_NONCONTIGUOUS EMAKEHR(0x1b32) -#define VLDTR_E_MS_METHODNIL EMAKEHR(0x1b33) -#define VLDTR_E_MS_DUP EMAKEHR(0x1b34) -#define VLDTR_E_MS_BADCALLINGCONV EMAKEHR(0x1b35) -#define VLDTR_E_MS_MISSARITY EMAKEHR(0x1b36) -#define VLDTR_E_MS_MISSARG EMAKEHR(0x1b37) -#define VLDTR_E_MS_ARITYMISMATCH EMAKEHR(0x1b38) -#define VLDTR_E_MS_METHODNOTGENERIC EMAKEHR(0x1b39) -#define VLDTR_E_SIG_MISSARITY EMAKEHR(0x1b3a) -#define VLDTR_E_SIG_ARITYMISMATCH EMAKEHR(0x1b3b) -#define VLDTR_E_MD_GENERIC_CCTOR EMAKEHR(0x1b3c) -#define VLDTR_E_MD_GENERIC_CTOR EMAKEHR(0x1b3d) -#define VLDTR_E_MD_GENERIC_IMPORT EMAKEHR(0x1b3e) -#define VLDTR_E_MD_GENERIC_BADCALLCONV EMAKEHR(0x1b3f) -#define VLDTR_E_EP_GENERIC_METHOD EMAKEHR(0x1b40) -#define VLDTR_E_MD_MISSARITY EMAKEHR(0x1b41) -#define VLDTR_E_MD_ARITYZERO EMAKEHR(0x1b42) -#define VLDTR_E_SIG_ARITYZERO EMAKEHR(0x1b43) -#define VLDTR_E_MS_ARITYZERO EMAKEHR(0x1b44) -#define VLDTR_E_MD_GPMISMATCH EMAKEHR(0x1b45) -#define VLDTR_E_EP_GENERIC_TYPE EMAKEHR(0x1b46) -#define VLDTR_E_MI_DECLNOTGENERIC EMAKEHR(0x1b47) -#define VLDTR_E_MI_IMPLNOTGENERIC EMAKEHR(0x1b48) -#define VLDTR_E_MI_ARITYMISMATCH EMAKEHR(0x1b49) -#define VLDTR_E_TD_EXTBADTYPESPEC EMAKEHR(0x1b4a) -#define VLDTR_E_SIG_BYREFINST EMAKEHR(0x1b4b) -#define VLDTR_E_MS_BYREFINST EMAKEHR(0x1b4c) -#define VLDTR_E_TS_EMPTY EMAKEHR(0x1b4d) -#define VLDTR_E_TS_HASSENTINALS EMAKEHR(0x1b4e) -#define VLDTR_E_TD_GENERICHASEXPLAYOUT EMAKEHR(0x1b4f) -#define VLDTR_E_SIG_BADTOKTYPE EMAKEHR(0x1b50) -#define VLDTR_E_IFACE_METHNOTIMPLTHISMOD EMAKEHR(0x1b51) -#define TLBX_E_CIRCULAR_EXPORT2 EMAKEHR(0x1b52) #define CORDBG_E_THREAD_NOT_SCHEDULED EMAKEHR(0x1c00) #define CORDBG_E_HANDLE_HAS_BEEN_DISPOSED EMAKEHR(0x1c01) #define CORDBG_E_NONINTERCEPTABLE_EXCEPTION EMAKEHR(0x1c02) -#define CORDBG_E_CANT_UNWIND_ABOVE_CALLBACK EMAKEHR(0x1c03) #define CORDBG_E_INTERCEPT_FRAME_ALREADY_SET EMAKEHR(0x1c04) #define CORDBG_E_NO_NATIVE_PATCH_AT_ADDR EMAKEHR(0x1c05) #define CORDBG_E_MUST_BE_INTEROP_DEBUGGING EMAKEHR(0x1c06) @@ -1129,11 +326,8 @@ #define CORDBG_E_TIMEOUT EMAKEHR(0x1c08) #define CORDBG_E_CANT_CALL_ON_THIS_THREAD EMAKEHR(0x1c09) #define CORDBG_E_ENC_INFOLESS_METHOD EMAKEHR(0x1c0a) -#define CORDBG_E_ENC_NESTED_HANLDERS EMAKEHR(0x1c0b) #define CORDBG_E_ENC_IN_FUNCLET EMAKEHR(0x1c0c) -#define CORDBG_E_ENC_LOCALLOC EMAKEHR(0x1c0d) #define CORDBG_E_ENC_EDIT_NOT_SUPPORTED EMAKEHR(0x1c0e) -#define CORDBG_E_FEABORT_DELAYED_UNTIL_THREAD_RESUMED EMAKEHR(0x1c0f) #define CORDBG_E_NOTREADY EMAKEHR(0x1c10) #define CORDBG_E_CANNOT_RESOLVE_ASSEMBLY EMAKEHR(0x1c11) #define CORDBG_E_MUST_BE_IN_LOAD_MODULE EMAKEHR(0x1c12) @@ -1151,7 +345,6 @@ #define CORDBG_E_ILLEGAL_IN_PROLOG EMAKEHR(0x1c24) #define CORDBG_E_ILLEGAL_IN_NATIVE_CODE EMAKEHR(0x1c25) #define CORDBG_E_ILLEGAL_IN_OPTIMIZED_CODE EMAKEHR(0x1c26) -#define CORDBG_E_MINIDUMP_UNSUPPORTED EMAKEHR(0x1c27) #define CORDBG_E_APPDOMAIN_MISMATCH EMAKEHR(0x1c28) #define CORDBG_E_CONTEXT_UNVAILABLE EMAKEHR(0x1c29) #define CORDBG_E_UNCOMPATIBLE_PLATFORMS EMAKEHR(0x1c30) @@ -1167,12 +360,6 @@ #define CORDBG_E_MODULE_LOADED_FROM_DISK EMAKEHR(0x1c3a) #define CORDBG_E_SYMBOLS_NOT_AVAILABLE EMAKEHR(0x1c3b) #define CORDBG_E_DEBUG_COMPONENT_MISSING EMAKEHR(0x1c3c) -#define CORDBG_E_REMOTE_MISMATCHED_CERTS EMAKEHR(0x1c3d) -#define CORDBG_E_REMOTE_NETWORK_FAILURE EMAKEHR(0x1c3e) -#define CORDBG_E_REMOTE_NO_LISTENER EMAKEHR(0x1c3f) -#define CORDBG_E_REMOTE_UNKNOWN_TARGET EMAKEHR(0x1c40) -#define CORDBG_E_REMOTE_INVALID_CONFIG EMAKEHR(0x1c41) -#define CORDBG_E_REMOTE_MISMATCHED_PROTOCOLS EMAKEHR(0x1c42) #define CORDBG_E_LIBRARY_PROVIDER_ERROR EMAKEHR(0x1c43) #define CORDBG_E_NOT_CLR EMAKEHR(0x1c44) #define CORDBG_E_MISSING_DATA_TARGET_INTERFACE EMAKEHR(0x1c45) @@ -1187,37 +374,10 @@ #define CORDBG_E_UNSUPPORTED EMAKEHR(0x1c4e) #define CORDBG_E_MISSING_DEBUGGER_EXPORTS EMAKEHR(0x1c4f) #define CORDBG_E_DATA_TARGET_ERROR EMAKEHR(0x1c61) -#define CORDBG_E_CODE_HAS_NO_METADATA EMAKEHR(0x1c62) -#define CORDBG_E_CODE_UNRECOGNIZED EMAKEHR(0x1c63) #define CORDBG_E_NO_IMAGE_AVAILABLE EMAKEHR(0x1c64) -#define CORDBG_E_TYPE_NOT_FOUND EMAKEHR(0x1c65) -#define CORDBG_E_VTABLE_HAS_NO_METADATA EMAKEHR(0x1c66) -#define CORDBG_E_NO_GENERIC_INFO EMAKEHR(0x1c67) -#define PEFMT_E_NO_CONTENTS EMAKEHR(0x1d00) -#define PEFMT_E_NO_NTHEADERS EMAKEHR(0x1d01) #define PEFMT_E_64BIT EMAKEHR(0x1d02) -#define PEFMT_E_NO_CORHEADER EMAKEHR(0x1d03) -#define PEFMT_E_NOT_ILONLY EMAKEHR(0x1d04) -#define PEFMT_E_IMPORT_DLLS EMAKEHR(0x1d05) -#define PEFMT_E_EXE_NOENTRYPOINT EMAKEHR(0x1d06) -#define PEFMT_E_BASE_RELOCS EMAKEHR(0x1d07) -#define PEFMT_E_ENTRYPOINT EMAKEHR(0x1d08) -#define PEFMT_E_ZERO_SIZEOFCODE EMAKEHR(0x1d09) -#define PEFMT_E_BAD_CORHEADER EMAKEHR(0x1d0a) #define PEFMT_E_32BIT EMAKEHR(0x1d0b) -#define CLR_OPTSVC_E_CONTROLLER_INTERRUPT EMAKEHR(0x1e00) -#define NGEN_FAILED_GET_DEPENDENCIES EMAKEHR(0x1f00) -#define NGEN_FAILED_NATIVE_IMAGE_DELETE EMAKEHR(0x1f01) -#define NGEN_E_TOO_MANY_INTERFACES EMAKEHR(0x1f02) -#define NGEN_E_OLDER_RUNTIME EMAKEHR(0x1f03) -#define NGEN_E_WORKER_UNEXPECTED_EXIT EMAKEHR(0x1f04) -#define NGEN_E_WORKER_UNEXPECTED_SYNC EMAKEHR(0x1f05) #define NGEN_E_SYS_ASM_NI_MISSING EMAKEHR(0x1f06) -#define NGEN_E_EXE_MACHINE_TYPE_MISMATCH EMAKEHR(0x1f07) -#define NGEN_E_ASSEMBLY_EXCLUSION_FILE_PARSE_ERROR EMAKEHR(0x1f08) -#define NGEN_E_HARDBOUND_DEPENDENCY_MISSING EMAKEHR(0x1f09) -#define NGEN_E_NOT_RUNNING_IN_EXPECTED_PACKAGE EMAKEHR(0x1f0a) -#define NGEN_E_FILE_NOT_ASSEMBLY EMAKEHR(0x1f0b) #define CLDB_E_INTERNALERROR EMAKEHR(0x1fff) #define CLR_E_BIND_ASSEMBLY_VERSION_TOO_LOW EMAKEHR(0x2000) #define CLR_E_BIND_ASSEMBLY_PUBLIC_KEY_MISMATCH EMAKEHR(0x2001) @@ -1235,7 +395,6 @@ #define COR_E_OUTOFMEMORY E_OUTOFMEMORY #define COR_E_NULLREFERENCE E_POINTER #define COR_E_ARITHMETIC __HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW) -#define COR_E_BAD_PATHNAME __HRESULT_FROM_WIN32(ERROR_BAD_PATHNAME) #define COR_E_PATHTOOLONG __HRESULT_FROM_WIN32(ERROR_FILENAME_EXCED_RANGE) #define COR_E_FILENOTFOUND __HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND) #define COR_E_ENDOFSTREAM __HRESULT_FROM_WIN32(ERROR_HANDLE_EOF) diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index 130e06ed4b6b..a3cc603e1810 100644 --- a/src/pal/src/CMakeLists.txt +++ b/src/pal/src/CMakeLists.txt @@ -16,8 +16,37 @@ if(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) include_directories(${CMAKE_CURRENT_BINARY_DIR}/libunwind/include/tdep) add_subdirectory(libunwind) -endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) +elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) + if(PAL_CMAKE_PLATFORM_ARCH_ARM) + find_library(UNWIND_ARCH NAMES unwind-arm) + endif() + + if(PAL_CMAKE_PLATFORM_ARCH_ARM64) + find_library(UNWIND_ARCH NAMES unwind-aarch64) + endif() + + if(PAL_CMAKE_PLATFORM_ARCH_AMD64) + find_library(UNWIND_ARCH NAMES unwind-x86_64) + endif() + + if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND) + set(UNWIND_LIBS ${UNWIND_ARCH}) + endif() + find_library(UNWIND_GENERIC NAMES unwind-generic) + + if(NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND) + set(UNWIND_LIBS ${UNWIND_LIBS} ${UNWIND_GENERIC}) + endif() + + find_library(UNWIND NAMES unwind) + + if(UNWIND STREQUAL UNWIND-NOTFOUND) + message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel.") + endif() + + set(UNWIND_LIBS ${UNWIND_LIBS} ${UNWIND}) +endif(NOT CLR_CMAKE_USE_SYSTEM_LIBUNWIND) include(configure.cmake) project(coreclrpal) @@ -275,14 +304,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) endif(CMAKE_SYSTEM_NAME STREQUAL Darwin) if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) - if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - find_library(UNWIND unwind) - endif() find_library(INTL intl) target_link_libraries(coreclrpal pthread rt - ${UNWIND} + ${UNWIND_LIBS} ${INTL} ) endif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD) @@ -342,36 +368,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) endif(NOT INTL STREQUAL INTL-NOTFOUND) if(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) - if(PAL_CMAKE_PLATFORM_ARCH_ARM) - find_library(UNWIND_ARCH NAMES unwind-arm) - endif() - - if(PAL_CMAKE_PLATFORM_ARCH_ARM64) - find_library(UNWIND_ARCH NAMES unwind-aarch64) - endif() - - if(PAL_CMAKE_PLATFORM_ARCH_AMD64) - find_library(UNWIND_ARCH NAMES unwind-x86_64) - endif() - - if(NOT UNWIND_ARCH STREQUAL UNWIND_ARCH-NOTFOUND) - target_link_libraries(coreclrpal ${UNWIND_ARCH}) - endif() - - find_library(UNWIND_GENERIC NAMES unwind-generic) - - if(NOT UNWIND_GENERIC STREQUAL UNWIND_GENERIC-NOTFOUND) - target_link_libraries(coreclrpal ${UNWIND_GENERIC}) - endif() - - find_library(UNWIND NAMES unwind) - - if(UNWIND STREQUAL UNWIND-NOTFOUND) - message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev or libunwind-devel.") - endif() - - target_link_libraries(coreclrpal ${UNWIND}) - + target_link_libraries(coreclrpal ${UNWIND_LIBS}) endif(CLR_CMAKE_USE_SYSTEM_LIBUNWIND) endif(CMAKE_SYSTEM_NAME STREQUAL Linux) diff --git a/src/pal/src/arch/amd64/context2.S b/src/pal/src/arch/amd64/context2.S index 46c941f2ad07..4fc32582b23b 100644 --- a/src/pal/src/arch/amd64/context2.S +++ b/src/pal/src/arch/amd64/context2.S @@ -76,22 +76,6 @@ LOCAL_LABEL(Done_CONTEXT_CONTROL): fxsave [rdi + CONTEXT_FltSave] LOCAL_LABEL(Done_CONTEXT_FLOATING_POINT): - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_DEBUG_REGISTERS - je LOCAL_LABEL(Done_CONTEXT_DEBUG_REGISTERS) - mov rdx, dr0 - mov [rdi + CONTEXT_Dr0], rdx - mov rdx, dr1 - mov [rdi + CONTEXT_Dr1], rdx - mov rdx, dr2 - mov [rdi + CONTEXT_Dr2], rdx - mov rdx, dr3 - mov [rdi + CONTEXT_Dr3], rdx - mov rdx, dr6 - mov [rdi + CONTEXT_Dr6], rdx - mov rdx, dr7 - mov [rdi + CONTEXT_Dr7], rdx -LOCAL_LABEL(Done_CONTEXT_DEBUG_REGISTERS): - free_stack 8 ret LEAF_END CONTEXT_CaptureContext, _TEXT @@ -107,31 +91,15 @@ LEAF_ENTRY RtlRestoreContext, _TEXT #ifdef HAS_ASAN test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_CONTROL - je LOCAL_LABEL(Restore_CONTEXT_DEBUG_REGISTERS) + je LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT) push_nonvol_reg rdi push_nonvol_reg rsi call EXTERNAL_C_FUNC(__asan_handle_no_return) pop_nonvol_reg rsi pop_nonvol_reg rdi -LOCAL_LABEL(Restore_CONTEXT_DEBUG_REGISTERS): +LOCAL_LABEL(Restore_CONTEXT_FLOATING_POINT): #endif - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_DEBUG_REGISTERS - je LOCAL_LABEL(Done_Restore_CONTEXT_DEBUG_REGISTERS) - mov rdx, [rdi + CONTEXT_Dr0] - mov dr0, rdx - mov rdx, [rdi + CONTEXT_Dr1] - mov dr1, rdx - mov rdx, [rdi + CONTEXT_Dr2] - mov dr2, rdx - mov rdx, [rdi + CONTEXT_Dr3] - mov dr3, rdx - mov rdx, [rdi + CONTEXT_Dr6] - mov dr6, rdx - mov rdx, [rdi + CONTEXT_Dr7] - mov dr7, rdx -LOCAL_LABEL(Done_Restore_CONTEXT_DEBUG_REGISTERS): - test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_FLOATING_POINT je LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT) fxrstor [rdi + CONTEXT_FltSave] diff --git a/src/pal/src/arch/arm/signalhandlerhelper.cpp b/src/pal/src/arch/arm/signalhandlerhelper.cpp index 4efecfc1c18e..f4a1760cb73f 100644 --- a/src/pal/src/arch/arm/signalhandlerhelper.cpp +++ b/src/pal/src/arch/arm/signalhandlerhelper.cpp @@ -59,7 +59,7 @@ void ExecuteHandlerOnOriginalStack(int code, siginfo_t *siginfo, void *context, #else size_t size = ALIGN_UP(sizeof(ucontext->uc_mcontext), 8); sp -= size / sizeof(size_t); - *(sigcontext *)sp = ucontext->uc_mcontext; + *(mcontext_t *)sp = ucontext->uc_mcontext; #endif // Switch the current context to the signal_handler_worker and the original stack diff --git a/src/pal/src/cruntime/misctls.cpp b/src/pal/src/cruntime/misctls.cpp index dd1e5d946d85..4805656f3c85 100644 --- a/src/pal/src/cruntime/misctls.cpp +++ b/src/pal/src/cruntime/misctls.cpp @@ -126,9 +126,4 @@ PAL_ctime( const PAL_time_t *clock ) PERF_EXIT(ctime); return retval; -} - -UINT GetExponent(double d) -{ - return (*((UINT*)&d + 1) >> 20) & 0x000007ff; } \ No newline at end of file diff --git a/src/pal/src/exception/seh.cpp b/src/pal/src/exception/seh.cpp index b05707076b8a..39779beb0b52 100644 --- a/src/pal/src/exception/seh.cpp +++ b/src/pal/src/exception/seh.cpp @@ -364,16 +364,22 @@ PAL_ERROR SEHDisable(CPalThread *pthrCurrent) --*/ -CatchHardwareExceptionHolder::CatchHardwareExceptionHolder() +extern "C" +void +PALAPI +PAL_CatchHardwareExceptionHolderEnter() { CPalThread *pThread = InternalGetCurrentThread(); - ++pThread->m_hardwareExceptionHolderCount; + pThread->IncrementHardwareExceptionHolderCount(); } -CatchHardwareExceptionHolder::~CatchHardwareExceptionHolder() +extern "C" +void +PALAPI +PAL_CatchHardwareExceptionHolderExit() { CPalThread *pThread = InternalGetCurrentThread(); - --pThread->m_hardwareExceptionHolderCount; + pThread->DecrementHardwareExceptionHolderCount(); } bool CatchHardwareExceptionHolder::IsEnabled() @@ -395,30 +401,12 @@ __declspec(thread) #endif // !__llvm__ static NativeExceptionHolderBase *t_nativeExceptionHolderHead = nullptr; -NativeExceptionHolderBase::NativeExceptionHolderBase() -{ - m_head = nullptr; - m_next = nullptr; -} - -NativeExceptionHolderBase::~NativeExceptionHolderBase() -{ - // Only destroy if Push was called - if (m_head != nullptr) - { - *m_head = m_next; - m_head = nullptr; - m_next = nullptr; - } -} - -void -NativeExceptionHolderBase::Push() +extern "C" +NativeExceptionHolderBase ** +PALAPI +PAL_GetNativeExceptionHolderHead() { - NativeExceptionHolderBase **head = &t_nativeExceptionHolderHead; - m_head = head; - m_next = *head; - *head = this; + return &t_nativeExceptionHolderHead; } NativeExceptionHolderBase * diff --git a/src/pal/src/exception/signal.cpp b/src/pal/src/exception/signal.cpp index 458e33169814..7f2e5c5b3dbe 100644 --- a/src/pal/src/exception/signal.cpp +++ b/src/pal/src/exception/signal.cpp @@ -199,6 +199,10 @@ Return : void FreeSignalAlternateStack() { stack_t ss, oss; + // The man page for sigaltstack says that when the ss.ss_flags is set to SS_DISABLE, + // all other ss fields are ignored. However, MUSL implementation checks that the + // ss_size is >= MINSIGSTKSZ even in this case. + ss.ss_size = MINSIGSTKSZ; ss.ss_flags = SS_DISABLE; int st = sigaltstack(&ss, &oss); if ((st == 0) && (oss.ss_flags != SS_DISABLE)) diff --git a/src/pal/src/file/file.cpp b/src/pal/src/file/file.cpp index 3f453c1f2033..0d30487fd415 100644 --- a/src/pal/src/file/file.cpp +++ b/src/pal/src/file/file.cpp @@ -687,7 +687,7 @@ CorUnix::InternalCreateFile( /* make file descriptor close-on-exec; inheritable handles will get "uncloseonexeced" in CreateProcess if they are actually being inherited*/ - if(-1 == fcntl(filed,F_SETFD,1)) + if(-1 == fcntl(filed,F_SETFD, FD_CLOEXEC)) { ASSERT("can't set close-on-exec flag; fcntl() failed. errno is %d " "(%s)\n", errno, strerror(errno)); diff --git a/src/pal/src/include/pal/malloc.hpp b/src/pal/src/include/pal/malloc.hpp index 9faf4273d9c6..580b6a916c17 100644 --- a/src/pal/src/include/pal/malloc.hpp +++ b/src/pal/src/include/pal/malloc.hpp @@ -85,6 +85,14 @@ namespace CorUnix{ return new (pMem) T(); } + // 1 arg case. + template + T* InternalNew(A1 arg1) + { + INTERNAL_NEW_COMMON(); + return new (pMem) T(arg1); + } + // 2 args case. template T* InternalNew(A1 arg1, A2 arg2) @@ -93,6 +101,14 @@ namespace CorUnix{ return new (pMem) T(arg1, arg2); } + // 3 args case. + template + T* InternalNew(A1 arg1, A2 arg2, A3 arg3) + { + INTERNAL_NEW_COMMON(); + return new (pMem) T(arg1, arg2, arg3); + } + // 4 args case. template T* InternalNew(A1 arg1, A2 arg2, A3 arg3, A4 arg4) diff --git a/src/pal/src/include/pal/mutex.hpp b/src/pal/src/include/pal/mutex.hpp index 6a46689d7dcc..ba82c2d2f437 100644 --- a/src/pal/src/include/pal/mutex.hpp +++ b/src/pal/src/include/pal/mutex.hpp @@ -71,7 +71,7 @@ DWORD SPINLOCKTryAcquire (LONG * lock); // Temporarily disabling usage of pthread process-shared mutexes on ARM/ARM64 due to functional issues that cannot easily be // detected with code due to hangs. See https://github.com/dotnet/coreclr/issues/5456. -#if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && !(defined(_ARM_) || defined(_ARM64_)) +#if HAVE_FULLY_FEATURED_PTHREAD_MUTEXES && HAVE_FUNCTIONAL_PTHREAD_ROBUST_MUTEXES && !(defined(_ARM_) || defined(_ARM64_) || defined(__FreeBSD__)) #define NAMED_MUTEX_USE_PTHREAD_MUTEX 1 #else #define NAMED_MUTEX_USE_PTHREAD_MUTEX 0 diff --git a/src/pal/src/include/pal/thread.hpp b/src/pal/src/include/pal/thread.hpp index ddacfb90390a..a1ad599ddd8f 100644 --- a/src/pal/src/include/pal/thread.hpp +++ b/src/pal/src/include/pal/thread.hpp @@ -207,7 +207,7 @@ namespace CorUnix { friend PAL_ERROR - CorUnix::InternalCreateThread( + InternalCreateThread( CPalThread *, LPSECURITY_ATTRIBUTES, DWORD, @@ -250,8 +250,6 @@ namespace CorUnix HANDLE *phThread ); - friend CatchHardwareExceptionHolder; - private: CPalThread *m_pNext; @@ -552,6 +550,18 @@ namespace CorUnix return m_hardwareExceptionHolderCount > 0; } + inline void + IncrementHardwareExceptionHolderCount() + { + ++m_hardwareExceptionHolderCount; + } + + inline void + DecrementHardwareExceptionHolderCount() + { + --m_hardwareExceptionHolderCount; + } + LPTHREAD_START_ROUTINE GetStartAddress( void @@ -810,6 +820,13 @@ inline SIZE_T THREADSilentGetCurrentThreadId() { pthread_threadid_np(pthread_self(), &tid); return (SIZE_T)tid; } +#elif defined(__FreeBSD__) +#include +inline SIZE_T THREADSilentGetCurrentThreadId() { + long tid; + thr_self(&tid); + return (SIZE_T)tid; +} #elif defined(__NetBSD__) #include #define THREADSilentGetCurrentThreadId() (SIZE_T)_lwp_self() diff --git a/src/pal/src/locale/utf8.cpp b/src/pal/src/locale/utf8.cpp index 4688cf011989..38599e6b08e8 100644 --- a/src/pal/src/locale/utf8.cpp +++ b/src/pal/src/locale/utf8.cpp @@ -20,6 +20,9 @@ Revision History: --*/ #include "pal/utf8.h" +#include "pal/malloc.hpp" + +using namespace CorUnix; #define FASTLOOP @@ -253,6 +256,8 @@ class DecoderFallbackBuffer // These wrap the internal methods so that we can check for people doing stuff that's incorrect public: + virtual ~DecoderFallbackBuffer() = default; + virtual bool Fallback(BYTE bytesUnknown[], int index, int size) = 0; // Get next character @@ -552,7 +557,7 @@ class DecoderExceptionFallback : public DecoderFallback virtual DecoderFallbackBuffer* CreateFallbackBuffer() { - return new DecoderExceptionFallbackBuffer(); + return InternalNew(); } // Maximum number of characters that this instance of this fallback could return @@ -564,7 +569,7 @@ class DecoderExceptionFallback : public DecoderFallback DecoderFallbackBuffer* DecoderReplacementFallback::CreateFallbackBuffer() { - return new DecoderReplacementFallbackBuffer(this); + return InternalNew(this); } class EncoderFallbackException : public ArgumentException @@ -728,6 +733,8 @@ class EncoderFallbackBuffer // These wrap the internal methods so that we can check for people doing stuff that is incorrect public: + virtual ~EncoderFallbackBuffer() = default; + virtual bool Fallback(WCHAR charUnknown, int index) = 0; virtual bool Fallback(WCHAR charUnknownHigh, WCHAR charUnknownLow, int index) = 0; @@ -1044,7 +1051,7 @@ class EncoderExceptionFallback : public EncoderFallback virtual EncoderFallbackBuffer* CreateFallbackBuffer() { - return new EncoderExceptionFallbackBuffer(); + return InternalNew(); } // Maximum number of characters that this instance of this fallback could return @@ -1056,7 +1063,7 @@ class EncoderExceptionFallback : public EncoderFallback EncoderFallbackBuffer* EncoderReplacementFallback::CreateFallbackBuffer() { - return new EncoderReplacementFallbackBuffer(this); + return InternalNew(this); } class UTF8Encoding @@ -1620,6 +1627,8 @@ class UTF8Encoding Contract::Assert(fallback == nullptr || fallback->GetRemaining() == 0, "[UTF8Encoding.GetCharCount]Expected empty fallback buffer at end"); + InternalDelete(fallback); + return charCount; } @@ -2123,6 +2132,8 @@ class UTF8Encoding Contract::Assert(fallback == nullptr || fallback->GetRemaining() == 0, "[UTF8Encoding.GetChars]Expected empty fallback buffer at end"); + InternalDelete(fallback); + return PtrDiff(pTarget, chars); } @@ -2511,6 +2522,8 @@ class UTF8Encoding ch = 0; } + InternalDelete(fallbackBuffer); + return (int)(pTarget - bytes); } @@ -2838,6 +2851,8 @@ class UTF8Encoding Contract::Assert(fallbackBuffer == nullptr || fallbackBuffer->GetRemaining() == 0, "[UTF8Encoding.GetByteCount]Expected Empty fallback buffer"); + InternalDelete(fallbackBuffer); + return byteCount; } diff --git a/src/pal/src/map/map.cpp b/src/pal/src/map/map.cpp index 228b48bfca1a..7e6c89bbb706 100644 --- a/src/pal/src/map/map.cpp +++ b/src/pal/src/map/map.cpp @@ -31,6 +31,7 @@ Module Name: #include "pal/file.hpp" #include "pal/malloc.hpp" +#include #include #include #include @@ -1661,7 +1662,7 @@ static INT MAPFileMapToMmapFlags( DWORD flags ) else if ( FILE_MAP_WRITE == flags ) { TRACE( "FILE_MAP_WRITE\n" ); - /* The limitation of x86 archetecture + /* The limitation of x86 architecture means you cant have writable but not readable page. In Windows maps of FILE_MAP_WRITE can still be read from. */ diff --git a/src/pal/src/misc/time.cpp b/src/pal/src/misc/time.cpp index d16fb587bac0..b660cc0a56b4 100644 --- a/src/pal/src/misc/time.cpp +++ b/src/pal/src/misc/time.cpp @@ -202,7 +202,11 @@ QueryPerformanceCounter( PERF_ENTRY(QueryPerformanceCounter); ENTRY("QueryPerformanceCounter()\n"); do -#if HAVE_CLOCK_MONOTONIC +#if HAVE_MACH_ABSOLUTE_TIME + { + lpPerformanceCount->QuadPart = (LONGLONG)mach_absolute_time(); + } +#elif HAVE_CLOCK_MONOTONIC { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) @@ -214,10 +218,6 @@ QueryPerformanceCounter( lpPerformanceCount->QuadPart = (LONGLONG)ts.tv_sec * (LONGLONG)tccSecondsToNanoSeconds + (LONGLONG)ts.tv_nsec; } -#elif HAVE_MACH_ABSOLUTE_TIME - { - lpPerformanceCount->QuadPart = (LONGLONG)mach_absolute_time(); - } #elif HAVE_GETHRTIME { lpPerformanceCount->QuadPart = (LONGLONG)gethrtime(); @@ -264,9 +264,7 @@ QueryPerformanceFrequency( BOOL retval = TRUE; PERF_ENTRY(QueryPerformanceFrequency); ENTRY("QueryPerformanceFrequency()\n"); -#if HAVE_GETHRTIME || HAVE_READ_REAL_TIME || HAVE_CLOCK_MONOTONIC - lpFrequency->QuadPart = (LONGLONG)tccSecondsToNanoSeconds; -#elif HAVE_MACH_ABSOLUTE_TIME +#if HAVE_MACH_ABSOLUTE_TIME // use denom == 0 to indicate that s_TimebaseInfo is uninitialised. if (s_TimebaseInfo.denom == 0) { @@ -277,9 +275,11 @@ QueryPerformanceFrequency( { lpFrequency->QuadPart = (LONGLONG)tccSecondsToNanoSeconds * ((LONGLONG)s_TimebaseInfo.denom / (LONGLONG)s_TimebaseInfo.numer); } +#elif HAVE_GETHRTIME || HAVE_READ_REAL_TIME || HAVE_CLOCK_MONOTONIC + lpFrequency->QuadPart = (LONGLONG)tccSecondsToNanoSeconds; #else lpFrequency->QuadPart = (LONGLONG)tccSecondsToMicroSeconds; -#endif // HAVE_GETHRTIME || HAVE_READ_REAL_TIME || HAVE_CLOCK_MONOTONIC +#endif // HAVE_MACH_ABSOLUTE_TIME LOGEXIT("QueryPerformanceFrequency\n"); PERF_EXIT(QueryPerformanceFrequency); return retval; @@ -338,7 +338,17 @@ GetTickCount64() { ULONGLONG retval = 0; -#if HAVE_CLOCK_MONOTONIC_COARSE || HAVE_CLOCK_MONOTONIC +#if HAVE_MACH_ABSOLUTE_TIME + { + // use denom == 0 to indicate that s_TimebaseInfo is uninitialised. + if (s_TimebaseInfo.denom == 0) + { + ASSERT("s_TimebaseInfo is uninitialized.\n"); + goto EXIT; + } + retval = (mach_absolute_time() * s_TimebaseInfo.numer / s_TimebaseInfo.denom) / tccMillieSecondsToNanoSeconds; + } +#elif HAVE_CLOCK_MONOTONIC_COARSE || HAVE_CLOCK_MONOTONIC { clockid_t clockType = #if HAVE_CLOCK_MONOTONIC_COARSE @@ -354,16 +364,6 @@ GetTickCount64() } retval = (ts.tv_sec * tccSecondsToMillieSeconds)+(ts.tv_nsec / tccMillieSecondsToNanoSeconds); } -#elif HAVE_MACH_ABSOLUTE_TIME - { - // use denom == 0 to indicate that s_TimebaseInfo is uninitialised. - if (s_TimebaseInfo.denom == 0) - { - ASSERT("s_TimebaseInfo is uninitialized.\n"); - goto EXIT; - } - retval = (mach_absolute_time() * s_TimebaseInfo.numer / s_TimebaseInfo.denom) / tccMillieSecondsToNanoSeconds; - } #elif HAVE_GETHRTIME { retval = (ULONGLONG)(gethrtime() / tccMillieSecondsToNanoSeconds); diff --git a/src/pal/src/thread/process.cpp b/src/pal/src/thread/process.cpp index a1be42fa35fb..da55bff9c38e 100644 --- a/src/pal/src/thread/process.cpp +++ b/src/pal/src/thread/process.cpp @@ -1544,7 +1544,7 @@ class PAL_RuntimeStartupHelper LONG ref = InterlockedDecrement(&m_ref); if (ref == 0) { - delete this; + InternalDelete(this); } return ref; } @@ -1836,7 +1836,7 @@ PAL_RegisterForRuntimeStartup( _ASSERTE(pfnCallback != NULL); _ASSERTE(ppUnregisterToken != NULL); - PAL_RuntimeStartupHelper *helper = new PAL_RuntimeStartupHelper(dwProcessId, pfnCallback, parameter); + PAL_RuntimeStartupHelper *helper = InternalNew(dwProcessId, pfnCallback, parameter); // Create the debuggee startup semaphore so the runtime (debuggee) knows to wait for // a debugger connection. diff --git a/src/palrt/CMakeLists.txt b/src/palrt/CMakeLists.txt index e19b55d9dc68..e5ca200a5ebb 100644 --- a/src/palrt/CMakeLists.txt +++ b/src/palrt/CMakeLists.txt @@ -5,8 +5,6 @@ set(PALRT_SOURCES bstr.cpp coguid.cpp comem.cpp - decarith.cpp - decconv.cpp guid.cpp memorystream.cpp path.cpp diff --git a/src/palrt/decarith.cpp b/src/palrt/decarith.cpp deleted file mode 100644 index f190707ab6d0..000000000000 --- a/src/palrt/decarith.cpp +++ /dev/null @@ -1,1267 +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. -// - -// -// =========================================================================== -// File: decarith.cpp -// -// =========================================================================== -/*** -* -*Purpose: -* Implement arithmetic for Decimal data type. -* -*Implementation Notes: -* -*****************************************************************************/ - -#include "common.h" - -#include -#include "convert.h" - -//*********************************************************************** -// -// Additional Decimal and Int64 definitions -// -#define COPYDEC(dest, src) {DECIMAL_SIGNSCALE(dest) = DECIMAL_SIGNSCALE(src); DECIMAL_HI32(dest) = DECIMAL_HI32(src); \ - DECIMAL_MID32(dest) = DECIMAL_MID32(src); DECIMAL_LO32(dest) = DECIMAL_LO32(src); } - -#define DEC_SCALE_MAX 28 -#define POWER10_MAX 9 - -// The following functions are defined in the classlibnative\bcltype\decimal.cpp -ULONG Div96By32(ULONG *rgulNum, ULONG ulDen); -ULONG Div96By64(ULONG *rgulNum, SPLIT64 sdlDen); -ULONG Div128By96(ULONG *rgulNum, ULONG *rgulDen); -int ScaleResult(ULONG *rgulRes, int iHiRes, int iScale); -ULONG IncreaseScale(ULONG *rgulNum, ULONG ulPwr); - -//*********************************************************************** -// -// Data tables -// - -static ULONG rgulPower10[POWER10_MAX+1] = {1, 10, 100, 1000, 10000, 100000, 1000000, - 10000000, 100000000, 1000000000}; - -struct DECOVFL -{ - ULONG Hi; - ULONG Mid; -}; - -static DECOVFL PowerOvfl[] = { -// This is a table of the largest values that can be in the upper two -// ULONGs of a 96-bit number that will not overflow when multiplied -// by a given power. For the upper word, this is a table of -// 2^32 / 10^n for 1 <= n <= 9. For the lower word, this is the -// remaining fraction part * 2^32. 2^32 = 4294967296. -// - { 429496729UL, 2576980377UL }, // 10^1 remainder 0.6 - { 42949672UL, 4123168604UL }, // 10^2 remainder 0.16 - { 4294967UL, 1271310319UL }, // 10^3 remainder 0.616 - { 429496UL, 3133608139UL }, // 10^4 remainder 0.1616 - { 42949UL, 2890341191UL }, // 10^5 remainder 0.51616 - { 4294UL, 4154504685UL }, // 10^6 remainder 0.551616 - { 429UL, 2133437386UL }, // 10^7 remainder 0.9551616 - { 42UL, 4078814305UL }, // 10^8 remainder 0.09991616 -// { 4UL, 1266874889UL }, // 10^9 remainder 0.709551616 -}; - -#define OVFL_MAX_9_HI 4 -#define OVFL_MAX_9_MID 1266874889 - -#define OVFL_MAX_5_HI 42949 -#define OVFL_MAX_5_MID 2890341191 - -#define OVFL_MAX_1_HI 429496729 - - - -//*********************************************************************** -// -// static helper functions -// - -/*** -* FullDiv64By32 -* -* Entry: -* pdlNum - Pointer to 64-bit dividend -* ulDen - 32-bit divisor -* -* Purpose: -* Do full divide, yielding 64-bit result and 32-bit remainder. -* -* Exit: -* Quotient overwrites dividend. -* Returns remainder. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG FullDiv64By32(DWORDLONG *pdlNum, ULONG ulDen) -{ - SPLIT64 sdlTmp; - SPLIT64 sdlRes; - - sdlTmp.int64 = *pdlNum; - sdlRes.u.Hi = 0; - - if (sdlTmp.u.Hi >= ulDen) { - // DivMod64by32 returns quotient in Lo, remainder in Hi. - // - sdlRes.u.Lo = sdlTmp.u.Hi; - sdlRes.int64 = DivMod64by32(sdlRes.int64, ulDen); - sdlTmp.u.Hi = sdlRes.u.Hi; - sdlRes.u.Hi = sdlRes.u.Lo; - } - - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulDen); - sdlRes.u.Lo = sdlTmp.u.Lo; - *pdlNum = sdlRes.int64; - return sdlTmp.u.Hi; -} - - - - -/*** -* SearchScale -* -* Entry: -* ulResHi - Top ULONG of quotient -* ulResLo - Middle ULONG of quotient -* iScale - Scale factor of quotient, range -DEC_SCALE_MAX to DEC_SCALE_MAX -* -* Purpose: -* Determine the max power of 10, <= 9, that the quotient can be scaled -* up by and still fit in 96 bits. -* -* Exit: -* Returns power of 10 to scale by, -1 if overflow error. -* -***********************************************************************/ - -int SearchScale(ULONG ulResHi, ULONG ulResLo, int iScale) -{ - int iCurScale; - - // Quick check to stop us from trying to scale any more. - // - if (ulResHi > OVFL_MAX_1_HI || iScale >= DEC_SCALE_MAX) { - iCurScale = 0; - goto HaveScale; - } - - if (iScale > DEC_SCALE_MAX - 9) { - // We can't scale by 10^9 without exceeding the max scale factor. - // See if we can scale to the max. If not, we'll fall into - // standard search for scale factor. - // - iCurScale = DEC_SCALE_MAX - iScale; - if (ulResHi < PowerOvfl[iCurScale - 1].Hi) - goto HaveScale; - - if (ulResHi == PowerOvfl[iCurScale - 1].Hi) { - UpperEq: - if (ulResLo >= PowerOvfl[iCurScale - 1].Mid) - iCurScale--; - goto HaveScale; - } - } - else if (ulResHi < OVFL_MAX_9_HI || (ulResHi == OVFL_MAX_9_HI && - ulResLo < OVFL_MAX_9_MID)) - return 9; - - // Search for a power to scale by < 9. Do a binary search - // on PowerOvfl[]. - // - iCurScale = 5; - if (ulResHi < OVFL_MAX_5_HI) - iCurScale = 7; - else if (ulResHi > OVFL_MAX_5_HI) - iCurScale = 3; - else - goto UpperEq; - - // iCurScale is 3 or 7. - // - if (ulResHi < PowerOvfl[iCurScale - 1].Hi) - iCurScale++; - else if (ulResHi > PowerOvfl[iCurScale - 1].Hi) - iCurScale--; - else - goto UpperEq; - - // iCurScale is 2, 4, 6, or 8. - // - // In all cases, we already found we could not use the power one larger. - // So if we can use this power, it is the biggest, and we're done. If - // we can't use this power, the one below it is correct for all cases - // unless it's 10^1 -- we might have to go to 10^0 (no scaling). - // - if (ulResHi > PowerOvfl[iCurScale - 1].Hi) - iCurScale--; - - if (ulResHi == PowerOvfl[iCurScale - 1].Hi) - goto UpperEq; - -HaveScale: - // iCurScale = largest power of 10 we can scale by without overflow, - // iCurScale < 9. See if this is enough to make scale factor - // positive if it isn't already. - // - if (iCurScale + iScale < 0) - iCurScale = -1; - - return iCurScale; -} - -/*** -* DecFixInt -* -* Entry: -* pdecRes - Pointer to Decimal result location -* pdecIn - Pointer to Decimal operand -* -* Purpose: -* Chop the value to integer. Return remainder so Int() function -* can round down if non-zero. -* -* Exit: -* Returns remainder. -* -* Exceptions: -* None. -* -***********************************************************************/ - -ULONG DecFixInt(LPDECIMAL pdecRes, LPDECIMAL pdecIn) -{ - ULONG rgulNum[3]; - ULONG ulRem; - ULONG ulPwr; - int iScale; - - if (pdecIn->u.u.scale > 0) { - rgulNum[0] = pdecIn->v.v.Lo32; - rgulNum[1] = pdecIn->v.v.Mid32; - rgulNum[2] = pdecIn->Hi32; - iScale = pdecIn->u.u.scale; - pdecRes->u.u.sign = pdecIn->u.u.sign; - ulRem = 0; - - do { - if (iScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iScale]; - - ulRem |= Div96By32(rgulNum, ulPwr); - iScale -= 9; - }while (iScale > 0); - - pdecRes->v.v.Lo32 = rgulNum[0]; - pdecRes->v.v.Mid32 = rgulNum[1]; - pdecRes->Hi32 = rgulNum[2]; - pdecRes->u.u.scale = 0; - - return ulRem; - } - - COPYDEC(*pdecRes, *pdecIn) - return 0; -} - - -//*********************************************************************** -// -// -// - -//********************************************************************** -// -// VarDecMul - Decimal Multiply -// -//********************************************************************** - -STDAPI VarDecMul(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes) -{ - SPLIT64 sdlTmp; - SPLIT64 sdlTmp2; - SPLIT64 sdlTmp3; - int iScale; - int iHiProd; - ULONG ulPwr; - ULONG ulRemLo; - ULONG ulRemHi; - ULONG rgulProd[6]; - - iScale = pdecL->u.u.scale + pdecR->u.u.scale; - - if ((pdecL->Hi32 | pdecL->v.v.Mid32 | pdecR->Hi32 | pdecR->v.v.Mid32) == 0) - { - // Upper 64 bits are zero. - // - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Lo32, pdecR->v.v.Lo32); - if (iScale > DEC_SCALE_MAX) - { - // Result iScale is too big. Divide result by power of 10 to reduce it. - // If the amount to divide by is > 19 the result is guaranteed - // less than 1/2. [max value in 64 bits = 1.84E19] - // - iScale -= DEC_SCALE_MAX; - if (iScale > 19) - { -ReturnZero: - DECIMAL_SETZERO(*pdecRes); - return NOERROR; - } - if (iScale > POWER10_MAX) - { - // Divide by 1E10 first, to get the power down to a 32-bit quantity. - // 1E10 itself doesn't fit in 32 bits, so we'll divide by 2.5E9 now - // then multiply the next divisor by 4 (which will be a max of 4E9). - // - ulRemLo = FullDiv64By32(&sdlTmp.int64, ulTenToTenDiv4); - ulPwr = rgulPower10[iScale - 10] << 2; - } - else - { - ulPwr = rgulPower10[iScale]; - ulRemLo = 0; - } - - // Power to divide by fits in 32 bits. - // - ulRemHi = FullDiv64By32(&sdlTmp.int64, ulPwr); - - // Round result. See if remainder >= 1/2 of divisor. - // Divisor is a power of 10, so it is always even. - // - ulPwr >>= 1; - if (ulRemHi >= ulPwr && (ulRemHi > ulPwr || (ulRemLo | (sdlTmp.u.Lo & 1)))) - sdlTmp.int64++; - - iScale = DEC_SCALE_MAX; - } - DECIMAL_LO32(*pdecRes) = sdlTmp.u.Lo; - DECIMAL_MID32(*pdecRes) = sdlTmp.u.Hi; - DECIMAL_HI32(*pdecRes) = 0; - } - else - { - - // At least one operand has bits set in the upper 64 bits. - // - // Compute and accumulate the 9 partial products into a - // 192-bit (24-byte) result. - // - // [l-h][l-m][l-l] left high, middle, low - // x [r-h][r-m][r-l] right high, middle, low - // ------------------------------ - // - // [0-h][0-l] l-l * r-l - // [1ah][1al] l-l * r-m - // [1bh][1bl] l-m * r-l - // [2ah][2al] l-m * r-m - // [2bh][2bl] l-l * r-h - // [2ch][2cl] l-h * r-l - // [3ah][3al] l-m * r-h - // [3bh][3bl] l-h * r-m - // [4-h][4-l] l-h * r-h - // ------------------------------ - // [p-5][p-4][p-3][p-2][p-1][p-0] prod[] array - // - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Lo32, pdecR->v.v.Lo32); - rgulProd[0] = sdlTmp.u.Lo; - - sdlTmp2.int64 = UInt32x32To64(pdecL->v.v.Lo32, pdecR->v.v.Mid32) + sdlTmp.u.Hi; - - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Mid32, pdecR->v.v.Lo32); - sdlTmp.int64 += sdlTmp2.int64; // this could generate carry - rgulProd[1] = sdlTmp.u.Lo; - if (sdlTmp.int64 < sdlTmp2.int64) // detect carry - sdlTmp2.u.Hi = 1; - else - sdlTmp2.u.Hi = 0; - sdlTmp2.u.Lo = sdlTmp.u.Hi; - - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Mid32, pdecR->v.v.Mid32) + sdlTmp2.int64; - - if (pdecL->Hi32 | pdecR->Hi32) { - // Highest 32 bits is non-zero. Calculate 5 more partial products. - // - sdlTmp2.int64 = UInt32x32To64(pdecL->v.v.Lo32, pdecR->Hi32); - sdlTmp.int64 += sdlTmp2.int64; // this could generate carry - if (sdlTmp.int64 < sdlTmp2.int64) // detect carry - sdlTmp3.u.Hi = 1; - else - sdlTmp3.u.Hi = 0; - - sdlTmp2.int64 = UInt32x32To64(pdecL->Hi32, pdecR->v.v.Lo32); - sdlTmp.int64 += sdlTmp2.int64; // this could generate carry - rgulProd[2] = sdlTmp.u.Lo; - if (sdlTmp.int64 < sdlTmp2.int64) // detect carry - sdlTmp3.u.Hi++; - sdlTmp3.u.Lo = sdlTmp.u.Hi; - - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Mid32, pdecR->Hi32); - sdlTmp.int64 += sdlTmp3.int64; // this could generate carry - if (sdlTmp.int64 < sdlTmp3.int64) // detect carry - sdlTmp3.u.Hi = 1; - else - sdlTmp3.u.Hi = 0; - - sdlTmp2.int64 = UInt32x32To64(pdecL->Hi32, pdecR->v.v.Mid32); - sdlTmp.int64 += sdlTmp2.int64; // this could generate carry - rgulProd[3] = sdlTmp.u.Lo; - if (sdlTmp.int64 < sdlTmp2.int64) // detect carry - sdlTmp3.u.Hi++; - sdlTmp3.u.Lo = sdlTmp.u.Hi; - - sdlTmp.int64 = UInt32x32To64(pdecL->Hi32, pdecR->Hi32) + sdlTmp3.int64; - rgulProd[4] = sdlTmp.u.Lo; - rgulProd[5] = sdlTmp.u.Hi; - - iHiProd = 5; - } - else { - rgulProd[2] = sdlTmp.u.Lo; - rgulProd[3] = sdlTmp.u.Hi; - iHiProd = 3; - } - - // Check for leading zero ULONGs on the product - // - while (rgulProd[iHiProd] == 0) { - iHiProd--; - if (iHiProd < 0) - goto ReturnZero; - } - - iScale = ScaleResult(rgulProd, iHiProd, iScale); - if (iScale == -1) - return DISP_E_OVERFLOW; - - pdecRes->v.v.Lo32 = rgulProd[0]; - pdecRes->v.v.Mid32 = rgulProd[1]; - pdecRes->Hi32 = rgulProd[2]; - } - - pdecRes->u.u.sign = pdecR->u.u.sign ^ pdecL->u.u.sign; - pdecRes->u.u.scale = (char)iScale; - return NOERROR; -} - - -//********************************************************************** -// -// VarDecAdd - Decimal Addition -// VarDecSub - Decimal Subtraction -// -//********************************************************************** - -static HRESULT DecAddSub(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes, char bSign); - -STDAPI VarDecAdd(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes) -{ - return DecAddSub(pdecL, pdecR, pdecRes, 0); -} - - -STDAPI VarDecSub(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes) -{ - return DecAddSub(pdecL, pdecR, pdecRes, DECIMAL_NEG); -} - - -static HRESULT DecAddSub(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes, char bSign) -{ - ULONG rgulNum[6]; - ULONG ulPwr; - int iScale; - int iHiProd; - int iCur; - SPLIT64 sdlTmp; - DECIMAL decRes; - DECIMAL decTmp; - LPDECIMAL pdecTmp; - - bSign ^= (pdecR->u.u.sign ^ pdecL->u.u.sign) & DECIMAL_NEG; - - if (pdecR->u.u.scale == pdecL->u.u.scale) { - // Scale factors are equal, no alignment necessary. - // - decRes.u.signscale = pdecL->u.signscale; - -AlignedAdd: - if (bSign) { - // Signs differ - subtract - // - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(*pdecL) - DECIMAL_LO64_GET(*pdecR)); - DECIMAL_HI32(decRes) = DECIMAL_HI32(*pdecL) - DECIMAL_HI32(*pdecR); - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > DECIMAL_LO64_GET(*pdecL)) { - decRes.Hi32--; - if (decRes.Hi32 >= pdecL->Hi32) - goto SignFlip; - } - else if (decRes.Hi32 > pdecL->Hi32) { - // Got negative result. Flip its sign. - // -SignFlip: - DECIMAL_LO64_SET(decRes, -(LONGLONG)DECIMAL_LO64_GET(decRes)); - decRes.Hi32 = ~decRes.Hi32; - if (DECIMAL_LO64_GET(decRes) == 0) - decRes.Hi32++; - decRes.u.u.sign ^= DECIMAL_NEG; - } - - } - else { - // Signs are the same - add - // - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(*pdecL) + DECIMAL_LO64_GET(*pdecR)); - decRes.Hi32 = pdecL->Hi32 + pdecR->Hi32; - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < DECIMAL_LO64_GET(*pdecL)) { - decRes.Hi32++; - if (decRes.Hi32 <= pdecL->Hi32) - goto AlignedScale; - } - else if (decRes.Hi32 < pdecL->Hi32) { -AlignedScale: - // The addition carried above 96 bits. Divide the result by 10, - // dropping the scale factor. - // - if (decRes.u.u.scale == 0) - return DISP_E_OVERFLOW; - decRes.u.u.scale--; - - sdlTmp.u.Lo = decRes.Hi32; - sdlTmp.u.Hi = 1; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - decRes.Hi32 = sdlTmp.u.Lo; - - sdlTmp.u.Lo = decRes.v.v.Mid32; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - decRes.v.v.Mid32 = sdlTmp.u.Lo; - - sdlTmp.u.Lo = decRes.v.v.Lo32; - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, 10); - decRes.v.v.Lo32 = sdlTmp.u.Lo; - - // See if we need to round up. - // - if (sdlTmp.u.Hi >= 5 && (sdlTmp.u.Hi > 5 || (decRes.v.v.Lo32 & 1))) { - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(decRes)+1) - if (DECIMAL_LO64_GET(decRes) == 0) - decRes.Hi32++; - } - } - } - } - else { - // Scale factors are not equal. Assume that a larger scale - // factor (more decimal places) is likely to mean that number - // is smaller. Start by guessing that the right operand has - // the larger scale factor. The result will have the larger - // scale factor. - // - decRes.u.u.scale = pdecR->u.u.scale; // scale factor of "smaller" - decRes.u.u.sign = pdecL->u.u.sign; // but sign of "larger" - iScale = decRes.u.u.scale - pdecL->u.u.scale; - - if (iScale < 0) { - // Guessed scale factor wrong. Swap operands. - // - iScale = -iScale; - decRes.u.u.scale = pdecL->u.u.scale; - decRes.u.u.sign ^= bSign; - pdecTmp = pdecR; - pdecR = pdecL; - pdecL = pdecTmp; - } - - // *pdecL will need to be multiplied by 10^iScale so - // it will have the same scale as *pdecR. We could be - // extending it to up to 192 bits of precision. - // - if (iScale <= POWER10_MAX) { - // Scaling won't make it larger than 4 ULONGs - // - ulPwr = rgulPower10[iScale]; - DECIMAL_LO64_SET(decTmp, UInt32x32To64(pdecL->v.v.Lo32, ulPwr)); - sdlTmp.int64 = UInt32x32To64(pdecL->v.v.Mid32, ulPwr); - sdlTmp.int64 += decTmp.v.v.Mid32; - decTmp.v.v.Mid32 = sdlTmp.u.Lo; - decTmp.Hi32 = sdlTmp.u.Hi; - sdlTmp.int64 = UInt32x32To64(pdecL->Hi32, ulPwr); - sdlTmp.int64 += decTmp.Hi32; - if (sdlTmp.u.Hi == 0) { - // Result fits in 96 bits. Use standard aligned add. - // - decTmp.Hi32 = sdlTmp.u.Lo; - pdecL = &decTmp; - goto AlignedAdd; - } - rgulNum[0] = decTmp.v.v.Lo32; - rgulNum[1] = decTmp.v.v.Mid32; - rgulNum[2] = sdlTmp.u.Lo; - rgulNum[3] = sdlTmp.u.Hi; - iHiProd = 3; - } - else { - // Have to scale by a bunch. Move the number to a buffer - // where it has room to grow as it's scaled. - // - rgulNum[0] = pdecL->v.v.Lo32; - rgulNum[1] = pdecL->v.v.Mid32; - rgulNum[2] = pdecL->Hi32; - iHiProd = 2; - - // Scan for zeros in the upper words. - // - if (rgulNum[2] == 0) { - iHiProd = 1; - if (rgulNum[1] == 0) { - iHiProd = 0; - if (rgulNum[0] == 0) { - // Left arg is zero, return right. - // - DECIMAL_LO64_SET(decRes, DECIMAL_LO64_GET(*pdecR)); - decRes.Hi32 = pdecR->Hi32; - decRes.u.u.sign ^= bSign; - goto RetDec; - } - } - } - - // Scaling loop, up to 10^9 at a time. iHiProd stays updated - // with index of highest non-zero ULONG. - // - for (; iScale > 0; iScale -= POWER10_MAX) { - if (iScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iScale]; - - sdlTmp.u.Hi = 0; - for (iCur = 0; iCur <= iHiProd; iCur++) { - sdlTmp.int64 = UInt32x32To64(rgulNum[iCur], ulPwr) + sdlTmp.u.Hi; - rgulNum[iCur] = sdlTmp.u.Lo; - } - - if (sdlTmp.u.Hi != 0) - // We're extending the result by another ULONG. - rgulNum[++iHiProd] = sdlTmp.u.Hi; - } - } - - // Scaling complete, do the add. Could be subtract if signs differ. - // - sdlTmp.u.Lo = rgulNum[0]; - sdlTmp.u.Hi = rgulNum[1]; - - if (bSign) { - // Signs differ, subtract. - // - DECIMAL_LO64_SET(decRes, sdlTmp.int64 - DECIMAL_LO64_GET(*pdecR)); - decRes.Hi32 = rgulNum[2] - pdecR->Hi32; - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) > sdlTmp.int64) { - decRes.Hi32--; - if (decRes.Hi32 >= rgulNum[2]) - goto LongSub; - } - else if (decRes.Hi32 > rgulNum[2]) { -LongSub: - // If rgulNum has more than 96 bits of precision, then we need to - // carry the subtraction into the higher bits. If it doesn't, - // then we subtracted in the wrong order and have to flip the - // sign of the result. - // - if (iHiProd <= 2) - goto SignFlip; - - iCur = 3; - while(rgulNum[iCur++]-- == 0); - if (rgulNum[iHiProd] == 0) - iHiProd--; - } - } - else { - // Signs the same, add. - // - DECIMAL_LO64_SET(decRes, sdlTmp.int64 + DECIMAL_LO64_GET(*pdecR)); - decRes.Hi32 = rgulNum[2] + pdecR->Hi32; - - // Propagate carry - // - if (DECIMAL_LO64_GET(decRes) < sdlTmp.int64) { - decRes.Hi32++; - if (decRes.Hi32 <= rgulNum[2]) - goto LongAdd; - } - else if (decRes.Hi32 < rgulNum[2]) { -LongAdd: - // Had a carry above 96 bits. - // - iCur = 3; - do { - if (iHiProd < iCur) { - rgulNum[iCur] = 1; - iHiProd = iCur; - break; - } - }while (++rgulNum[iCur++] == 0); - } - } - - if (iHiProd > 2) { - rgulNum[0] = decRes.v.v.Lo32; - rgulNum[1] = decRes.v.v.Mid32; - rgulNum[2] = decRes.Hi32; - decRes.u.u.scale = ScaleResult(rgulNum, iHiProd, decRes.u.u.scale); - if (decRes.u.u.scale == (BYTE) -1) - return DISP_E_OVERFLOW; - - decRes.v.v.Lo32 = rgulNum[0]; - decRes.v.v.Mid32 = rgulNum[1]; - decRes.Hi32 = rgulNum[2]; - } - } - -RetDec: - COPYDEC(*pdecRes, decRes) - return NOERROR; -} - - -//********************************************************************** -// -// VarDecDiv - Decimal Divide -// -//********************************************************************** - -STDAPI VarDecDiv(LPDECIMAL pdecL, LPDECIMAL pdecR, LPDECIMAL pdecRes) -{ - ULONG rgulQuo[3]; - ULONG rgulQuoSave[3]; - ULONG rgulRem[4]; - ULONG rgulDivisor[3]; - ULONG ulPwr; - ULONG ulTmp; - ULONG ulTmp1; - SPLIT64 sdlTmp; - SPLIT64 sdlDivisor; - int iScale; - int iCurScale; - - iScale = pdecL->u.u.scale - pdecR->u.u.scale; - rgulDivisor[0] = pdecR->v.v.Lo32; - rgulDivisor[1] = pdecR->v.v.Mid32; - rgulDivisor[2] = pdecR->Hi32; - - if (rgulDivisor[1] == 0 && rgulDivisor[2] == 0) { - // Divisor is only 32 bits. Easy divide. - // - if (rgulDivisor[0] == 0) - return DISP_E_DIVBYZERO; - - rgulQuo[0] = pdecL->v.v.Lo32; - rgulQuo[1] = pdecL->v.v.Mid32; - rgulQuo[2] = pdecL->Hi32; - rgulRem[0] = Div96By32(rgulQuo, rgulDivisor[0]); - - for (;;) { - if (rgulRem[0] == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale; - } - break; - } - - // We have computed a quotient based on the natural scale - // ( - ). We have a non-zero - // remainder, so now we should increase the scale if possible to - // include more quotient bits. - // - // If it doesn't cause overflow, we'll loop scaling by 10^9 and - // computing more quotient bits as long as the remainder stays - // non-zero. If scaling by that much would cause overflow, we'll - // drop out of the loop and scale by as much as we can. - // - // Scaling by 10^9 will overflow if rgulQuo[2].rgulQuo[1] >= 2^32 / 10^9 - // = 4.294 967 296. So the upper limit is rgulQuo[2] == 4 and - // rgulQuo[1] == 0.294 967 296 * 2^32 = 1,266,874,889.7+. Since - // quotient bits in rgulQuo[0] could be all 1's, then 1,266,874,888 - // is the largest value in rgulQuo[1] (when rgulQuo[2] == 4) that is - // assured not to overflow. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - ulTmp = rgulRem[0] << 1; - if (ulTmp < rgulRem[0] || (ulTmp >= rgulDivisor[0] && - (ulTmp > rgulDivisor[0] || (rgulQuo[0] & 1)))) { -RoundUp: - if (++rgulQuo[0] == 0) - if (++rgulQuo[1] == 0) - rgulQuo[2]++; - } - break; - } - - if (iCurScale == -1) - return DISP_E_OVERFLOW; - -HaveScale: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) - return DISP_E_OVERFLOW; - - sdlTmp.int64 = DivMod64by32(UInt32x32To64(rgulRem[0], ulPwr), rgulDivisor[0]); - rgulRem[0] = sdlTmp.u.Hi; - - rgulQuo[0] += sdlTmp.u.Lo; - if (rgulQuo[0] < sdlTmp.u.Lo) { - if (++rgulQuo[1] == 0) - rgulQuo[2]++; - } - } // for (;;) - } - else { - // Divisor has bits set in the upper 64 bits. - // - // Divisor must be fully normalized (shifted so bit 31 of the most - // significant ULONG is 1). Locate the MSB so we know how much to - // normalize by. The dividend will be shifted by the same amount so - // the quotient is not changed. - // - if (rgulDivisor[2] == 0) - ulTmp = rgulDivisor[1]; - else - ulTmp = rgulDivisor[2]; - - iCurScale = 0; - if (!(ulTmp & 0xFFFF0000)) { - iCurScale += 16; - ulTmp <<= 16; - } - if (!(ulTmp & 0xFF000000)) { - iCurScale += 8; - ulTmp <<= 8; - } - if (!(ulTmp & 0xF0000000)) { - iCurScale += 4; - ulTmp <<= 4; - } - if (!(ulTmp & 0xC0000000)) { - iCurScale += 2; - ulTmp <<= 2; - } - if (!(ulTmp & 0x80000000)) { - iCurScale++; - ulTmp <<= 1; - } - - // Shift both dividend and divisor left by iCurScale. - // - sdlTmp.int64 = DECIMAL_LO64_GET(*pdecL) << iCurScale; - rgulRem[0] = sdlTmp.u.Lo; - rgulRem[1] = sdlTmp.u.Hi; - sdlTmp.u.Lo = pdecL->v.v.Mid32; - sdlTmp.u.Hi = pdecL->Hi32; - sdlTmp.int64 <<= iCurScale; - rgulRem[2] = sdlTmp.u.Hi; - rgulRem[3] = (pdecL->Hi32 >> (31 - iCurScale)) >> 1; - - sdlDivisor.u.Lo = rgulDivisor[0]; - sdlDivisor.u.Hi = rgulDivisor[1]; - sdlDivisor.int64 <<= iCurScale; - - if (rgulDivisor[2] == 0) { - // Have a 64-bit divisor in sdlDivisor. The remainder - // (currently 96 bits spread over 4 ULONGs) will be < divisor. - // - sdlTmp.u.Lo = rgulRem[2]; - sdlTmp.u.Hi = rgulRem[3]; - - rgulQuo[2] = 0; - rgulQuo[1] = Div96By64(&rgulRem[1], sdlDivisor); - rgulQuo[0] = Div96By64(rgulRem, sdlDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale64; - } - break; - } - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - sdlTmp.u.Lo = rgulRem[0]; - sdlTmp.u.Hi = rgulRem[1]; - if (sdlTmp.u.Hi >= 0x80000000 || (sdlTmp.int64 <<= 1) > sdlDivisor.int64 || - (sdlTmp.int64 == sdlDivisor.int64 && (rgulQuo[0] & 1))) - goto RoundUp; - break; - } - - if (iCurScale == -1) - return DISP_E_OVERFLOW; - -HaveScale64: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) - return DISP_E_OVERFLOW; - - rgulRem[2] = 0; // rem is 64 bits, IncreaseScale uses 96 - IncreaseScale(rgulRem, ulPwr); - ulTmp = Div96By64(rgulRem, sdlDivisor); - rgulQuo[0] += ulTmp; - if (rgulQuo[0] < ulTmp) - if (++rgulQuo[1] == 0) - rgulQuo[2]++; - - } // for (;;) - } - else { - // Have a 96-bit divisor in rgulDivisor[]. - // - // Start by finishing the shift left by iCurScale. - // - sdlTmp.u.Lo = rgulDivisor[1]; - sdlTmp.u.Hi = rgulDivisor[2]; - sdlTmp.int64 <<= iCurScale; - rgulDivisor[0] = sdlDivisor.u.Lo; - rgulDivisor[1] = sdlDivisor.u.Hi; - rgulDivisor[2] = sdlTmp.u.Hi; - - // The remainder (currently 96 bits spread over 4 ULONGs) - // will be < divisor. - // - rgulQuo[2] = 0; - rgulQuo[1] = 0; - rgulQuo[0] = Div128By96(rgulRem, rgulDivisor); - - for (;;) { - if ((rgulRem[0] | rgulRem[1] | rgulRem[2]) == 0) { - if (iScale < 0) { - iCurScale = min(9, -iScale); - goto HaveScale96; - } - break; - } - - // Remainder is non-zero. Scale up quotient and remainder by - // powers of 10 so we can compute more significant bits. - // - iCurScale = SearchScale(rgulQuo[2], rgulQuo[1], iScale); - if (iCurScale == 0) { - // No more scaling to be done, but remainder is non-zero. - // Round quotient. - // - if (rgulRem[2] >= 0x80000000) - goto RoundUp; - - ulTmp = rgulRem[0] > 0x80000000; - ulTmp1 = rgulRem[1] > 0x80000000; - rgulRem[0] <<= 1; - rgulRem[1] = (rgulRem[1] << 1) + ulTmp; - rgulRem[2] = (rgulRem[2] << 1) + ulTmp1; - - if (rgulRem[2] > rgulDivisor[2] || (rgulRem[2] == rgulDivisor[2] && - (rgulRem[1] > rgulDivisor[1] || (rgulRem[1] == rgulDivisor[1] && - (rgulRem[0] > rgulDivisor[0] || (rgulRem[0] == rgulDivisor[0] && - (rgulQuo[0] & 1))))))) - goto RoundUp; - break; - } - - if (iCurScale == -1) - return DISP_E_OVERFLOW; - -HaveScale96: - ulPwr = rgulPower10[iCurScale]; - iScale += iCurScale; - - if (IncreaseScale(rgulQuo, ulPwr) != 0) - return DISP_E_OVERFLOW; - - rgulRem[3] = IncreaseScale(rgulRem, ulPwr); - ulTmp = Div128By96(rgulRem, rgulDivisor); - rgulQuo[0] += ulTmp; - if (rgulQuo[0] < ulTmp) - if (++rgulQuo[1] == 0) - rgulQuo[2]++; - - } // for (;;) - } - } - - // No more remainder. Try extracting any extra powers of 10 we may have - // added. We do this by trying to divide out 10^8, 10^4, 10^2, and 10^1. - // If a division by one of these powers returns a zero remainder, then - // we keep the quotient. If the remainder is not zero, then we restore - // the previous value. - // - // Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 - // we can extract. We use this as a quick test on whether to try a - // given power. - // - while ((rgulQuo[0] & 0xFF) == 0 && iScale >= 8) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100000000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 8; - } - else - break; - } - - if ((rgulQuo[0] & 0xF) == 0 && iScale >= 4) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10000) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 4; - } - } - - if ((rgulQuo[0] & 3) == 0 && iScale >= 2) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 100) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 2; - } - } - - if ((rgulQuo[0] & 1) == 0 && iScale >= 1) { - rgulQuoSave[0] = rgulQuo[0]; - rgulQuoSave[1] = rgulQuo[1]; - rgulQuoSave[2] = rgulQuo[2]; - - if (Div96By32(rgulQuoSave, 10) == 0) { - rgulQuo[0] = rgulQuoSave[0]; - rgulQuo[1] = rgulQuoSave[1]; - rgulQuo[2] = rgulQuoSave[2]; - iScale -= 1; - } - } - - pdecRes->Hi32 = rgulQuo[2]; - pdecRes->v.v.Mid32 = rgulQuo[1]; - pdecRes->v.v.Lo32 = rgulQuo[0]; - pdecRes->u.u.scale = iScale; - pdecRes->u.u.sign = pdecL->u.u.sign ^ pdecR->u.u.sign; - return NOERROR; -} - - -//********************************************************************** -// -// VarDecAbs - Decimal Absolute Value -// -//********************************************************************** - -STDAPI VarDecAbs(LPDECIMAL pdecOprd, LPDECIMAL pdecRes) -{ - COPYDEC(*pdecRes, *pdecOprd) - pdecRes->u.u.sign &= ~DECIMAL_NEG; - return NOERROR; -} - - -//********************************************************************** -// -// VarDecFix - Decimal Fix (chop to integer) -// -//********************************************************************** - -STDAPI VarDecFix(LPDECIMAL pdecOprd, LPDECIMAL pdecRes) -{ - DecFixInt(pdecRes, pdecOprd); - return NOERROR; -} - - -//********************************************************************** -// -// VarDecInt - Decimal Int (round down to integer) -// -//********************************************************************** - -STDAPI VarDecInt(LPDECIMAL pdecOprd, LPDECIMAL pdecRes) -{ - if (DecFixInt(pdecRes, pdecOprd) != 0 && (pdecRes->u.u.sign & DECIMAL_NEG)) { - // We have chopped off a non-zero amount from a negative value. Since - // we round toward -infinity, we must increase the integer result by - // 1 to make it more negative. This will never overflow because - // in order to have a remainder, we must have had a non-zero scale factor. - // Our scale factor is back to zero now. - // - DECIMAL_LO64_SET(*pdecRes, DECIMAL_LO64_GET(*pdecRes) + 1); - if (DECIMAL_LO64_GET(*pdecRes) == 0) - pdecRes->Hi32++; - } - return NOERROR; -} - - -//********************************************************************** -// -// VarDecNeg - Decimal Negate -// -//********************************************************************** - -STDAPI VarDecNeg(LPDECIMAL pdecOprd, LPDECIMAL pdecRes) -{ - COPYDEC(*pdecRes, *pdecOprd) - pdecRes->u.u.sign ^= DECIMAL_NEG; - return NOERROR; -} - - -//********************************************************************** -// -// VarDecCmp - Decimal Compare -// -//********************************************************************** - -STDAPI VarDecCmp(LPDECIMAL pdecL, LPDECIMAL pdecR) -{ - ULONG ulSgnL; - ULONG ulSgnR; - - // First check signs and whether either are zero. If both are - // non-zero and of the same sign, just use subtraction to compare. - // - ulSgnL = pdecL->v.v.Lo32 | pdecL->v.v.Mid32 | pdecL->Hi32; - ulSgnR = pdecR->v.v.Lo32 | pdecR->v.v.Mid32 | pdecR->Hi32; - if (ulSgnL != 0) - ulSgnL = (pdecL->u.u.sign & DECIMAL_NEG) | 1; - - if (ulSgnR != 0) - ulSgnR = (pdecR->u.u.sign & DECIMAL_NEG) | 1; - - // ulSgnL & ulSgnR have values 1, 0, or 0x81 depending on if the left/right - // operand is +, 0, or -. - // - if (ulSgnL == ulSgnR) { - if (ulSgnL == 0) // both are zero - return VARCMP_EQ; // return equal - - DECIMAL decRes; - - DecAddSub(pdecL, pdecR, &decRes, DECIMAL_NEG); - if (DECIMAL_LO64_GET(decRes) == 0 && decRes.Hi32 == 0) - return VARCMP_EQ; - if (decRes.u.u.sign & DECIMAL_NEG) - return VARCMP_LT; - return VARCMP_GT; - } - - // Signs are different. Used signed byte compares - // - if ((char)ulSgnL > (char)ulSgnR) - return VARCMP_GT; - return VARCMP_LT; -} - -STDAPI VarDecRound(LPDECIMAL pdecIn, int cDecimals, LPDECIMAL pdecRes) -{ - ULONG rgulNum[3]; - ULONG ulRem; - ULONG ulSticky; - ULONG ulPwr; - int iScale; - - if (cDecimals < 0) - return E_INVALIDARG; - - iScale = pdecIn->u.u.scale - cDecimals; - if (iScale > 0) - { - rgulNum[0] = pdecIn->v.v.Lo32; - rgulNum[1] = pdecIn->v.v.Mid32; - rgulNum[2] = pdecIn->Hi32; - pdecRes->u.u.sign = pdecIn->u.u.sign; - ulRem = ulSticky = 0; - - do { - ulSticky |= ulRem; - if (iScale > POWER10_MAX) - ulPwr = ulTenToNine; - else - ulPwr = rgulPower10[iScale]; - - ulRem = Div96By32(rgulNum, ulPwr); - iScale -= 9; - }while (iScale > 0); - - // Now round. ulRem has last remainder, ulSticky has sticky bits. - // To do IEEE rounding, we add LSB of result to sticky bits so - // either causes round up if remainder * 2 == last divisor. - // - ulSticky |= rgulNum[0] & 1; - ulRem = (ulRem << 1) + (ulSticky != 0); - if (ulPwr < ulRem && - ++rgulNum[0] == 0 && - ++rgulNum[1] == 0 - ) - ++rgulNum[2]; - - pdecRes->v.v.Lo32 = rgulNum[0]; - pdecRes->v.v.Mid32 = rgulNum[1]; - pdecRes->Hi32 = rgulNum[2]; - pdecRes->u.u.scale = cDecimals; - return NOERROR; - } - - COPYDEC(*pdecRes, *pdecIn) - return NOERROR; -} diff --git a/src/palrt/decconv.cpp b/src/palrt/decconv.cpp deleted file mode 100644 index 9cb7575b045a..000000000000 --- a/src/palrt/decconv.cpp +++ /dev/null @@ -1,602 +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. -// - -// -// =========================================================================== -// File: decconv.cpp -// -// =========================================================================== -/*** -* -*Purpose: -* This module contains the low level conversion for Decimal data type. -* -*Implementation Notes: -* -*****************************************************************************/ - -#include "common.h" -#include "convert.h" - -#include -#include -#include - -#define VALIDATEDECIMAL(dec) \ - if (DECIMAL_SCALE(dec) > DECMAX || (DECIMAL_SIGN(dec) & ~DECIMAL_NEG) != 0) \ - return E_INVALIDARG; - -#define RESULT(X) ((HRESULT)(X)) - -//*********************************************************************** -// -// Data tables -// - -const double dblPower10[] = { - 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, 1e23, 1e24, 1e25, 1e26, 1e27, 1e28, 1e29, - 1e30, 1e31, 1e32, 1e33, 1e34, 1e35, 1e36, 1e37, 1e38, 1e39, - 1e40, 1e41, 1e42, 1e43, 1e44, 1e45, 1e46, 1e47, 1e48, 1e49, - 1e50, 1e51, 1e52, 1e53, 1e54, 1e55, 1e56, 1e57, 1e58, 1e59, - 1e60, 1e61, 1e62, 1e63, 1e64, 1e65, 1e66, 1e67, 1e68, 1e69, - 1e70, 1e71, 1e72, 1e73, 1e74, 1e75, 1e76, 1e77, 1e78, 1e79, - 1e80 }; - -double fnDblPower10(int ix) -{ - const int maxIx = (sizeof(dblPower10)/sizeof(dblPower10[0])); - _ASSERTE(ix >= 0); - if (ix < maxIx) - return dblPower10[ix]; - return pow(10.0, ix); -} // double fnDblPower10() - -#define DBLBIAS 1022 -#define SNGBIAS 126 -#define DECMAX 28 - -const SPLIT64 sdlTenToEighteen = { UI64(1000000000000000000) }; -const DBLSTRUCT ds2to64 = DEFDS(0, 0, DBLBIAS + 65, 0); - -//*********************************************************************** -// -// Data tables -// - -const SPLIT64 sdlPower10[] = { {UI64(10000000000)}, // 1E10 - {UI64(100000000000)}, // 1E11 - {UI64(1000000000000)}, // 1E12 - {UI64(10000000000000)}, // 1E13 - {UI64(100000000000000)} }; // 1E14 - -const unsigned __int64 ulPower10[] = {1, - UI64(10), - UI64(100), - UI64(1000), - UI64(10000), - UI64(100000), - UI64(1000000), - UI64(10000000), - UI64(100000000), - UI64(1000000000), - UI64(10000000000), - UI64(100000000000), - UI64(1000000000000), - UI64(10000000000000), - UI64(100000000000000), - UI64(1000000000000000), - UI64(10000000000000000), - UI64(100000000000000000), - UI64(1000000000000000000), - UI64(10000000000000000000)}; - -DWORDLONG UInt64x64To128(SPLIT64 sdlOp1, SPLIT64 sdlOp2, DWORDLONG *pdlHi) -{ - SPLIT64 sdlTmp1; - SPLIT64 sdlTmp2; - SPLIT64 sdlTmp3; - - sdlTmp1.int64 = UInt32x32To64(sdlOp1.u.Lo, sdlOp2.u.Lo); // lo partial prod - sdlTmp2.int64 = UInt32x32To64(sdlOp1.u.Lo, sdlOp2.u.Hi); // mid 1 partial prod - sdlTmp1.u.Hi += sdlTmp2.u.Lo; - if (sdlTmp1.u.Hi < sdlTmp2.u.Lo) // test for carry - sdlTmp2.u.Hi++; - sdlTmp3.int64 = UInt32x32To64(sdlOp1.u.Hi, sdlOp2.u.Hi) + (DWORDLONG)sdlTmp2.u.Hi; - sdlTmp2.int64 = UInt32x32To64(sdlOp1.u.Hi, sdlOp2.u.Lo); - sdlTmp1.u.Hi += sdlTmp2.u.Lo; - if (sdlTmp1.u.Hi < sdlTmp2.u.Lo) // test for carry - sdlTmp2.u.Hi++; - sdlTmp3.int64 += (DWORDLONG)sdlTmp2.u.Hi; - - *pdlHi = sdlTmp3.int64; - return sdlTmp1.int64; -} - - -//*********************************************************************** -// -// Conversion to/from Decimal data type -// - - -STDAPI -VarDecFromR4(float fltIn, DECIMAL FAR* pdecOut) -{ - int iExp; // number of bits to left of binary point - int iPower; - ULONG ulMant; - double dbl; - SPLIT64 sdlLo; - SPLIT64 sdlHi; - int lmax, cur; // temps used during scale reduction - - // The most we can scale by is 10^28, which is just slightly more - // than 2^93. So a float with an exponent of -94 could just - // barely reach 0.5, but smaller exponents will always round to zero. - // - if ( (iExp = ((SNGSTRUCT *)&fltIn)->exp - SNGBIAS) < -94 ) - { - DECIMAL_SETZERO(*pdecOut); - return NOERROR; - } - - if (iExp > 96) - return RESULT(DISP_E_OVERFLOW); - - // Round the input to a 7-digit integer. The R4 format has - // only 7 digits of precision, and we want to keep garbage digits - // out of the Decimal were making. - // - // Calculate max power of 10 input value could have by multiplying - // the exponent by log10(2). Using scaled integer multiplcation, - // log10(2) * 2 ^ 16 = .30103 * 65536 = 19728.3. - // - dbl = fabs(fltIn); - iPower = 6 - ((iExp * 19728) >> 16); - - if (iPower >= 0) { - // We have less than 7 digits, scale input up. - // - if (iPower > DECMAX) - iPower = DECMAX; - - dbl = dbl * dblPower10[iPower]; - } - else { - if (iPower != -1 || dbl >= 1E7) - dbl = dbl / fnDblPower10(-iPower); - else - iPower = 0; // didn't scale it - } - - _ASSERTE(dbl < 1E7); - if (dbl < 1E6 && iPower < DECMAX) - { - dbl *= 10; - iPower++; - _ASSERTE(dbl >= 1E6); - } - - // Round to integer - // - ulMant = (LONG)dbl; - dbl -= (double)ulMant; // difference between input & integer - if ( dbl > 0.5 || (dbl == 0.5 && (ulMant & 1)) ) - ulMant++; - - if (ulMant == 0) - { - DECIMAL_SETZERO(*pdecOut); - return NOERROR; - } - - if (iPower < 0) { - // Add -iPower factors of 10, -iPower <= (29 - 7) = 22. - // - iPower = -iPower; - if (iPower < 10) { - sdlLo.int64 = UInt32x32To64(ulMant, (ULONG)ulPower10[iPower]); - - DECIMAL_LO32(*pdecOut) = sdlLo.u.Lo; - DECIMAL_MID32(*pdecOut) = sdlLo.u.Hi; - DECIMAL_HI32(*pdecOut) = 0; - } - else { - // Have a big power of 10. - // - if (iPower > 18) { - sdlLo.int64 = UInt32x32To64(ulMant, (ULONG)ulPower10[iPower - 18]); - sdlLo.int64 = UInt64x64To128(sdlLo, sdlTenToEighteen, &sdlHi.int64); - - if (sdlHi.u.Hi != 0) - return RESULT(DISP_E_OVERFLOW); - } - else { - sdlLo.int64 = UInt32x32To64(ulMant, (ULONG)ulPower10[iPower - 9]); - sdlHi.int64 = UInt32x32To64(ulTenToNine, sdlLo.u.Hi); - sdlLo.int64 = UInt32x32To64(ulTenToNine, sdlLo.u.Lo); - sdlHi.int64 += sdlLo.u.Hi; - sdlLo.u.Hi = sdlHi.u.Lo; - sdlHi.u.Lo = sdlHi.u.Hi; - } - DECIMAL_LO32(*pdecOut) = sdlLo.u.Lo; - DECIMAL_MID32(*pdecOut) = sdlLo.u.Hi; - DECIMAL_HI32(*pdecOut) = sdlHi.u.Lo; - } - DECIMAL_SCALE(*pdecOut) = 0; - } - else { - // Factor out powers of 10 to reduce the scale, if possible. - // The maximum number we could factor out would be 6. This - // comes from the fact we have a 7-digit number, and the - // MSD must be non-zero -- but the lower 6 digits could be - // zero. Note also the scale factor is never negative, so - // we can't scale by any more than the power we used to - // get the integer. - // - // DivMod32by32 returns the quotient in Lo, the remainder in Hi. - // - lmax = min(iPower, 6); - - // lmax is the largest power of 10 to try, lmax <= 6. - // We'll try powers 4, 2, and 1 unless they're too big. - // - for (cur = 4; cur > 0; cur >>= 1) - { - if (cur > lmax) - continue; - - sdlLo.int64 = DivMod32by32(ulMant, (ULONG)ulPower10[cur]); - - if (sdlLo.u.Hi == 0) { - ulMant = sdlLo.u.Lo; - iPower -= cur; - lmax -= cur; - } - } - DECIMAL_LO32(*pdecOut) = ulMant; - DECIMAL_MID32(*pdecOut) = 0; - DECIMAL_HI32(*pdecOut) = 0; - DECIMAL_SCALE(*pdecOut) = iPower; - } - - DECIMAL_SIGN(*pdecOut) = (char)((SNGSTRUCT *)&fltIn)->sign << 7; - return NOERROR; -} - -STDAPI -VarDecFromR8(double dblIn, DECIMAL FAR* pdecOut) -{ - int iExp; // number of bits to left of binary point - int iPower; // power-of-10 scale factor - SPLIT64 sdlMant; - SPLIT64 sdlLo; - double dbl; - int lmax, cur; // temps used during scale reduction - ULONG ulPwrCur; - ULONG ulQuo; - - - // The most we can scale by is 10^28, which is just slightly more - // than 2^93. So a float with an exponent of -94 could just - // barely reach 0.5, but smaller exponents will always round to zero. - // - if ( (iExp = ((DBLSTRUCT *)&dblIn)->u.exp - DBLBIAS) < -94 ) - { - DECIMAL_SETZERO(*pdecOut); - return NOERROR; - } - - if (iExp > 96) - return RESULT(DISP_E_OVERFLOW); - - // Round the input to a 15-digit integer. The R8 format has - // only 15 digits of precision, and we want to keep garbage digits - // out of the Decimal were making. - // - // Calculate max power of 10 input value could have by multiplying - // the exponent by log10(2). Using scaled integer multiplcation, - // log10(2) * 2 ^ 16 = .30103 * 65536 = 19728.3. - // - dbl = fabs(dblIn); - iPower = 14 - ((iExp * 19728) >> 16); - - if (iPower >= 0) { - // We have less than 15 digits, scale input up. - // - if (iPower > DECMAX) - iPower = DECMAX; - - dbl = dbl * dblPower10[iPower]; - } - else { - if (iPower != -1 || dbl >= 1E15) - dbl = dbl / fnDblPower10(-iPower); - else - iPower = 0; // didn't scale it - } - - _ASSERTE(dbl < 1E15); - if (dbl < 1E14 && iPower < DECMAX) - { - dbl *= 10; - iPower++; - _ASSERTE(dbl >= 1E14); - } - - // Round to int64 - // - sdlMant.int64 = (LONGLONG)dbl; - dbl -= (double)(LONGLONG)sdlMant.int64; // dif between input & integer - if ( dbl > 0.5 || (dbl == 0.5 && (sdlMant.u.Lo & 1)) ) - sdlMant.int64++; - - if (sdlMant.int64 == 0) - { - DECIMAL_SETZERO(*pdecOut); - return NOERROR; - } - - if (iPower < 0) { - // Add -iPower factors of 10, -iPower <= (29 - 15) = 14. - // - iPower = -iPower; - if (iPower < 10) { - sdlLo.int64 = UInt32x32To64(sdlMant.u.Lo, (ULONG)ulPower10[iPower]); - sdlMant.int64 = UInt32x32To64(sdlMant.u.Hi, (ULONG)ulPower10[iPower]); - sdlMant.int64 += sdlLo.u.Hi; - sdlLo.u.Hi = sdlMant.u.Lo; - sdlMant.u.Lo = sdlMant.u.Hi; - } - else { - // Have a big power of 10. - // - _ASSERTE(iPower <= 14); - sdlLo.int64 = UInt64x64To128(sdlMant, sdlPower10[iPower-10], &sdlMant.int64); - - if (sdlMant.u.Hi != 0) - return RESULT(DISP_E_OVERFLOW); - } - DECIMAL_LO32(*pdecOut) = sdlLo.u.Lo; - DECIMAL_MID32(*pdecOut) = sdlLo.u.Hi; - DECIMAL_HI32(*pdecOut) = sdlMant.u.Lo; - DECIMAL_SCALE(*pdecOut) = 0; - } - else { - // Factor out powers of 10 to reduce the scale, if possible. - // The maximum number we could factor out would be 14. This - // comes from the fact we have a 15-digit number, and the - // MSD must be non-zero -- but the lower 14 digits could be - // zero. Note also the scale factor is never negative, so - // we can't scale by any more than the power we used to - // get the integer. - // - // DivMod64by32 returns the quotient in Lo, the remainder in Hi. - // - lmax = min(iPower, 14); - - // lmax is the largest power of 10 to try, lmax <= 14. - // We'll try powers 8, 4, 2, and 1 unless they're too big. - // - for (cur = 8; cur > 0; cur >>= 1) - { - if (cur > lmax) - continue; - - ulPwrCur = (ULONG)ulPower10[cur]; - - if (sdlMant.u.Hi >= ulPwrCur) { - // Overflow if we try to divide in one step. - // - sdlLo.int64 = DivMod64by32(sdlMant.u.Hi, ulPwrCur); - ulQuo = sdlLo.u.Lo; - sdlLo.u.Lo = sdlMant.u.Lo; - sdlLo.int64 = DivMod64by32(sdlLo.int64, ulPwrCur); - } - else { - ulQuo = 0; - sdlLo.int64 = DivMod64by32(sdlMant.int64, ulPwrCur); - } - - if (sdlLo.u.Hi == 0) { - sdlMant.u.Hi = ulQuo; - sdlMant.u.Lo = sdlLo.u.Lo; - iPower -= cur; - lmax -= cur; - } - } - - DECIMAL_HI32(*pdecOut) = 0; - DECIMAL_SCALE(*pdecOut) = iPower; - DECIMAL_LO32(*pdecOut) = sdlMant.u.Lo; - DECIMAL_MID32(*pdecOut) = sdlMant.u.Hi; - } - - DECIMAL_SIGN(*pdecOut) = (char)((DBLSTRUCT *)&dblIn)->u.sign << 7; - return NOERROR; -} - -STDAPI -VarDecFromCy(CY cyIn, DECIMAL FAR* pdecOut) -{ - DECIMAL_SIGN(*pdecOut) = (UCHAR)((cyIn.u.Hi >> 24) & DECIMAL_NEG); - if (DECIMAL_SIGN(*pdecOut)) - cyIn.int64 = -cyIn.int64; - - DECIMAL_LO32(*pdecOut) = cyIn.u.Lo; - DECIMAL_MID32(*pdecOut) = cyIn.u.Hi; - DECIMAL_SCALE(*pdecOut) = 4; - DECIMAL_HI32(*pdecOut) = 0; - return NOERROR; -} - -STDAPI VarR4FromDec(DECIMAL FAR* pdecIn, float FAR* pfltOut) -{ - double dbl; - - VALIDATEDECIMAL(*pdecIn); // E_INVALIDARG check - - // Can't overflow; no errors possible. - // - VarR8FromDec(pdecIn, &dbl); - *pfltOut = (float)dbl; - return NOERROR; -} - -STDAPI VarR8FromDec(DECIMAL FAR* pdecIn, double FAR* pdblOut) -{ - SPLIT64 sdlTmp; - double dbl; - - VALIDATEDECIMAL(*pdecIn); // E_INVALIDARG check - - sdlTmp.u.Lo = DECIMAL_LO32(*pdecIn); - sdlTmp.u.Hi = DECIMAL_MID32(*pdecIn); - - if ( (LONG)DECIMAL_MID32(*pdecIn) < 0 ) - dbl = (ds2to64.dbl + (double)(LONGLONG)sdlTmp.int64 + - (double)DECIMAL_HI32(*pdecIn) * ds2to64.dbl) / fnDblPower10(DECIMAL_SCALE(*pdecIn)) ; - else - dbl = ((double)(LONGLONG)sdlTmp.int64 + - (double)DECIMAL_HI32(*pdecIn) * ds2to64.dbl) / fnDblPower10(DECIMAL_SCALE(*pdecIn)); - - if (DECIMAL_SIGN(*pdecIn)) - dbl = -dbl; - - *pdblOut = dbl; - return NOERROR; -} - -STDAPI VarCyFromDec(DECIMAL FAR* pdecIn, CY FAR* pcyOut) -{ - SPLIT64 sdlTmp; - SPLIT64 sdlTmp1; - int scale; - ULONG ulPwr; - ULONG ul; - - VALIDATEDECIMAL(*pdecIn); // E_INVALIDARG check - - scale = DECIMAL_SCALE(*pdecIn) - 4; // the power of 10 to divide by - - if (scale == 0) { - // No scaling needed -- the Decimal has 4 decimal places, - // just what Currency needs. - // - if ( DECIMAL_HI32(*pdecIn) != 0 || - (DECIMAL_MID32(*pdecIn) >= 0x80000000 && - (DECIMAL_MID32(*pdecIn) != 0x80000000 || DECIMAL_LO32(*pdecIn) != 0 || !DECIMAL_SIGN(*pdecIn))) ) - return RESULT(DISP_E_OVERFLOW); - - sdlTmp.u.Lo = DECIMAL_LO32(*pdecIn); - sdlTmp.u.Hi = DECIMAL_MID32(*pdecIn); - - if (DECIMAL_SIGN(*pdecIn)) - pcyOut->int64 = -(LONGLONG)sdlTmp.int64; - else - pcyOut->int64 = sdlTmp.int64; - return NOERROR; - } - - // Need to scale to get 4 decimal places. -4 <= scale <= 24. - // - if (scale < 0) { - sdlTmp1.int64 = UInt32x32To64((ULONG)ulPower10[-scale], DECIMAL_MID32(*pdecIn)); - sdlTmp.int64 = UInt32x32To64((ULONG)ulPower10[-scale], DECIMAL_LO32(*pdecIn)); - sdlTmp.u.Hi += sdlTmp1.u.Lo; - if (DECIMAL_HI32(*pdecIn) != 0 || sdlTmp1.u.Hi != 0 || sdlTmp1.u.Lo > sdlTmp.u.Hi) - return RESULT(DISP_E_OVERFLOW); - } - else if (scale < 10) { - // DivMod64by32 returns the quotient in Lo, the remainder in Hi. - // - ulPwr = (ULONG)ulPower10[scale]; - if (DECIMAL_HI32(*pdecIn) >= ulPwr) - return RESULT(DISP_E_OVERFLOW); - sdlTmp1.u.Lo = DECIMAL_MID32(*pdecIn); - sdlTmp1.u.Hi = DECIMAL_HI32(*pdecIn); - sdlTmp1.int64 = DivMod64by32(sdlTmp1.int64, ulPwr); - sdlTmp.u.Hi = sdlTmp1.u.Lo; // quotient to high half of result - sdlTmp1.u.Lo = DECIMAL_LO32(*pdecIn); // extended remainder - sdlTmp1.int64 = DivMod64by32(sdlTmp1.int64, ulPwr); - sdlTmp.u.Lo = sdlTmp1.u.Lo; // quotient to low half of result - - // Round result based on remainder in sdlTmp1.Hi. - // - ulPwr >>= 1; // compare to power/2 (power always even) - if (sdlTmp1.u.Hi > ulPwr || (sdlTmp1.u.Hi == ulPwr && (sdlTmp.u.Lo & 1))) - sdlTmp.int64++; - } - else { - // We have a power of 10 in the range 10 - 24. These powers do - // not fit in 32 bits. We'll handle this by scaling 2 or 3 times, - // first by 10^10, then by the remaining amount (or 10^9, then - // the last bit). - // - // To scale by 10^10, we'll actually divide by 10^10/4, which fits - // in 32 bits. The second scaling is multiplied by four - // to account for it, just barely assured of fitting in 32 bits - // (4E9 < 2^32). Note that the upper third of the quotient is - // either zero or one, so we skip the divide step to calculate it. - // (Max 4E9 divided by 2.5E9.) - // - // DivMod64by32 returns the quotient in Lo, the remainder in Hi. - // - if (DECIMAL_HI32(*pdecIn) >= ulTenToTenDiv4) { - sdlTmp.u.Hi = 1; // upper 1st quotient - sdlTmp1.u.Hi = DECIMAL_HI32(*pdecIn) - ulTenToTenDiv4; // remainder - } - else { - sdlTmp.u.Hi = 0; // upper 1st quotient - sdlTmp1.u.Hi = DECIMAL_HI32(*pdecIn); // remainder - } - sdlTmp1.u.Lo = DECIMAL_MID32(*pdecIn); // extended remainder - sdlTmp1.int64 = DivMod64by32(sdlTmp1.int64, ulTenToTenDiv4); - sdlTmp.u.Lo = sdlTmp1.u.Lo; // middle 1st quotient - - sdlTmp1.u.Lo = DECIMAL_LO32(*pdecIn); // extended remainder - sdlTmp1.int64 = DivMod64by32(sdlTmp1.int64, ulTenToTenDiv4); - - ulPwr = (ULONG)(ulPower10[min(scale-10, 9)] << 2); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulPwr); - ul = sdlTmp.u.Lo; // upper 2nd quotient - - sdlTmp.u.Lo = sdlTmp1.u.Lo; // extended remainder - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulPwr); - sdlTmp1.u.Lo = sdlTmp.u.Hi; // save final remainder - sdlTmp.u.Hi = ul; // position high result - - if (scale >= 20) { - ulPwr = (ULONG)(ulPower10[scale-19]); - sdlTmp.int64 = DivMod64by32(sdlTmp.int64, ulPwr); - sdlTmp1.u.Hi |= sdlTmp1.u.Lo; // combine sticky bits - sdlTmp1.u.Lo = sdlTmp.u.Hi; // final remainder - sdlTmp.u.Hi = 0; // guaranteed result fits in 32 bits - } - - // Round result based on remainder in sdlTmp1.Lo. sdlTmp1.Hi is - // the remainder from the first division(s), representing sticky bits. - // Current result is in sdlTmp. - // - ulPwr >>= 1; // compare to power/2 (power always even) - if (sdlTmp1.u.Lo > ulPwr || (sdlTmp1.u.Lo == ulPwr && - ((sdlTmp.u.Lo & 1) || sdlTmp1.u.Hi != 0))) - sdlTmp.int64++; - } - - if (sdlTmp.u.Hi >= 0x80000000 && - (sdlTmp.int64 != UI64(0x8000000000000000) || !DECIMAL_SIGN(*pdecIn))) - return RESULT(DISP_E_OVERFLOW); - - if (DECIMAL_SIGN(*pdecIn)) - sdlTmp.int64 = -(LONGLONG)sdlTmp.int64; - - pcyOut->int64 = sdlTmp.int64; - return NOERROR; -} - - diff --git a/src/palrt/guid.cpp b/src/palrt/guid.cpp index 14cd3bb49073..4ec5c8c62864 100644 --- a/src/palrt/guid.cpp +++ b/src/palrt/guid.cpp @@ -11,7 +11,7 @@ // =========================================================================== #define INITGUID -#include "guiddef.h" +#include // These are GUIDs and IIDs that would normally be provided by the system via uuid.lib, // and that the PALRT exposes through headers. diff --git a/src/palrt/guiddef.h b/src/palrt/guiddef.h deleted file mode 100644 index a082619b9566..000000000000 --- a/src/palrt/guiddef.h +++ /dev/null @@ -1,26 +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. -// - -// -// =========================================================================== -// File: guiddef.h -// -// =========================================================================== -// simplified guiddef.h for PAL - -#include "common.h" - -#ifdef DEFINE_GUID -#undef DEFINE_GUID -#endif - -#ifdef INITGUID -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID DECLSPEC_SELECTANY name \ - = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } -#else -#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ - EXTERN_C const GUID FAR name -#endif // INITGUID diff --git a/src/scripts/genRuntimeEventSources.py b/src/scripts/genRuntimeEventSources.py index 5795a4d22aa2..1bde74ad8be1 100644 --- a/src/scripts/genRuntimeEventSources.py +++ b/src/scripts/genRuntimeEventSources.py @@ -39,7 +39,7 @@ "win:UInt32" : "UInt32", "win:UInt64" : "UInt64", "win:Int32" : "Int32", - "win:Pointer" : "UIntPtr", + "win:Pointer" : "IntPtr", "win:UnicodeString" : "string", "win:Binary" : "byte[]", "win:Double" : "double", @@ -116,7 +116,7 @@ def generateEvent(eventNode, providerNode, outputFile, stringTable): # Calculate the number of arguments. for argumentNode in argumentNodes: if argumentNode.nodeName == "data": - if argumentNode.getAttribute("inType") != "win:Binary" and argumentNode.getAttribute("inType") != "win:AnsiString": + if argumentNode.getAttribute("inType") != "win:Binary" and argumentNode.getAttribute("inType") != "win:AnsiString" and argumentNode.getAttribute("count") == "": argumentCount += 1 else: break @@ -181,9 +181,26 @@ def generateEvents(providerNode, outputFile, stringTable): eventsNode = node break + # Get the list of event nodes. + eventNodes = eventsNode.getElementsByTagName("event") + + # Build a list of events to be emitted. This is where old versions of events are stripped. + # key = eventID, value = version + eventList = dict() + for eventNode in eventNodes: + eventID = eventNode.getAttribute("value") + eventVersion = eventNode.getAttribute("version") + eventList[eventID] = eventVersion + # Iterate over each event node and process it. - for eventNode in eventsNode.getElementsByTagName("event"): - generateEvent(eventNode, providerNode, outputFile, stringTable) + # Only emit events for the latest version of the event, otherwise EventSource initialization will fail. + for eventNode in eventNodes: + eventID = eventNode.getAttribute("value") + eventVersion = eventNode.getAttribute("version") + if eventID in eventList and eventList[eventID] == eventVersion: + generateEvent(eventNode, providerNode, outputFile, stringTable) + elif eventID not in eventList: + raise ValueError("eventID could not be found in the list of events to emit.", eventID) def generateValueMapEnums(providerNode, outputFile, stringTable, enumTypeMap): @@ -355,11 +372,19 @@ def generateEventSources(manifestFullPath, intermediatesDirFullPath): """ writeOutput(outputFile, header) increaseTabLevel() - writeOutput(outputFile, "[EventSource(Name = \"" + providerName + "\", Guid = \"" + providerNode.getAttribute("guid") + "\")]\n") - writeOutput(outputFile, "internal sealed unsafe class " + providerNameToClassNameMap[providerName] + " : EventSource\n") + + className = providerNameToClassNameMap[providerName] + writeOutput(outputFile, "[EventSource(Name = \"" + providerName + "\")]\n") + writeOutput(outputFile, "internal sealed partial class " + className + " : EventSource\n") writeOutput(outputFile, "{\n") increaseTabLevel() + # Create a static property for the EventSource name so that we don't have to initialize the EventSource to get its name. + writeOutput(outputFile, "internal const string EventSourceName = \"" + providerName + "\";\n") + + # Write the static Log property. + writeOutput(outputFile, "internal static " + className + " Log = new " + className + "();\n\n") + # Write the keywords class. generateKeywordsClass(providerNode, outputFile) diff --git a/src/tools/r2rdump/Amd64/UnwindInfo.cs b/src/tools/r2rdump/Amd64/UnwindInfo.cs new file mode 100644 index 000000000000..4f7bb45ef092 --- /dev/null +++ b/src/tools/r2rdump/Amd64/UnwindInfo.cs @@ -0,0 +1,250 @@ +// 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.Text; +using System.Xml.Serialization; + +namespace R2RDump.Amd64 +{ + public enum UnwindOpCodes + { + UWOP_PUSH_NONVOL = 0, + UWOP_ALLOC_LARGE, + UWOP_ALLOC_SMALL, + UWOP_SET_FPREG, + UWOP_SAVE_NONVOL, + UWOP_SAVE_NONVOL_FAR, + UWOP_EPILOG, + UWOP_SPARE_CODE, + UWOP_SAVE_XMM128, + UWOP_SAVE_XMM128_FAR, + UWOP_PUSH_MACHFRAME, + UWOP_SET_FPREG_LARGE, + } + + public enum UnwindFlags + { + UNW_FLAG_NHANDLER = 0x0, + UNW_FLAG_EHANDLER = 0x1, + UNW_FLAG_UHANDLER = 0x2, + UNW_FLAG_CHAININFO = 0x4, + } + + public struct UnwindCode + { + [XmlAttribute("Index")] + public int Index { get; set; } + + public byte CodeOffset { get; set; } + public UnwindOpCodes UnwindOp { get; set; } //4 bits + public byte OpInfo { get; set; } //4 bits + + public byte OffsetLow { get; set; } + public byte OffsetHigh { get; set; } //4 bits + + public uint FrameOffset { get; set; } + + public UnwindCode(byte[] image, int index, ref int offset) + { + Index = index; + + int off = offset; + CodeOffset = NativeReader.ReadByte(image, ref off); + byte op = NativeReader.ReadByte(image, ref off); + UnwindOp = (UnwindOpCodes)(op & 15); + OpInfo = (byte)(op >> 4); + + OffsetLow = CodeOffset; + OffsetHigh = OpInfo; + + FrameOffset = NativeReader.ReadUInt16(image, ref offset); + } + } + + public struct UnwindInfo : BaseUnwindInfo + { + private const int _sizeofUnwindCode = 2; + private const int _offsetofUnwindCode = 4; + + public byte Version { get; set; } //3 bits + public byte Flags { get; set; } //5 bits + public byte SizeOfProlog { get; set; } + public byte CountOfUnwindCodes { get; set; } + public Amd64Registers FrameRegister { get; set; } //4 bits + public byte FrameOffset { get; set; } //4 bits + public UnwindCode[] UnwindCode { get; set; } + public uint PersonalityRoutineRVA { get; set; } + public int Size { get; set; } + + public UnwindInfo(byte[] image, int offset) + { + byte versionAndFlags = NativeReader.ReadByte(image, ref offset); + Version = (byte)(versionAndFlags & 7); + Flags = (byte)(versionAndFlags >> 3); + SizeOfProlog = NativeReader.ReadByte(image, ref offset); + CountOfUnwindCodes = NativeReader.ReadByte(image, ref offset); + byte frameRegisterAndOffset = NativeReader.ReadByte(image, ref offset); + FrameRegister = (Amd64Registers)(frameRegisterAndOffset & 15); + FrameOffset = (byte)(frameRegisterAndOffset >> 4); + + UnwindCode = new UnwindCode[CountOfUnwindCodes]; + for (int i = 0; i < CountOfUnwindCodes; i++) + { + UnwindCode[i] = new UnwindCode(image, i, ref offset); + } + + PersonalityRoutineRVA = NativeReader.ReadUInt32(image, ref offset); + + Size = _offsetofUnwindCode + CountOfUnwindCodes * _sizeofUnwindCode; + int alignmentPad = ((Size + sizeof(int) - 1) & ~(sizeof(int) - 1)) - Size; + Size += (alignmentPad + sizeof(uint)); + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\tVersion: {Version}"); + sb.Append($"\tFlags: 0x{Flags:X8} ("); + if (Flags == (byte)UnwindFlags.UNW_FLAG_NHANDLER) + { + sb.Append(" UNW_FLAG_NHANDLER"); + } + else + { + if ((Flags & (byte)UnwindFlags.UNW_FLAG_EHANDLER) != 0) + sb.Append(" UNW_FLAG_EHANDLER"); + if ((Flags & (byte)UnwindFlags.UNW_FLAG_UHANDLER) != 0) + sb.Append(" UNW_FLAG_UHANDLER"); + if ((Flags & (byte)UnwindFlags.UNW_FLAG_CHAININFO) != 0) + sb.Append(" UNW_FLAG_CHAININFO"); + } + sb.AppendLine(" )"); + + sb.AppendLine($"\tSizeOfProlog: {SizeOfProlog}"); + sb.AppendLine($"\tCountOfUnwindCodes: {CountOfUnwindCodes}"); + sb.AppendLine($"\tFrameRegister: {FrameRegister}"); + sb.AppendLine($"\tFrameOffset: {FrameOffset}"); + sb.AppendLine($"\tUnwind Codes:"); + sb.AppendLine($"\t\t------------------"); + for (int i = 0; i < CountOfUnwindCodes; i++) + { + sb.Append(GetUnwindCode(ref i)); + sb.AppendLine($"\t\t------------------"); + } + sb.AppendLine($"\tPersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}"); + sb.AppendLine($"\tSize: {Size} bytes"); + + return sb.ToString(); + } + + private string GetUnwindCode(ref int i) + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\t\tCodeOffset: 0x{UnwindCode[i].CodeOffset:X2}"); + sb.AppendLine($"\t\tUnwindOp: {UnwindCode[i].UnwindOp}({(byte)UnwindCode[i].UnwindOp})"); + + switch (UnwindCode[i].UnwindOp) + { + case UnwindOpCodes.UWOP_PUSH_NONVOL: + sb.AppendLine($"\t\tOpInfo: {(Amd64Registers)UnwindCode[i].OpInfo}({UnwindCode[i].OpInfo})"); + break; + case UnwindOpCodes.UWOP_ALLOC_LARGE: + sb.Append($"\t\tOpInfo: {UnwindCode[i].OpInfo} - "); + if (UnwindCode[i].OpInfo == 0) + { + i++; + sb.AppendLine("Scaled small"); + uint frameOffset = UnwindCode[i].FrameOffset * 8; + sb.AppendLine($"\t\tFrameOffset: {UnwindCode[i].FrameOffset} * 8 = {frameOffset} = 0x{frameOffset:X5})"); + } + else if (UnwindCode[i].OpInfo == 1) + { + i++; + sb.AppendLine("Unscaled large"); + uint offset = UnwindCode[i].FrameOffset; + i++; + offset = ((UnwindCode[i].FrameOffset << 16) | offset); + sb.AppendLine($"\t\tFrameOffset: 0x{offset:X8})"); + } + else + { + sb.AppendLine("Unknown"); + } + break; + case UnwindOpCodes.UWOP_ALLOC_SMALL: + int opInfo = UnwindCode[i].OpInfo * 8 + 8; + sb.AppendLine($"\t\tOpInfo: {UnwindCode[i].OpInfo} * 8 + 8 = {opInfo} = 0x{opInfo:X2}"); + break; + case UnwindOpCodes.UWOP_SET_FPREG: + sb.AppendLine($"\t\tOpInfo: Unused({UnwindCode[i].OpInfo})"); + break; + case UnwindOpCodes.UWOP_SET_FPREG_LARGE: + { + sb.AppendLine($"\t\tOpInfo: Unused({UnwindCode[i].OpInfo})"); + i++; + uint offset = UnwindCode[i].FrameOffset; + i++; + offset = ((UnwindCode[i].FrameOffset << 16) | offset); + sb.AppendLine($"\t\tScaled Offset: {offset} * 16 = {offset * 16} = 0x{(offset * 16):X8}"); + if ((UnwindCode[i].FrameOffset & 0xF0000000) != 0) + { + R2RDump.WriteWarning("Illegal unwindInfo unscaled offset: too large"); + } + } + break; + case UnwindOpCodes.UWOP_SAVE_NONVOL: + { + sb.AppendLine($"\t\tOpInfo: {(Amd64Registers)UnwindCode[i].OpInfo}({UnwindCode[i].OpInfo})"); + i++; + uint offset = UnwindCode[i].FrameOffset * 8; + sb.AppendLine($"\t\tScaled Offset: {UnwindCode[i].FrameOffset} * 8 = {offset} = 0x{offset:X5}"); + } + break; + case UnwindOpCodes.UWOP_SAVE_NONVOL_FAR: + { + sb.AppendLine($"\t\tOpInfo: {(Amd64Registers)UnwindCode[i].OpInfo}({UnwindCode[i].OpInfo})"); + i++; + uint offset = UnwindCode[i].FrameOffset; + i++; + offset = ((UnwindCode[i].FrameOffset << 16) | offset); + sb.AppendLine($"\t\tUnscaled Large Offset: 0x{offset:X8}"); + } + break; + case UnwindOpCodes.UWOP_SAVE_XMM128: + { + sb.AppendLine($"\t\tOpInfo: XMM{UnwindCode[i].OpInfo}({UnwindCode[i].OpInfo})"); + i++; + uint offset = UnwindCode[i].FrameOffset * 16; + sb.AppendLine($"\t\tScaled Offset: {UnwindCode[i].FrameOffset} * 16 = {offset} = 0x{offset:X5}"); + } + break; + + case UnwindOpCodes.UWOP_SAVE_XMM128_FAR: + { + sb.AppendLine($"\t\tOpInfo: XMM{UnwindCode[i].OpInfo}({UnwindCode[i].OpInfo})"); + i++; + uint offset = UnwindCode[i].FrameOffset; + i++; + offset = ((UnwindCode[i].FrameOffset << 16) | offset); + sb.AppendLine($"\t\tUnscaled Large Offset: 0x{offset:X8}"); + } + break; + case UnwindOpCodes.UWOP_EPILOG: + case UnwindOpCodes.UWOP_SPARE_CODE: + case UnwindOpCodes.UWOP_PUSH_MACHFRAME: + default: + sb.AppendLine($"\t\tOpInfo: {UnwindCode[i].OpInfo}"); + sb.AppendLine(); + sb.AppendLine($"\t\tOffsetLow: {UnwindCode[i].OffsetLow}"); + sb.AppendLine($"\t\tOffsetHigh: {UnwindCode[i].OffsetHigh}"); + sb.AppendLine(); + sb.AppendLine($"\t\tFrameOffset: {FrameOffset}"); + break; + } + return sb.ToString(); + } + } +} diff --git a/src/tools/r2rdump/CoreDisTools.cs b/src/tools/r2rdump/CoreDisTools.cs index 52cb9009ec1f..194b449adbfd 100644 --- a/src/tools/r2rdump/CoreDisTools.cs +++ b/src/tools/r2rdump/CoreDisTools.cs @@ -3,13 +3,17 @@ // See the LICENSE file in the project root for more information. using System; +using System.Collections.Generic; using System.Reflection.PortableExecutable; using System.Runtime.InteropServices; +using System.Text; namespace R2RDump { - class CoreDisTools + public class CoreDisTools { + private const string _dll = "coredistools.dll"; + public enum TargetArch { Target_Host, // Target is the same as host architecture @@ -19,26 +23,39 @@ public enum TargetArch Target_Arm64 }; - [DllImport("coredistools.dll")] - [return: MarshalAs(UnmanagedType.I8)] - public static extern long InitDisasm(TargetArch Target); + [DllImport(_dll)] + public static extern IntPtr InitBufferedDisasm(TargetArch Target); + + [DllImport(_dll)] + public static extern void DumpCodeBlock(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size); + + [DllImport(_dll)] + [return: MarshalAs(UnmanagedType.I4)] + public static extern int DumpInstruction(IntPtr Disasm, ulong Address, IntPtr Bytes, int Size); + + [DllImport(_dll)] + public static extern IntPtr GetOutputBuffer(); - [DllImport("coredistools.dll")] - public static extern void DumpCodeBlock(long Disasm, ulong Address, IntPtr Bytes, int Size); + [DllImport(_dll)] + public static extern void ClearOutputBuffer(); - [DllImport("coredistools.dll")] - public static extern void FinishDisasm(long Disasm); + [DllImport(_dll)] + public static extern void FinishDisasm(IntPtr Disasm); - public unsafe static void DumpCodeBlock(long Disasm, int Address, int Offset, byte[] image, int Size) + public unsafe static int GetInstruction(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, int rtfOffset, byte[] image, out string instr) { + int instrSize = 1; fixed (byte* p = image) { - IntPtr ptr = (IntPtr)(p + Offset); - DumpCodeBlock(Disasm, (ulong)Address, ptr, Size); + IntPtr ptr = (IntPtr)(p + imageOffset + rtfOffset); + instrSize = DumpInstruction(Disasm, (ulong)(rtf.StartAddress + rtfOffset), ptr, rtf.Size); } + IntPtr pBuffer = GetOutputBuffer(); + instr = Marshal.PtrToStringAnsi(pBuffer); + return instrSize; } - public static long GetDisasm(Machine machine) + public static IntPtr GetDisasm(Machine machine) { TargetArch target = TargetArch.Target_Host; switch (machine) @@ -56,7 +73,7 @@ public static long GetDisasm(Machine machine) target = TargetArch.Target_Thumb; break; } - return InitDisasm(target); + return InitBufferedDisasm(target); } } } diff --git a/src/tools/r2rdump/DisassemblingTypeProvider.cs b/src/tools/r2rdump/DisassemblingTypeProvider.cs index c0a7e148c1db..46db0feab878 100644 --- a/src/tools/r2rdump/DisassemblingTypeProvider.cs +++ b/src/tools/r2rdump/DisassemblingTypeProvider.cs @@ -43,7 +43,7 @@ public virtual string GetTypeFromDefinition(MetadataReader reader, TypeDefinitio if ((definition.Attributes & TypeAttributes.NestedPublic) != 0 || (definition.Attributes & TypeAttributes.NestedFamily) != 0) { TypeDefinitionHandle declaringTypeHandle = definition.GetDeclaringType(); - return GetTypeFromDefinition(reader, declaringTypeHandle, 0) + "/" + name; + return GetTypeFromDefinition(reader, declaringTypeHandle, 0) + "." + name; } return name; diff --git a/src/tools/r2rdump/GCInfo.cs b/src/tools/r2rdump/GCInfo.cs new file mode 100644 index 000000000000..a940634436d0 --- /dev/null +++ b/src/tools/r2rdump/GCInfo.cs @@ -0,0 +1,575 @@ +// 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.Collections.Generic; +using System.Reflection.PortableExecutable; +using System.Text; +using System.Xml.Serialization; + +namespace R2RDump +{ + public class GcInfo + { + private enum GcInfoHeaderFlags + { + GC_INFO_IS_VARARG = 0x1, + GC_INFO_HAS_SECURITY_OBJECT = 0x2, + GC_INFO_HAS_GS_COOKIE = 0x4, + GC_INFO_HAS_PSP_SYM = 0x8, + GC_INFO_HAS_GENERICS_INST_CONTEXT_MASK = 0x30, + GC_INFO_HAS_GENERICS_INST_CONTEXT_NONE = 0x00, + GC_INFO_HAS_GENERICS_INST_CONTEXT_MT = 0x10, + GC_INFO_HAS_GENERICS_INST_CONTEXT_MD = 0x20, + GC_INFO_HAS_GENERICS_INST_CONTEXT_THIS = 0x30, + GC_INFO_HAS_STACK_BASE_REGISTER = 0x40, + GC_INFO_WANTS_REPORT_ONLY_LEAF = 0x80, // GC_INFO_HAS_TAILCALLS = 0x80, for ARM and ARM64 + GC_INFO_HAS_EDIT_AND_CONTINUE_PRESERVED_SLOTS = 0x100, + GC_INFO_REVERSE_PINVOKE_FRAME = 0x200, + + GC_INFO_FLAGS_BIT_SIZE_VERSION_1 = 9, + GC_INFO_FLAGS_BIT_SIZE = 10, + }; + + public struct InterruptibleRange + { + [XmlAttribute("Index")] + public uint Index { get; set; } + public uint StartOffset { get; set; } + public uint StopOffset { get; set; } + public InterruptibleRange(uint index, uint start, uint stop) + { + Index = index; + StartOffset = start; + StopOffset = stop; + } + } + + public class GcTransition + { + [XmlAttribute("Index")] + public int CodeOffset { get; set; } + public int SlotId { get; set; } + public bool IsLive { get; set; } + public int ChunkId { get; set; } + + public GcTransition() { } + + public GcTransition(int codeOffset, int slotId, bool isLive, int chunkId) + { + CodeOffset = codeOffset; + SlotId = slotId; + IsLive = isLive; + ChunkId = chunkId; + } + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\t\tCodeOffset: {CodeOffset}"); + sb.AppendLine($"\t\tSlotId: {SlotId}"); + sb.AppendLine($"\t\tIsLive: {IsLive}"); + sb.AppendLine($"\t\tChunkId: {ChunkId}"); + sb.Append($"\t\t--------------------"); + + return sb.ToString(); + } + public string GetSlotState(GcSlotTable slotTable) + { + GcSlotTable.GcSlot slot = slotTable.GcSlots[SlotId]; + string slotStr = ""; + if (slot.StackSlot == null) + { + slotStr = Enum.GetName(typeof(Amd64Registers), slot.RegisterNumber); + } + else + { + slotStr = $"sp{slot.StackSlot.SpOffset:+#;-#;+0}"; + } + string isLiveStr = "live"; + if (!IsLive) + isLiveStr = "dead"; + return $"{slotStr} is {isLiveStr}"; + } + } + + public struct SafePointOffset + { + [XmlAttribute("Index")] + public int Index { get; set; } + public uint Value { get; set; } + public SafePointOffset(int index, uint value) + { + Index = index; + Value = value; + } + } + + private const int GCINFO_VERSION = 2; + private const int MIN_GCINFO_VERSION_WITH_RETURN_KIND = 2; + private const int MIN_GCINFO_VERSION_WITH_REV_PINVOKE_FRAME = 2; + + private bool _slimHeader; + private bool _hasSecurityObject; + private bool _hasGSCookie; + private bool _hasPSPSym; + private bool _hasGenericsInstContext; + private bool _hasStackBaseRegister; + private bool _hasSizeOfEditAndContinuePreservedArea; + private bool _hasReversePInvokeFrame; + private bool _wantsReportOnlyLeaf; + + private Machine _machine; + private GcInfoTypes _gcInfoTypes; + + public int Version { get; set; } + public int CodeLength { get; set; } + public ReturnKinds ReturnKind { get; set; } + public uint ValidRangeStart { get; set; } + public uint ValidRangeEnd { get; set; } + public int SecurityObjectStackSlot { get; set; } + public int GSCookieStackSlot { get; set; } + public int PSPSymStackSlot { get; set; } + public int GenericsInstContextStackSlot { get; set; } + public uint StackBaseRegister { get; set; } + public uint SizeOfEditAndContinuePreservedArea { get; set; } + public int ReversePInvokeFrameStackSlot { get; set; } + public uint SizeOfStackOutgoingAndScratchArea { get; set; } + public uint NumSafePoints { get; set; } + public uint NumInterruptibleRanges { get; set; } + public List SafePointOffsets { get; set; } + public List InterruptibleRanges { get; set; } + public GcSlotTable SlotTable { get; set; } + public int Size { get; set; } + public int Offset { get; set; } + + [XmlIgnore] + public Dictionary Transitions { get; set; } + + public GcInfo() { } + + public GcInfo(byte[] image, int offset, Machine machine, ushort majorVersion) + { + Offset = offset; + _gcInfoTypes = new GcInfoTypes(machine); + + SecurityObjectStackSlot = -1; + GSCookieStackSlot = -1; + PSPSymStackSlot = -1; + SecurityObjectStackSlot = -1; + GenericsInstContextStackSlot = -1; + StackBaseRegister = 0xffffffff; + SizeOfEditAndContinuePreservedArea = 0xffffffff; + ReversePInvokeFrameStackSlot = -1; + + Version = ReadyToRunVersionToGcInfoVersion(majorVersion); + int bitOffset = offset * 8; + int startBitOffset = bitOffset; + + ParseHeaderFlags(image, ref bitOffset); + + if (Version >= MIN_GCINFO_VERSION_WITH_RETURN_KIND) // IsReturnKindAvailable + { + int returnKindBits = (_slimHeader) ? _gcInfoTypes.SIZE_OF_RETURN_KIND_SLIM : _gcInfoTypes.SIZE_OF_RETURN_KIND_FAT; + ReturnKind = (ReturnKinds)NativeReader.ReadBits(image, returnKindBits, ref bitOffset); + } + + CodeLength = _gcInfoTypes.DenormalizeCodeLength((int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.CODE_LENGTH_ENCBASE, ref bitOffset)); + + if (_hasGSCookie) + { + uint normPrologSize = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.NORM_PROLOG_SIZE_ENCBASE, ref bitOffset) + 1; + uint normEpilogSize = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.NORM_PROLOG_SIZE_ENCBASE, ref bitOffset); + + ValidRangeStart = normPrologSize; + ValidRangeEnd = (uint)CodeLength - normEpilogSize; + } + else if (_hasSecurityObject || _hasGenericsInstContext) + { + ValidRangeStart = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.NORM_PROLOG_SIZE_ENCBASE, ref bitOffset) + 1; + ValidRangeEnd = ValidRangeStart + 1; + } + + if (_hasSecurityObject) + { + SecurityObjectStackSlot = _gcInfoTypes.DenormalizeStackSlot(NativeReader.DecodeVarLengthSigned(image, _gcInfoTypes.SECURITY_OBJECT_STACK_SLOT_ENCBASE, ref bitOffset)); + } + + if (_hasGSCookie) + { + GSCookieStackSlot = _gcInfoTypes.DenormalizeStackSlot(NativeReader.DecodeVarLengthSigned(image, _gcInfoTypes.GS_COOKIE_STACK_SLOT_ENCBASE, ref bitOffset)); + } + + if (_hasPSPSym) + { + PSPSymStackSlot = _gcInfoTypes.DenormalizeStackSlot(NativeReader.DecodeVarLengthSigned(image, _gcInfoTypes.PSP_SYM_STACK_SLOT_ENCBASE, ref bitOffset)); + } + + if (_hasGenericsInstContext) + { + GenericsInstContextStackSlot = _gcInfoTypes.DenormalizeStackSlot(NativeReader.DecodeVarLengthSigned(image, _gcInfoTypes.GENERICS_INST_CONTEXT_STACK_SLOT_ENCBASE, ref bitOffset)); + } + + if (_hasStackBaseRegister && !_slimHeader) + { + StackBaseRegister = _gcInfoTypes.DenormalizeStackBaseRegister(NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.STACK_BASE_REGISTER_ENCBASE, ref bitOffset)); + } + + if (_hasSizeOfEditAndContinuePreservedArea) + { + SizeOfEditAndContinuePreservedArea = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE, ref bitOffset); + } + + if (_hasReversePInvokeFrame) + { + ReversePInvokeFrameStackSlot = NativeReader.DecodeVarLengthSigned(image, _gcInfoTypes.REVERSE_PINVOKE_FRAME_ENCBASE, ref bitOffset); + } + + // FIXED_STACK_PARAMETER_SCRATCH_AREA (this macro is always defined in _gcInfoTypes.h) + if (!_slimHeader) + { + SizeOfStackOutgoingAndScratchArea = _gcInfoTypes.DenormalizeSizeOfStackArea(NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.SIZE_OF_STACK_AREA_ENCBASE, ref bitOffset)); + } + + // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED (this macro is always defined in _gcInfoTypes.h) + NumSafePoints = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.NUM_SAFE_POINTS_ENCBASE, ref bitOffset); + + if (!_slimHeader) + { + NumInterruptibleRanges = NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.NUM_INTERRUPTIBLE_RANGES_ENCBASE, ref bitOffset); + } + + // PARTIALLY_INTERRUPTIBLE_GC_SUPPORTED (this macro is always defined in _gcInfoTypes.h) + SafePointOffsets = EnumerateSafePoints(image, ref bitOffset); + uint numBitsPerOffset = GcInfoTypes.CeilOfLog2(CodeLength); + bitOffset += (int)(NumSafePoints * numBitsPerOffset); + + InterruptibleRanges = EnumerateInterruptibleRanges(image, _gcInfoTypes.INTERRUPTIBLE_RANGE_DELTA1_ENCBASE, _gcInfoTypes.INTERRUPTIBLE_RANGE_DELTA2_ENCBASE, ref bitOffset); + + SlotTable = new GcSlotTable(image, machine, _gcInfoTypes, ref bitOffset); + + Transitions = GetTranstions(image, ref bitOffset); + + Size = bitOffset - startBitOffset; + + _machine = machine; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\tVersion: {Version}"); + sb.AppendLine($"\tCodeLength: {CodeLength}"); + sb.AppendLine($"\tReturnKind: {Enum.GetName(typeof(ReturnKinds), ReturnKind)}"); + sb.AppendLine($"\tValidRangeStart: {ValidRangeStart}"); + sb.AppendLine($"\tValidRangeEnd: {ValidRangeEnd}"); + if (SecurityObjectStackSlot != -1) + sb.AppendLine($"\tSecurityObjectStackSlot: caller.sp{SecurityObjectStackSlot:+#;-#;+0}"); + + if (GSCookieStackSlot != -1) + { + sb.AppendLine($"\tGSCookieStackSlot: caller.sp{GSCookieStackSlot:+#;-#;+0}"); + sb.AppendLine($"GS cookie valid range: [{ValidRangeStart};{ValidRangeEnd})"); + } + + if (PSPSymStackSlot != -1) + { + if (_machine == Machine.Amd64) + { + sb.AppendLine($"\tPSPSymStackSlot: initial.sp{PSPSymStackSlot:+#;-#;+0}"); + } + else + { + sb.AppendLine($"\tPSPSymStackSlot: caller.sp{PSPSymStackSlot:+#;-#;+0}"); + } + } + + if (GenericsInstContextStackSlot != -1) + { + sb.AppendLine($"\tGenericsInstContextStackSlot: caller.sp{GenericsInstContextStackSlot:+#;-#;+0}"); + } + + if (StackBaseRegister != 0xffffffff) + sb.AppendLine($"\tStackBaseRegister: {(Amd64Registers)StackBaseRegister}"); + if (_machine == Machine.Amd64) + { + sb.AppendLine($"\tWants Report Only Leaf: {_wantsReportOnlyLeaf}"); + } + else if (_machine == Machine.Arm || _machine == Machine.Arm64) + { + sb.AppendLine($"\tHas Tailcalls: {_wantsReportOnlyLeaf}"); + } + + sb.AppendLine($"\tSize of parameter area: 0x{SizeOfStackOutgoingAndScratchArea:X}"); + if (SizeOfEditAndContinuePreservedArea != 0xffffffff) + sb.AppendLine($"\tSizeOfEditAndContinuePreservedArea: 0x{SizeOfEditAndContinuePreservedArea:X}"); + if (ReversePInvokeFrameStackSlot != -1) + sb.AppendLine($"\tReversePInvokeFrameStackSlot: {ReversePInvokeFrameStackSlot}"); + sb.AppendLine($"\tNumSafePoints: {NumSafePoints}"); + sb.AppendLine($"\tNumInterruptibleRanges: {NumInterruptibleRanges}"); + sb.AppendLine($"\tSafePointOffsets:"); + foreach (SafePointOffset offset in SafePointOffsets) + { + sb.AppendLine($"\t\t{offset.Value}"); + } + sb.AppendLine($"\tInterruptibleRanges:"); + foreach (InterruptibleRange range in InterruptibleRanges) + { + sb.AppendLine($"\t\tstart:{range.StartOffset}, end:{range.StopOffset}"); + } + sb.AppendLine($"\tSlotTable:"); + sb.Append(SlotTable.ToString()); + sb.AppendLine($"\tTransitions:"); + foreach (GcTransition trans in Transitions.Values) + { + sb.AppendLine(trans.ToString()); + } + sb.AppendLine($"\tSize: {Size} bytes"); + + return sb.ToString(); + } + + private void ParseHeaderFlags(byte[] image, ref int bitOffset) + { + GcInfoHeaderFlags headerFlags; + _slimHeader = (NativeReader.ReadBits(image, 1, ref bitOffset) == 0); + if (_slimHeader) + { + headerFlags = NativeReader.ReadBits(image, 1, ref bitOffset) == 1 ? GcInfoHeaderFlags.GC_INFO_HAS_STACK_BASE_REGISTER : 0; + } + else + { + int numFlagBits = (int)((Version == 1) ? GcInfoHeaderFlags.GC_INFO_FLAGS_BIT_SIZE_VERSION_1 : GcInfoHeaderFlags.GC_INFO_FLAGS_BIT_SIZE); + headerFlags = (GcInfoHeaderFlags)NativeReader.ReadBits(image, numFlagBits, ref bitOffset); + } + + _hasSecurityObject = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_SECURITY_OBJECT) != 0; + _hasGSCookie = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_GS_COOKIE) != 0; + _hasPSPSym = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_PSP_SYM) != 0; + _hasGenericsInstContext = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_GENERICS_INST_CONTEXT_MASK) != GcInfoHeaderFlags.GC_INFO_HAS_GENERICS_INST_CONTEXT_NONE; + _hasStackBaseRegister = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_STACK_BASE_REGISTER) != 0; + _hasSizeOfEditAndContinuePreservedArea = (headerFlags & GcInfoHeaderFlags.GC_INFO_HAS_EDIT_AND_CONTINUE_PRESERVED_SLOTS) != 0; + if (Version >= MIN_GCINFO_VERSION_WITH_REV_PINVOKE_FRAME) // IsReversePInvokeFrameAvailable + { + _hasReversePInvokeFrame = (headerFlags & GcInfoHeaderFlags.GC_INFO_REVERSE_PINVOKE_FRAME) != 0; + } + _wantsReportOnlyLeaf = ((headerFlags & GcInfoHeaderFlags.GC_INFO_WANTS_REPORT_ONLY_LEAF) != 0); + } + + private List EnumerateSafePoints(byte[] image, ref int bitOffset) + { + List safePoints = new List(); + uint numBitsPerOffset = GcInfoTypes.CeilOfLog2(CodeLength); + for (int i = 0; i < NumSafePoints; i++) + { + uint normOffset = (uint)NativeReader.ReadBits(image, (int)numBitsPerOffset, ref bitOffset); + safePoints.Add(new SafePointOffset(i, normOffset)); + } + return safePoints; + } + + private List EnumerateInterruptibleRanges(byte[] image, int interruptibleRangeDelta1EncBase, int interruptibleRangeDelta2EncBase, ref int bitOffset) + { + List ranges = new List(); + uint lastinterruptibleRangeStopOffset = 0; + + for (uint i = 0; i < NumInterruptibleRanges; i++) + { + uint normStartDelta = NativeReader.DecodeVarLengthUnsigned(image, interruptibleRangeDelta1EncBase, ref bitOffset); + uint normStopDelta = NativeReader.DecodeVarLengthUnsigned(image, interruptibleRangeDelta2EncBase, ref bitOffset) + 1; + + uint rangeStartOffset = lastinterruptibleRangeStopOffset + normStartDelta; + uint rangeStopOffset = rangeStartOffset + normStopDelta; + ranges.Add(new InterruptibleRange(i, rangeStartOffset, rangeStopOffset)); + + lastinterruptibleRangeStopOffset = rangeStopOffset; + } + return ranges; + } + + ///

+ /// GcInfo version is 1 up to ReadyTorun version 1.x. + /// GcInfo version is current from ReadyToRun version 2.0 + /// + private int ReadyToRunVersionToGcInfoVersion(int readyToRunMajorVersion) + { + return (readyToRunMajorVersion == 1) ? 1 : GCINFO_VERSION; + } + + public Dictionary GetTranstions(byte[] image, ref int bitOffset) + { + int totalInterruptibleLength = 0; + if (NumInterruptibleRanges == 0) + { + totalInterruptibleLength = CodeLength; + } + else + { + foreach (InterruptibleRange range in InterruptibleRanges) + { + totalInterruptibleLength += (int)(range.StopOffset - range.StartOffset); + } + } + + int numChunks = (totalInterruptibleLength + _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK - 1) / _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK; //=2 + int numBitsPerPointer = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.POINTER_SIZE_ENCBASE, ref bitOffset); + if (numBitsPerPointer == 0) + { + return new Dictionary(); + } + + int[] chunkPointers = new int[numChunks]; + for (int i = 0; i < numChunks; i++) + { + chunkPointers[i] = NativeReader.ReadBits(image, numBitsPerPointer, ref bitOffset); + } + int info2Offset = (int)Math.Ceiling(bitOffset / 8.0) * 8; + + List transitions = new List(); + bool[] liveAtEnd = new bool[SlotTable.GcSlots.Count - SlotTable.NumUntracked]; + for (int currentChunk = 0; currentChunk < numChunks; currentChunk++) + { + if (chunkPointers[currentChunk] == 0) + { + continue; + } + else + { + bitOffset = info2Offset + chunkPointers[currentChunk] - 1; + } + + int couldBeLiveOffset = bitOffset; + int slotId = 0; + bool fSimple = (NativeReader.ReadBits(image, 1, ref couldBeLiveOffset) == 0); + bool fSkipFirst = false; + int couldBeLiveCnt = 0; + if (!fSimple) + { + fSkipFirst = (NativeReader.ReadBits(image, 1, ref couldBeLiveOffset) == 0); + slotId = -1; + } + + uint numCouldBeLiveSlots = GetNumCouldBeLiveSlots(image, ref bitOffset); + + int finalStateOffset = bitOffset; + bitOffset += (int)numCouldBeLiveSlots; + + int normChunkBaseCodeOffset = currentChunk * _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK; + for (int i = 0; i < numCouldBeLiveSlots; i++) + { + slotId = GetNextSlotId(image, fSimple, fSkipFirst, slotId, ref couldBeLiveCnt, ref couldBeLiveOffset); + + bool isLive = !liveAtEnd[slotId]; + liveAtEnd[slotId] = (NativeReader.ReadBits(image, 1, ref finalStateOffset) != 0); + + // Read transitions + while (NativeReader.ReadBits(image, 1, ref bitOffset) != 0) + { + int transitionOffset = NativeReader.ReadBits(image, _gcInfoTypes.NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2, ref bitOffset) + normChunkBaseCodeOffset; + transitions.Add(new GcTransition(transitionOffset, slotId, isLive, currentChunk)); + isLive = !isLive; + } + slotId++; + } + } + + transitions.Sort((s1, s2) => s1.CodeOffset.CompareTo(s2.CodeOffset)); + + return UpdateTransitionCodeOffset(transitions); + } + + private uint GetNumCouldBeLiveSlots(byte[] image, ref int bitOffset) + { + uint numCouldBeLiveSlots = 0; + int numTracked = SlotTable.GcSlots.Count - (int)SlotTable.NumUntracked; + if (NativeReader.ReadBits(image, 1, ref bitOffset) != 0) + { + // RLE encoded + bool fSkip = (NativeReader.ReadBits(image, 1, ref bitOffset) == 0); + bool fReport = true; + uint readSlots = NativeReader.DecodeVarLengthUnsigned(image, fSkip ? _gcInfoTypes.LIVESTATE_RLE_SKIP_ENCBASE : _gcInfoTypes.LIVESTATE_RLE_RUN_ENCBASE, ref bitOffset); + fSkip = !fSkip; + while (readSlots < numTracked) + { + uint cnt = NativeReader.DecodeVarLengthUnsigned(image, fSkip ? _gcInfoTypes.LIVESTATE_RLE_SKIP_ENCBASE : _gcInfoTypes.LIVESTATE_RLE_RUN_ENCBASE, ref bitOffset) + 1; + if (fReport) + { + numCouldBeLiveSlots += cnt; + } + readSlots += cnt; + fSkip = !fSkip; + fReport = !fReport; + } + } + else + { + foreach (var slot in SlotTable.GcSlots) + { + if (slot.Flags == GcSlotFlags.GC_SLOT_UNTRACKED) + break; + + if (NativeReader.ReadBits(image, 1, ref bitOffset) != 0) + numCouldBeLiveSlots++; + } + } + return numCouldBeLiveSlots; + } + + private int GetNextSlotId(byte[] image, bool fSimple, bool fSkipFirst, int slotId, ref int couldBeLiveCnt, ref int couldBeLiveOffset) + { + if (fSimple) + { + while (NativeReader.ReadBits(image, 1, ref couldBeLiveOffset) == 0) + slotId++; + } + else if (couldBeLiveCnt > 0) + { + // We have more from the last run to report + couldBeLiveCnt--; + } + // We need to find a new run + else if (fSkipFirst) + { + int tmp = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.LIVESTATE_RLE_SKIP_ENCBASE, ref couldBeLiveOffset) + 1; + slotId += tmp; + couldBeLiveCnt = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.LIVESTATE_RLE_RUN_ENCBASE, ref couldBeLiveOffset); + } + else + { + int tmp = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.LIVESTATE_RLE_RUN_ENCBASE, ref couldBeLiveOffset) + 1; + slotId += tmp; + couldBeLiveCnt = (int)NativeReader.DecodeVarLengthUnsigned(image, _gcInfoTypes.LIVESTATE_RLE_SKIP_ENCBASE, ref couldBeLiveOffset); + } + return slotId; + } + + private Dictionary UpdateTransitionCodeOffset(List transitions) + { + Dictionary updatedTransitions = new Dictionary(); + int cumInterruptibleLength = 0; + using (IEnumerator interruptibleRangesIter = InterruptibleRanges.GetEnumerator()) + { + interruptibleRangesIter.MoveNext(); + InterruptibleRange currentRange = interruptibleRangesIter.Current; + int currentRangeLength = (int)(currentRange.StopOffset - currentRange.StartOffset); + foreach (GcTransition transition in transitions) + { + int codeOffset = transition.CodeOffset + (int)currentRange.StartOffset - cumInterruptibleLength; + if (codeOffset > currentRange.StopOffset) + { + cumInterruptibleLength += currentRangeLength; + interruptibleRangesIter.MoveNext(); + currentRange = interruptibleRangesIter.Current; + currentRangeLength = (int)(currentRange.StopOffset - currentRange.StartOffset); + codeOffset = transition.CodeOffset + (int)currentRange.StartOffset - cumInterruptibleLength; + } + transition.CodeOffset = codeOffset; + updatedTransitions[codeOffset] = transition; + } + } + return updatedTransitions; + } + } +} diff --git a/src/tools/r2rdump/GCInfoTypes.cs b/src/tools/r2rdump/GCInfoTypes.cs new file mode 100644 index 000000000000..a285ebba5a19 --- /dev/null +++ b/src/tools/r2rdump/GCInfoTypes.cs @@ -0,0 +1,220 @@ +// 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.Reflection.PortableExecutable; +using System.Text; + +namespace R2RDump +{ + public class GcInfoTypes + { + private Machine _target; + + internal int SIZE_OF_RETURN_KIND_SLIM { get; } = 2; + internal int SIZE_OF_RETURN_KIND_FAT { get; } = 2; + internal int CODE_LENGTH_ENCBASE { get; } = 8; + internal int NORM_PROLOG_SIZE_ENCBASE { get; } = 5; + internal int SECURITY_OBJECT_STACK_SLOT_ENCBASE { get; } = 6; + internal int GS_COOKIE_STACK_SLOT_ENCBASE { get; } = 6; + internal int PSP_SYM_STACK_SLOT_ENCBASE { get; } = 6; + internal int GENERICS_INST_CONTEXT_STACK_SLOT_ENCBASE { get; } = 6; + internal int STACK_BASE_REGISTER_ENCBASE { get; } = 3; + internal int SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE { get; } = 4; + internal int REVERSE_PINVOKE_FRAME_ENCBASE { get; } = 6; + internal int SIZE_OF_STACK_AREA_ENCBASE { get; } = 3; + internal int NUM_SAFE_POINTS_ENCBASE { get; } = 3; + internal int NUM_INTERRUPTIBLE_RANGES_ENCBASE { get; } = 1; + internal int INTERRUPTIBLE_RANGE_DELTA1_ENCBASE { get; } = 6; + internal int INTERRUPTIBLE_RANGE_DELTA2_ENCBASE { get; } = 6; + + internal int MAX_PREDECODED_SLOTS { get; } = 64; + internal int NUM_REGISTERS_ENCBASE { get; } = 2; + internal int NUM_STACK_SLOTS_ENCBASE { get; } = 2; + internal int NUM_UNTRACKED_SLOTS_ENCBASE { get; } = 1; + internal int REGISTER_ENCBASE { get; } = 3; + internal int REGISTER_DELTA_ENCBASE { get; } = 2; + internal int STACK_SLOT_ENCBASE { get; } = 6; + internal int STACK_SLOT_DELTA_ENCBASE { get; } = 4; + internal int POINTER_SIZE_ENCBASE { get; } = 3; + internal int NUM_NORM_CODE_OFFSETS_PER_CHUNK { get; } = 64; + internal int LIVESTATE_RLE_RUN_ENCBASE { get; } = 2; + internal int LIVESTATE_RLE_SKIP_ENCBASE { get; } = 4; + internal int NUM_NORM_CODE_OFFSETS_PER_CHUNK_LOG2 { get; } = 6; + + internal GcInfoTypes(Machine machine) + { + _target = machine; + + switch (machine) + { + case Machine.Amd64: + SIZE_OF_RETURN_KIND_FAT = 4; + NUM_SAFE_POINTS_ENCBASE = 2; + break; + case Machine.Arm: + CODE_LENGTH_ENCBASE = 7; + SECURITY_OBJECT_STACK_SLOT_ENCBASE = 5; + GS_COOKIE_STACK_SLOT_ENCBASE = 5; + PSP_SYM_STACK_SLOT_ENCBASE = 5; + GENERICS_INST_CONTEXT_STACK_SLOT_ENCBASE = 5; + STACK_BASE_REGISTER_ENCBASE = 1; + SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE = 3; + REVERSE_PINVOKE_FRAME_ENCBASE = 5; + NUM_INTERRUPTIBLE_RANGES_ENCBASE = 2; + INTERRUPTIBLE_RANGE_DELTA1_ENCBASE = 4; + NUM_STACK_SLOTS_ENCBASE = 3; + NUM_UNTRACKED_SLOTS_ENCBASE = 3; + REGISTER_ENCBASE = 2; + REGISTER_DELTA_ENCBASE = 1; + break; + case Machine.Arm64: + SIZE_OF_RETURN_KIND_FAT = 4; + STACK_BASE_REGISTER_ENCBASE = 2; + NUM_REGISTERS_ENCBASE = 3; + break; + case Machine.I386: + CODE_LENGTH_ENCBASE = 6; + NORM_PROLOG_SIZE_ENCBASE = 4; + SIZE_OF_EDIT_AND_CONTINUE_PRESERVED_AREA_ENCBASE = 3; + SIZE_OF_STACK_AREA_ENCBASE = 6; + NUM_SAFE_POINTS_ENCBASE = 4; + INTERRUPTIBLE_RANGE_DELTA1_ENCBASE = 5; + INTERRUPTIBLE_RANGE_DELTA2_ENCBASE = 5; + NUM_REGISTERS_ENCBASE = 3; + NUM_STACK_SLOTS_ENCBASE = 5; + NUM_UNTRACKED_SLOTS_ENCBASE = 5; + REGISTER_DELTA_ENCBASE = 3; + break; + } + } + + internal int DenormalizeCodeLength(int x) + { + switch (_target) + { + case Machine.Arm: + return (x << 1); + case Machine.Arm64: + return (x << 2); + } + return x; + } + + internal int DenormalizeStackSlot(int x) + { + switch (_target) + { + case Machine.Amd64: + return (x << 3); + case Machine.Arm: + return (x << 2); + case Machine.Arm64: + return (x << 3); + } + return x; + } + + internal uint DenormalizeStackBaseRegister(uint x) + { + switch (_target) + { + case Machine.Amd64: + return (x ^ 5); + case Machine.Arm: + return ((x ^ 7) + 4); + case Machine.Arm64: + return (x ^ 29); + } + return x; + } + + internal uint DenormalizeSizeOfStackArea(uint x) + { + switch (_target) + { + case Machine.Amd64: + return (x << 3); + case Machine.Arm: + return (x << 2); + case Machine.Arm64: + return (x << 3); + } + return x; + } + + internal static uint CeilOfLog2(int x) + { + if (x == 0) + return 0; + uint result = (uint)((x & (x - 1)) != 0 ? 1 : 0); + while (x != 1) + { + result++; + x >>= 1; + } + return result; + } + } + + public enum ReturnKinds + { + RT_Scalar = 0, + RT_Object = 1, + RT_ByRef = 2, + RT_Unset = 3, // Encoding 3 means RT_Float on X86 + RT_Scalar_Obj = RT_Object << 2 | RT_Scalar, + RT_Scalar_ByRef = RT_ByRef << 2 | RT_Scalar, + + RT_Obj_Obj = RT_Object << 2 | RT_Object, + RT_Obj_ByRef = RT_ByRef << 2 | RT_Object, + + RT_ByRef_Obj = RT_Object << 2 | RT_ByRef, + RT_ByRef_ByRef = RT_ByRef << 2 | RT_ByRef, + + RT_Illegal = 0xFF + }; + + public enum GcSlotFlags + { + GC_SLOT_BASE = 0x0, + GC_SLOT_INTERIOR = 0x1, + GC_SLOT_PINNED = 0x2, + GC_SLOT_UNTRACKED = 0x4, + }; + + public enum GcStackSlotBase + { + GC_CALLER_SP_REL = 0x0, + GC_SP_REL = 0x1, + GC_FRAMEREG_REL = 0x2, + + GC_SPBASE_FIRST = GC_CALLER_SP_REL, + GC_SPBASE_LAST = GC_FRAMEREG_REL, + }; + + public class GcStackSlot + { + public int SpOffset { get; set; } + public GcStackSlotBase Base { get; set; } + + public GcStackSlot() { } + + public GcStackSlot(int spOffset, GcStackSlotBase stackSlotBase) + { + SpOffset = spOffset; + Base = stackSlotBase; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\t\t\t\tSpOffset: {SpOffset}"); + sb.Append($"\t\t\t\tBase: {Enum.GetName(typeof(GcStackSlotBase), Base)}"); + + return sb.ToString(); + } + }; +} diff --git a/src/tools/r2rdump/GCSlotTable.cs b/src/tools/r2rdump/GCSlotTable.cs new file mode 100644 index 000000000000..3be9a3bac62a --- /dev/null +++ b/src/tools/r2rdump/GCSlotTable.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. + +using System; +using System.Collections.Generic; +using System.Reflection.PortableExecutable; +using System.Text; +using System.Xml.Serialization; + +namespace R2RDump +{ + public class GcSlotTable + { + public struct GcSlot + { + [XmlAttribute("Index")] + public int Index { get; set; } + public int RegisterNumber { get; set; } + public GcStackSlot StackSlot { get; set; } + public GcSlotFlags Flags { get; set; } + + public GcSlot(int index, int registerNumber, GcStackSlot stack, GcSlotFlags flags, bool isUntracked = false) + { + Index = index; + RegisterNumber = registerNumber; + StackSlot = stack; + if (isUntracked) + { + Flags = GcSlotFlags.GC_SLOT_UNTRACKED; + } + else + { + Flags = flags; + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + if (StackSlot != null) + { + sb.AppendLine($"\t\t\tStack:"); + sb.AppendLine(StackSlot.ToString()); + } + else + { + sb.AppendLine($"\t\t\tRegisterNumber: {RegisterNumber}"); + } + sb.AppendLine($"\t\t\tFlags: {Flags}"); + + return sb.ToString(); + } + } + + public uint NumRegisters { get; set; } + public uint NumStackSlots { get; set; } + public uint NumUntracked { get; set; } + public uint NumSlots { get; set; } + public List GcSlots { get; set; } + + public GcSlotTable() { } + + public GcSlotTable(byte[] image, Machine machine, GcInfoTypes gcInfoTypes, ref int bitOffset) + { + if (NativeReader.ReadBits(image, 1, ref bitOffset) != 0) + { + NumRegisters = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.NUM_REGISTERS_ENCBASE, ref bitOffset); + } + if (NativeReader.ReadBits(image, 1, ref bitOffset) != 0) + { + NumStackSlots = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.NUM_STACK_SLOTS_ENCBASE, ref bitOffset); + NumUntracked = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.NUM_UNTRACKED_SLOTS_ENCBASE, ref bitOffset); + } + NumSlots = NumRegisters + NumStackSlots + NumUntracked; + + GcSlots = new List(); + if (NumRegisters > 0) + { + DecodeRegisters(image, gcInfoTypes, ref bitOffset); + } + if ((NumStackSlots > 0) && (GcSlots.Count < gcInfoTypes.MAX_PREDECODED_SLOTS)) + { + DecodeStackSlots(image, machine, gcInfoTypes, NumStackSlots, false, ref bitOffset); + } + if ((NumUntracked > 0) && (GcSlots.Count < gcInfoTypes.MAX_PREDECODED_SLOTS)) + { + DecodeStackSlots(image, machine, gcInfoTypes, NumUntracked, true, ref bitOffset); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"\t\tNumSlots({NumSlots}) = NumRegisters({NumRegisters}) + NumStackSlots({NumStackSlots}) + NumUntracked({NumUntracked})"); + sb.AppendLine($"\t\tGcSlots:"); + sb.AppendLine($"\t\t\t-------------------------"); + foreach (GcSlot slot in GcSlots) + { + sb.Append(slot.ToString()); + sb.AppendLine($"\t\t\t-------------------------"); + } + + return sb.ToString(); + } + + private void DecodeRegisters(byte[] image, GcInfoTypes gcInfoTypes, ref int bitOffset) + { + // We certainly predecode the first register + uint regNum = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.REGISTER_ENCBASE, ref bitOffset); + GcSlotFlags flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset); + GcSlots.Add(new GcSlot(GcSlots.Count, (int)regNum, null, flags)); + + for (int i = 1; i < NumRegisters; i++) + { + if ((uint)flags != 0) + { + regNum = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.REGISTER_ENCBASE, ref bitOffset); + flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset); + } + else + { + uint regDelta = NativeReader.DecodeVarLengthUnsigned(image, gcInfoTypes.REGISTER_DELTA_ENCBASE, ref bitOffset) + 1; + regNum += regDelta; + } + GcSlots.Add(new GcSlot(GcSlots.Count, (int)regNum, null, flags)); + } + } + + private void DecodeStackSlots(byte[] image, Machine machine, GcInfoTypes gcInfoTypes, uint nSlots, bool isUntracked, ref int bitOffset) + { + // We have stack slots left and more room to predecode + GcStackSlotBase spBase = (GcStackSlotBase)NativeReader.ReadBits(image, 2, ref bitOffset); + int normSpOffset = NativeReader.DecodeVarLengthSigned(image, gcInfoTypes.STACK_SLOT_ENCBASE, ref bitOffset); + int spOffset = gcInfoTypes.DenormalizeStackSlot(normSpOffset); + GcSlotFlags flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset); + GcSlots.Add(new GcSlot(GcSlots.Count, -1, new GcStackSlot(spOffset, spBase), flags, isUntracked)); + + for (int i = 1; i < nSlots; i++) + { + spBase = (GcStackSlotBase)NativeReader.ReadBits(image, 2, ref bitOffset); + if ((uint)flags != 0) + { + normSpOffset = NativeReader.DecodeVarLengthSigned(image, gcInfoTypes.STACK_SLOT_ENCBASE, ref bitOffset); + spOffset = gcInfoTypes.DenormalizeStackSlot(normSpOffset); + flags = (GcSlotFlags)NativeReader.ReadBits(image, 2, ref bitOffset); + } + else + { + int normSpOffsetDelta = NativeReader.DecodeVarLengthSigned(image, gcInfoTypes.STACK_SLOT_DELTA_ENCBASE, ref bitOffset); + normSpOffset += normSpOffsetDelta; + spOffset = gcInfoTypes.DenormalizeStackSlot(normSpOffset); + } + GcSlots.Add(new GcSlot(GcSlots.Count, -1, new GcStackSlot(spOffset, spBase), flags, isUntracked)); + } + } + } +} diff --git a/src/tools/r2rdump/NativeArray.cs b/src/tools/r2rdump/NativeArray.cs index 41042ff54c5d..bb0c746f6e2e 100644 --- a/src/tools/r2rdump/NativeArray.cs +++ b/src/tools/r2rdump/NativeArray.cs @@ -2,6 +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. +using System.Text; + namespace R2RDump { class NativeArray @@ -10,6 +12,7 @@ class NativeArray private uint _baseOffset; private uint _nElements; private byte _entryIndexSize; + private byte[] _image; public NativeArray(byte[] image, uint offset) { @@ -17,6 +20,7 @@ public NativeArray(byte[] image, uint offset) _baseOffset = NativeReader.DecodeUnsigned(image, offset, ref val); _nElements = (val >> 2); _entryIndexSize = (byte)(val & 3); + _image = image; } public uint GetCount() @@ -24,6 +28,24 @@ public uint GetCount() return _nElements; } + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + sb.AppendLine($"NativeArray Size: {_nElements}"); + sb.AppendLine($"EntryIndexSize: {_entryIndexSize}"); + for (uint i = 0; i < _nElements; i++) + { + int val = 0; + if (TryGetAt(_image, i, ref val)) + { + sb.AppendLine($"{i}: {val}"); + } + } + + return sb.ToString(); + } + public bool TryGetAt(byte[] image, uint index, ref int pOffset) { if (index >= _nElements) diff --git a/src/tools/r2rdump/NativeHashtable.cs b/src/tools/r2rdump/NativeHashtable.cs index b596622b1dcf..acb4f6dfbe30 100644 --- a/src/tools/r2rdump/NativeHashtable.cs +++ b/src/tools/r2rdump/NativeHashtable.cs @@ -2,6 +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.Collections.Generic; +using System.Text; + namespace R2RDump { struct NativeParser @@ -10,12 +13,14 @@ struct NativeParser /// The current index of the image byte array /// public uint Offset { get; set; } + public byte LowHashcode { get; } byte[] _image; - public NativeParser(byte[] image, uint offset) + public NativeParser(byte[] image, uint offset, byte lowHashcode = 0) { Offset = offset; + LowHashcode = lowHashcode; _image = image; } @@ -36,7 +41,8 @@ public uint GetRelativeOffset() public NativeParser GetParserFromRelativeOffset() { - return new NativeParser(_image, GetRelativeOffset()); + byte lowHashcode = GetByte(); + return new NativeParser(_image, GetRelativeOffset(), lowHashcode); } public byte GetByte() @@ -51,7 +57,7 @@ public uint GetCompressedData() { int off = (int)Offset; uint val = NativeReader.ReadCompressedData(_image, ref off); - Offset += 1; + Offset = (uint)off; return val; } @@ -76,8 +82,9 @@ struct NativeHashtable private uint _baseOffset; private uint _bucketMask; private byte _entryIndexSize; + private uint _endOffset; - public NativeHashtable(byte[] image, NativeParser parser) + public NativeHashtable(byte[] image, NativeParser parser, uint endOffset) { uint header = parser.GetByte(); _baseOffset = parser.Offset; @@ -92,6 +99,46 @@ public NativeHashtable(byte[] image, NativeParser parser) if (entryIndexSize > 2) throw new System.BadImageFormatException(); _entryIndexSize = entryIndexSize; + + _endOffset = endOffset; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + + SortedDictionary entries = new SortedDictionary(); + AllEntriesEnumerator allEntriesEnum = EnumerateAllEntries(); + NativeParser curParser = allEntriesEnum.GetNext(); + while (!curParser.IsNull()) + { + entries[curParser.Offset] = curParser.LowHashcode; + curParser = allEntriesEnum.GetNext(); + } + entries[_endOffset] = 0; + + sb.AppendLine($"NativeHashtable Size: {entries.Count - 1}"); + sb.AppendLine($"EntryIndexSize: {_entryIndexSize}"); + int curOffset = -1; + foreach (KeyValuePair entry in entries) + { + int nextOffset = (int)entry.Key; + if (curOffset != -1) + { + for (int i = curOffset; i < nextOffset; i++) + { + sb.Append($"{_image[i]:X2} "); + } + sb.AppendLine(); + } + if (nextOffset != _endOffset) + { + sb.Append($"0x{entry.Value:X2} -> "); + } + curOffset = nextOffset; + } + + return sb.ToString(); } // @@ -132,7 +179,6 @@ public NativeParser GetNext() { while (_parser.Offset < _endOffset) { - byte lowHashcode = _parser.GetByte(); return _parser.GetParserFromRelativeOffset(); } diff --git a/src/tools/r2rdump/NativeReader.cs b/src/tools/r2rdump/NativeReader.cs index 59fd2881a6b6..5839580d0321 100644 --- a/src/tools/r2rdump/NativeReader.cs +++ b/src/tools/r2rdump/NativeReader.cs @@ -10,6 +10,8 @@ namespace R2RDump { class NativeReader { + private const int BITS_PER_BYTE = 8; + /// /// Extracts a 64bit value from the image byte array /// @@ -83,7 +85,7 @@ public static ushort ReadUInt16(byte[] image, ref int start) /// /// PE image /// Start index of the value - /// /// + /// /// The gets incremented by the size of the value /// public static byte ReadByte(byte[] image, ref int start) @@ -93,6 +95,80 @@ public static byte ReadByte(byte[] image, ref int start) return val; } + // + /// Extracts bits from the image byte array + /// + /// PE image + /// Number of bits to read + /// Start bit of the value + /// + /// The gets incremented by + /// + public static int ReadBits(byte[] image, int numBits, ref int bitOffset) + { + int start = bitOffset / BITS_PER_BYTE; + int bits = bitOffset % BITS_PER_BYTE; + int val = image[start] >> bits; + bits += numBits; + while (bits > BITS_PER_BYTE) + { + start++; + bits -= BITS_PER_BYTE; + if (bits > 0) + { + int extraBits = image[start] << (numBits - bits); + val ^= extraBits; + } + } + val &= (1 << numBits) - 1; + bitOffset += numBits; + return val; + } + + // + /// Decode variable length numbers + /// + /// PE image + /// Number of bits to read + /// Start bit of the value + /// + /// The gets incremented by the size of the value + /// + public static uint DecodeVarLengthUnsigned(byte[] image, int len, ref int bitOffset) + { + uint numEncodings = (uint)(1 << len); + uint result = 0; + for (int shift = 0; ; shift += len) + { + uint currentChunk = (uint)ReadBits(image, len + 1, ref bitOffset); + result |= (currentChunk & (numEncodings - 1)) << shift; + if ((currentChunk & numEncodings) == 0) + { + // Extension bit is not set, we're done. + return result; + } + } + } + + public static int DecodeVarLengthSigned(byte[] image, int len, ref int bitOffset) + { + int numEncodings = (1 << len); + int result = 0; + for (int shift = 0; ; shift += len) + { + int currentChunk = ReadBits(image, len + 1, ref bitOffset); + result |= (currentChunk & (numEncodings - 1)) << shift; + if ((currentChunk & numEncodings) == 0) + { + // Extension bit is not set, sign-extend and we're done. + int sbits = BITS_PER_BYTE - (shift + len); + result <<= sbits; + result >>= sbits; // This provides the sign extension + return result; + } + } + } + public static uint DecodeUnsigned(byte[] image, uint offset, ref uint pValue) { if (offset >= image.Length) diff --git a/src/tools/r2rdump/NibbleReader.cs b/src/tools/r2rdump/NibbleReader.cs new file mode 100644 index 000000000000..341c1d029a44 --- /dev/null +++ b/src/tools/r2rdump/NibbleReader.cs @@ -0,0 +1,90 @@ +// 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. + +namespace R2RDump +{ + /// + /// Helper to read memory by 4-bit (half-byte) nibbles as is used for encoding + /// method fixups. More or less ported over from CoreCLR src\inc\nibblestream.h. + /// + class NibbleReader + { + /// + /// Special value in _nextNibble saying there's no next nibble and the next byte + /// must be read from the image. + /// + private const byte NoNextNibble = 0xFF; + + /// + /// Byte array representing the PE file. + /// + private byte[] _image; + + /// + /// Offset within the image. + /// + private int _offset; + + /// + /// Value of the next nibble or 0xFF when there's no cached next nibble. + /// + private byte _nextNibble; + + public NibbleReader(byte[] image, int offset) + { + _image = image; + _offset = offset; + _nextNibble = NoNextNibble; + } + + public byte ReadNibble() + { + byte result; + if (_nextNibble != NoNextNibble) + { + result = _nextNibble; + _nextNibble = NoNextNibble; + } + else + { + _nextNibble = _image[_offset++]; + result = (byte)(_nextNibble & 0x0F); + _nextNibble >>= 4; + } + return result; + } + + /// + /// Read an unsigned int that was encoded via variable length nibble encoding + /// from CoreCLR NibbleWriter::WriteEncodedU32. + /// + public uint ReadUInt() + { + uint value = 0; + + // The encoding is variably lengthed, with the high-bit of every nibble indicating whether + // there is another nibble in the value. Each nibble contributes 3 bits to the value. + uint nibble; + do + { + nibble = ReadNibble(); + value = (value << 3) + (nibble & 0x7); + } + while ((nibble & 0x8) != 0); + + return value; + } + + /// + /// Read an encoded signed integer from the nibble reader. This uses the same unsigned + /// encoding, just left shifting the absolute value by one and filling in bit #0 with the sign bit. + /// + public int ReadInt() + { + uint unsignedValue = ReadUInt(); + int signedValue = (int)(unsignedValue >> 1); + return ((unsignedValue & 1) != 0 ? -signedValue : signedValue); + } + } +} diff --git a/src/tools/r2rdump/R2RDump.cs b/src/tools/r2rdump/R2RDump.cs index b287fa0284fe..aa9413160adc 100644 --- a/src/tools/r2rdump/R2RDump.cs +++ b/src/tools/r2rdump/R2RDump.cs @@ -6,26 +6,61 @@ using System.Collections.Generic; using System.CommandLine; using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Serialization; namespace R2RDump { + public abstract class Dumper + { + internal R2RReader _r2r; + internal bool _raw; + internal bool _header; + internal bool _disasm; + internal IntPtr _disassembler; + internal bool _unwind; + internal bool _gc; + internal bool _sectionContents; + internal TextWriter _writer; + + abstract internal void Begin(); + abstract internal void End(); + abstract internal void WriteDivider(string title); + abstract internal void WriteSubDivider(); + abstract internal void SkipLine(); + abstract internal void DumpHeader(bool dumpSections); + abstract internal void DumpSection(R2RSection section, XmlNode parentNode = null); + abstract internal void DumpAllMethods(); + abstract internal void DumpMethod(R2RMethod method, XmlNode parentNode = null); + abstract internal void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNode = null); + abstract internal unsafe void DumpDisasm(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, byte[] image, XmlNode parentNode = null); + abstract internal void DumpBytes(int rva, uint size, XmlNode parentNode = null, string name = "Raw", bool convertToOffset = true); + abstract internal void DumpSectionContents(R2RSection section, XmlNode parentNode = null); + abstract internal XmlNode DumpQueryCount(string q, string title, int count); + } + class R2RDump { - private bool _help = false; + private bool _help; private IReadOnlyList _inputFilenames = Array.Empty(); private string _outputFilename = null; - private bool _raw = false; - private bool _header = false; - private bool _disasm = false; + private bool _xml; + private bool _raw; + private bool _header; + private bool _disasm; private IReadOnlyList _queries = Array.Empty(); private IReadOnlyList _keywords = Array.Empty(); private IReadOnlyList _runtimeFunctions = Array.Empty(); private IReadOnlyList _sections = Array.Empty(); - private bool _diff = false; - private long _disassembler; - private bool _types = false; - private bool _unwind = false; + private bool _diff; + private IntPtr _disassembler; + private bool _unwind; + private bool _gc; + private bool _sectionContents; private TextWriter _writer; + private Dictionary _selectedSections = new Dictionary(); + private Dumper _dumper; private R2RDump() { @@ -33,6 +68,7 @@ private R2RDump() private ArgumentSyntax ParseCommandLine(string[] args) { + bool verbose = false; ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => { syntax.ApplicationName = "R2RDump"; @@ -42,18 +78,31 @@ private ArgumentSyntax ParseCommandLine(string[] args) syntax.DefineOption("h|help", ref _help, "Help message for R2RDump"); syntax.DefineOptionList("i|in", ref _inputFilenames, "Input file(s) to dump. Expects them to by ReadyToRun images"); syntax.DefineOption("o|out", ref _outputFilename, "Output file path. Dumps everything to the specified file except help message and exception messages"); - syntax.DefineOption("v|verbose|raw", ref _raw, "Dump the raw bytes of each section or runtime function"); + syntax.DefineOption("x|xml", ref _xml, "Output in XML format"); + syntax.DefineOption("raw", ref _raw, "Dump the raw bytes of each section or runtime function"); syntax.DefineOption("header", ref _header, "Dump R2R header"); syntax.DefineOption("d|disasm", ref _disasm, "Show disassembly of methods or runtime functions"); syntax.DefineOptionList("q|query", ref _queries, "Query method by exact name, signature, row id or token"); syntax.DefineOptionList("k|keyword", ref _keywords, "Search method by keyword"); syntax.DefineOptionList("r|runtimefunction", ref _runtimeFunctions, ArgStringToInt, "Get one runtime function by id or relative virtual address"); syntax.DefineOptionList("s|section", ref _sections, "Get section by keyword"); - syntax.DefineOption("types", ref _types, "Dump available types"); syntax.DefineOption("unwind", ref _unwind, "Dump unwindInfo"); - syntax.DefineOption("diff", ref _diff, "Compare two R2R images (not yet implemented)"); // not yet implemented + syntax.DefineOption("gc", ref _gc, "Dump gcInfo and slot table"); + syntax.DefineOption("sc", ref _sectionContents, "Dump section contents"); + syntax.DefineOption("v|verbose", ref verbose, "Dump raw bytes, disassembly, unwindInfo, gcInfo and section contents"); + syntax.DefineOption("diff", ref _diff, "Compare two R2R images (not yet implemented)"); }); + if (verbose) + { + _disasm = true; + _unwind = true; + _gc = true; + _sectionContents = true; + } + + _disasm = false; // TODO: this requires the coredistools nuget package with the most recent changes + return argSyntax; } @@ -87,139 +136,6 @@ public static void WriteWarning(string warning) Console.WriteLine($"Warning: {warning}"); } - private void WriteDivider(string title) - { - int len = 61 - title.Length - 2; - _writer.WriteLine(new String('=', len/2) + " " + title + " " + new String('=', (int)Math.Ceiling(len/2.0))); - _writer.WriteLine(); - } - - private void WriteSubDivider() - { - _writer.WriteLine("_______________________________________________"); - _writer.WriteLine(); - } - - /// - /// Dumps the R2RHeader and all the sections in the header - /// - private void DumpHeader(R2RReader r2r, bool dumpSections) - { - _writer.WriteLine(r2r.R2RHeader.ToString()); - if (_raw) - { - DumpBytes(r2r, r2r.R2RHeader.RelativeVirtualAddress, (uint)r2r.R2RHeader.Size); - } - _writer.WriteLine(); - if (dumpSections) - { - WriteDivider("R2R Sections"); - _writer.WriteLine($"{r2r.R2RHeader.Sections.Count} sections"); - _writer.WriteLine(); - foreach (R2RSection section in r2r.R2RHeader.Sections.Values) - { - DumpSection(r2r, section); - } - } - _writer.WriteLine(); - } - - /// - /// Dumps one R2RSection - /// - private void DumpSection(R2RReader r2r, R2RSection section) - { - WriteSubDivider(); - _writer.WriteLine(section.ToString()); - if (_raw) - { - DumpBytes(r2r, section.RelativeVirtualAddress, (uint)section.Size); - } - } - - /// - /// Dumps one R2RMethod. - /// - private void DumpMethod(R2RReader r2r, R2RMethod method) - { - WriteSubDivider(); - _writer.WriteLine(method.ToString()); - - foreach (RuntimeFunction runtimeFunction in method.RuntimeFunctions) - { - DumpRuntimeFunction(r2r, runtimeFunction); - } - } - - /// - /// Dumps one runtime function. - /// - private void DumpRuntimeFunction(R2RReader r2r, RuntimeFunction rtf) - { - if (_disasm) - { - _writer.WriteLine($"Id: {rtf.Id}"); - CoreDisTools.DumpCodeBlock(_disassembler, rtf.StartAddress, r2r.GetOffset(rtf.StartAddress), r2r.Image, rtf.Size); - } - else - { - _writer.Write($"{rtf}"); - } - if (_raw) - { - DumpBytes(r2r, rtf.StartAddress, (uint)rtf.Size); - } - if (_unwind) - { - _writer.WriteLine("UnwindInfo:"); - _writer.Write(rtf.UnwindInfo); - } - _writer.WriteLine(); - } - - /// - /// Prints a formatted string containing a block of bytes from the relative virtual address and size - /// - public void DumpBytes(R2RReader r2r, int rva, uint size) - { - uint start = (uint)r2r.GetOffset(rva); - if (start > r2r.Image.Length || start + size > r2r.Image.Length) - { - throw new IndexOutOfRangeException(); - } - _writer.Write(" "); - if (rva % 16 != 0) - { - int floor = rva / 16 * 16; - _writer.Write($"{floor:X8}:"); - _writer.Write(new String(' ', (rva - floor) * 3)); - } - for (uint i = 0; i < size; i++) - { - if ((rva + i) % 16 == 0) - { - _writer.Write($"{rva + i:X8}:"); - } - _writer.Write($" {r2r.Image[start + i]:X2}"); - if ((rva + i) % 16 == 15 && i != size - 1) - { - _writer.WriteLine(); - _writer.Write(" "); - } - } - _writer.WriteLine(); - } - - private void DumpAvailableTypes(R2RReader r2r) - { - WriteDivider("Available Types"); - foreach (string name in r2r.AvailableTypes) - { - _writer.WriteLine(name); - } - _writer.WriteLine(); - } - // /// For each query in the list of queries, search for all methods matching the query by name, signature or id /// @@ -231,17 +147,15 @@ private void QueryMethod(R2RReader r2r, string title, IReadOnlyList quer { if (queries.Count > 0) { - WriteDivider(title); + _dumper.WriteDivider(title); } foreach (string q in queries) { IList res = FindMethod(r2r, q, exact); - - _writer.WriteLine(res.Count + " result(s) for \"" + q + "\""); - _writer.WriteLine(); + XmlNode queryNode = _dumper.DumpQueryCount(q, "Methods", res.Count); foreach (R2RMethod method in res) { - DumpMethod(r2r, method); + _dumper.DumpMethod(method, queryNode); } } } @@ -255,17 +169,15 @@ private void QuerySection(R2RReader r2r, IReadOnlyList queries) { if (queries.Count > 0) { - WriteDivider("R2R Section"); + _dumper.WriteDivider("R2R Section"); } foreach (string q in queries) { IList res = FindSection(r2r, q); - - _writer.WriteLine(res.Count + " result(s) for \"" + q + "\""); - _writer.WriteLine(); + XmlNode queryNode = _dumper.DumpQueryCount(q, "Sections", res.Count); foreach (R2RSection section in res) { - DumpSection(r2r, section); + _dumper.DumpSection(section, queryNode); } } } @@ -280,7 +192,7 @@ private void QueryRuntimeFunction(R2RReader r2r, IReadOnlyList queries) { if (queries.Count > 0) { - WriteDivider("Runtime Functions"); + _dumper.WriteDivider("Runtime Functions"); } foreach (int q in queries) { @@ -291,8 +203,8 @@ private void QueryRuntimeFunction(R2RReader r2r, IReadOnlyList queries) WriteWarning("Unable to find by id " + q); continue; } - _writer.WriteLine(rtf.Method.SignatureString); - DumpRuntimeFunction(r2r, rtf); + XmlNode queryNode = _dumper.DumpQueryCount(q.ToString(), "Runtime Function", 1); + _dumper.DumpRuntimeFunction(rtf, queryNode); } } @@ -302,32 +214,24 @@ private void QueryRuntimeFunction(R2RReader r2r, IReadOnlyList queries) /// The structure containing the info of the ReadyToRun image public void Dump(R2RReader r2r) { - _writer.WriteLine($"Filename: {r2r.Filename}"); - _writer.WriteLine($"Machine: {r2r.Machine}"); - _writer.WriteLine($"ImageBase: 0x{r2r.ImageBase:X8}"); - _writer.WriteLine(); + + _dumper.Begin(); if (_queries.Count == 0 && _keywords.Count == 0 && _runtimeFunctions.Count == 0 && _sections.Count == 0) //dump all sections and methods { - WriteDivider("R2R Header"); - DumpHeader(r2r, true); + _dumper.WriteDivider("R2R Header"); + _dumper.DumpHeader(true); if (!_header) { - WriteDivider("R2R Methods"); - _writer.WriteLine($"{r2r.R2RMethods.Count} methods"); - _writer.WriteLine(); - foreach (R2RMethod method in r2r.R2RMethods) - { - DumpMethod(r2r, method); - } + _dumper.DumpAllMethods(); } } else //dump queried sections/methods/runtimeFunctions { if (_header) { - DumpHeader(r2r, false); + _dumper.DumpHeader(false); } QuerySection(r2r, _sections); @@ -336,13 +240,7 @@ public void Dump(R2RReader r2r) QueryMethod(r2r, "R2R Methods by Keyword", _keywords, false); } - if (_types) - { - DumpAvailableTypes(r2r); - } - - _writer.WriteLine("============================================================="); - _writer.WriteLine(); + _dumper.End(); } /// @@ -454,15 +352,6 @@ public RuntimeFunction FindRuntimeFunction(R2RReader r2r, int rtfQuery) private int Run(string[] args) { ArgumentSyntax syntax = ParseCommandLine(args); - - if (_help) - { - _writer.WriteLine(syntax.GetHelpText()); - return 0; - } - - if (_inputFilenames.Count == 0) - throw new ArgumentException("Input filename must be specified (--in )"); // open output stream if (_outputFilename != null) @@ -474,16 +363,35 @@ private int Run(string[] args) _writer = Console.Out; } + if (_help) + { + _writer.WriteLine(syntax.GetHelpText()); + return 0; + } + try { + if (_inputFilenames.Count == 0) + throw new ArgumentException("Input filename must be specified (--in )"); + foreach (string filename in _inputFilenames) { R2RReader r2r = new R2RReader(filename); + if (_disasm) { _disassembler = CoreDisTools.GetDisasm(r2r.Machine); } + if (_xml) + { + _dumper = new XmlDumper(r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents); + } + else + { + _dumper = new TextDumper(r2r, _writer, _raw, _header, _disasm, _disassembler, _unwind, _gc, _sectionContents); + } + Dump(r2r); if (_disasm) @@ -495,6 +403,22 @@ private int Run(string[] args) catch (Exception e) { Console.WriteLine("Error: " + e.ToString()); + if (e is ArgumentException) + { + Console.WriteLine(); + Console.WriteLine(syntax.GetHelpText()); + } + if (_xml) + { + XmlDocument document = new XmlDocument(); + XmlNode node = document.CreateNode("element", "Error", ""); + node.InnerText = e.Message; + document.AppendChild(node); + if (_writer != null) + { + document.Save(_writer); + } + } return 1; } finally diff --git a/src/tools/r2rdump/R2RDump.csproj b/src/tools/r2rdump/R2RDump.csproj index e783e1698a64..b0ad5a3a8cee 100644 --- a/src/tools/r2rdump/R2RDump.csproj +++ b/src/tools/r2rdump/R2RDump.csproj @@ -1,18 +1,32 @@ - + + - Exe - netcoreapp2.0 - - - + R2RDump + 1.0.0.0 true + Exe + AnyCPU + Open + true + netcoreapp2.0 + 2.0.0 + .NETCoreApp + false + 8002,NU1701 - - - + + 1.0.1-prerelease-00003 + + + 0.1.0-e160119-1 + + + 1.6.0 + + diff --git a/src/tools/r2rdump/R2RHeader.cs b/src/tools/r2rdump/R2RHeader.cs index 96eacd583a92..7212d3eff70b 100644 --- a/src/tools/r2rdump/R2RHeader.cs +++ b/src/tools/r2rdump/R2RHeader.cs @@ -8,7 +8,7 @@ namespace R2RDump { - class R2RHeader + public class R2RHeader { [Flags] public enum ReadyToRunFlag @@ -26,35 +26,37 @@ public enum ReadyToRunFlag /// /// RVA to the begining of the ReadyToRun header /// - public int RelativeVirtualAddress { get; } + public int RelativeVirtualAddress { get; set; } /// /// Size of the ReadyToRun header /// - public int Size { get; } + public int Size { get; set; } /// /// Signature of the header in string and hex formats /// - public string SignatureString { get; } - public uint Signature { get; } + public string SignatureString { get; set; } + public uint Signature { get; set; } /// /// The ReadyToRun version /// - public ushort MajorVersion { get; } - public ushort MinorVersion { get; } + public ushort MajorVersion { get; set; } + public ushort MinorVersion { get; set; } /// /// Flags in the header /// eg. PLATFORM_NEUTRAL_SOURCE, SKIP_TYPE_VALIDATION /// - public uint Flags { get; } + public uint Flags { get; set; } /// /// The ReadyToRun section RVAs and sizes /// - public Dictionary Sections { get; } + public IDictionary Sections { get; } + + public R2RHeader() { } /// /// Initializes the fields of the R2RHeader @@ -68,9 +70,9 @@ public R2RHeader(byte[] image, int rva, int curOffset) RelativeVirtualAddress = rva; int startOffset = curOffset; - byte[] signature = new byte[sizeof(uint)]; - Array.Copy(image, curOffset, signature, 0, sizeof(uint)); - SignatureString = System.Text.Encoding.UTF8.GetString(signature); + byte[] signature = new byte[sizeof(uint) - 1]; // -1 removes the null character at the end of the cstring + Array.Copy(image, curOffset, signature, 0, sizeof(uint) - 1); + SignatureString = Encoding.UTF8.GetString(signature); Signature = NativeReader.ReadUInt32(image, ref curOffset); if (Signature != READYTORUN_SIGNATURE) { diff --git a/src/tools/r2rdump/R2RImportSection.cs b/src/tools/r2rdump/R2RImportSection.cs new file mode 100644 index 000000000000..bf7a056d74c6 --- /dev/null +++ b/src/tools/r2rdump/R2RImportSection.cs @@ -0,0 +1,133 @@ +// 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.Collections.Generic; +using System.Reflection.PortableExecutable; +using System.Text; +using System.Xml.Serialization; + +namespace R2RDump +{ + public struct R2RImportSection + { + public enum CorCompileImportType + { + CORCOMPILE_IMPORT_TYPE_UNKNOWN = 0, + CORCOMPILE_IMPORT_TYPE_EXTERNAL_METHOD = 1, + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH = 2, + CORCOMPILE_IMPORT_TYPE_STRING_HANDLE = 3, + CORCOMPILE_IMPORT_TYPE_TYPE_HANDLE = 4, + CORCOMPILE_IMPORT_TYPE_METHOD_HANDLE = 5, + CORCOMPILE_IMPORT_TYPE_VIRTUAL_METHOD = 6, + }; + + public enum CorCompileImportFlags + { + CORCOMPILE_IMPORT_FLAGS_UNKNOWN = 0x0000, + CORCOMPILE_IMPORT_FLAGS_EAGER = 0x0001, // Section at module load time. + CORCOMPILE_IMPORT_FLAGS_CODE = 0x0002, // Section contains code. + CORCOMPILE_IMPORT_FLAGS_PCODE = 0x0004, // Section contains pointers to code. + }; + + public struct ImportSectionEntry + { + public int StartOffset { get; set; } + public long Section { get; set; } + [XmlAttribute("Index")] + public uint SignatureRVA { get; set; } + public byte[] SignatureSample { get; set; } + public ImportSectionEntry(int startOffset, long section, uint signatureRVA, byte[] signatureSample) + { + StartOffset = startOffset; + Section = section; + SignatureRVA = signatureRVA; + SignatureSample = signatureSample; + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append($@"+{StartOffset:X4} Section: 0x{Section:X8} SignatureRVA: 0x{SignatureRVA:X8} "); + foreach (byte b in SignatureSample) + { + sb.AppendFormat("{0:X2} ", b); + } + sb.Append("..."); + return sb.ToString(); + } + } + + /// + /// Section containing values to be fixed up + /// + [XmlAttribute("Index")] + public int SectionRVA { get; set; } + public int SectionSize { get; set; } + + /// + /// One or more of ImportSectionFlags + /// + public CorCompileImportFlags Flags { get; set; } + + /// + /// One of ImportSectionType + /// + public CorCompileImportType Type { get; set; } + + /// + /// + /// + public byte EntrySize { get; set; } + + /// + /// RVA of optional signature descriptors + /// + public int SignatureRVA { get; set; } + public List Entries { get; set; } + + /// + /// RVA of optional auxiliary data (typically GC info) + /// + public int AuxiliaryDataRVA { get; set; } + public GcInfo AuxiliaryData { get; set; } + + public R2RImportSection(byte[] image, int rva, int size, CorCompileImportFlags flags, byte type, byte entrySize, int signatureRVA, List entries, int auxDataRVA, int auxDataOffset, Machine machine, ushort majorVersion) + { + SectionRVA = rva; + SectionSize = size; + Flags = flags; + Type = (CorCompileImportType)type; + EntrySize = entrySize; + + SignatureRVA = signatureRVA; + Entries = entries; + + AuxiliaryDataRVA = auxDataRVA; + AuxiliaryData = null; + if (AuxiliaryDataRVA != 0) + { + AuxiliaryData = new GcInfo(image, auxDataOffset, machine, majorVersion); + } + } + + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine($"SectionRVA: 0x{SectionRVA:X8} ({SectionRVA})"); + sb.AppendLine($"SectionSize: {SectionSize} bytes"); + sb.AppendLine($"Flags: {Flags}"); + sb.AppendLine($"Type: {Type}"); + sb.AppendLine($"EntrySize: {EntrySize}"); + sb.AppendLine($"SignatureRVA: 0x{SignatureRVA:X8} ({SignatureRVA})"); + sb.AppendLine($"AuxiliaryDataRVA: 0x{AuxiliaryDataRVA:X8} ({AuxiliaryDataRVA})"); + if (AuxiliaryDataRVA != 0) + { + sb.AppendLine("AuxiliaryData:"); + sb.AppendLine(AuxiliaryData.ToString()); + } + return sb.ToString(); + } + } +} diff --git a/src/tools/r2rdump/R2RMethod.cs b/src/tools/r2rdump/R2RMethod.cs index ea439ff1e376..5cd8c3a2e84f 100644 --- a/src/tools/r2rdump/R2RMethod.cs +++ b/src/tools/r2rdump/R2RMethod.cs @@ -9,20 +9,27 @@ using System.Reflection.Metadata; using System.Reflection.Metadata.Ecma335; using System.Text; +using System.Xml.Serialization; namespace R2RDump { - class RuntimeFunction + public interface BaseUnwindInfo + { + + } + + public class RuntimeFunction { /// /// The index of the runtime function /// - public int Id { get; } + [XmlAttribute("Index")] + public int Id { get; set; } /// /// The relative virtual address to the start of the code block /// - public int StartAddress { get; } + public int StartAddress { get; set; } /// /// The size of the code block in bytes @@ -31,30 +38,41 @@ class RuntimeFunction /// The EndAddress field in the runtime functions section is conditional on machine type /// Size is -1 for images without the EndAddress field /// - public int Size { get; } + public int Size { get; set; } /// /// The relative virtual address to the unwind info /// - public int UnwindRVA { get; } + public int UnwindRVA { get; set; } + + public int CodeOffset { get; set; } /// /// The method that this runtime function belongs to /// public R2RMethod Method { get; } - public UnwindInfo UnwindInfo { get; } + public BaseUnwindInfo UnwindInfo { get; } + + public RuntimeFunction() { } - public RuntimeFunction(int id, int startRva, int endRva, int unwindRva, R2RMethod method, UnwindInfo unwindInfo) + public RuntimeFunction(int id, int startRva, int endRva, int unwindRva, int codeOffset, R2RMethod method, BaseUnwindInfo unwindInfo, GcInfo gcInfo) { Id = id; StartAddress = startRva; - Size = endRva - startRva; - if (endRva == -1) - Size = -1; UnwindRVA = unwindRva; Method = method; UnwindInfo = unwindInfo; + if (endRva != -1) + { + Size = endRva - startRva; + } + else if (gcInfo != null) + { + Size = gcInfo.CodeLength; + } + CodeOffset = codeOffset; + method.GcInfo = gcInfo; } public override string ToString() @@ -71,12 +89,13 @@ public override string ToString() { sb.AppendLine($"Size: {Size} bytes"); } + sb.AppendLine($"UnwindRVA: 0x{UnwindRVA:X8}"); return sb.ToString(); } } - class R2RMethod + public class R2RMethod { private const int _mdtMethodDef = 0x06000000; @@ -86,41 +105,32 @@ class R2RMethod /// /// The name of the method /// - public string Name { get; } + public string Name { get; set; } /// /// The signature with format: namespace.class.methodName(S, T, ...) /// - public string SignatureString { get; } + public string SignatureString { get; set; } - public bool IsGeneric { get; } - - /*/// - /// The return type of the method - /// - public string ReturnType { get; } - - /// - /// The argument types of the method - /// - public string[] ArgTypes { get; }*/ + public bool IsGeneric { get; set; } public MethodSignature Signature { get; } /// /// The type that the method belongs to /// - public string DeclaringType { get; } + public string DeclaringType { get; set; } /// /// The token of the method consisting of the table code (0x06) and row id /// - public uint Token { get; } + public uint Token { get; set; } /// /// The row id of the method /// - public uint Rid { get; } + [XmlAttribute("Index")] + public uint Rid { get; set; } /// /// All the runtime functions of this method @@ -130,7 +140,12 @@ class R2RMethod /// /// The id of the entrypoint runtime function /// - public int EntryPointRuntimeFunctionId { get; } + public int EntryPointRuntimeFunctionId { get; set; } + + [XmlIgnore] + public GcInfo GcInfo { get; set; } + + public FixupCell[] Fixups { get; set; } /// /// Maps all the generic parameters to the type in the instance @@ -172,10 +187,12 @@ public enum GenericElementTypes Array = 0x1d, }; + public R2RMethod() { } + /// /// Extracts the method signature from the metadata by rid /// - public R2RMethod(MetadataReader mdReader, uint rid, int entryPointId, GenericElementTypes[] instanceArgs, uint[] tok) + public R2RMethod(MetadataReader mdReader, uint rid, int entryPointId, GenericElementTypes[] instanceArgs, uint[] tok, FixupCell[] fixups) { Token = _mdtMethodDef | rid; Rid = rid; @@ -204,12 +221,14 @@ public R2RMethod(MetadataReader mdReader, uint rid, int entryPointId, GenericEle argCount = signatureReader.ReadCompressedInteger(); } + Fixups = fixups; + DisassemblingTypeProvider provider = new DisassemblingTypeProvider(); if (IsGeneric && instanceArgs != null && tok != null) { InitGenericInstances(genericParams, instanceArgs, tok); } - + DisassemblingGenericContext genericContext = new DisassemblingGenericContext(new string[0], _genericParamInstanceMap.Values.ToArray()); Signature = _methodDef.DecodeSignature(provider, genericContext); @@ -283,6 +302,14 @@ public override string ToString() sb.AppendLine($"Rid: {Rid}"); sb.AppendLine($"EntryPointRuntimeFunctionId: {EntryPointRuntimeFunctionId}"); sb.AppendLine($"Number of RuntimeFunctions: {RuntimeFunctions.Count}"); + if (Fixups != null) + { + sb.AppendLine($"Number of fixups: {Fixups.Count()}"); + foreach (FixupCell cell in Fixups) + { + sb.AppendLine($" TableIndex {cell.TableIndex}, Offset {cell.CellOffset:X4}"); + } + } return sb.ToString(); } diff --git a/src/tools/r2rdump/R2RReader.cs b/src/tools/r2rdump/R2RReader.cs index 4c1a5ad4eb23..9b2940d67104 100644 --- a/src/tools/r2rdump/R2RReader.cs +++ b/src/tools/r2rdump/R2RReader.cs @@ -12,7 +12,53 @@ namespace R2RDump { - class R2RReader + public enum Amd64Registers + { + EAX = 0, + ECX = 1, + EDX = 2, + EBX = 3, + ESP = 4, + EBP = 5, + ESI = 6, + EDI = 7, + E8 = 8, + E9 = 9, + E10 = 10, + E11 = 11, + E12 = 12, + E13 = 13, + E14 = 14, + E15 = 15, + } + + /// + /// This structure represents a single precode fixup cell decoded from the + /// nibble-oriented per-method fixup blob. Each method entrypoint fixup + /// represents an array of cells that must be fixed up before the method + /// can start executing. + /// + public struct FixupCell + { + /// + /// Zero-based index of the import table within the import tables section. + /// + public uint TableIndex; + + /// + /// Zero-based offset of the entry in the import table; it must be a multiple + /// of the target architecture pointer size. + /// + public uint CellOffset; + + public FixupCell(uint tableIndex, uint cellOffset) + { + TableIndex = tableIndex; + CellOffset = cellOffset; + } + } + + public class R2RReader { private readonly PEReader _peReader; private readonly MetadataReader _mdReader; @@ -25,23 +71,23 @@ class R2RReader /// /// Name of the image file /// - public string Filename { get; } + public string Filename { get; set; } /// /// True if the image is ReadyToRun /// - public bool IsR2R { get; } + public bool IsR2R { get; set; } /// /// The type of target machine /// - public Machine Machine { get; } + public Machine Machine { get; set; } /// /// The preferred address of the first byte of image when loaded into memory; /// must be a multiple of 64K. /// - public ulong ImageBase { get; } + public ulong ImageBase { get; set; } /// /// The ReadyToRun header @@ -56,7 +102,16 @@ class R2RReader /// /// The available types from READYTORUN_SECTION_AVAILABLE_TYPES /// - public List AvailableTypes { get; } + public IList AvailableTypes { get; } + + /// + /// The compiler identifier string from READYTORUN_SECTION_COMPILER_IDENTIFIER + /// + public string CompilerIdentifier { get; } + + public IList ImportSections { get; } + + public unsafe R2RReader() { } /// /// Initializes the fields of the R2RHeader and R2RMethods @@ -73,13 +128,18 @@ public unsafe R2RReader(string filename) IntPtr ptr = (IntPtr)p; _peReader = new PEReader(p, Image.Length); - IsR2R = (_peReader.PEHeaders.CorHeader.Flags == CorFlags.ILLibrary); + IsR2R = ((_peReader.PEHeaders.CorHeader.Flags & CorFlags.ILLibrary) != 0); if (!IsR2R) { throw new BadImageFormatException("The file is not a ReadyToRun image"); } Machine = _peReader.PEHeaders.CoffHeader.Machine; + if (!Machine.IsDefined(typeof(Machine), Machine)) + { + Machine = Machine.Amd64; + R2RDump.WriteWarning($"Invalid Machine: {Machine}"); + } ImageBase = _peReader.PEHeaders.PEHeader.ImageBase; // initialize R2RHeader @@ -95,20 +155,28 @@ public unsafe R2RReader(string filename) { _mdReader = _peReader.GetMetadataReader(); - int runtimeFunctionSize = CalculateRuntimeFunctionSize(); - R2RSection runtimeFunctionSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS]; - uint nRuntimeFunctions = (uint)(runtimeFunctionSection.Size / runtimeFunctionSize); - int runtimeFunctionOffset = GetOffset(runtimeFunctionSection.RelativeVirtualAddress); - bool[] isEntryPoint = new bool[nRuntimeFunctions]; - - // initialize R2RMethods R2RMethods = new List(); - ParseMethodDefEntrypoints(isEntryPoint); - ParseInstanceMethodEntrypoints(isEntryPoint); - ParseRuntimeFunctions(isEntryPoint, runtimeFunctionOffset, runtimeFunctionSize); + if (R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS)) + { + int runtimeFunctionSize = CalculateRuntimeFunctionSize(); + R2RSection runtimeFunctionSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS]; + uint nRuntimeFunctions = (uint)(runtimeFunctionSection.Size / runtimeFunctionSize); + int runtimeFunctionOffset = GetOffset(runtimeFunctionSection.RelativeVirtualAddress); + bool[] isEntryPoint = new bool[nRuntimeFunctions]; + + // initialize R2RMethods + ParseMethodDefEntrypoints(isEntryPoint); + ParseInstanceMethodEntrypoints(isEntryPoint); + ParseRuntimeFunctions(isEntryPoint, runtimeFunctionOffset, runtimeFunctionSize); + } AvailableTypes = new List(); ParseAvailableTypes(); + + CompilerIdentifier = ParseCompilerIdentifier(); + + ImportSections = new List(); + ParseImportSections(); } } } @@ -130,6 +198,10 @@ private int CalculateRuntimeFunctionSize() /// private void ParseMethodDefEntrypoints(bool[] isEntryPoint) { + if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_METHODDEF_ENTRYPOINTS)) + { + return; + } int methodDefEntryPointsRVA = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_METHODDEF_ENTRYPOINTS].RelativeVirtualAddress; int methodDefEntryPointsOffset = GetOffset(methodDefEntryPointsRVA); NativeArray methodEntryPoints = new NativeArray(Image, (uint)methodDefEntryPointsOffset); @@ -140,7 +212,10 @@ private void ParseMethodDefEntrypoints(bool[] isEntryPoint) int offset = 0; if (methodEntryPoints.TryGetAt(Image, rid - 1, ref offset)) { - R2RMethod method = new R2RMethod(_mdReader, rid, GetEntryPointIdFromOffset(offset), null, null); + int runtimeFunctionId; + FixupCell[] fixups; + GetEntryPointInfoFromOffset(offset, out runtimeFunctionId, out fixups); + R2RMethod method = new R2RMethod(_mdReader, rid, runtimeFunctionId, null, null, fixups); if (method.EntryPointRuntimeFunctionId < 0 || method.EntryPointRuntimeFunctionId >= isEntryPoint.Length) { @@ -157,10 +232,14 @@ private void ParseMethodDefEntrypoints(bool[] isEntryPoint) /// private void ParseInstanceMethodEntrypoints(bool[] isEntryPoint) { + if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS)) + { + return; + } R2RSection instMethodEntryPointSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS]; int instMethodEntryPointsOffset = GetOffset(instMethodEntryPointSection.RelativeVirtualAddress); NativeParser parser = new NativeParser(Image, (uint)instMethodEntryPointsOffset); - NativeHashtable instMethodEntryPoints = new NativeHashtable(Image, parser); + NativeHashtable instMethodEntryPoints = new NativeHashtable(Image, parser, (uint)(instMethodEntryPointsOffset + instMethodEntryPointSection.Size)); NativeHashtable.AllEntriesEnumerator allEntriesEnum = instMethodEntryPoints.EnumerateAllEntries(); NativeParser curParser = allEntriesEnum.GetNext(); while (!curParser.IsNull()) @@ -182,9 +261,10 @@ private void ParseInstanceMethodEntrypoints(bool[] isEntryPoint) } } - uint id = curParser.GetUnsigned(); - id = id >> 1; - R2RMethod method = new R2RMethod(_mdReader, rid, (int)id, args, tokens); + int runtimeFunctionId; + FixupCell[] fixups; + GetEntryPointInfoFromOffset((int)curParser.Offset, out runtimeFunctionId, out fixups); + R2RMethod method = new R2RMethod(_mdReader, rid, runtimeFunctionId, args, tokens, fixups); if (method.EntryPointRuntimeFunctionId >= 0 && method.EntryPointRuntimeFunctionId < isEntryPoint.Length) { isEntryPoint[method.EntryPointRuntimeFunctionId] = true; @@ -207,6 +287,8 @@ private void ParseRuntimeFunctions(bool[] isEntryPoint, int runtimeFunctionOffse if (runtimeFunctionId == -1) continue; curOffset = runtimeFunctionOffset + runtimeFunctionId * runtimeFunctionSize; + GcInfo gcInfo = null; + int codeOffset = 0; do { int startRva = NativeReader.ReadInt32(Image, ref curOffset); @@ -218,8 +300,20 @@ private void ParseRuntimeFunctions(bool[] isEntryPoint, int runtimeFunctionOffse int unwindRva = NativeReader.ReadInt32(Image, ref curOffset); int unwindOffset = GetOffset(unwindRva); - method.RuntimeFunctions.Add(new RuntimeFunction(runtimeFunctionId, startRva, endRva, unwindRva, method, new UnwindInfo(Image, unwindOffset))); + BaseUnwindInfo unwindInfo = null; + if (Machine == Machine.Amd64) + { + unwindInfo = new Amd64.UnwindInfo(Image, unwindOffset); + if (isEntryPoint[runtimeFunctionId]) + { + gcInfo = new GcInfo(Image, unwindOffset + ((Amd64.UnwindInfo)unwindInfo).Size, Machine, R2RHeader.MajorVersion); + } + } + + RuntimeFunction rtf = new RuntimeFunction(runtimeFunctionId, startRva, endRva, unwindRva, codeOffset, method, unwindInfo, gcInfo); + method.RuntimeFunctions.Add(rtf); runtimeFunctionId++; + codeOffset += rtf.Size; } while (runtimeFunctionId < isEntryPoint.Length && !isEntryPoint[runtimeFunctionId]); } @@ -227,10 +321,14 @@ private void ParseRuntimeFunctions(bool[] isEntryPoint, int runtimeFunctionOffse private void ParseAvailableTypes() { + if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES)) + { + return; + } R2RSection availableTypesSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES]; int availableTypesOffset = GetOffset(availableTypesSection.RelativeVirtualAddress); NativeParser parser = new NativeParser(Image, (uint)availableTypesOffset); - NativeHashtable availableTypes = new NativeHashtable(Image, parser); + NativeHashtable availableTypes = new NativeHashtable(Image, parser, (uint)(availableTypesOffset + availableTypesSection.Size)); NativeHashtable.AllEntriesEnumerator allEntriesEnum = availableTypes.EnumerateAllEntries(); NativeParser curParser = allEntriesEnum.GetNext(); while (!curParser.IsNull()) @@ -243,6 +341,96 @@ private void ParseAvailableTypes() } } + private string ParseCompilerIdentifier() + { + if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_COMPILER_IDENTIFIER)) + { + return ""; + } + R2RSection compilerIdentifierSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_COMPILER_IDENTIFIER]; + byte[] identifier = new byte[compilerIdentifierSection.Size - 1]; + int identifierOffset = GetOffset(compilerIdentifierSection.RelativeVirtualAddress); + Array.Copy(Image, identifierOffset, identifier, 0, compilerIdentifierSection.Size - 1); + return Encoding.UTF8.GetString(identifier); + } + + private void ParseImportSections() + { + if (!R2RHeader.Sections.ContainsKey(R2RSection.SectionType.READYTORUN_SECTION_IMPORT_SECTIONS)) + { + return; + } + R2RSection importSectionsSection = R2RHeader.Sections[R2RSection.SectionType.READYTORUN_SECTION_IMPORT_SECTIONS]; + int offset = GetOffset(importSectionsSection.RelativeVirtualAddress); + int endOffset = offset + importSectionsSection.Size; + while (offset < endOffset) + { + int rva = NativeReader.ReadInt32(Image, ref offset); + int sectionOffset = GetOffset(rva); + int startOffset = sectionOffset; + int size = NativeReader.ReadInt32(Image, ref offset); + R2RImportSection.CorCompileImportFlags flags = (R2RImportSection.CorCompileImportFlags)NativeReader.ReadUInt16(Image, ref offset); + byte type = NativeReader.ReadByte(Image, ref offset); + byte entrySize = NativeReader.ReadByte(Image, ref offset); + int entryCount = 0; + if (entrySize != 0) + { + entryCount = size / entrySize; + } + int signatureRVA = NativeReader.ReadInt32(Image, ref offset); + + int signatureOffset = 0; + if (signatureRVA != 0) + { + signatureOffset = GetOffset(signatureRVA); + } + List entries = new List(); + switch (flags) + { + case R2RImportSection.CorCompileImportFlags.CORCOMPILE_IMPORT_FLAGS_EAGER: + { + int tempSignatureOffset = signatureOffset; + int firstSigRva = NativeReader.ReadInt32(Image, ref tempSignatureOffset); + uint sigRva = 0; + while (sigRva != firstSigRva) + { + int entryOffset = sectionOffset - startOffset; + sigRva = NativeReader.ReadUInt32(Image, ref signatureOffset); + long section = NativeReader.ReadInt64(Image, ref sectionOffset); + int sigOff = GetOffset((int)sigRva); + int sigSampleLength = Math.Min(8, Image.Length - sigOff); + byte[] signatureSample = new byte[sigSampleLength]; + Array.Copy(Image, sigOff, signatureSample, 0, sigSampleLength); + entries.Add(new R2RImportSection.ImportSectionEntry(entryOffset, section, sigRva, signatureSample)); + } + } + break; + case R2RImportSection.CorCompileImportFlags.CORCOMPILE_IMPORT_FLAGS_CODE: + case R2RImportSection.CorCompileImportFlags.CORCOMPILE_IMPORT_FLAGS_PCODE: + for (int i = 0; i < entryCount; i++) + { + int entryOffset = sectionOffset - startOffset; + long section = NativeReader.ReadInt64(Image, ref sectionOffset); + uint sigRva = NativeReader.ReadUInt32(Image, ref signatureOffset); + int sigOff = GetOffset((int)sigRva); + int sigSampleLength = Math.Min(8, Image.Length - sigOff); + byte[] signatureSample = new byte[sigSampleLength]; + Array.Copy(Image, sigOff, signatureSample, 0, sigSampleLength); + entries.Add(new R2RImportSection.ImportSectionEntry(entryOffset, section, sigRva, signatureSample)); + } + break; + } + + int auxDataRVA = NativeReader.ReadInt32(Image, ref offset); + int auxDataOffset = 0; + if (auxDataRVA != 0) + { + auxDataOffset = GetOffset(auxDataRVA); + } + ImportSections.Add(new R2RImportSection(Image, rva, size, flags, type, entrySize, signatureRVA, entries, auxDataRVA, auxDataOffset, Machine, R2RHeader.MajorVersion)); + } + } + /// /// Get the index in the image byte array corresponding to the RVA /// @@ -250,6 +438,10 @@ private void ParseAvailableTypes() public int GetOffset(int rva) { int index = _peReader.PEHeaders.GetContainingSectionIndex(rva); + if (index == -1) + { + throw new BadImageFormatException("Failed to convert invalid RVA to offset: " + rva); + } SectionHeader containingSection = _peReader.PEHeaders.SectionHeaders[index]; return rva - containingSection.VirtualAddress + containingSection.PointerToRawData; } @@ -275,8 +467,10 @@ public static string GetTypeDefFullName(MetadataReader mdReader, TypeDefinitionH /// /// Reads the method entrypoint from the offset. Used for non-generic methods /// - private int GetEntryPointIdFromOffset(int offset) + private void GetEntryPointInfoFromOffset(int offset, out int runtimeFunctionIndex, out FixupCell[] fixupCells) { + fixupCells = null; + // get the id of the entry point runtime function from the MethodEntryPoints NativeArray uint id = 0; // the RUNTIME_FUNCTIONS index offset = (int)NativeReader.DecodeUnsigned(Image, (uint)offset, ref id); @@ -288,7 +482,8 @@ private int GetEntryPointIdFromOffset(int offset) NativeReader.DecodeUnsigned(Image, (uint)offset, ref val); offset -= (int)val; } - // TODO: Dump fixups + + fixupCells = DecodeFixupCells(offset); id >>= 2; } @@ -297,7 +492,45 @@ private int GetEntryPointIdFromOffset(int offset) id >>= 1; } - return (int)id; + runtimeFunctionIndex = (int)id; + } + + private FixupCell[] DecodeFixupCells(int offset) + { + List cells = new List(); + NibbleReader reader = new NibbleReader(Image, offset); + + // The following algorithm has been loosely ported from CoreCLR, + // src\vm\ceeload.inl, BOOL Module::FixupDelayListAux + uint curTableIndex = reader.ReadUInt(); + + while (true) + { + uint fixupIndex = reader.ReadUInt(); // Accumulate the real rva from the delta encoded rva + + while (true) + { + cells.Add(new FixupCell(curTableIndex, fixupIndex)); + + uint delta = reader.ReadUInt(); + + // Delta of 0 means end of entries in this table + if (delta == 0) + break; + + fixupIndex += delta; + } + + uint tableIndex = reader.ReadUInt(); + + if (tableIndex == 0) + break; + + curTableIndex = curTableIndex + tableIndex; + + } // Done with all entries in this table + + return cells.ToArray(); } } } diff --git a/src/tools/r2rdump/R2RSection.cs b/src/tools/r2rdump/R2RSection.cs index 8d6d7cf99c57..ff39c81b196f 100644 --- a/src/tools/r2rdump/R2RSection.cs +++ b/src/tools/r2rdump/R2RSection.cs @@ -5,10 +5,11 @@ using System; using System.Collections.Generic; using System.Text; +using System.Xml.Serialization; namespace R2RDump { - struct R2RSection + public struct R2RSection { public enum SectionType { @@ -28,17 +29,18 @@ public enum SectionType /// /// The ReadyToRun section type /// - public SectionType Type { get; } + [XmlAttribute("Index")] + public SectionType Type { get; set; } /// /// The RVA to the section /// - public int RelativeVirtualAddress { get; } + public int RelativeVirtualAddress { get; set; } /// /// The size of the section /// - public int Size { get; } + public int Size { get; set; } public R2RSection(SectionType type, int rva, int size) { diff --git a/src/tools/r2rdump/TextDumper.cs b/src/tools/r2rdump/TextDumper.cs new file mode 100644 index 000000000000..a1c6905f3efb --- /dev/null +++ b/src/tools/r2rdump/TextDumper.cs @@ -0,0 +1,305 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; + +namespace R2RDump +{ + class TextDumper : Dumper + { + public TextDumper(R2RReader r2r, TextWriter writer, bool raw, bool header, bool disasm, IntPtr disassembler, bool unwind, bool gc, bool sectionContents) + { + _r2r = r2r; + _writer = writer; + + _raw = raw; + _header = header; + _disasm = disasm; + _disassembler = disassembler; + _unwind = unwind; + _gc = gc; + _sectionContents = sectionContents; + } + + internal override void Begin() + { + _writer.WriteLine($"Filename: {_r2r.Filename}"); + _writer.WriteLine($"Machine: {_r2r.Machine}"); + _writer.WriteLine($"ImageBase: 0x{_r2r.ImageBase:X8}"); + SkipLine(); + } + + internal override void End() + { + _writer.WriteLine("============================================================="); + SkipLine(); + } + + internal override void WriteDivider(string title) + { + int len = 61 - title.Length - 2; + _writer.WriteLine(new String('=', len / 2) + " " + title + " " + new String('=', (int)Math.Ceiling(len / 2.0))); + SkipLine(); + } + + internal override void WriteSubDivider() + { + _writer.WriteLine("_______________________________________________"); + SkipLine(); + } + + internal override void SkipLine() + { + _writer.WriteLine(); + } + + /// + /// Dumps the R2RHeader and all the sections in the header + /// + internal override void DumpHeader(bool dumpSections) + { + _writer.WriteLine(_r2r.R2RHeader.ToString()); + + if (_raw) + { + DumpBytes(_r2r.R2RHeader.RelativeVirtualAddress, (uint)_r2r.R2RHeader.Size); + } + SkipLine(); + if (dumpSections) + { + WriteDivider("R2R Sections"); + _writer.WriteLine($"{_r2r.R2RHeader.Sections.Count} sections"); + SkipLine(); + + foreach (R2RSection section in _r2r.R2RHeader.Sections.Values) + { + DumpSection(section); + } + } + SkipLine(); + } + + /// + /// Dumps one R2RSection + /// + internal override void DumpSection(R2RSection section, XmlNode parentNode = null) + { + WriteSubDivider(); + _writer.WriteLine(section.ToString()); + + if (_raw) + { + DumpBytes(section.RelativeVirtualAddress, (uint)section.Size); + SkipLine(); + } + if (_sectionContents) + { + DumpSectionContents(section); + SkipLine(); + } + } + + internal override void DumpAllMethods() + { + WriteDivider("R2R Methods"); + _writer.WriteLine($"{_r2r.R2RMethods.Count} methods"); + SkipLine(); + foreach (R2RMethod method in _r2r.R2RMethods) + { + DumpMethod(method); + } + } + + /// + /// Dumps one R2RMethod. + /// + internal override void DumpMethod(R2RMethod method, XmlNode parentNode = null) + { + WriteSubDivider(); + _writer.WriteLine(method.ToString()); + + if (_gc) + { + _writer.WriteLine("GcInfo:"); + _writer.Write(method.GcInfo); + + if (_raw) + { + DumpBytes(method.GcInfo.Offset, (uint)method.GcInfo.Size, null, "", false); + } + } + SkipLine(); + + foreach (RuntimeFunction runtimeFunction in method.RuntimeFunctions) + { + DumpRuntimeFunction(runtimeFunction); + } + } + + /// + /// Dumps one runtime function. + /// + internal override void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNode = null) + { + _writer.WriteLine(rtf.Method.SignatureString); + _writer.Write($"{rtf}"); + + if (_disasm) + { + DumpDisasm(_disassembler, rtf, _r2r.GetOffset(rtf.StartAddress), _r2r.Image); + } + + if (_raw) + { + _writer.WriteLine("Raw Bytes:"); + DumpBytes(rtf.StartAddress, (uint)rtf.Size); + } + if (_unwind) + { + _writer.WriteLine("UnwindInfo:"); + _writer.Write(rtf.UnwindInfo); + if (_raw) + { + DumpBytes(rtf.UnwindRVA, (uint)((Amd64.UnwindInfo)rtf.UnwindInfo).Size); + } + } + SkipLine(); + } + + internal unsafe override void DumpDisasm(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, byte[] image, XmlNode parentNode = null) + { + int rtfOffset = 0; + int codeOffset = rtf.CodeOffset; + while (rtfOffset < rtf.Size) + { + string instr; + int instrSize = CoreDisTools.GetInstruction(Disasm, rtf, imageOffset, rtfOffset, image, out instr); + + _writer.Write(instr); + if (rtf.Method.GcInfo != null && rtf.Method.GcInfo.Transitions.ContainsKey(codeOffset)) + { + _writer.WriteLine($"\t\t\t\t{rtf.Method.GcInfo.Transitions[codeOffset].GetSlotState(rtf.Method.GcInfo.SlotTable)}"); + } + + CoreDisTools.ClearOutputBuffer(); + rtfOffset += instrSize; + codeOffset += instrSize; + } + } + + /// + /// Prints a formatted string containing a block of bytes from the relative virtual address and size + /// + internal override void DumpBytes(int rva, uint size, XmlNode parentNode = null, string name = "Raw", bool convertToOffset = true) + { + int start = rva; + if (convertToOffset) + start = _r2r.GetOffset(rva); + if (start > _r2r.Image.Length || start + size > _r2r.Image.Length) + { + throw new IndexOutOfRangeException(); + } + + _writer.Write(" "); + if (rva % 16 != 0) + { + int floor = rva / 16 * 16; + _writer.Write($"{floor:X8}:"); + _writer.Write(new String(' ', (rva - floor) * 3)); + } + for (uint i = 0; i < size; i++) + { + if ((rva + i) % 16 == 0) + { + _writer.Write($"{rva + i:X8}:"); + } + _writer.Write($" {_r2r.Image[start + i]:X2}"); + if ((rva + i) % 16 == 15 && i != size - 1) + { + SkipLine(); + _writer.Write(" "); + } + } + SkipLine(); + } + + internal override void DumpSectionContents(R2RSection section, XmlNode parentNode = null) + { + switch (section.Type) + { + case R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES: + uint availableTypesSectionOffset = (uint)_r2r.GetOffset(section.RelativeVirtualAddress); + NativeParser availableTypesParser = new NativeParser(_r2r.Image, availableTypesSectionOffset); + NativeHashtable availableTypes = new NativeHashtable(_r2r.Image, availableTypesParser, (uint)(availableTypesSectionOffset + section.Size)); + _writer.WriteLine(availableTypes.ToString()); + + foreach (string name in _r2r.AvailableTypes) + { + _writer.WriteLine(name); + } + break; + case R2RSection.SectionType.READYTORUN_SECTION_METHODDEF_ENTRYPOINTS: + NativeArray methodEntryPoints = new NativeArray(_r2r.Image, (uint)_r2r.GetOffset(section.RelativeVirtualAddress)); + _writer.Write(methodEntryPoints.ToString()); + break; + case R2RSection.SectionType.READYTORUN_SECTION_INSTANCE_METHOD_ENTRYPOINTS: + uint instanceSectionOffset = (uint)_r2r.GetOffset(section.RelativeVirtualAddress); + NativeParser instanceParser = new NativeParser(_r2r.Image, instanceSectionOffset); + NativeHashtable instMethodEntryPoints = new NativeHashtable(_r2r.Image, instanceParser, (uint)(instanceSectionOffset + section.Size)); + _writer.Write(instMethodEntryPoints.ToString()); + break; + case R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS: + int rtfOffset = _r2r.GetOffset(section.RelativeVirtualAddress); + int rtfEndOffset = rtfOffset + section.Size; + int rtfIndex = 0; + while (rtfOffset < rtfEndOffset) + { + uint rva = NativeReader.ReadUInt32(_r2r.Image, ref rtfOffset); + _writer.WriteLine($"{rtfIndex}: 0x{rva:X8}"); + rtfIndex++; + } + break; + case R2RSection.SectionType.READYTORUN_SECTION_COMPILER_IDENTIFIER: + _writer.WriteLine(_r2r.CompilerIdentifier); + break; + case R2RSection.SectionType.READYTORUN_SECTION_IMPORT_SECTIONS: + foreach (R2RImportSection importSection in _r2r.ImportSections) + { + _writer.Write(importSection.ToString()); + if (_raw && importSection.Entries.Count != 0) + { + if (importSection.SectionRVA != 0) + { + _writer.WriteLine("Section Bytes:"); + DumpBytes(importSection.SectionRVA, (uint)importSection.SectionSize); + } + if (importSection.SignatureRVA != 0) + { + _writer.WriteLine("Signature Bytes:"); + DumpBytes(importSection.SignatureRVA, (uint)importSection.Entries.Count * sizeof(int)); + } + if (importSection.AuxiliaryDataRVA != 0) + { + _writer.WriteLine("AuxiliaryData Bytes:"); + DumpBytes(importSection.AuxiliaryDataRVA, (uint)importSection.AuxiliaryData.Size); + } + } + foreach (R2RImportSection.ImportSectionEntry entry in importSection.Entries) + { + _writer.WriteLine(entry.ToString()); + } + _writer.WriteLine(); + } + break; + } + } + + internal override XmlNode DumpQueryCount(string q, string title, int count) + { + _writer.WriteLine(count + " result(s) for \"" + q + "\""); + SkipLine(); + return null; + } + } +} diff --git a/src/tools/r2rdump/UnwindInfo.cs b/src/tools/r2rdump/UnwindInfo.cs deleted file mode 100644 index ae7952e84483..000000000000 --- a/src/tools/r2rdump/UnwindInfo.cs +++ /dev/null @@ -1,117 +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. - -using System.Text; - -namespace R2RDump -{ - struct UnwindCode - { - public byte CodeOffset { get; } - public byte UnwindOp { get; } //4 bits - public byte OpInfo { get; } //4 bits - - public byte OffsetLow { get; } - public byte OffsetHigh { get; } //4 bits - - public ushort FrameOffset { get; } - - public UnwindCode(byte[] image, ref int offset) - { - int off = offset; - CodeOffset = NativeReader.ReadByte(image, ref off); - byte op = NativeReader.ReadByte(image, ref off); - UnwindOp = (byte)(op & 15); - OpInfo = (byte)(op >> 4); - - OffsetLow = CodeOffset; - OffsetHigh = OpInfo; - - FrameOffset = NativeReader.ReadUInt16(image, ref offset); - } - - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - string tab2 = new string(' ', 8); - string tab3 = new string(' ', 12); - - sb.AppendLine($"{tab2}{{"); - sb.AppendLine($"{tab3}CodeOffset: {CodeOffset}"); - sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}"); - sb.AppendLine($"{tab3}OpInfo: {OpInfo}"); - sb.AppendLine($"{tab2}}}"); - sb.AppendLine($"{tab2}{{"); - sb.AppendLine($"{tab3}OffsetLow: {OffsetLow}"); - sb.AppendLine($"{tab3}UnwindOp: {UnwindOp}"); - sb.AppendLine($"{tab3}OffsetHigh: {OffsetHigh}"); - sb.AppendLine($"{tab2}}}"); - sb.AppendLine($"{tab2}FrameOffset: {FrameOffset}"); - sb.AppendLine($"{tab2}------------------"); - - return sb.ToString(); - } - } - - struct UnwindInfo - { - private const int _sizeofUnwindCode = 2; - private const int _offsetofUnwindCode = 4; - - public byte Version { get; } //3 bits - public byte Flags { get; } //5 bits - public byte SizeOfProlog { get; } - public byte CountOfUnwindCodes { get; } - public byte FrameRegister { get; } //4 bits - public byte FrameOffset { get; } //4 bits - public UnwindCode[] UnwindCode { get; } - public uint PersonalityRoutineRVA { get; } - public int Size { get; } - - public UnwindInfo(byte[] image, int offset) - { - byte versionAndFlags = NativeReader.ReadByte(image, ref offset); - Version = (byte)(versionAndFlags & 7); - Flags = (byte)(versionAndFlags >> 3); - SizeOfProlog = NativeReader.ReadByte(image, ref offset); - CountOfUnwindCodes = NativeReader.ReadByte(image, ref offset); - byte frameRegisterAndOffset = NativeReader.ReadByte(image, ref offset); - FrameRegister = (byte)(frameRegisterAndOffset & 15); - FrameOffset = (byte)(frameRegisterAndOffset >> 4); - - UnwindCode = new UnwindCode[CountOfUnwindCodes]; - for (int i = 0; i < CountOfUnwindCodes; i++) - { - UnwindCode[i] = new UnwindCode(image, ref offset); - } - - PersonalityRoutineRVA = NativeReader.ReadUInt32(image, ref offset); - - Size = _offsetofUnwindCode + CountOfUnwindCodes * _sizeofUnwindCode + sizeof(uint); - } - - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - string tab = " "; - - sb.AppendLine($"{tab}Version: {Version}"); - sb.AppendLine($"{tab}Flags: 0x{Flags:X8}"); - sb.AppendLine($"{tab}SizeOfProlog: {SizeOfProlog}"); - sb.AppendLine($"{tab}CountOfUnwindCodes: {CountOfUnwindCodes}"); - sb.AppendLine($"{tab}FrameRegister: {FrameRegister}"); - sb.AppendLine($"{tab}FrameOffset: {FrameOffset}"); - sb.AppendLine($"{tab}Unwind Codes:"); - sb.AppendLine($"{tab}{tab}------------------"); - for (int i = 0; i < CountOfUnwindCodes; i++) - { - sb.Append(UnwindCode[i].ToString()); - } - sb.AppendLine($"{tab}PersonalityRoutineRVA: 0x{PersonalityRoutineRVA:X8}"); - sb.AppendLine($"{tab}Size: {Size}"); - - return sb.ToString(); - } - } -} diff --git a/src/tools/r2rdump/XmlDumper.cs b/src/tools/r2rdump/XmlDumper.cs new file mode 100644 index 000000000000..913a8be1ee8e --- /dev/null +++ b/src/tools/r2rdump/XmlDumper.cs @@ -0,0 +1,335 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Serialization; + +namespace R2RDump +{ + public class XmlDumper : Dumper + { + public XmlDocument XmlDocument { get; } + private XmlNode _rootNode; + + public XmlDumper(R2RReader r2r, TextWriter writer, bool raw, bool header, bool disasm, IntPtr disassembler, bool unwind, bool gc, bool sectionContents) + { + _r2r = r2r; + _writer = writer; + XmlDocument = new XmlDocument(); + + _raw = raw; + _header = header; + _disasm = disasm; + _disassembler = disassembler; + _unwind = unwind; + _gc = gc; + _sectionContents = sectionContents; + } + + public XmlDocument GetXmlDocument() + { + Begin(); + DumpHeader(true); + DumpAllMethods(); + return XmlDocument; + } + + internal override void Begin() + { + _rootNode = XmlDocument.CreateNode("element", "R2RDump", ""); + XmlDocument.AppendChild(_rootNode); + Serialize(_r2r, _rootNode); + } + + internal override void End() { + if (_writer != null) + { + XmlDocument.Save(_writer); + } + } + + internal override void WriteDivider(string title) + { + } + + internal override void WriteSubDivider() + { + } + + internal override void SkipLine() + { + } + + /// + /// Dumps the R2RHeader and all the sections in the header + /// + internal override void DumpHeader(bool dumpSections) + { + XmlNode headerNode = XmlDocument.CreateNode("element", "Header", ""); + _rootNode.AppendChild(headerNode); + Serialize(_r2r.R2RHeader, headerNode); + + if (_raw) + { + DumpBytes(_r2r.R2RHeader.RelativeVirtualAddress, (uint)_r2r.R2RHeader.Size, headerNode); + } + + if (dumpSections) + { + XmlNode sectionsNode = XmlDocument.CreateNode("element", "Sections", ""); + _rootNode.AppendChild(sectionsNode); + AddXMLNode("Count", _r2r.R2RHeader.Sections.Count.ToString(), sectionsNode); + + foreach (R2RSection section in _r2r.R2RHeader.Sections.Values) + { + DumpSection(section, sectionsNode); + } + } + } + + /// + /// Dumps one R2RSection + /// + internal override void DumpSection(R2RSection section, XmlNode parentNode) + { + XmlNode sectionNode = XmlDocument.CreateNode("element", "Section", ""); + AddIndexAttribute(sectionNode, $"{section.Type}"); + parentNode.AppendChild(sectionNode); + Serialize(section, sectionNode); + + if (_raw) + { + DumpBytes(section.RelativeVirtualAddress, (uint)section.Size, sectionNode); + } + if (_sectionContents) + { + DumpSectionContents(section, sectionNode); + } + } + + internal override void DumpAllMethods() + { + XmlNode methodsNode = XmlDocument.CreateNode("element", "Methods", ""); + _rootNode.AppendChild(methodsNode); + AddXMLNode("Count", _r2r.R2RMethods.Count.ToString(), methodsNode); + foreach (R2RMethod method in _r2r.R2RMethods) + { + DumpMethod(method, methodsNode); + } + } + + /// + /// Dumps one R2RMethod. + /// + internal override void DumpMethod(R2RMethod method, XmlNode parentNode) + { + XmlNode methodNode = XmlDocument.CreateNode("element", "Method", ""); + AddIndexAttribute(methodNode, $"{method.Rid}"); + parentNode.AppendChild(methodNode); + Serialize(method, methodNode); + + if (_gc && method.GcInfo != null) + { + XmlNode gcNode = XmlDocument.CreateNode("element", "GcInfo", ""); + methodNode.AppendChild(gcNode); + Serialize(method.GcInfo, gcNode); + + foreach (GcInfo.GcTransition transition in method.GcInfo.Transitions.Values) + { + Serialize(transition, gcNode); + } + + if (_raw) + { + DumpBytes(method.GcInfo.Offset, (uint)method.GcInfo.Size, gcNode, "Raw", false); + } + } + + XmlNode rtfsNode = null; + rtfsNode = XmlDocument.CreateNode("element", "RuntimeFunctions", ""); + methodNode.AppendChild(rtfsNode); + + foreach (RuntimeFunction runtimeFunction in method.RuntimeFunctions) + { + DumpRuntimeFunction(runtimeFunction, rtfsNode); + } + } + + /// + /// Dumps one runtime function. + /// + internal override void DumpRuntimeFunction(RuntimeFunction rtf, XmlNode parentNode) + { + XmlNode rtfNode = XmlDocument.CreateNode("element", "RuntimeFunction", ""); + parentNode.AppendChild(rtfNode); + AddXMLNode("MethodRid", rtf.Method.Rid.ToString(), rtfNode); + Serialize(rtf, rtfNode); + + if (_disasm) + { + DumpDisasm(_disassembler, rtf, _r2r.GetOffset(rtf.StartAddress), _r2r.Image, rtfNode); + } + + if (_raw) + { + DumpBytes(rtf.StartAddress, (uint)rtf.Size, rtfNode); + } + if (_unwind && rtf.UnwindInfo != null) + { + XmlNode unwindNode = null; + unwindNode = XmlDocument.CreateNode("element", "UnwindInfo", ""); + rtfNode.AppendChild(unwindNode); + Serialize(rtf.UnwindInfo, unwindNode); + + if (_raw) + { + DumpBytes(rtf.UnwindRVA, (uint)((Amd64.UnwindInfo)rtf.UnwindInfo).Size, unwindNode); + } + } + } + + internal unsafe override void DumpDisasm(IntPtr Disasm, RuntimeFunction rtf, int imageOffset, byte[] image, XmlNode parentNode) + { + int rtfOffset = 0; + int codeOffset = rtf.CodeOffset; + Dictionary transitions = rtf.Method.GcInfo.Transitions; + GcSlotTable slotTable = rtf.Method.GcInfo.SlotTable; + while (rtfOffset < rtf.Size) + { + string instr; + int instrSize = CoreDisTools.GetInstruction(Disasm, rtf, imageOffset, rtfOffset, image, out instr); + + AddXMLNode("offset"+codeOffset, instr, parentNode, $"{codeOffset}"); + if (transitions.ContainsKey(codeOffset)) + { + AddXMLNode("Transition", transitions[codeOffset].GetSlotState(slotTable), parentNode, $"{codeOffset}"); + } + + CoreDisTools.ClearOutputBuffer(); + rtfOffset += instrSize; + codeOffset += instrSize; + } + } + + /// + /// Prints a formatted string containing a block of bytes from the relative virtual address and size + /// + internal override void DumpBytes(int rva, uint size, XmlNode parentNode, string name = "Raw", bool convertToOffset = true) + { + int start = rva; + if (convertToOffset) + start = _r2r.GetOffset(rva); + if (start > _r2r.Image.Length || start + size > _r2r.Image.Length) + { + throw new IndexOutOfRangeException(); + } + + if (parentNode != null) + { + StringBuilder sb = new StringBuilder(); + sb.Append($"{_r2r.Image[start]:X2}"); + for (uint i = 1; i < size; i++) + { + sb.Append($" {_r2r.Image[start + i]:X2}"); + } + AddXMLNode(name, sb.ToString(), parentNode, $"{start}"); + return; + } + } + + internal override void DumpSectionContents(R2RSection section, XmlNode parentNode) + { + XmlNode contentsNode = XmlDocument.CreateNode("element", "Contents", ""); + parentNode.AppendChild(contentsNode); + + switch (section.Type) + { + case R2RSection.SectionType.READYTORUN_SECTION_AVAILABLE_TYPES: + int availableTypesId = 0; + foreach (string name in _r2r.AvailableTypes) + { + AddXMLNode("AvailableType", name, contentsNode, $"{availableTypesId++}"); + } + break; + case R2RSection.SectionType.READYTORUN_SECTION_RUNTIME_FUNCTIONS: + int rtfOffset = _r2r.GetOffset(section.RelativeVirtualAddress); + int rtfEndOffset = rtfOffset + section.Size; + int rtfIndex = 0; + while (rtfOffset < rtfEndOffset) + { + uint rva = NativeReader.ReadUInt32(_r2r.Image, ref rtfOffset); + AddXMLNode($"id{rtfIndex}", $"0x{rva:X8}", contentsNode, $"{rtfIndex}"); + rtfIndex++; + } + break; + case R2RSection.SectionType.READYTORUN_SECTION_COMPILER_IDENTIFIER: + AddXMLNode("CompilerIdentifier", _r2r.CompilerIdentifier, contentsNode); + break; + case R2RSection.SectionType.READYTORUN_SECTION_IMPORT_SECTIONS: + foreach (R2RImportSection importSection in _r2r.ImportSections) + { + Serialize(importSection, contentsNode); + if (_raw && importSection.Entries.Count != 0) + { + if (importSection.SectionRVA != 0) + { + DumpBytes(importSection.SectionRVA, (uint)importSection.SectionSize, contentsNode, "SectionBytes"); + } + if (importSection.SignatureRVA != 0) + { + DumpBytes(importSection.SignatureRVA, (uint)importSection.Entries.Count * sizeof(int), contentsNode, "SignatureBytes"); + } + if (importSection.AuxiliaryDataRVA != 0) + { + DumpBytes(importSection.AuxiliaryDataRVA, (uint)importSection.AuxiliaryData.Size, contentsNode, "AuxiliaryDataBytes"); + } + } + foreach (R2RImportSection.ImportSectionEntry entry in importSection.Entries) + { + Serialize(entry, contentsNode); + } + } + break; + } + } + + internal override XmlNode DumpQueryCount(string q, string title, int count) + { + XmlNode queryNode = XmlDocument.CreateNode("element", title, ""); + _rootNode.AppendChild(queryNode); + AddXMLNode("Query", q, queryNode); + AddXMLNode("Count", count.ToString(), queryNode); + return queryNode; + } + + private void Serialize(object obj, XmlNode node) + { + using (XmlWriter xmlWriter = node.CreateNavigator().AppendChild()) + { + xmlWriter.WriteWhitespace(""); + XmlSerializer Serializer = new XmlSerializer(obj.GetType()); + Serializer.Serialize(xmlWriter, obj); + } + } + + private XmlNode AddXMLNode(String name, String contents, XmlNode parentNode, string index = "") + { + XmlNode node = XmlDocument.CreateNode("element", name, ""); + if (!index.Equals("")) + { + AddIndexAttribute(node, index); + } + parentNode.AppendChild(node); + node.InnerText = contents; + return node; + } + + private void AddIndexAttribute(XmlNode node, string index) + { + XmlAttribute attr = XmlDocument.CreateAttribute("Index"); + attr.Value = index; + node.Attributes.SetNamedItem(attr); + } + } +} diff --git a/src/utilcode/CMakeLists.txt b/src/utilcode/CMakeLists.txt index 9629e5140f88..f591e7cbec42 100644 --- a/src/utilcode/CMakeLists.txt +++ b/src/utilcode/CMakeLists.txt @@ -54,8 +54,7 @@ set(UTILCODE_COMMON_SOURCES debug.cpp pedecoder.cpp winfix.cpp - longfilepathwrappers.cpp - jithost.cpp + longfilepathwrappers.cpp ) # These source file do not yet compile on Linux. diff --git a/src/utilcode/ex.cpp b/src/utilcode/ex.cpp index 92b25b0aafbf..2360f29e77de 100644 --- a/src/utilcode/ex.cpp +++ b/src/utilcode/ex.cpp @@ -547,173 +547,47 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) #ifdef _DEBUG // @todo: do we want to burn strings for this in a free build? - CASE_HRESULT(CEE_E_ENTRYPOINT) CASE_HRESULT(CEE_E_CVTRES_NOT_FOUND) - CASE_HRESULT(MSEE_E_LOADLIBFAILED) - CASE_HRESULT(MSEE_E_GETPROCFAILED) - CASE_HRESULT(MSEE_E_MULTCOPIESLOADED) CASE_HRESULT(COR_E_APPDOMAINUNLOADED) CASE_HRESULT(COR_E_CANNOTUNLOADAPPDOMAIN) CASE_HRESULT(MSEE_E_ASSEMBLYLOADINPROGRESS) - CASE_HRESULT(MSEE_E_CANNOTCREATEAPPDOMAIN) CASE_HRESULT(COR_E_FIXUPSINEXE) - CASE_HRESULT(COR_E_NO_LOADLIBRARY_ALLOWED) CASE_HRESULT(COR_E_MODULE_HASH_CHECK_FAILED) CASE_HRESULT(FUSION_E_LOADFROM_BLOCKED) CASE_HRESULT(FUSION_E_CACHEFILE_FAILED) CASE_HRESULT(FUSION_E_REF_DEF_MISMATCH) CASE_HRESULT(FUSION_E_INVALID_PRIVATE_ASM_LOCATION) CASE_HRESULT(FUSION_E_ASM_MODULE_MISSING) - CASE_HRESULT(FUSION_E_UNEXPECTED_MODULE_FOUND) CASE_HRESULT(FUSION_E_PRIVATE_ASM_DISALLOWED) CASE_HRESULT(FUSION_E_SIGNATURE_CHECK_FAILED) - CASE_HRESULT(FUSION_E_DATABASE_ERROR) CASE_HRESULT(FUSION_E_INVALID_NAME) CASE_HRESULT(FUSION_E_CODE_DOWNLOAD_DISABLED) - CASE_HRESULT(FUSION_E_UNINSTALL_DISALLOWED) CASE_HRESULT(CLDB_E_FILE_BADREAD) CASE_HRESULT(CLDB_E_FILE_BADWRITE) - CASE_HRESULT(CLDB_E_FILE_READONLY) - CASE_HRESULT(CLDB_E_NAME_ERROR) CASE_HRESULT(CLDB_S_TRUNCATION) - CASE_HRESULT(CLDB_E_TRUNCATION) CASE_HRESULT(CLDB_E_FILE_OLDVER) - CASE_HRESULT(CLDB_E_RELOCATED) - CASE_HRESULT(CLDB_S_NULL) CASE_HRESULT(CLDB_E_SMDUPLICATE) CASE_HRESULT(CLDB_E_NO_DATA) - CASE_HRESULT(CLDB_E_READONLY) CASE_HRESULT(CLDB_E_INCOMPATIBLE) CASE_HRESULT(CLDB_E_FILE_CORRUPT) - CASE_HRESULT(CLDB_E_SCHEMA_VERNOTFOUND) CASE_HRESULT(CLDB_E_BADUPDATEMODE) - CASE_HRESULT(CLDB_E_INDEX_NONULLKEYS) - CASE_HRESULT(CLDB_E_INDEX_DUPLICATE) - CASE_HRESULT(CLDB_E_INDEX_BADTYPE) CASE_HRESULT(CLDB_E_INDEX_NOTFOUND) - CASE_HRESULT(CLDB_S_INDEX_TABLESCANREQUIRED) CASE_HRESULT(CLDB_E_RECORD_NOTFOUND) - CASE_HRESULT(CLDB_E_RECORD_OVERFLOW) - CASE_HRESULT(CLDB_E_RECORD_DUPLICATE) - CASE_HRESULT(CLDB_E_RECORD_PKREQUIRED) - CASE_HRESULT(CLDB_E_RECORD_DELETED) CASE_HRESULT(CLDB_E_RECORD_OUTOFORDER) - CASE_HRESULT(CLDB_E_COLUMN_OVERFLOW) - CASE_HRESULT(CLDB_E_COLUMN_READONLY) - CASE_HRESULT(CLDB_E_COLUMN_SPECIALCOL) - CASE_HRESULT(CLDB_E_COLUMN_PKNONULLS) - CASE_HRESULT(CLDB_E_TABLE_CANTDROP) - CASE_HRESULT(CLDB_E_OBJECT_NOTFOUND) - CASE_HRESULT(CLDB_E_OBJECT_COLNOTFOUND) - CASE_HRESULT(CLDB_E_VECTOR_BADINDEX) CASE_HRESULT(CLDB_E_TOO_BIG) - CASE_HRESULT(META_E_DUPLICATE) - CASE_HRESULT(META_E_GUID_REQUIRED) - CASE_HRESULT(META_E_TYPEDEF_MISMATCH) - CASE_HRESULT(META_E_MERGE_COLLISION) - CASE_HRESULT(META_E_METHD_NOT_FOUND) - CASE_HRESULT(META_E_FIELD_NOT_FOUND) - CASE_HRESULT(META_S_PARAM_MISMATCH) - CASE_HRESULT(META_E_PARAM_MISMATCH) CASE_HRESULT(META_E_BADMETADATA) - CASE_HRESULT(META_E_INTFCEIMPL_NOT_FOUND) - CASE_HRESULT(META_E_CLASS_LAYOUT_INCONSISTENT) - CASE_HRESULT(META_E_FIELD_MARSHAL_NOT_FOUND) - CASE_HRESULT(META_E_METHODSEM_NOT_FOUND) - CASE_HRESULT(META_E_EVENT_NOT_FOUND) - CASE_HRESULT(META_E_PROP_NOT_FOUND) CASE_HRESULT(META_E_BAD_SIGNATURE) CASE_HRESULT(META_E_BAD_INPUT_PARAMETER) - CASE_HRESULT(META_E_METHDIMPL_INCONSISTENT) - CASE_HRESULT(META_E_MD_INCONSISTENCY) CASE_HRESULT(META_E_CANNOTRESOLVETYPEREF) CASE_HRESULT(META_S_DUPLICATE) CASE_HRESULT(META_E_STRINGSPACE_FULL) - CASE_HRESULT(META_E_UNEXPECTED_REMAP) CASE_HRESULT(META_E_HAS_UNMARKALL) CASE_HRESULT(META_E_MUST_CALL_UNMARKALL) - CASE_HRESULT(TLBX_E_CANT_LOAD_MODULE) - CASE_HRESULT(TLBX_E_CANT_LOAD_CLASS) - CASE_HRESULT(TLBX_E_NULL_MODULE) - CASE_HRESULT(TLBX_E_NO_CLSID_KEY) - CASE_HRESULT(TLBX_E_CIRCULAR_EXPORT) - CASE_HRESULT(TLBX_E_CIRCULAR_EXPORT2) - CASE_HRESULT(TLBX_E_CIRCULAR_IMPORT) - CASE_HRESULT(TLBX_E_BAD_NATIVETYPE) - CASE_HRESULT(TLBX_E_BAD_VTABLE) - CASE_HRESULT(TLBX_E_CRM_NON_STATIC) - CASE_HRESULT(TLBX_E_CRM_INVALID_SIG) - CASE_HRESULT(TLBX_E_CLASS_LOAD_EXCEPTION) - CASE_HRESULT(TLBX_E_UNKNOWN_SIGNATURE) - CASE_HRESULT(TLBX_E_REFERENCED_TYPELIB) - CASE_HRESULT(TLBX_S_REFERENCED_TYPELIB) - CASE_HRESULT(TLBX_E_LAYOUT_ERROR) - CASE_HRESULT(TLBX_E_NOTIUNKNOWN) - CASE_HRESULT(TLBX_E_NONVISIBLEVALUECLASS) - CASE_HRESULT(TLBX_E_LPTSTR_NOT_ALLOWED) - CASE_HRESULT(TLBX_E_AUTO_CS_NOT_ALLOWED) - CASE_HRESULT(TLBX_S_NOSTDINTERFACE) - CASE_HRESULT(TLBX_S_DUPLICATE_DISPID) - CASE_HRESULT(TLBX_E_ENUM_VALUE_INVALID) - CASE_HRESULT(TLBX_W_ENUM_VALUE_TOOBIG) - CASE_HRESULT(TLBX_E_DUPLICATE_IID) - CASE_HRESULT(TLBX_E_NO_NESTED_ARRAYS) - CASE_HRESULT(TLBX_E_PARAM_ERROR_NAMED) - CASE_HRESULT(TLBX_E_PARAM_ERROR_UNNAMED) - CASE_HRESULT(TLBX_E_AGNOST_SIGNATURE) - CASE_HRESULT(TLBX_E_CONVERT_FAIL) - CASE_HRESULT(TLBX_W_DUAL_NOT_DISPATCH) - CASE_HRESULT(TLBX_E_BAD_SIGNATURE) - CASE_HRESULT(TLBX_E_ARRAY_NEEDS_NT_FIXED) - CASE_HRESULT(TLBX_E_CLASS_NEEDS_NT_INTF) - CASE_HRESULT(TLBX_E_INVALID_TYPEINFO) - CASE_HRESULT(TLBX_E_INVALID_TYPEINFO_UNNAMED) - CASE_HRESULT(TLBX_E_CTX_NESTED) - CASE_HRESULT(TLBX_E_ERROR_MESSAGE) - CASE_HRESULT(TLBX_E_CANT_SAVE) - CASE_HRESULT(TLBX_W_LIBNOTREGISTERED) - CASE_HRESULT(TLBX_E_CANTLOADLIBRARY) - CASE_HRESULT(TLBX_E_BAD_VT_TYPE) - CASE_HRESULT(TLBX_E_NO_MSCOREE_TLB) - CASE_HRESULT(TLBX_E_BAD_MSCOREE_TLB) - CASE_HRESULT(TLBX_E_TLB_EXCEPTION) - CASE_HRESULT(TLBX_E_MULTIPLE_LCIDS) - CASE_HRESULT(TLBX_I_TYPEINFO_IMPORTED) - CASE_HRESULT(TLBX_E_AMBIGUOUS_RETURN) - CASE_HRESULT(TLBX_E_PROPGET_WITHOUT_RETURN) - CASE_HRESULT(TLBX_E_DUPLICATE_TYPE_NAME) - CASE_HRESULT(TLBX_I_USEIUNKNOWN) - CASE_HRESULT(TLBX_I_UNCONVERTABLE_ARGS) - CASE_HRESULT(TLBX_I_UNCONVERTABLE_FIELD) - CASE_HRESULT(TLBX_I_NONSEQUENTIALSTRUCT) - CASE_HRESULT(TLBX_W_WARNING_MESSAGE) - CASE_HRESULT(TLBX_I_RESOLVEREFFAILED) - CASE_HRESULT(TLBX_E_ASANY) - CASE_HRESULT(TLBX_E_INVALIDLCIDPARAM) - CASE_HRESULT(TLBX_E_LCIDONDISPONLYITF) - CASE_HRESULT(TLBX_E_NONPUBLIC_FIELD) - CASE_HRESULT(TLBX_I_TYPE_EXPORTED) - CASE_HRESULT(TLBX_I_DUPLICATE_DISPID) - CASE_HRESULT(TLBX_E_BAD_NAMES) - CASE_HRESULT(TLBX_E_BITNESS_MISMATCH) - CASE_HRESULT(TLBX_I_REF_TYPE_AS_STRUCT) - CASE_HRESULT(TLBX_E_GENERICINST_SIGNATURE) - CASE_HRESULT(TLBX_E_GENERICPAR_SIGNATURE) - CASE_HRESULT(TLBX_I_GENERIC_TYPE) - CASE_HRESULT(TLBX_W_EXPORTING_AUTO_LAYOUT) - CASE_HRESULT(TLBX_E_TYPED_REF) - CASE_HRESULT(TLBX_W_DEFAULT_INTF_NOT_VISIBLE) - CASE_HRESULT(TLBX_W_NON_INTEGRAL_CA_TYPE) - CASE_HRESULT(TLBX_W_IENUM_CA_ON_IUNK) - CASE_HRESULT(TLBX_E_NO_SAFEHANDLE_ARRAYS) - CASE_HRESULT(TLBX_W_NO_PROPS_IN_EVENTS) CASE_HRESULT(META_E_CA_INVALID_TARGET) CASE_HRESULT(META_E_CA_INVALID_VALUE) CASE_HRESULT(META_E_CA_INVALID_BLOB) CASE_HRESULT(META_E_CA_REPEATED_ARG) CASE_HRESULT(META_E_CA_UNKNOWN_ARGUMENT) - CASE_HRESULT(META_E_CA_VARIANT_NYI) - CASE_HRESULT(META_E_CA_ARRAY_NYI) CASE_HRESULT(META_E_CA_UNEXPECTED_TYPE) CASE_HRESULT(META_E_CA_INVALID_ARGTYPE) CASE_HRESULT(META_E_CA_INVALID_ARG_FOR_TYPE) @@ -721,69 +595,16 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(META_E_CA_INVALID_MARSHALAS_FIELDS) CASE_HRESULT(META_E_CA_NT_FIELDONLY) CASE_HRESULT(META_E_CA_NEGATIVE_PARAMINDEX) - CASE_HRESULT(META_E_CA_NEGATIVE_MULTIPLIER) CASE_HRESULT(META_E_CA_NEGATIVE_CONSTSIZE) CASE_HRESULT(META_E_CA_FIXEDSTR_SIZE_REQUIRED) CASE_HRESULT(META_E_CA_CUSTMARSH_TYPE_REQUIRED) - CASE_HRESULT(META_E_CA_FILENAME_REQUIRED) CASE_HRESULT(META_E_CA_BAD_FRIENDS_ARGS) - CASE_HRESULT(VLDTR_S_WRN) - CASE_HRESULT(VLDTR_S_ERR) - CASE_HRESULT(VLDTR_S_WRNERR) CASE_HRESULT(VLDTR_E_RID_OUTOFRANGE) - CASE_HRESULT(VLDTR_E_CDTKN_OUTOFRANGE) - CASE_HRESULT(VLDTR_E_CDRID_OUTOFRANGE) CASE_HRESULT(VLDTR_E_STRING_INVALID) CASE_HRESULT(VLDTR_E_GUID_INVALID) CASE_HRESULT(VLDTR_E_BLOB_INVALID) - CASE_HRESULT(VLDTR_E_MOD_MULTI) - CASE_HRESULT(VLDTR_E_MOD_NULLMVID) - CASE_HRESULT(VLDTR_E_TR_NAMENULL) - CASE_HRESULT(VLDTR_E_TR_DUP) - CASE_HRESULT(VLDTR_E_TD_NAMENULL) - CASE_HRESULT(VLDTR_E_TD_DUPNAME) - CASE_HRESULT(VLDTR_E_TD_DUPGUID) - CASE_HRESULT(VLDTR_E_TD_NOTIFACEOBJEXTNULL) - CASE_HRESULT(VLDTR_E_TD_OBJEXTENDSNONNULL) - CASE_HRESULT(VLDTR_E_TD_EXTENDSSEALED) - CASE_HRESULT(VLDTR_E_TD_DLTNORTSPCL) - CASE_HRESULT(VLDTR_E_TD_RTSPCLNOTDLT) - CASE_HRESULT(VLDTR_E_MI_DECLPRIV) - CASE_HRESULT(VLDTR_E_AS_BADNAME) - CASE_HRESULT(VLDTR_E_FILE_SYSNAME) - CASE_HRESULT(VLDTR_E_MI_BODYSTATIC) - CASE_HRESULT(VLDTR_E_TD_IFACENOTABS) - CASE_HRESULT(VLDTR_E_TD_IFACEPARNOTNIL) - CASE_HRESULT(VLDTR_E_TD_IFACEGUIDNULL) - CASE_HRESULT(VLDTR_E_MI_DECLFINAL) - CASE_HRESULT(VLDTR_E_TD_VTNOTSEAL) - CASE_HRESULT(VLDTR_E_PD_BADFLAGS) - CASE_HRESULT(VLDTR_E_IFACE_DUP) - CASE_HRESULT(VLDTR_E_MR_NAMENULL) - CASE_HRESULT(VLDTR_E_MR_VTBLNAME) - CASE_HRESULT(VLDTR_E_MR_DELNAME) - CASE_HRESULT(VLDTR_E_MR_PARNIL) CASE_HRESULT(VLDTR_E_MR_BADCALLINGCONV) - CASE_HRESULT(VLDTR_E_MR_NOTVARARG) - CASE_HRESULT(VLDTR_E_MR_NAMEDIFF) - CASE_HRESULT(VLDTR_E_MR_SIGDIFF) - CASE_HRESULT(VLDTR_E_MR_DUP) - CASE_HRESULT(VLDTR_E_CL_TDAUTO) - CASE_HRESULT(VLDTR_E_CL_BADPCKSZ) - CASE_HRESULT(VLDTR_E_CL_DUP) - CASE_HRESULT(VLDTR_E_FL_BADOFFSET) - CASE_HRESULT(VLDTR_E_FL_TDNIL) - CASE_HRESULT(VLDTR_E_FL_NOCL) - CASE_HRESULT(VLDTR_E_FL_TDNOTEXPLCT) - CASE_HRESULT(VLDTR_E_FL_FLDSTATIC) - CASE_HRESULT(VLDTR_E_FL_DUP) - CASE_HRESULT(VLDTR_E_MODREF_NAMENULL) - CASE_HRESULT(VLDTR_E_MODREF_DUP) - CASE_HRESULT(VLDTR_E_TR_BADSCOPE) - CASE_HRESULT(VLDTR_E_TD_NESTEDNOENCL) - CASE_HRESULT(VLDTR_E_TD_EXTTRRES) CASE_HRESULT(VLDTR_E_SIGNULL) - CASE_HRESULT(VLDTR_E_SIGNODATA) CASE_HRESULT(VLDTR_E_MD_BADCALLINGCONV) CASE_HRESULT(VLDTR_E_MD_THISSTATIC) CASE_HRESULT(VLDTR_E_MD_NOTTHISNOTSTATIC) @@ -799,221 +620,13 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(VLDTR_E_SIG_MISSNLBND) CASE_HRESULT(VLDTR_E_SIG_MISSLBND) CASE_HRESULT(VLDTR_E_SIG_BADELTYPE) - CASE_HRESULT(VLDTR_E_FD_BADCALLINGCONV) - CASE_HRESULT(VLDTR_E_MD_NAMENULL) - CASE_HRESULT(VLDTR_E_MD_PARNIL) - CASE_HRESULT(VLDTR_E_MD_DUP) - CASE_HRESULT(VLDTR_E_FD_NAMENULL) - CASE_HRESULT(VLDTR_E_FD_PARNIL) - CASE_HRESULT(VLDTR_E_FD_DUP) - CASE_HRESULT(VLDTR_E_AS_MULTI) - CASE_HRESULT(VLDTR_E_AS_NAMENULL) - CASE_HRESULT(VLDTR_E_SIG_TOKTYPEMISMATCH) - CASE_HRESULT(VLDTR_E_CL_TDINTF) - CASE_HRESULT(VLDTR_E_ASOS_OSPLTFRMIDINVAL) - CASE_HRESULT(VLDTR_E_AR_NAMENULL) CASE_HRESULT(VLDTR_E_TD_ENCLNOTNESTED) - CASE_HRESULT(VLDTR_E_AROS_OSPLTFRMIDINVAL) - CASE_HRESULT(VLDTR_E_FILE_NAMENULL) - CASE_HRESULT(VLDTR_E_CT_NAMENULL) - CASE_HRESULT(VLDTR_E_TD_EXTENDSCHILD) - CASE_HRESULT(VLDTR_E_MAR_NAMENULL) - CASE_HRESULT(VLDTR_E_FILE_DUP) - CASE_HRESULT(VLDTR_E_FILE_NAMEFULLQLFD) - CASE_HRESULT(VLDTR_E_CT_DUP) - CASE_HRESULT(VLDTR_E_MAR_DUP) - CASE_HRESULT(VLDTR_E_MAR_NOTPUBPRIV) - CASE_HRESULT(VLDTR_E_TD_ENUMNOVALUE) - CASE_HRESULT(VLDTR_E_TD_ENUMVALSTATIC) - CASE_HRESULT(VLDTR_E_TD_ENUMVALNOTSN) - CASE_HRESULT(VLDTR_E_TD_ENUMFLDNOTST) - CASE_HRESULT(VLDTR_E_TD_ENUMFLDNOTLIT) - CASE_HRESULT(VLDTR_E_TD_ENUMNOLITFLDS) - CASE_HRESULT(VLDTR_E_TD_ENUMFLDSIGMISMATCH) - CASE_HRESULT(VLDTR_E_TD_ENUMVALNOT1ST) - CASE_HRESULT(VLDTR_E_FD_NOTVALUERTSN) - CASE_HRESULT(VLDTR_E_FD_VALUEPARNOTENUM) - CASE_HRESULT(VLDTR_E_FD_INSTINIFACE) - CASE_HRESULT(VLDTR_E_FD_NOTPUBINIFACE) - CASE_HRESULT(VLDTR_E_FMD_GLOBALNOTPUBPRIVSC) - CASE_HRESULT(VLDTR_E_FMD_GLOBALNOTSTATIC) - CASE_HRESULT(VLDTR_E_FD_GLOBALNORVA) - CASE_HRESULT(VLDTR_E_MD_CTORZERORVA) - CASE_HRESULT(VLDTR_E_FD_MARKEDNOMARSHAL) - CASE_HRESULT(VLDTR_E_FD_MARSHALNOTMARKED) - CASE_HRESULT(VLDTR_E_FD_MARKEDNODEFLT) - CASE_HRESULT(VLDTR_E_FD_DEFLTNOTMARKED) - CASE_HRESULT(VLDTR_E_FMD_MARKEDNOSECUR) - CASE_HRESULT(VLDTR_E_FMD_SECURNOTMARKED) CASE_HRESULT(VLDTR_E_FMD_PINVOKENOTSTATIC) - CASE_HRESULT(VLDTR_E_FMD_MARKEDNOPINVOKE) - CASE_HRESULT(VLDTR_E_FMD_PINVOKENOTMARKED) - CASE_HRESULT(VLDTR_E_FMD_BADIMPLMAP) - CASE_HRESULT(VLDTR_E_IMAP_BADMODREF) - CASE_HRESULT(VLDTR_E_IMAP_BADMEMBER) - CASE_HRESULT(VLDTR_E_IMAP_BADIMPORTNAME) - CASE_HRESULT(VLDTR_E_IMAP_BADCALLCONV) - CASE_HRESULT(VLDTR_E_FMD_BADACCESSFLAG) - CASE_HRESULT(VLDTR_E_FD_INITONLYANDLITERAL) - CASE_HRESULT(VLDTR_E_FD_LITERALNOTSTATIC) - CASE_HRESULT(VLDTR_E_FMD_RTSNNOTSN) - CASE_HRESULT(VLDTR_E_MD_ABSTPARNOTABST) - CASE_HRESULT(VLDTR_E_MD_NOTSTATABSTININTF) - CASE_HRESULT(VLDTR_E_MD_NOTPUBININTF) - CASE_HRESULT(VLDTR_E_MD_CTORININTF) - CASE_HRESULT(VLDTR_E_MD_GLOBALCTORCCTOR) - CASE_HRESULT(VLDTR_E_MD_CTORSTATIC) - CASE_HRESULT(VLDTR_E_MD_CTORNOTSNRTSN) - CASE_HRESULT(VLDTR_E_MD_CTORVIRT) - CASE_HRESULT(VLDTR_E_MD_CTORABST) - CASE_HRESULT(VLDTR_E_MD_CCTORNOTSTATIC) - CASE_HRESULT(VLDTR_E_MD_ZERORVA) - CASE_HRESULT(VLDTR_E_MD_FINNOTVIRT) - CASE_HRESULT(VLDTR_E_MD_STATANDFINORVIRT) - CASE_HRESULT(VLDTR_E_MD_ABSTANDFINAL) - CASE_HRESULT(VLDTR_E_MD_ABSTANDIMPL) - CASE_HRESULT(VLDTR_E_MD_ABSTANDPINVOKE) - CASE_HRESULT(VLDTR_E_MD_ABSTNOTVIRT) - CASE_HRESULT(VLDTR_E_MD_NOTABSTNOTIMPL) - CASE_HRESULT(VLDTR_E_MD_NOTABSTBADFLAGSRVA) - CASE_HRESULT(VLDTR_E_MD_PRIVSCOPENORVA) - CASE_HRESULT(VLDTR_E_MD_GLOBALABSTORVIRT) - CASE_HRESULT(VLDTR_E_SIG_LONGFORM) - CASE_HRESULT(VLDTR_E_MD_MULTIPLESEMANTICS) - CASE_HRESULT(VLDTR_E_MD_INVALIDSEMANTICS) - CASE_HRESULT(VLDTR_E_MD_SEMANTICSNOTEXIST) - CASE_HRESULT(VLDTR_E_MI_DECLNOTVIRT) - CASE_HRESULT(VLDTR_E_FMD_GLOBALITEM) - CASE_HRESULT(VLDTR_E_MD_MULTSEMANTICFLAGS) - CASE_HRESULT(VLDTR_E_MD_NOSEMANTICFLAGS) - CASE_HRESULT(VLDTR_E_FD_FLDINIFACE) - CASE_HRESULT(VLDTR_E_AS_HASHALGID) - CASE_HRESULT(VLDTR_E_AS_PROCID) - CASE_HRESULT(VLDTR_E_AR_PROCID) - CASE_HRESULT(VLDTR_E_CN_PARENTRANGE) - CASE_HRESULT(VLDTR_E_AS_BADFLAGS) - CASE_HRESULT(VLDTR_E_TR_HASTYPEDEF) - CASE_HRESULT(VLDTR_E_IFACE_BADIMPL) - CASE_HRESULT(VLDTR_E_IFACE_BADIFACE) - CASE_HRESULT(VLDTR_E_TD_SECURNOTMARKED) - CASE_HRESULT(VLDTR_E_TD_MARKEDNOSECUR) - CASE_HRESULT(VLDTR_E_MD_CCTORHASARGS) - CASE_HRESULT(VLDTR_E_CT_BADIMPL) - CASE_HRESULT(VLDTR_E_MI_ALIENBODY) - CASE_HRESULT(VLDTR_E_MD_CCTORCALLCONV) - CASE_HRESULT(VLDTR_E_MI_BADCLASS) - CASE_HRESULT(VLDTR_E_MI_CLASSISINTF) - CASE_HRESULT(VLDTR_E_MI_BADDECL) - CASE_HRESULT(VLDTR_E_MI_BADBODY) - CASE_HRESULT(VLDTR_E_MI_DUP) - CASE_HRESULT(VLDTR_E_FD_BADPARENT) - CASE_HRESULT(VLDTR_E_MD_PARAMOUTOFSEQ) - CASE_HRESULT(VLDTR_E_MD_PARASEQTOOBIG) - CASE_HRESULT(VLDTR_E_MD_PARMMARKEDNOMARSHAL) - CASE_HRESULT(VLDTR_E_MD_PARMMARSHALNOTMARKED) - CASE_HRESULT(VLDTR_E_MD_PARMMARKEDNODEFLT) - CASE_HRESULT(VLDTR_E_MD_PARMDEFLTNOTMARKED) - CASE_HRESULT(VLDTR_E_PR_BADSCOPE) - CASE_HRESULT(VLDTR_E_PR_NONAME) - CASE_HRESULT(VLDTR_E_PR_NOSIG) - CASE_HRESULT(VLDTR_E_PR_DUP) - CASE_HRESULT(VLDTR_E_PR_BADCALLINGCONV) - CASE_HRESULT(VLDTR_E_PR_MARKEDNODEFLT) - CASE_HRESULT(VLDTR_E_PR_DEFLTNOTMARKED) - CASE_HRESULT(VLDTR_E_PR_BADSEMANTICS) - CASE_HRESULT(VLDTR_E_PR_BADMETHOD) - CASE_HRESULT(VLDTR_E_PR_ALIENMETHOD) - CASE_HRESULT(VLDTR_E_CN_BLOBNOTNULL) - CASE_HRESULT(VLDTR_E_CN_BLOBNULL) - CASE_HRESULT(VLDTR_E_EV_BADSCOPE) - CASE_HRESULT(VLDTR_E_EV_NONAME) - CASE_HRESULT(VLDTR_E_EV_DUP) - CASE_HRESULT(VLDTR_E_EV_BADEVTYPE) - CASE_HRESULT(VLDTR_E_EV_EVTYPENOTCLASS) - CASE_HRESULT(VLDTR_E_EV_BADSEMANTICS) - CASE_HRESULT(VLDTR_E_EV_BADMETHOD) - CASE_HRESULT(VLDTR_E_EV_ALIENMETHOD) - CASE_HRESULT(VLDTR_E_EV_NOADDON) - CASE_HRESULT(VLDTR_E_EV_NOREMOVEON) - CASE_HRESULT(VLDTR_E_CT_DUPTDNAME) - CASE_HRESULT(VLDTR_E_MAR_BADOFFSET) - CASE_HRESULT(VLDTR_E_DS_BADOWNER) - CASE_HRESULT(VLDTR_E_DS_BADFLAGS) - CASE_HRESULT(VLDTR_E_DS_NOBLOB) - CASE_HRESULT(VLDTR_E_MAR_BADIMPL) - CASE_HRESULT(VLDTR_E_MR_VARARGCALLINGCONV) - CASE_HRESULT(VLDTR_E_MD_CTORNOTVOID) - CASE_HRESULT(VLDTR_E_EV_FIRENOTVOID) - CASE_HRESULT(VLDTR_E_AS_BADLOCALE) - CASE_HRESULT(VLDTR_E_CN_PARENTTYPE) CASE_HRESULT(VLDTR_E_SIG_SENTINMETHODDEF) CASE_HRESULT(VLDTR_E_SIG_SENTMUSTVARARG) CASE_HRESULT(VLDTR_E_SIG_MULTSENTINELS) - CASE_HRESULT(VLDTR_E_SIG_LASTSENTINEL) CASE_HRESULT(VLDTR_E_SIG_MISSARG) CASE_HRESULT(VLDTR_E_SIG_BYREFINFIELD) - CASE_HRESULT(VLDTR_E_MD_SYNCMETHODINVTYPE) - CASE_HRESULT(VLDTR_E_TD_NAMETOOLONG) - CASE_HRESULT(VLDTR_E_AS_PROCDUP) - CASE_HRESULT(VLDTR_E_ASOS_DUP) - CASE_HRESULT(VLDTR_E_MAR_BADFLAGS) - CASE_HRESULT(VLDTR_E_CT_NOTYPEDEFID) - CASE_HRESULT(VLDTR_E_FILE_BADFLAGS) - CASE_HRESULT(VLDTR_E_FILE_NULLHASH) - CASE_HRESULT(VLDTR_E_MOD_NONAME) - CASE_HRESULT(VLDTR_E_MOD_NAMEFULLQLFD) - CASE_HRESULT(VLDTR_E_TD_RTSPCLNOTSPCL) - CASE_HRESULT(VLDTR_E_TD_EXTENDSIFACE) - CASE_HRESULT(VLDTR_E_MD_CTORPINVOKE) - CASE_HRESULT(VLDTR_E_TD_SYSENUMNOTCLASS) - CASE_HRESULT(VLDTR_E_TD_SYSENUMNOTEXTVTYPE) - CASE_HRESULT(VLDTR_E_MI_SIGMISMATCH) - CASE_HRESULT(VLDTR_E_TD_ENUMHASMETHODS) - CASE_HRESULT(VLDTR_E_TD_ENUMIMPLIFACE) - CASE_HRESULT(VLDTR_E_TD_ENUMHASPROP) - CASE_HRESULT(VLDTR_E_TD_ENUMHASEVENT) - CASE_HRESULT(VLDTR_E_TD_BADMETHODLST) - CASE_HRESULT(VLDTR_E_TD_BADFIELDLST) - CASE_HRESULT(VLDTR_E_CN_BADTYPE) - CASE_HRESULT(VLDTR_E_TD_ENUMNOINSTFLD) - CASE_HRESULT(VLDTR_E_TD_ENUMMULINSTFLD) - CASE_HRESULT(VLDTR_E_INTERRUPTED) - CASE_HRESULT(VLDTR_E_NOTINIT) - CASE_HRESULT(VLDTR_E_IFACE_NOTIFACE) - CASE_HRESULT(VLDTR_E_FD_RVAHASNORVA) - CASE_HRESULT(VLDTR_E_FD_RVAHASZERORVA) - CASE_HRESULT(VLDTR_E_MD_RVAANDIMPLMAP) - CASE_HRESULT(VLDTR_E_TD_EXTRAFLAGS) - CASE_HRESULT(VLDTR_E_TD_EXTENDSITSELF) - CASE_HRESULT(VLDTR_E_TD_SYSVTNOTEXTOBJ) - CASE_HRESULT(VLDTR_E_TD_EXTTYPESPEC) - CASE_HRESULT(VLDTR_E_TD_VTNOSIZE) - CASE_HRESULT(VLDTR_E_TD_IFACESEALED) - CASE_HRESULT(VLDTR_E_NC_BADNESTED) - CASE_HRESULT(VLDTR_E_NC_BADENCLOSER) - CASE_HRESULT(VLDTR_E_NC_DUP) - CASE_HRESULT(VLDTR_E_NC_DUPENCLOSER) - CASE_HRESULT(VLDTR_E_FRVA_ZERORVA) - CASE_HRESULT(VLDTR_E_FRVA_BADFIELD) - CASE_HRESULT(VLDTR_E_FRVA_DUPRVA) - CASE_HRESULT(VLDTR_E_FRVA_DUPFIELD) - CASE_HRESULT(VLDTR_E_EP_BADTOKEN) - CASE_HRESULT(VLDTR_E_EP_INSTANCE) - CASE_HRESULT(VLDTR_E_TD_ENUMFLDBADTYPE) - CASE_HRESULT(VLDTR_E_MD_BADRVA) - CASE_HRESULT(VLDTR_E_FD_LITERALNODEFAULT) - CASE_HRESULT(VLDTR_E_IFACE_METHNOTIMPL) - CASE_HRESULT(VLDTR_E_CA_BADPARENT) - CASE_HRESULT(VLDTR_E_CA_BADTYPE) - CASE_HRESULT(VLDTR_E_CA_NOTCTOR) - CASE_HRESULT(VLDTR_E_CA_BADSIG) - CASE_HRESULT(VLDTR_E_CA_NOSIG) - CASE_HRESULT(VLDTR_E_CA_BADPROLOG) - CASE_HRESULT(VLDTR_E_MD_BADLOCALSIGTOK) - CASE_HRESULT(VLDTR_E_MD_BADHEADER) - CASE_HRESULT(VLDTR_E_EP_TOOMANYARGS) - CASE_HRESULT(VLDTR_E_EP_BADRET) - CASE_HRESULT(VLDTR_E_EP_BADARG) CASE_HRESULT(VLDTR_E_SIG_BADVOID) CASE_HRESULT(CORDBG_E_UNRECOVERABLE_ERROR) CASE_HRESULT(CORDBG_E_PROCESS_TERMINATED) @@ -1023,12 +636,10 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(CORDBG_E_BAD_REFERENCE_VALUE) CASE_HRESULT(CORDBG_E_FIELD_NOT_AVAILABLE) CASE_HRESULT(CORDBG_E_NON_NATIVE_FRAME) - CASE_HRESULT(CORDBG_E_NONCONTINUABLE_EXCEPTION) CASE_HRESULT(CORDBG_E_CODE_NOT_AVAILABLE) CASE_HRESULT(CORDBG_E_FUNCTION_NOT_IL) CASE_HRESULT(CORDBG_S_BAD_START_SEQUENCE_POINT) CASE_HRESULT(CORDBG_S_BAD_END_SEQUENCE_POINT) - CASE_HRESULT(CORDBG_S_INSUFFICIENT_INFO_FOR_SET_IP) CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_FINALLY) CASE_HRESULT(CORDBG_E_CANT_SET_IP_OUT_OF_FINALLY) CASE_HRESULT(CORDBG_E_CANT_SET_IP_INTO_CATCH) @@ -1039,46 +650,30 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(CORDBG_E_FUNC_EVAL_NOT_COMPLETE) CASE_HRESULT(CORDBG_S_FUNC_EVAL_HAS_NO_RESULT) CASE_HRESULT(CORDBG_S_VALUE_POINTS_TO_VOID) - CASE_HRESULT(CORDBG_E_INPROC_NOT_IMPL) CASE_HRESULT(CORDBG_S_FUNC_EVAL_ABORTED) CASE_HRESULT(CORDBG_E_STATIC_VAR_NOT_AVAILABLE) - CASE_HRESULT(CORDBG_E_OBJECT_IS_NOT_COPYABLE_VALUE_CLASS) CASE_HRESULT(CORDBG_E_CANT_SETIP_INTO_OR_OUT_OF_FILTER) CASE_HRESULT(CORDBG_E_CANT_CHANGE_JIT_SETTING_FOR_ZAP_MODULE) - CASE_HRESULT(CORDBG_E_REMOTE_CONNECTION_CONN_RESET) - CASE_HRESULT(CORDBG_E_REMOTE_CONNECTION_KEEP_ALIVE) - CASE_HRESULT(CORDBG_E_REMOTE_CONNECTION_FATAL_ERROR) CASE_HRESULT(CORDBG_E_CANT_SET_TO_JMC) CASE_HRESULT(CORDBG_E_BAD_THREAD_STATE) CASE_HRESULT(CORDBG_E_DEBUGGER_ALREADY_ATTACHED) CASE_HRESULT(CORDBG_E_SUPERFLOUS_CONTINUE) CASE_HRESULT(CORDBG_E_SET_VALUE_NOT_ALLOWED_ON_NONLEAF_FRAME) - CASE_HRESULT(CORDBG_E_ENC_EH_MAX_NESTING_LEVEL_CANT_INCREASE) CASE_HRESULT(CORDBG_E_ENC_MODULE_NOT_ENC_ENABLED) CASE_HRESULT(CORDBG_E_SET_IP_NOT_ALLOWED_ON_EXCEPTION) CASE_HRESULT(CORDBG_E_VARIABLE_IS_ACTUALLY_LITERAL) CASE_HRESULT(CORDBG_E_PROCESS_DETACHED) - CASE_HRESULT(CORDBG_E_ENC_METHOD_SIG_CHANGED) - CASE_HRESULT(CORDBG_E_ENC_METHOD_NO_LOCAL_SIG) CASE_HRESULT(CORDBG_E_ENC_CANT_ADD_FIELD_TO_VALUE_OR_LAYOUT_CLASS) - CASE_HRESULT(CORDBG_E_ENC_CANT_CHANGE_FIELD) - CASE_HRESULT(CORDBG_E_ENC_CANT_ADD_NON_PRIVATE_MEMBER) CASE_HRESULT(CORDBG_E_FIELD_NOT_STATIC) CASE_HRESULT(CORDBG_E_FIELD_NOT_INSTANCE) - CASE_HRESULT(CORDBG_E_ENC_ZAPPED_WITHOUT_ENC) - CASE_HRESULT(CORDBG_E_ENC_BAD_METHOD_INFO) CASE_HRESULT(CORDBG_E_ENC_JIT_CANT_UPDATE) - CASE_HRESULT(CORDBG_E_ENC_MISSING_CLASS) CASE_HRESULT(CORDBG_E_ENC_INTERNAL_ERROR) CASE_HRESULT(CORDBG_E_ENC_HANGING_FIELD) CASE_HRESULT(CORDBG_E_MODULE_NOT_LOADED) - CASE_HRESULT(CORDBG_E_ENC_CANT_CHANGE_SUPERCLASS) CASE_HRESULT(CORDBG_E_UNABLE_TO_SET_BREAKPOINT) CASE_HRESULT(CORDBG_E_DEBUGGING_NOT_POSSIBLE) CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_ENABLED) CASE_HRESULT(CORDBG_E_KERNEL_DEBUGGER_PRESENT) - CASE_HRESULT(CORDBG_E_HELPER_THREAD_DEAD) - CASE_HRESULT(CORDBG_E_INTERFACE_INHERITANCE_CANT_CHANGE) CASE_HRESULT(CORDBG_E_INCOMPATIBLE_PROTOCOL) CASE_HRESULT(CORDBG_E_TOO_MANY_PROCESSES) CASE_HRESULT(CORDBG_E_INTEROP_NOT_SUPPORTED) @@ -1086,90 +681,30 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(CORDBG_E_OBJECT_NEUTERED) CASE_HRESULT(CORPROF_E_FUNCTION_NOT_COMPILED) CASE_HRESULT(CORPROF_E_DATAINCOMPLETE) - CASE_HRESULT(CORPROF_E_NOT_REJITABLE_METHODS) - CASE_HRESULT(CORPROF_E_CANNOT_UPDATE_METHOD) CASE_HRESULT(CORPROF_E_FUNCTION_NOT_IL) CASE_HRESULT(CORPROF_E_NOT_MANAGED_THREAD) CASE_HRESULT(CORPROF_E_CALL_ONLY_FROM_INIT) - CASE_HRESULT(CORPROF_E_INPROC_NOT_ENABLED) - CASE_HRESULT(CORPROF_E_JITMAPS_NOT_ENABLED) - CASE_HRESULT(CORPROF_E_INPROC_ALREADY_BEGUN) - CASE_HRESULT(CORPROF_E_INPROC_NOT_AVAILABLE) CASE_HRESULT(CORPROF_E_NOT_YET_AVAILABLE) - CASE_HRESULT(SECURITY_E_XML_TO_ASN_ENCODING) CASE_HRESULT(SECURITY_E_INCOMPATIBLE_SHARE) CASE_HRESULT(SECURITY_E_UNVERIFIABLE) CASE_HRESULT(SECURITY_E_INCOMPATIBLE_EVIDENCE) CASE_HRESULT(CLDB_E_INTERNALERROR) - CASE_HRESULT(CORSEC_E_DECODE_SET) - CASE_HRESULT(CORSEC_E_ENCODE_SET) - CASE_HRESULT(CORSEC_E_UNSUPPORTED_FORMAT) - CASE_HRESULT(SN_CRYPTOAPI_CALL_FAILED) - CASE_HRESULT(SN_NO_SUITABLE_CSP) - CASE_HRESULT(CORSEC_E_INVALID_ATTR) CASE_HRESULT(CORSEC_E_POLICY_EXCEPTION) CASE_HRESULT(CORSEC_E_MIN_GRANT_FAIL) CASE_HRESULT(CORSEC_E_NO_EXEC_PERM) CASE_HRESULT(CORSEC_E_XMLSYNTAX) CASE_HRESULT(CORSEC_E_INVALID_STRONGNAME) CASE_HRESULT(CORSEC_E_MISSING_STRONGNAME) - CASE_HRESULT(CORSEC_E_CONTAINER_NOT_FOUND) CASE_HRESULT(CORSEC_E_INVALID_IMAGE_FORMAT) CASE_HRESULT(CORSEC_E_CRYPTO) CASE_HRESULT(CORSEC_E_CRYPTO_UNEX_OPER) - CASE_HRESULT(CORSECATTR_E_BAD_ATTRIBUTE) - CASE_HRESULT(CORSECATTR_E_MISSING_CONSTRUCTOR) - CASE_HRESULT(CORSECATTR_E_FAILED_TO_CREATE_PERM) - CASE_HRESULT(CORSECATTR_E_BAD_ACTION_ASM) - CASE_HRESULT(CORSECATTR_E_BAD_ACTION_OTHER) - CASE_HRESULT(CORSECATTR_E_BAD_PARENT) - CASE_HRESULT(CORSECATTR_E_TRUNCATED) - CASE_HRESULT(CORSECATTR_E_BAD_VERSION) CASE_HRESULT(CORSECATTR_E_BAD_ACTION) - CASE_HRESULT(CORSECATTR_E_NO_SELF_REF) - CASE_HRESULT(CORSECATTR_E_BAD_NONCAS) - CASE_HRESULT(CORSECATTR_E_ASSEMBLY_LOAD_FAILED) - CASE_HRESULT(CORSECATTR_E_ASSEMBLY_LOAD_FAILED_EX) - CASE_HRESULT(CORSECATTR_E_TYPE_LOAD_FAILED) - CASE_HRESULT(CORSECATTR_E_TYPE_LOAD_FAILED_EX) - CASE_HRESULT(CORSECATTR_E_ABSTRACT) - CASE_HRESULT(CORSECATTR_E_UNSUPPORTED_TYPE) - CASE_HRESULT(CORSECATTR_E_UNSUPPORTED_ENUM_TYPE) - CASE_HRESULT(CORSECATTR_E_NO_FIELD) - CASE_HRESULT(CORSECATTR_E_NO_PROPERTY) - CASE_HRESULT(CORSECATTR_E_EXCEPTION) - CASE_HRESULT(CORSECATTR_E_EXCEPTION_HR) - CASE_HRESULT(ISS_E_ISOSTORE) - CASE_HRESULT(ISS_E_OPEN_STORE_FILE) - CASE_HRESULT(ISS_E_OPEN_FILE_MAPPING) - CASE_HRESULT(ISS_E_MAP_VIEW_OF_FILE) - CASE_HRESULT(ISS_E_GET_FILE_SIZE) - CASE_HRESULT(ISS_E_CREATE_MUTEX) - CASE_HRESULT(ISS_E_LOCK_FAILED) - CASE_HRESULT(ISS_E_FILE_WRITE) - CASE_HRESULT(ISS_E_SET_FILE_POINTER) - CASE_HRESULT(ISS_E_CREATE_DIR) - CASE_HRESULT(ISS_E_STORE_NOT_OPEN) - CASE_HRESULT(ISS_E_CORRUPTED_STORE_FILE) - CASE_HRESULT(ISS_E_STORE_VERSION) - CASE_HRESULT(ISS_E_FILE_NOT_MAPPED) - CASE_HRESULT(ISS_E_BLOCK_SIZE_TOO_SMALL) - CASE_HRESULT(ISS_E_ALLOC_TOO_LARGE) - CASE_HRESULT(ISS_E_USAGE_WILL_EXCEED_QUOTA) - CASE_HRESULT(ISS_E_TABLE_ROW_NOT_FOUND) - CASE_HRESULT(ISS_E_DEPRECATE) - CASE_HRESULT(ISS_E_CALLER) - CASE_HRESULT(ISS_E_PATH_LENGTH) - CASE_HRESULT(ISS_E_MACHINE) - CASE_HRESULT(ISS_E_MACHINE_DACL) - CASE_HRESULT(ISS_E_ISOSTORE_END) CASE_HRESULT(COR_E_APPLICATION) CASE_HRESULT(COR_E_ARGUMENTOUTOFRANGE) CASE_HRESULT(COR_E_ARITHMETIC) CASE_HRESULT(COR_E_ARRAYTYPEMISMATCH) CASE_HRESULT(COR_E_CONTEXTMARSHAL) CASE_HRESULT(COR_E_TIMEOUT) - CASE_HRESULT(COR_E_DEVICESNOTSUPPORTED) CASE_HRESULT(COR_E_DIVIDEBYZERO) CASE_HRESULT(COR_E_EXCEPTION) CASE_HRESULT(COR_E_EXECUTIONENGINE) @@ -1194,9 +729,6 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(COR_E_NOTSUPPORTED) CASE_HRESULT(COR_E_OVERFLOW) CASE_HRESULT(COR_E_RANK) - CASE_HRESULT(COR_E_REMOTING) - CASE_HRESULT(COR_E_SERVER) - CASE_HRESULT(COR_E_SERVICEDCOMPONENT) CASE_HRESULT(COR_E_SECURITY) CASE_HRESULT(COR_E_SERIALIZATION) CASE_HRESULT(COR_E_STACKOVERFLOW) @@ -1224,200 +756,13 @@ LPCSTR Exception::GetHRSymbolicName(HRESULT hr) CASE_HRESULT(COR_E_ENDOFSTREAM) CASE_HRESULT(COR_E_FILELOAD) CASE_HRESULT(COR_E_FILENOTFOUND) - CASE_HRESULT(COR_E_BAD_PATHNAME) CASE_HRESULT(COR_E_IO) CASE_HRESULT(COR_E_DIRECTORYNOTFOUND) CASE_HRESULT(COR_E_PATHTOOLONG) CASE_HRESULT(COR_E_OBJECTDISPOSED) CASE_HRESULT(COR_E_NEWER_RUNTIME) CASE_HRESULT(CLR_E_SHIM_RUNTIMELOAD) - CASE_HRESULT(CLR_E_SHIM_RUNTIMEEXPORT) - CASE_HRESULT(CLR_E_SHIM_INSTALLROOT) - CASE_HRESULT(CLR_E_SHIM_INSTALLCOMP) - CASE_HRESULT(VER_E_HRESULT) - CASE_HRESULT(VER_E_OFFSET) - CASE_HRESULT(VER_E_OPCODE) - CASE_HRESULT(VER_E_OPERAND) - CASE_HRESULT(VER_E_TOKEN) - CASE_HRESULT(VER_E_EXCEPT) - CASE_HRESULT(VER_E_STACK_SLOT) - CASE_HRESULT(VER_E_LOC) - CASE_HRESULT(VER_E_ARG) - CASE_HRESULT(VER_E_FOUND) - CASE_HRESULT(VER_E_EXPECTED) - CASE_HRESULT(VER_E_UNKNOWN_OPCODE) - CASE_HRESULT(VER_E_SIG_CALLCONV) - CASE_HRESULT(VER_E_SIG_ELEMTYPE) - CASE_HRESULT(VER_E_RET_SIG) CASE_HRESULT(VER_E_FIELD_SIG) - CASE_HRESULT(VER_E_INTERNAL) - CASE_HRESULT(VER_E_STACK_TOO_LARGE) - CASE_HRESULT(VER_E_ARRAY_NAME_LONG) - CASE_HRESULT(VER_E_FALLTHRU) - CASE_HRESULT(VER_E_TRY_GTEQ_END) - CASE_HRESULT(VER_E_TRYEND_GT_CS) - CASE_HRESULT(VER_E_HND_GTEQ_END) - CASE_HRESULT(VER_E_HNDEND_GT_CS) - CASE_HRESULT(VER_E_FLT_GTEQ_CS) - CASE_HRESULT(VER_E_TRY_START) - CASE_HRESULT(VER_E_HND_START) - CASE_HRESULT(VER_E_FLT_START) - CASE_HRESULT(VER_E_TRY_OVERLAP) - CASE_HRESULT(VER_E_TRY_EQ_HND_FIL) - CASE_HRESULT(VER_E_TRY_SHARE_FIN_FAL) - CASE_HRESULT(VER_E_HND_OVERLAP) - CASE_HRESULT(VER_E_HND_EQ) - CASE_HRESULT(VER_E_FIL_OVERLAP) - CASE_HRESULT(VER_E_FIL_EQ) - CASE_HRESULT(VER_E_FIL_CONT_TRY) - CASE_HRESULT(VER_E_FIL_CONT_HND) - CASE_HRESULT(VER_E_FIL_CONT_FIL) - CASE_HRESULT(VER_E_FIL_GTEQ_CS) - CASE_HRESULT(VER_E_FIL_START) - CASE_HRESULT(VER_E_FALLTHRU_EXCEP) - CASE_HRESULT(VER_E_FALLTHRU_INTO_HND) - CASE_HRESULT(VER_E_FALLTHRU_INTO_FIL) - CASE_HRESULT(VER_E_LEAVE) - CASE_HRESULT(VER_E_RETHROW) - CASE_HRESULT(VER_E_ENDFINALLY) - CASE_HRESULT(VER_E_ENDFILTER) - CASE_HRESULT(VER_E_ENDFILTER_MISSING) - CASE_HRESULT(VER_E_BR_INTO_TRY) - CASE_HRESULT(VER_E_BR_INTO_HND) - CASE_HRESULT(VER_E_BR_INTO_FIL) - CASE_HRESULT(VER_E_BR_OUTOF_TRY) - CASE_HRESULT(VER_E_BR_OUTOF_HND) - CASE_HRESULT(VER_E_BR_OUTOF_FIL) - CASE_HRESULT(VER_E_BR_OUTOF_FIN) - CASE_HRESULT(VER_E_RET_FROM_TRY) - CASE_HRESULT(VER_E_RET_FROM_HND) - CASE_HRESULT(VER_E_RET_FROM_FIL) - CASE_HRESULT(VER_E_BAD_JMP_TARGET) - CASE_HRESULT(VER_E_PATH_LOC) - CASE_HRESULT(VER_E_PATH_THIS) - CASE_HRESULT(VER_E_PATH_STACK) - CASE_HRESULT(VER_E_PATH_STACK_DEPTH) - CASE_HRESULT(VER_E_THIS) - CASE_HRESULT(VER_E_THIS_UNINIT_EXCEP) - CASE_HRESULT(VER_E_THIS_UNINIT_STORE) - CASE_HRESULT(VER_E_THIS_UNINIT_RET) - CASE_HRESULT(VER_E_THIS_UNINIT_V_RET) - CASE_HRESULT(VER_E_THIS_UNINIT_BR) - CASE_HRESULT(VER_E_LDFTN_CTOR) - CASE_HRESULT(VER_E_STACK_NOT_EQ) - CASE_HRESULT(VER_E_STACK_UNEXPECTED) - CASE_HRESULT(VER_E_STACK_EXCEPTION) - CASE_HRESULT(VER_E_STACK_OVERFLOW) - CASE_HRESULT(VER_E_STACK_UNDERFLOW) - CASE_HRESULT(VER_E_STACK_EMPTY) - CASE_HRESULT(VER_E_STACK_UNINIT) - CASE_HRESULT(VER_E_STACK_I_I4_I8) - CASE_HRESULT(VER_E_STACK_R_R4_R8) - CASE_HRESULT(VER_E_STACK_NO_R_I8) - CASE_HRESULT(VER_E_STACK_NUMERIC) - CASE_HRESULT(VER_E_STACK_OBJREF) - CASE_HRESULT(VER_E_STACK_P_OBJREF) - CASE_HRESULT(VER_E_STACK_BYREF) - CASE_HRESULT(VER_E_STACK_METHOD) - CASE_HRESULT(VER_E_STACK_ARRAY_SD) - CASE_HRESULT(VER_E_STACK_VALCLASS) - CASE_HRESULT(VER_E_STACK_P_VALCLASS) - CASE_HRESULT(VER_E_STACK_NO_VALCLASS) - CASE_HRESULT(VER_E_LOC_DEAD) - CASE_HRESULT(VER_E_LOC_NUM) - CASE_HRESULT(VER_E_ARG_NUM) - CASE_HRESULT(VER_E_TOKEN_RESOLVE) - CASE_HRESULT(VER_E_TOKEN_TYPE) - CASE_HRESULT(VER_E_TOKEN_TYPE_MEMBER) - CASE_HRESULT(VER_E_TOKEN_TYPE_FIELD) - CASE_HRESULT(VER_E_TOKEN_TYPE_SIG) - CASE_HRESULT(VER_E_UNVERIFIABLE) - CASE_HRESULT(VER_E_LDSTR_OPERAND) - CASE_HRESULT(VER_E_RET_PTR_TO_STACK) - CASE_HRESULT(VER_E_RET_VOID) - CASE_HRESULT(VER_E_RET_MISSING) - CASE_HRESULT(VER_E_RET_EMPTY) - CASE_HRESULT(VER_E_RET_UNINIT) - CASE_HRESULT(VER_E_ARRAY_ACCESS) - CASE_HRESULT(VER_E_ARRAY_V_STORE) - CASE_HRESULT(VER_E_ARRAY_SD) - CASE_HRESULT(VER_E_ARRAY_SD_PTR) - CASE_HRESULT(VER_E_ARRAY_FIELD) - CASE_HRESULT(VER_E_ARGLIST) - CASE_HRESULT(VER_E_VALCLASS) - CASE_HRESULT(VER_E_METHOD_ACCESS) - CASE_HRESULT(VER_E_FIELD_ACCESS) - CASE_HRESULT(VER_E_DEAD) - CASE_HRESULT(VER_E_FIELD_STATIC) - CASE_HRESULT(VER_E_FIELD_NO_STATIC) - CASE_HRESULT(VER_E_ADDR) - CASE_HRESULT(VER_E_ADDR_BYREF) - CASE_HRESULT(VER_E_ADDR_LITERAL) - CASE_HRESULT(VER_E_INITONLY) - CASE_HRESULT(VER_E_THROW) - CASE_HRESULT(VER_E_CALLVIRT_VALCLASS) - CASE_HRESULT(VER_E_CALL_SIG) - CASE_HRESULT(VER_E_CALL_STATIC) - CASE_HRESULT(VER_E_CTOR) - CASE_HRESULT(VER_E_CTOR_VIRT) - CASE_HRESULT(VER_E_CTOR_OR_SUPER) - CASE_HRESULT(VER_E_CTOR_MUL_INIT) - CASE_HRESULT(VER_E_SIG) - CASE_HRESULT(VER_E_SIG_ARRAY) - CASE_HRESULT(VER_E_SIG_ARRAY_PTR) - CASE_HRESULT(VER_E_SIG_ARRAY_BYREF) - CASE_HRESULT(VER_E_SIG_ELEM_PTR) - CASE_HRESULT(VER_E_SIG_VARARG) - CASE_HRESULT(VER_E_SIG_VOID) - CASE_HRESULT(VER_E_SIG_BYREF_BYREF) - CASE_HRESULT(VER_E_CODE_SIZE_ZERO) - CASE_HRESULT(VER_E_BAD_VARARG) - CASE_HRESULT(VER_E_TAIL_CALL) - CASE_HRESULT(VER_E_TAIL_BYREF) - CASE_HRESULT(VER_E_TAIL_RET) - CASE_HRESULT(VER_E_TAIL_RET_VOID) - CASE_HRESULT(VER_E_TAIL_RET_TYPE) - CASE_HRESULT(VER_E_TAIL_STACK_EMPTY) - CASE_HRESULT(VER_E_METHOD_END) - CASE_HRESULT(VER_E_BAD_BRANCH) - CASE_HRESULT(VER_E_FIN_OVERLAP) - CASE_HRESULT(VER_E_LEXICAL_NESTING) - CASE_HRESULT(VER_E_VOLATILE) - CASE_HRESULT(VER_E_UNALIGNED) - CASE_HRESULT(VER_E_INNERMOST_FIRST) - CASE_HRESULT(VER_E_CALLI_VIRTUAL) - CASE_HRESULT(VER_E_CALL_ABSTRACT) - CASE_HRESULT(VER_E_STACK_UNEXP_ARRAY) - CASE_HRESULT(VER_E_NOT_IN_GC_HEAP) - CASE_HRESULT(VER_E_TRY_N_EMPTY_STACK) - CASE_HRESULT(VER_E_DLGT_CTOR) - CASE_HRESULT(VER_E_DLGT_BB) - CASE_HRESULT(VER_E_DLGT_PATTERN) - CASE_HRESULT(VER_E_DLGT_LDFTN) - CASE_HRESULT(VER_E_FTN_ABSTRACT) - CASE_HRESULT(VER_E_SIG_C_VC) - CASE_HRESULT(VER_E_SIG_VC_C) - CASE_HRESULT(VER_E_BOX_PTR_TO_STACK) - CASE_HRESULT(VER_E_SIG_BYREF_TB_AH) - CASE_HRESULT(VER_E_SIG_ARRAY_TB_AH) - CASE_HRESULT(VER_E_ENDFILTER_STACK) - CASE_HRESULT(VER_E_DLGT_SIG_I) - CASE_HRESULT(VER_E_DLGT_SIG_O) - CASE_HRESULT(VER_E_RA_PTR_TO_STACK) - CASE_HRESULT(VER_E_CATCH_VALUE_TYPE) - CASE_HRESULT(VER_E_CATCH_BYREF) - CASE_HRESULT(VER_E_FIL_PRECEED_HND) - CASE_HRESULT(VER_E_LDVIRTFTN_STATIC) - CASE_HRESULT(VER_E_CALLVIRT_STATIC) - CASE_HRESULT(VER_E_INITLOCALS) - CASE_HRESULT(VER_E_BR_TO_EXCEPTION) - CASE_HRESULT(VER_E_CALL_CTOR) - CASE_HRESULT(VER_E_BAD_PE) - CASE_HRESULT(VER_E_BAD_MD) - CASE_HRESULT(VER_E_BAD_APPDOMAIN) - CASE_HRESULT(VER_E_TYPELOAD) - CASE_HRESULT(VER_E_PE_LOAD) - CASE_HRESULT(VER_E_WRITE_RVA_STATIC) CASE_HRESULT(CORDBG_E_THREAD_NOT_SCHEDULED) #endif diff --git a/src/utilcode/jithost.cpp b/src/utilcode/jithost.cpp deleted file mode 100644 index 3174aa618803..000000000000 --- a/src/utilcode/jithost.cpp +++ /dev/null @@ -1,77 +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. - -#include "stdafx.h" - -#include "utilcode.h" -#include "corjit.h" -#include "jithost.h" - -void* JitHost::allocateMemory(size_t size, bool usePageAllocator) -{ - WRAPPER_NO_CONTRACT; - - if (usePageAllocator) - { - return GetEEMemoryManager()->ClrVirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE); - } - else - { - return ClrAllocInProcessHeap(0, S_SIZE_T(size)); - } -} - -void JitHost::freeMemory(void* block, bool usePageAllocator) -{ - WRAPPER_NO_CONTRACT; - - if (usePageAllocator) - { - GetEEMemoryManager()->ClrVirtualFree(block, 0, MEM_RELEASE); - } - else - { - ClrFreeInProcessHeap(0, block); - } -} - -int JitHost::getIntConfigValue(const wchar_t* name, int defaultValue) -{ - WRAPPER_NO_CONTRACT; - - // Translate JIT call into runtime configuration query - CLRConfig::ConfigDWORDInfo info{ name, defaultValue, CLRConfig::EEConfig_default }; - - // Perform a CLRConfig look up on behalf of the JIT. - return CLRConfig::GetConfigValue(info); -} - -const wchar_t* JitHost::getStringConfigValue(const wchar_t* name) -{ - WRAPPER_NO_CONTRACT; - - // Translate JIT call into runtime configuration query - CLRConfig::ConfigStringInfo info{ name, CLRConfig::EEConfig_default }; - - // Perform a CLRConfig look up on behalf of the JIT. - return CLRConfig::GetConfigValue(info); -} - -void JitHost::freeStringConfigValue(const wchar_t* value) -{ - WRAPPER_NO_CONTRACT; - - CLRConfig::FreeConfigString(const_cast(value)); -} - -JitHost JitHost::theJitHost; -ICorJitHost* JitHost::getJitHost() -{ - STATIC_CONTRACT_SO_TOLERANT; - STATIC_CONTRACT_GC_NOTRIGGER; - STATIC_CONTRACT_NOTHROW; - STATIC_CONTRACT_CANNOT_TAKE_LOCK; - - return &theJitHost; -} diff --git a/src/utilcode/opinfo.cpp b/src/utilcode/opinfo.cpp index 60da66047a52..0494155c03b1 100644 --- a/src/utilcode/opinfo.cpp +++ b/src/utilcode/opinfo.cpp @@ -99,7 +99,6 @@ const BYTE* OpInfo::fetch(const BYTE* instrPtr, OpArgsVal* args) { break; case InlineR: { __int64 d = GET_UNALIGNED_VAL64(instrPtr); instrPtr +=8; - instrPtr += 8; args->r = *((double*) (&d)); } break; case InlineSwitch: diff --git a/src/utilcode/util.cpp b/src/utilcode/util.cpp index 97b90ed06f22..e95f3f4a085f 100644 --- a/src/utilcode/util.cpp +++ b/src/utilcode/util.cpp @@ -852,13 +852,14 @@ BYTE * ClrVirtualAllocWithinRange(const BYTE *pMinAddr, } #endif -/*static*/ BOOL CPUGroupInfo::m_enableGCCPUGroups = FALSE; -/*static*/ BOOL CPUGroupInfo::m_threadUseAllCpuGroups = FALSE; -/*static*/ WORD CPUGroupInfo::m_nGroups = 0; -/*static*/ WORD CPUGroupInfo::m_nProcessors = 0; -/*static*/ WORD CPUGroupInfo::m_initialGroup = 0; +/*static*/ BOOL CPUGroupInfo::m_enableGCCPUGroups = FALSE; +/*static*/ BOOL CPUGroupInfo::m_threadUseAllCpuGroups = FALSE; +/*static*/ WORD CPUGroupInfo::m_nGroups = 0; +/*static*/ WORD CPUGroupInfo::m_nProcessors = 0; +/*static*/ WORD CPUGroupInfo::m_initialGroup = 0; /*static*/ CPU_Group_Info *CPUGroupInfo::m_CPUGroupInfoArray = NULL; -/*static*/ LONG CPUGroupInfo::m_initialization = 0; +/*static*/ LONG CPUGroupInfo::m_initialization = 0; +/*static*/ bool CPUGroupInfo::s_hadSingleProcessorAtStartup = false; // Check and setup function pointers for >64 LP Support /*static*/ BOOL CPUGroupInfo::InitCPUGroupInfoAPI() @@ -1066,6 +1067,18 @@ DWORD LCM(DWORD u, DWORD v) m_enableGCCPUGroups = enableGCCPUGroups && hasMultipleGroups; m_threadUseAllCpuGroups = threadUseAllCpuGroups && hasMultipleGroups; #endif // _TARGET_AMD64_ || _TARGET_ARM64_ + + // Determine if the process is affinitized to a single processor (or if the system has a single processor) + DWORD_PTR processAffinityMask, systemAffinityMask; + if (GetProcessAffinityMask(GetCurrentProcess(), &processAffinityMask, &systemAffinityMask)) + { + processAffinityMask &= systemAffinityMask; + if (processAffinityMask != 0 && // only one CPU group is involved + (processAffinityMask & (processAffinityMask - 1)) == 0) // only one bit is set + { + s_hadSingleProcessorAtStartup = true; + } + } } /*static*/ BOOL CPUGroupInfo::IsInitialized() diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt index cb75a09adbe2..709c5e6f73ed 100644 --- a/src/vm/CMakeLists.txt +++ b/src/vm/CMakeLists.txt @@ -81,6 +81,7 @@ set(VM_SOURCES_DAC_AND_WKS_COMMON ilstubresolver.cpp inlinetracking.cpp instmethhash.cpp + jithost.cpp jitinterface.cpp loaderallocator.cpp memberload.cpp diff --git a/src/vm/ClrEtwAll.man b/src/vm/ClrEtwAll.man index 441f0a0c9551..1081477bfb63 100644 --- a/src/vm/ClrEtwAll.man +++ b/src/vm/ClrEtwAll.man @@ -75,6 +75,8 @@ message="$(string.RuntimePublisher.MonitoringKeywordMessage)" symbol="CLR_MONITORING_KEYWORD" /> + @@ -3261,7 +3263,7 @@ symbol="CodeSymbols" message="$(string.RuntimePublisher.CodeSymbolsEventMessage)"/> @@ -6853,6 +6855,7 @@ + diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 8a69a997a7cd..3ca7ec7e24a2 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -2774,8 +2774,6 @@ void SystemDomain::LoadBaseSystemClasses() g_pExecutionEngineExceptionClass = MscorlibBinder::GetException(kExecutionEngineException); g_pThreadAbortExceptionClass = MscorlibBinder::GetException(kThreadAbortException); - - // used by gc to handle predefined agility checking g_pThreadClass = MscorlibBinder::GetClass(CLASS__THREAD); #ifdef FEATURE_COMINTEROP @@ -8966,76 +8964,10 @@ void AppDomain::ClearGCHandles() GCHeapUtilities::GetGCHeap()->WaitUntilConcurrentGCComplete(); - // Keep async pin handles alive by moving them to default domain - HandleAsyncPinHandles(); - // Remove our handle store as a source of GC roots m_handleStore->Uproot(); } -// When an AD is unloaded, we will release all objects in this AD. -// If a future asynchronous operation, like io completion port function, -// we need to keep the memory space fixed so that the gc heap is not corrupted. -void AppDomain::HandleAsyncPinHandles() -{ - CONTRACTL - { - GC_TRIGGERS; - MODE_COOPERATIVE; - NOTHROW; - } - CONTRACTL_END; - - IGCHandleStore *pBucket = m_handleStore; - - // IO completion port picks IO job using FIFO. Here is how we know which AsyncPinHandle can be freed. - // 1. We mark all non-pending AsyncPinHandle with READYTOCLEAN. - // 2. We queue a dump Overlapped to the IO completion as a marker. - // 3. When the Overlapped is picked up by completion port, we wait until all previous IO jobs are processed. - // 4. Then we can delete all AsyncPinHandle marked with READYTOCLEAN. - IGCHandleStore *pBucketInDefault = SystemDomain::System()->DefaultDomain()->m_handleStore; - - auto clearIfComplete = [](Object* object) - { - LIMITED_METHOD_CONTRACT; - - assert(object != nullptr); - if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass) - { - return; - } - - OVERLAPPEDDATAREF overlapped = (OVERLAPPEDDATAREF)(ObjectToOBJECTREF((Object*)object)); - if (overlapped->HasCompleted()) - { - // IO has finished. We don't need to pin the user buffer any longer. - overlapped->m_userObject = NULL; - } - - BashMTForPinnedObject(ObjectToOBJECTREF(object)); - }; - - auto setHandle = [](Object* object, OBJECTHANDLE handle) - { - LIMITED_METHOD_CONTRACT; - - assert(object != nullptr); - assert(handle); - - if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass) - { - return; - } - - OverlappedDataObject* overlapped = (OverlappedDataObject*)object; - overlapped->m_pinSelf = handle; - }; - - pBucket->RelocateAsyncPinnedHandles(pBucketInDefault, clearIfComplete, setHandle); - - OverlappedDataObject::RequestCleanup(); -} - void AppDomain::ClearGCRoots() { CONTRACTL diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp index d92aabb535db..dabe46bc3828 100644 --- a/src/vm/appdomain.hpp +++ b/src/vm/appdomain.hpp @@ -497,6 +497,12 @@ struct DomainLocalModule }; // struct DomainLocalModule +#define OFFSETOF__DomainLocalModule__m_pDataBlob_ (6 * TARGET_POINTER_SIZE) +#ifdef FEATURE_64BIT_ALIGNMENT +#define OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob (TARGET_POINTER_SIZE /* m_pGCStatics */ + TARGET_POINTER_SIZE /* m_padding */) +#else +#define OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob TARGET_POINTER_SIZE /* m_pGCStatics */ +#endif typedef DPTR(class DomainLocalBlock) PTR_DomainLocalBlock; class DomainLocalBlock @@ -3438,7 +3444,6 @@ class AppDomain : public BaseDomain void Close(); void ClearGCRoots(); void ClearGCHandles(); - void HandleAsyncPinHandles(); void UnwindThreads(); // Return TRUE if EE is stopped // Return FALSE if more work is needed diff --git a/src/vm/appdomainnative.cpp b/src/vm/appdomainnative.cpp index 3c1b64a37080..49e0f6201307 100644 --- a/src/vm/appdomainnative.cpp +++ b/src/vm/appdomainnative.cpp @@ -419,22 +419,6 @@ FCIMPL1(Object*, AppDomainNative::GetDynamicDir, AppDomainBaseObject* refThisUNS } FCIMPLEND -FCIMPL1(FC_BOOL_RET, AppDomainNative::IsFinalizingForUnload, AppDomainBaseObject* refThisUNSAFE) -{ - FCALL_CONTRACT; - - BOOL retVal = FALSE; - APPDOMAINREF refThis = (APPDOMAINREF) refThisUNSAFE; - HELPER_METHOD_FRAME_BEGIN_RET_1(refThis); - - AppDomain* pApp = ValidateArg(refThis); - retVal = pApp->IsFinalizing(); - - HELPER_METHOD_FRAME_END(); - FC_RETURN_BOOL(retVal); -} -FCIMPLEND - FCIMPL2(StringObject*, AppDomainNative::nApplyPolicy, AppDomainBaseObject* refThisUNSAFE, AssemblyNameBaseObject* refAssemblyNameUNSAFE) { FCALL_CONTRACT; diff --git a/src/vm/appdomainnative.hpp b/src/vm/appdomainnative.hpp index e2d564a747da..9728ef8ec03c 100644 --- a/src/vm/appdomainnative.hpp +++ b/src/vm/appdomainnative.hpp @@ -33,7 +33,6 @@ class AppDomainNative static FCDECL1(INT32, GetId, AppDomainBaseObject* refThisUNSAFE); static FCDECL1(INT32, GetIdForUnload, AppDomainBaseObject* refDomainUNSAFE); static FCDECL1(FC_BOOL_RET, IsDomainIdValid, INT32 dwId); - static FCDECL1(FC_BOOL_RET, IsFinalizingForUnload, AppDomainBaseObject* refThisUNSAFE); static FCDECL1(void, ForceToSharedDomain, Object* pObjectUNSAFE); static FCDECL1(LPVOID, GetFusionContext, AppDomainBaseObject* refThis); static FCDECL2(Object*, IsStringInterned, AppDomainBaseObject* refThis, StringObject* pString); diff --git a/src/vm/arm/stubs.cpp b/src/vm/arm/stubs.cpp index 916c949df1ef..cb9ff602ffed 100644 --- a/src/vm/arm/stubs.cpp +++ b/src/vm/arm/stubs.cpp @@ -1680,6 +1680,13 @@ VOID StubLinkerCPU::EmitShuffleThunk(ShuffleEntry *pShuffleEntryArray) void StubLinkerCPU::ThumbEmitCallManagedMethod(MethodDesc *pMD, bool fTailcall) { + bool isRelative = MethodTable::VTableIndir2_t::isRelative + && pMD->IsVtableSlot(); + +#ifndef FEATURE_NGEN_RELOCS_OPTIMIZATIONS + _ASSERTE(!isRelative); +#endif + // Use direct call if possible. if (pMD->HasStableEntryPoint()) { @@ -1691,14 +1698,47 @@ void StubLinkerCPU::ThumbEmitCallManagedMethod(MethodDesc *pMD, bool fTailcall) // mov r12, #slotaddress ThumbEmitMovConstant(ThumbReg(12), (TADDR)pMD->GetAddrOfSlot()); + if (isRelative) + { + if (!fTailcall) + { + // str r4, [sp, 0] + ThumbEmitStoreRegIndirect(ThumbReg(4), thumbRegSp, 0); + } + + // mov r4, r12 + ThumbEmitMovRegReg(ThumbReg(4), ThumbReg(12)); + } + // ldr r12, [r12] ThumbEmitLoadRegIndirect(ThumbReg(12), ThumbReg(12), 0); + + if (isRelative) + { + // add r12, r4 + ThumbEmitAddReg(ThumbReg(12), ThumbReg(4)); + + if (!fTailcall) + { + // ldr r4, [sp, 0] + ThumbEmitLoadRegIndirect(ThumbReg(4), thumbRegSp, 0); + } + } } if (fTailcall) { - // bx r12 - ThumbEmitJumpRegister(ThumbReg(12)); + if (!isRelative) + { + // bx r12 + ThumbEmitJumpRegister(ThumbReg(12)); + } + else + { + // Replace LR with R12 on stack: hybrid-tail call, same as for EmitShuffleThunk + // str r12, [sp, 4] + ThumbEmitStoreRegIndirect(ThumbReg(12), thumbRegSp, 4); + } } else { @@ -1835,6 +1875,13 @@ void StubLinkerCPU::ThumbEmitCallWithGenericInstantiationParameter(MethodDesc *p } } + bool isRelative = MethodTable::VTableIndir2_t::isRelative + && pMD->IsVtableSlot(); + +#ifndef FEATURE_NGEN_RELOCS_OPTIMIZATIONS + _ASSERTE(!isRelative); +#endif + // Update descriptor count to the actual number used. cArgDescriptors = idxCurrentDesc; @@ -1927,7 +1974,17 @@ void StubLinkerCPU::ThumbEmitCallWithGenericInstantiationParameter(MethodDesc *p } // Emit a tail call to the target method. + if (isRelative) + { + ThumbEmitProlog(1, 0, FALSE); + } + ThumbEmitCallManagedMethod(pMD, true); + + if (isRelative) + { + ThumbEmitEpilog(); + } } else { @@ -1936,7 +1993,9 @@ void StubLinkerCPU::ThumbEmitCallWithGenericInstantiationParameter(MethodDesc *p // Calculate the size of the new stack frame: // // +------------+ - // SP -> | | <-+ + // SP -> | | <-- Space for helper arg, if isRelative is true + // +------------+ + // | | <-+ // : : | Outgoing arguments // | | <-+ // +------------+ @@ -1967,6 +2026,12 @@ void StubLinkerCPU::ThumbEmitCallWithGenericInstantiationParameter(MethodDesc *p DWORD cbStackArgs = (pLastArg->m_idxDst + 1) * 4; DWORD cbStackFrame = cbStackArgs + sizeof(GSCookie) + sizeof(StubHelperFrame); cbStackFrame = ALIGN_UP(cbStackFrame, 8); + + if (isRelative) + { + cbStackFrame += 4; + } + DWORD cbStackFrameWithoutSavedRegs = cbStackFrame - (13 * 4); // r0-r11,lr // Prolog: @@ -2175,8 +2240,25 @@ void StubLinkerCPU::EmitUnboxMethodStub(MethodDesc *pMD) // add r0, #4 ThumbEmitIncrement(ThumbReg(0), 4); + bool isRelative = MethodTable::VTableIndir2_t::isRelative + && pMD->IsVtableSlot(); + +#ifndef FEATURE_NGEN_RELOCS_OPTIMIZATIONS + _ASSERTE(!isRelative); +#endif + + if (isRelative) + { + ThumbEmitProlog(1, 0, FALSE); + } + // Tail call the real target. ThumbEmitCallManagedMethod(pMD, true /* tail call */); + + if (isRelative) + { + ThumbEmitEpilog(); + } } } diff --git a/src/vm/arm64/PInvokeStubs.asm b/src/vm/arm64/PInvokeStubs.asm index eb522d920eca..440af92b6bc2 100644 --- a/src/vm/arm64/PInvokeStubs.asm +++ b/src/vm/arm64/PInvokeStubs.asm @@ -45,11 +45,6 @@ __PInvokeStubFuncName SETS "$FuncPrefix":CC:"Stub" __PInvokeGenStubFuncName SETS "$FuncPrefix":CC:"GenILStub" __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" - IF "$VASigCookieReg" == "x1" -__PInvokeStubFuncName SETS "$__PInvokeStubFuncName":CC:"_RetBuffArg" -__PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg" - ENDIF - NESTED_ENTRY $__PInvokeStubFuncName ; get the stub @@ -84,9 +79,7 @@ __PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg" mov x2, $HiddenArg ; x1 = VaSigCookie - IF "$VASigCookieReg" != "x1" mov x1, $VASigCookieReg - ENDIF ; x0 = pTransitionBlock add x0, sp, #__PWTB_TransitionBlock @@ -118,7 +111,6 @@ __PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg" ; ------------------------------------------------------------------ ; VarargPInvokeStub & VarargPInvokeGenILStub -; There is a separate stub when the method has a hidden return buffer arg. ; ; in: ; x0 = VASigCookie* @@ -137,16 +129,6 @@ __PInvokeGenStubFuncName SETS "$__PInvokeGenStubFuncName":CC:"_RetBuffArg" ; PINVOKE_STUB GenericPInvokeCalli, x15, x12, {true} -; ------------------------------------------------------------------ -; VarargPInvokeStub_RetBuffArg & VarargPInvokeGenILStub_RetBuffArg -; Vararg PInvoke Stub when the method has a hidden return buffer arg -; -; in: -; x1 = VASigCookie* -; x12 = MethodDesc* -; - PINVOKE_STUB VarargPInvoke, x1, x12, {false} - ; Must be at very end of file END diff --git a/src/vm/arm64/cgencpu.h b/src/vm/arm64/cgencpu.h index 7e3d62056a73..6edf704b8f24 100644 --- a/src/vm/arm64/cgencpu.h +++ b/src/vm/arm64/cgencpu.h @@ -578,7 +578,7 @@ struct StubPrecode { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; } CONTRACTL_END; @@ -591,7 +591,7 @@ struct StubPrecode { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; } CONTRACTL_END; @@ -704,7 +704,7 @@ struct FixupPrecode { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; } CONTRACTL_END; @@ -717,7 +717,7 @@ struct FixupPrecode { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; } CONTRACTL_END; @@ -778,7 +778,7 @@ struct ThisPtrRetBufPrecode { CONTRACTL { THROWS; - GC_TRIGGERS; + GC_NOTRIGGER; } CONTRACTL_END; diff --git a/src/vm/arm64/pinvokestubs.S b/src/vm/arm64/pinvokestubs.S index 2ff6a8d7de67..ad64db855afa 100644 --- a/src/vm/arm64/pinvokestubs.S +++ b/src/vm/arm64/pinvokestubs.S @@ -59,9 +59,7 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): mov x2, \HiddenArg // x1 = VaSigCookie - .ifnc \VASigCookieReg, x1 mov x1, \VASigCookieReg - .endif // x0 = pTransitionBlock add x0, sp, #__PWTB_TransitionBlock @@ -90,7 +88,6 @@ LOCAL_LABEL(\__PInvokeStubFuncName\()_0): // ------------------------------------------------------------------ // VarargPInvokeStub & VarargPInvokeGenILStub -// There is a separate stub when the method has a hidden return buffer arg. // // in: // x0 = VASigCookie* @@ -108,13 +105,3 @@ PINVOKE_STUB VarargPInvokeStub, VarargPInvokeGenILStub, VarargPInvokeStubWorker, // x12 = Unmanaged target // PINVOKE_STUB GenericPInvokeCalliHelper, GenericPInvokeCalliGenILStub, GenericPInvokeCalliStubWorker, x15, x12, 1, 1 - -// ------------------------------------------------------------------ -// VarargPInvokeStub_RetBuffArg & VarargPInvokeGenILStub_RetBuffArg -// Vararg PInvoke Stub when the method has a hidden return buffer arg -// -// in: -// x1 = VASigCookie* -// x12 = MethodDesc* -// -PINVOKE_STUB VarargPInvokeStub_RetBuffArg, VarargPInvokeGenILStub_RetBuffArg, VarargPInvokeStubWorker, x1, x12, 0 diff --git a/src/vm/array.cpp b/src/vm/array.cpp index b9e7d6e27a74..5103e9efc015 100644 --- a/src/vm/array.cpp +++ b/src/vm/array.cpp @@ -374,7 +374,7 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy // If none, we need to allocate space for the slots if (!canShareVtableChunks) { - cbMT += numVirtuals * sizeof(PCODE); + cbMT += numVirtuals * sizeof(MethodTable::VTableIndir2_t); } // Canonical methodtable has an array of non virtual slots pointed to by the optional member @@ -432,13 +432,6 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy pClass->SetArrayElementType (elemType); pClass->SetMethodTable (pMT); -#if defined(_DEBUG) - // Non-covariant arrays of agile types are agile - if (elemType != ELEMENT_TYPE_CLASS && elemTypeHnd.IsAppDomainAgile()) - pClass->SetAppDomainAgile(); - pClass->SetAppDomainAgilityDone(); -#endif - // Fill In the method table pClass->SetNumMethods(numVirtuals + numNonVirtualSlots); @@ -544,7 +537,7 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy else { // Use the locally allocated chunk - it.SetIndirectionSlot((PTR_PCODE)(pMemory+cbArrayClass+offsetOfUnsharedVtableChunks)); + it.SetIndirectionSlot((MethodTable::VTableIndir2_t *)(pMemory+cbArrayClass+offsetOfUnsharedVtableChunks)); offsetOfUnsharedVtableChunks += it.GetSize(); } } diff --git a/src/vm/ceeload.cpp b/src/vm/ceeload.cpp index 2155c370f403..5c4df90a80bf 100644 --- a/src/vm/ceeload.cpp +++ b/src/vm/ceeload.cpp @@ -2017,6 +2017,12 @@ void Module::BuildStaticsOffsets(AllocMemTracker *pamTracker) // | Class Data (one byte per class) | pointer to gc statics | primitive type statics | // // +#ifndef CROSSBITNESS_COMPILE + // The assertions must hold in every non-crossbitness scenario + _ASSERTE(OFFSETOF__DomainLocalModule__m_pDataBlob_ == DomainLocalModule::OffsetOfDataBlob()); + _ASSERTE(OFFSETOF__ThreadLocalModule__m_pDataBlob == ThreadLocalModule::OffsetOfDataBlob()); +#endif + DWORD dwNonGCBytes[2] = { DomainLocalModule::OffsetOfDataBlob() + sizeof(BYTE)*dwNumTypes, ThreadLocalModule::OffsetOfDataBlob() + sizeof(BYTE)*dwNumTypes @@ -2233,11 +2239,14 @@ void Module::GetOffsetsForRegularStaticData( return; } +#ifndef CROSSBITNESS_COMPILE + _ASSERTE(OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob == DomainLocalModule::DynamicEntry::GetOffsetOfDataBlob()); +#endif // Statics for instantiated types are allocated dynamically per-instantiation if (bDynamic) { // Non GC statics are embedded in the Dynamic Entry. - *pOutNonGCStaticOffset = DomainLocalModule::DynamicEntry::GetOffsetOfDataBlob(); + *pOutNonGCStaticOffset = OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob; return; } @@ -2253,9 +2262,12 @@ void Module::GetOffsetsForRegularStaticData( *pOutStaticHandleOffset = m_pRegularStaticOffsets[index*2]; *pOutNonGCStaticOffset = m_pRegularStaticOffsets[index*2 + 1]; +#ifdef CROSSBITNESS_COMPILE + *pOutNonGCStaticOffset += OFFSETOF__DomainLocalModule__m_pDataBlob_ - DomainLocalModule::OffsetOfDataBlob(); +#endif // Check we didnt go out of what we predicted we would need for the class - if (*pOutStaticHandleOffset + sizeof(OBJECTREF*)*dwGCStaticHandles > + if (*pOutStaticHandleOffset + TARGET_POINTER_SIZE*dwGCStaticHandles > m_pRegularStaticOffsets[(index+1)*2] || *pOutNonGCStaticOffset + dwNonGCStaticBytes > m_pRegularStaticOffsets[(index+1)*2 + 1]) @@ -2291,11 +2303,14 @@ void Module::GetOffsetsForThreadStaticData( return; } +#ifndef CROSSBITNESS_COMPILE + _ASSERTE(OFFSETOF__ThreadLocalModule__DynamicEntry__m_pDataBlob == ThreadLocalModule::DynamicEntry::GetOffsetOfDataBlob()); +#endif // Statics for instantiated types are allocated dynamically per-instantiation if (bDynamic) { // Non GC thread statics are embedded in the Dynamic Entry. - *pOutNonGCStaticOffset = ThreadLocalModule::DynamicEntry::GetOffsetOfDataBlob(); + *pOutNonGCStaticOffset = OFFSETOF__ThreadLocalModule__DynamicEntry__m_pDataBlob; return; } @@ -2311,9 +2326,12 @@ void Module::GetOffsetsForThreadStaticData( *pOutStaticHandleOffset = m_pThreadStaticOffsets[index*2]; *pOutNonGCStaticOffset = m_pThreadStaticOffsets[index*2 + 1]; +#ifdef CROSSBITNESS_COMPILE + *pOutNonGCStaticOffset += OFFSETOF__ThreadLocalModule__m_pDataBlob - ThreadLocalModule::GetOffsetOfDataBlob(); +#endif // Check we didnt go out of what we predicted we would need for the class - if (*pOutStaticHandleOffset + sizeof(OBJECTREF*)*dwGCStaticHandles > + if (*pOutStaticHandleOffset + TARGET_POINTER_SIZE*dwGCStaticHandles > m_pThreadStaticOffsets[(index+1)*2] || *pOutNonGCStaticOffset + dwNonGCStaticBytes > m_pThreadStaticOffsets[(index+1)*2 + 1]) diff --git a/src/vm/ceemain.cpp b/src/vm/ceemain.cpp index f599a2aa2390..da4c7c5f6584 100644 --- a/src/vm/ceemain.cpp +++ b/src/vm/ceemain.cpp @@ -175,6 +175,7 @@ #include "finalizerthread.h" #include "threadsuspend.h" #include "disassembler.h" +#include "jithost.h" #ifndef FEATURE_PAL #include "dwreport.h" @@ -908,6 +909,8 @@ void EEStartupHelper(COINITIEE fFlags) ExecutionManager::Init(); + JitHost::Init(); + #ifndef CROSSGEN_COMPILE #ifndef FEATURE_PAL @@ -1012,8 +1015,6 @@ void EEStartupHelper(COINITIEE fFlags) // Now we really have fully initialized the garbage collector SetGarbageCollectorFullyInitialized(); - InitializePinHandleTable(); - #ifdef DEBUGGING_SUPPORTED // Make a call to publish the DefaultDomain for the debugger // This should be done before assemblies/modules are loaded into it (i.e. SystemDomain::Init) @@ -1097,13 +1098,6 @@ void EEStartupHelper(COINITIEE fFlags) #ifndef CROSSGEN_COMPILE -#ifdef FEATURE_TIERED_COMPILATION - if (g_pConfig->TieredCompilation()) - { - SystemDomain::System()->DefaultDomain()->GetTieredCompilationManager()->InitiateTier1CountingDelay(); - } -#endif - #ifdef _DEBUG //if g_fEEStarted was false when we loaded the System Module, we did not run ExpandAll on it. In diff --git a/src/vm/class.cpp b/src/vm/class.cpp index f66a719bb0fe..fe7fe7e8a768 100644 --- a/src/vm/class.cpp +++ b/src/vm/class.cpp @@ -1042,480 +1042,6 @@ CorElementType EEClass::ComputeInternalCorElementTypeForValueType(MethodTable * return ELEMENT_TYPE_VALUETYPE; } -#if defined(_DEBUG) -//******************************************************************************* -void EEClass::GetPredefinedAgility(Module *pModule, mdTypeDef td, - BOOL *pfIsAgile, BOOL *pfCheckAgile) -{ - - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - FORBID_FAULT; - } - CONTRACTL_END - - // - // There are 4 settings possible: - // IsAgile CheckAgile - // F F (default) Use normal type logic to determine agility - // T F "Proxy" Treated as agile even though may not be. - // F T "Maybe" Not agile, but specific instances can be made agile. - // T T "Force" All instances are forced agile, even though not typesafe. - // - // Also, note that object arrays of agile or maybe agile types are made maybe agile. - // - - static const struct PredefinedAgility - { - const char *name; - BOOL isAgile; - BOOL checkAgile; - } - - // Matches based on name with the first records having higher precedence than subsequent ones - // so that when there is an ambiguity, the first one will be used: - // System.Globalization.CultureNotFoundException - // comes before - // System.Globalization.* - // - // although System.Globalization.CultureNotFoundException matches both records, the first - // is the one that will be used - agility[] = - { - // The Thread leak across context boundaries. - // We manage the leaks manually - { g_ThreadClassName, TRUE, FALSE }, - - // The SharedStatics class is a container for process-wide data - { g_SharedStaticsClassName, FALSE, TRUE }, - - // The extra dot at the start is to accomodate the string comparison logic below - // when there is no namespace for a type - {".StringMaker", FALSE, TRUE }, - - {g_StringBufferClassName, FALSE, TRUE }, - - { "System.ActivationArguments", FALSE, TRUE }, - { "System.AppDomainSetup" , FALSE, TRUE }, - { "System.AppDomainInitializerInfo", FALSE, TRUE }, - - // Make all containers maybe agile - { "System.Collections.*", FALSE, TRUE }, - { "System.Collections.Generic.*", FALSE, TRUE }, - - // Make all globalization objects agile except for System.Globalization.CultureNotFoundException - // The exception inherits from ArgumentException so needs the same agility - // this must come before the more general declaration below so that it will match first - { "System.Globalization.CultureNotFoundException", FALSE, FALSE }, - // We have CultureInfo objects on thread. Because threads leak across - // app domains, we have to be prepared for CultureInfo to leak across. - // CultureInfo exposes all of the other globalization objects, so we - // just make the entire namespace app domain agile. - { "System.Globalization.*", FALSE, TRUE }, - - // Remoting structures for legally smuggling messages across app domains - { "System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage", FALSE, TRUE }, - { "System.Runtime.Remoting.Messaging.SmuggledMethodReturnMessage", FALSE, TRUE }, - { "System.Runtime.Remoting.Messaging.SmuggledObjRef", FALSE, TRUE}, - { "System.Runtime.Remoting.ObjRef", FALSE, TRUE }, - { "System.Runtime.Remoting.ChannelInfo", FALSE, TRUE }, - { "System.Runtime.Remoting.Channels.CrossAppDomainData", FALSE, TRUE }, - - // Remoting cached data structures are all in mscorlib - { "System.Runtime.Remoting.Metadata.RemotingCachedData", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.RemotingFieldCachedData", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.RemotingParameterCachedData", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.RemotingMethodCachedData", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.RemotingTypeCachedData", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.SoapAttribute", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.SoapFieldAttribute", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.SoapMethodAttribute",FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.SoapParameterAttribute", FALSE, TRUE }, - { "System.Runtime.Remoting.Metadata.SoapTypeAttribute", FALSE, TRUE }, - - // Reflection types - { g_ReflectionMemberInfoName, FALSE, TRUE }, - { g_TypeClassName, FALSE, TRUE }, - { g_ReflectionClassName, FALSE, TRUE }, - { g_ReflectionConstructorInfoName, FALSE, TRUE }, - { g_ReflectionConstructorName, FALSE, TRUE }, - { g_ReflectionEventInfoName, FALSE, TRUE }, - { g_ReflectionEventName, FALSE, TRUE }, - { g_ReflectionFieldInfoName, FALSE, TRUE }, - { g_ReflectionFieldName, FALSE, TRUE }, - { g_MethodBaseName, FALSE, TRUE }, - { g_ReflectionMethodInfoName, FALSE, TRUE }, - { g_ReflectionMethodName, FALSE, TRUE }, - { g_ReflectionPropertyInfoName, FALSE, TRUE }, - { g_ReflectionPropInfoName, FALSE, TRUE }, - { g_ReflectionParamInfoName, FALSE, TRUE }, - { g_ReflectionParamName, FALSE, TRUE }, - - { "System.RuntimeType+RuntimeTypeCache", FALSE, TRUE }, - { "System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1", FALSE, TRUE }, - { "System.RuntimeType+RuntimeTypeCache+MemberInfoCache`1+Filter", FALSE, TRUE }, - { "System.Reflection.CerHashtable`2", FALSE, TRUE }, - { "System.Reflection.CerHashtable`2+Table", FALSE, TRUE }, - { "System.Reflection.RtFieldInfo", FALSE, TRUE }, - { "System.Reflection.MdFieldInfo", FALSE, TRUE }, - { "System.Signature", FALSE, TRUE }, - { "System.Reflection.MetadataImport", FALSE, TRUE }, - - // LogSwitches are agile even though we can't prove it - // @todo: do they need really to be? - { "System.Diagnostics.LogSwitch", FALSE, TRUE }, - - // There is a process global PermissionTokenFactory - { "System.Security.PermissionToken", FALSE, TRUE }, - { g_PermissionTokenFactoryName, FALSE, TRUE }, - - // Mark all the exceptions we throw agile. This makes - // most BVTs pass even though exceptions leak - // - // Note that making exception checked automatically - // makes a bunch of subclasses checked as well. - // - // Pre-allocated exceptions - { g_ExceptionClassName, FALSE, TRUE }, - { g_OutOfMemoryExceptionClassName, FALSE, TRUE }, - { g_StackOverflowExceptionClassName, FALSE, TRUE }, - { g_ExecutionEngineExceptionClassName, FALSE, TRUE }, - - // SecurityDocument contains pointers and other agile types - { "System.Security.SecurityDocument", TRUE, TRUE }, - - // BinaryFormatter smuggles these across appdomains. - { "System.Runtime.Serialization.Formatters.Binary.BinaryObjectWithMap", TRUE, FALSE}, - { "System.Runtime.Serialization.Formatters.Binary.BinaryObjectWithMapTyped", TRUE, FALSE}, - - { NULL } - }; - - if (pModule == SystemDomain::SystemModule()) - { - while (TRUE) - { - LPCUTF8 pszName; - LPCUTF8 pszNamespace; - HRESULT hr; - mdTypeDef tdEnclosing; - - if (FAILED(pModule->GetMDImport()->GetNameOfTypeDef(td, &pszName, &pszNamespace))) - { - break; - } - - // We rely the match algorithm matching the first items in the list before subsequent ones - // so that when there is an ambiguity, the first one will be used: - // System.Globalization.CultureNotFoundException - // comes before - // System.Globalization.* - // - // although System.Globalization.CultureNotFoundException matches both records, the first - // is the one that will be used - const PredefinedAgility *p = agility; - while (p->name != NULL) - { - SIZE_T length = strlen(pszNamespace); - if (strncmp(pszNamespace, p->name, length) == 0 - && (strcmp(pszName, p->name + length + 1) == 0 - || strcmp("*", p->name + length + 1) == 0)) - { - *pfIsAgile = p->isAgile; - *pfCheckAgile = p->checkAgile; - return; - } - - p++; - } - - // Perhaps we have a nested type like 'bucket' that is supposed to be - // agile or checked agile by virtue of being enclosed in a type like - // hashtable, which is itself inside "System.Collections". - tdEnclosing = mdTypeDefNil; - hr = pModule->GetMDImport()->GetNestedClassProps(td, &tdEnclosing); - if (SUCCEEDED(hr)) - { - BAD_FORMAT_NOTHROW_ASSERT(tdEnclosing != td && TypeFromToken(tdEnclosing) == mdtTypeDef); - td = tdEnclosing; - } - else - break; - } - } - - *pfIsAgile = FALSE; - *pfCheckAgile = FALSE; -} - -//******************************************************************************* -void EEClass::SetAppDomainAgileAttribute(MethodTable * pMT) -{ - CONTRACTL - { - THROWS; - GC_TRIGGERS; - INJECT_FAULT(COMPlusThrowOM()); - // PRECONDITION(!IsAppDomainAgilityDone()); - } - CONTRACTL_END - - EEClass * pClass = pMT->GetClass(); - - // - // The most general case for provably a agile class is - // (1) No instance fields of non-sealed or non-agile types - // (2) Class is in system domain (its type must be not unloadable - // & loaded in all app domains) - // (3) The class can't have a finalizer - // (4) The class can't be a COMClass - // - - _ASSERTE(!pClass->IsAppDomainAgilityDone()); - - BOOL fCheckAgile = FALSE; - BOOL fAgile = FALSE; - BOOL fFieldsAgile = TRUE; - WORD nFields = 0; - - if (!pMT->GetModule()->IsSystem()) - { - // - // No types outside of the system domain can even think about - // being agile - // - - goto exit; - } - - if (pMT->IsComObjectType()) - { - // - // No COM type is agile, as there is domain specific stuff in the sync block - // - - goto exit; - } - - if (pMT->IsInterface()) - { - // - // Don't mark interfaces agile - // - - goto exit; - } - - if (pMT->ContainsGenericVariables()) - { - // Types containing formal type parameters aren't agile - goto exit; - } - - // - // See if we need agile checking in the class - // - - GetPredefinedAgility(pMT->GetModule(), pMT->GetCl(), - &fAgile, &fCheckAgile); - - if (pMT->HasFinalizer()) - { - if (!fAgile && !fCheckAgile) - { - // - // If we're finalizable, we need domain affinity. Otherwise, we may appear - // to a particular app domain not to call the finalizer (since it may run - // in a different domain.) - // - // Note: do not change this assumption. The eager finalizaton code for - // appdomain unloading assumes that no obects other than those in mscorlib - // can be agile and finalizable - // - goto exit; - } - else - { - - // Note that a finalizable object will be considered potentially agile if it has one of the two - // predefined agility bits set. This will cause an assert in the eager finalization code if you add - // a finalizer to such a class - we don't want to have them as we can't run them eagerly and running - // them after we've cleared the roots/handles means it can't do much safely. Right now thread is the - // only one we allow. - _ASSERTE(g_pThreadClass == NULL || pMT->IsAgileAndFinalizable()); - } - } - - // - // Now see if the type is "naturally agile" - that is, it's type structure - // guarantees agility. - // - - if (pMT->GetParentMethodTable() != NULL) - { - EEClass * pParentClass = pMT->GetParentMethodTable()->GetClass(); - - // - // Make sure our parent was computed. This should only happen - // when we are prejitting - otherwise it is computed for each - // class as its loaded. - // - - _ASSERTE(pParentClass->IsAppDomainAgilityDone()); - - if (!pParentClass->IsAppDomainAgile()) - { - fFieldsAgile = FALSE; - if (fCheckAgile) - _ASSERTE(pParentClass->IsCheckAppDomainAgile()); - } - - // - // To save having to list a lot of trivial (layout-wise) subclasses, - // automatically check a subclass if its parent is checked and - // it introduces no new fields. - // - - if (!fCheckAgile - && pParentClass->IsCheckAppDomainAgile() - && pClass->GetNumInstanceFields() == pParentClass->GetNumInstanceFields()) - fCheckAgile = TRUE; - } - - nFields = pMT->GetNumInstanceFields() - - (pMT->GetParentMethodTable() == NULL ? 0 : pMT->GetParentMethodTable()->GetNumInstanceFields()); - - if (fFieldsAgile || fCheckAgile) - { - FieldDesc *pFD = pClass->GetFieldDescList(); - FieldDesc *pFDEnd = pFD + nFields; - while (pFD < pFDEnd) - { - switch (pFD->GetFieldType()) - { - case ELEMENT_TYPE_CLASS: - { - // - // There is a bit of a problem in computing the classes which are naturally agile - - // we don't want to load types of non-value type fields. So for now we'll - // err on the side of conservatism and not allow any non-value type fields other than - // the forced agile types listed above. - // - - MetaSig sig(pFD); - CorElementType type = sig.NextArg(); - SigPointer sigPtr = sig.GetArgProps(); - - // - // Don't worry about strings - // - - if (type == ELEMENT_TYPE_STRING) - break; - - // Find our field's token so we can proceed cautiously - mdToken token = mdTokenNil; - - if (type == ELEMENT_TYPE_CLASS) - IfFailThrow(sigPtr.GetToken(&token)); - - // - // First, a special check to see if the field is of our own type. - // - - if (token == pMT->GetCl() && pMT->IsSealed()) - break; - - // - // Now, look for the field's TypeHandle. - // - // @todo: there is some ifdef'd code here to to load the type if it's - // not already loading. This code has synchronization problems, as well - // as triggering more aggressive loading than normal. So it's disabled - // for now. - // - - TypeHandle th; -#if 0 - if (TypeFromToken(token) == mdTypeDef - && GetClassLoader()->FindUnresolvedClass(GetModule, token) == NULL) - th = pFD->GetFieldTypeHandleThrowing(); - else -#endif // 0 - th = pFD->LookupFieldTypeHandle(); - - // - // See if the referenced type is agile. Note that there is a reasonable - // chance that the type hasn't been loaded yet. If this is the case, - // we just have to assume that it's not agile, since we can't trigger - // extra loads here (for fear of circular recursion.) - // - // If you have an agile class which runs into this problem, you can solve it by - // setting the type manually to be agile. - // - - if (th.IsNull() - || !th.IsAppDomainAgile() - || (!th.IsTypeDesc() - && !th.AsMethodTable()->IsSealed())) - { - // - // Treat the field as non-agile. - // - - fFieldsAgile = FALSE; - if (fCheckAgile) - pFD->SetDangerousAppDomainAgileField(); - } - } - - break; - - case ELEMENT_TYPE_VALUETYPE: - { - TypeHandle th; - - { - // Loading a non-self-ref valuetype field. - OVERRIDE_TYPE_LOAD_LEVEL_LIMIT(CLASS_LOADED); - - th = pFD->GetApproxFieldTypeHandleThrowing(); - } - - _ASSERTE(!th.IsNull()); - - if (!th.IsAppDomainAgile()) - { - fFieldsAgile = FALSE; - if (fCheckAgile) - pFD->SetDangerousAppDomainAgileField(); - } - } - - break; - - default: - break; - } - - pFD++; - } - } - - if (fFieldsAgile || fAgile) - pClass->SetAppDomainAgile(); - - if (fCheckAgile && !fFieldsAgile) - pClass->SetCheckAppDomainAgile(); - -exit: - LOG((LF_CLASSLOADER, LL_INFO1000, "CLASSLOADER: AppDomainAgileAttribute for %s is %d\n", pClass->GetDebugClassName(), pClass->IsAppDomainAgile())); - pClass->SetAppDomainAgilityDone(); -} -#endif // defined(_DEBUG) - //******************************************************************************* // // Debugger notification @@ -2943,21 +2469,7 @@ void EEClass::Save(DataImage *image, MethodTable *pMT) LOG((LF_ZAP, LL_INFO10000, "EEClass::Save %s (%p)\n", m_szDebugClassName, this)); - // Optimize packable fields before saving into ngen image (the packable fields are located at the end of - // the EEClass or sub-type instance and packing will transform them into a space-efficient format which - // should reduce the result returned by the GetSize() call below). Packing will fail if the compression - // algorithm would result in an increase in size. We track this in the m_fFieldsArePacked data member - // which we use to determine whether to access the fields in their packed or unpacked format. - // Special case: we don't attempt to pack fields for the System.Threading.OverlappedData class since a - // host can change the size of this at runtime. This requires modifying one of the packable fields and we - // don't support updates to such fields if they were successfully packed. - if (g_pOverlappedDataClass == NULL) - { - g_pOverlappedDataClass = MscorlibBinder::GetClass(CLASS__OVERLAPPEDDATA); - _ASSERTE(g_pOverlappedDataClass); - } - if (this != g_pOverlappedDataClass->GetClass()) - m_fFieldsArePacked = GetPackedFields()->PackFields(); + m_fFieldsArePacked = GetPackedFields()->PackFields(); DWORD cbSize = GetSize(); diff --git a/src/vm/class.h b/src/vm/class.h index 7533e9c02c07..58b0c01e808f 100644 --- a/src/vm/class.h +++ b/src/vm/class.h @@ -1796,100 +1796,8 @@ class EEClass // DO NOT CREATE A NEW EEClass USING NEW! #if defined(_DEBUG) public: enum{ - AUXFLAG_APP_DOMAIN_AGILE = 0x00000001, - AUXFLAG_CHECK_APP_DOMAIN_AGILE = 0x00000002, - AUXFLAG_APP_DOMAIN_AGILITY_DONE = 0x00000004, - AUXFLAG_DESTROYED = 0x00000008, // The Destruct() method has already been called on this class + AUXFLAG_DESTROYED = 0x00000008, // The Destruct() method has already been called on this class }; - - inline DWORD GetAuxFlagsRaw() - { - LIMITED_METHOD_CONTRACT; - return m_wAuxFlags; - } - inline DWORD* GetAuxFlagsPtr() - { - LIMITED_METHOD_CONTRACT; - return (DWORD*)(&m_wAuxFlags); - } - inline void SetAuxFlags(DWORD flag) - { - LIMITED_METHOD_CONTRACT; - m_wAuxFlags |= (WORD)flag; - } - - // This flag is set (in a checked build only?) for classes whose - // instances are always app domain agile. This can - // be either because of type system guarantees or because - // the class is explicitly marked. - inline BOOL IsAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - return (m_wAuxFlags & AUXFLAG_APP_DOMAIN_AGILE); - } - inline void SetAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - m_wAuxFlags |= AUXFLAG_APP_DOMAIN_AGILE; - } - // This flag is set in a checked build for classes whose - // instances may be marked app domain agile, but agility - // isn't guaranteed by type safety. The JIT will compile - // in extra checks to field assignment on some fields - // in such a class. - inline BOOL IsCheckAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - return (m_wAuxFlags & AUXFLAG_CHECK_APP_DOMAIN_AGILE); - } - - inline void SetCheckAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - m_wAuxFlags |= AUXFLAG_CHECK_APP_DOMAIN_AGILE; - } - - // This flag is set in a checked build to indicate that the - // appdomain agility for a class had been set. This is used - // for debugging purposes to make sure that we don't allocate - // an object before the agility is set. - inline BOOL IsAppDomainAgilityDone() - { - LIMITED_METHOD_CONTRACT; - return (m_wAuxFlags & AUXFLAG_APP_DOMAIN_AGILITY_DONE); - } - inline void SetAppDomainAgilityDone() - { - LIMITED_METHOD_CONTRACT; - m_wAuxFlags |= AUXFLAG_APP_DOMAIN_AGILITY_DONE; - } - // - // This predicate checks whether or not the class is "naturally" - // app domain agile - that is: - // (1) it is in the system domain - // (2) all the fields are app domain agile - // (3) it has no finalizer - // - // Or, this also returns true for a proxy type which is allowed - // to have cross app domain refs. - // - inline BOOL IsTypesafeAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - return IsAppDomainAgile() && !IsCheckAppDomainAgile(); - } - // - // This predictate tests whether any instances are allowed - // to be app domain agile. - // - inline BOOL IsNeverAppDomainAgile() - { - LIMITED_METHOD_CONTRACT; - return !IsAppDomainAgile() && !IsCheckAppDomainAgile(); - } - static void SetAppDomainAgileAttribute(MethodTable * pMT); - - static void GetPredefinedAgility(Module *pModule, mdTypeDef td, BOOL *pfIsAgile, BOOL *pfIsCheckAgile); #endif // defined(_DEBUG) //------------------------------------------------------------- diff --git a/src/vm/classnames.h b/src/vm/classnames.h index 08286f801370..fec305232634 100644 --- a/src/vm/classnames.h +++ b/src/vm/classnames.h @@ -42,12 +42,10 @@ #define g_NotifyCollectionChangedEventHandlerName "System.Collections.Specialized.NotifyCollectionChangedEventHandler" #define g_NotifyCollectionChangedEventArgsName "System.Collections.Specialized.NotifyCollectionChangedEventArgs" #define g_NotifyCollectionChangedEventArgsMarshalerName "System.Runtime.InteropServices.WindowsRuntime.NotifyCollectionChangedEventArgsMarshaler" -#define g_WinRTNotifyCollectionChangedEventArgsNameW W("Windows.UI.Xaml.Interop.NotifyCollectionChangedEventArgs") #define g_INotifyPropertyChangedName "System.ComponentModel.INotifyPropertyChanged" #define g_PropertyChangedEventHandlerName "System.ComponentModel.PropertyChangedEventHandler" #define g_PropertyChangedEventArgsName "System.ComponentModel.PropertyChangedEventArgs" #define g_PropertyChangedEventArgsMarshalerName "System.Runtime.InteropServices.WindowsRuntime.PropertyChangedEventArgsMarshaler" -#define g_WinRTPropertyChangedEventArgsNameW W("Windows.UI.Xaml.Data.PropertyChangedEventArgs") #define g_WinRTIIteratorClassName "Windows.Foundation.Collections.IIterator`1" #define g_WinRTIIteratorClassNameW W("Windows.Foundation.Collections.IIterator`1") #define g_ICommandName "System.Windows.Input.ICommand" diff --git a/src/vm/codeversion.cpp b/src/vm/codeversion.cpp index cf756e14f9d9..2726a162961f 100644 --- a/src/vm/codeversion.cpp +++ b/src/vm/codeversion.cpp @@ -940,6 +940,9 @@ HRESULT ILCodeVersion::SetActiveNativeCodeVersion(NativeCodeVersion activeNative ILCodeVersionNode* ILCodeVersion::AsNode() { LIMITED_METHOD_CONTRACT; + //This is dangerous - NativeCodeVersion coerces non-explicit versions to NULL but ILCodeVersion assumes the caller + //will never invoke AsNode() on a non-explicit node. Asserting for now as a minimal fix, but we should revisit this. + _ASSERTE(m_storageKind == StorageKind::Explicit); return m_pVersionNode; } #endif //DACCESS_COMPILE @@ -947,6 +950,9 @@ ILCodeVersionNode* ILCodeVersion::AsNode() PTR_ILCodeVersionNode ILCodeVersion::AsNode() const { LIMITED_METHOD_DAC_CONTRACT; + //This is dangerous - NativeCodeVersion coerces non-explicit versions to NULL but ILCodeVersion assumes the caller + //will never invoke AsNode() on a non-explicit node. Asserting for now as a minimal fix, but we should revisit this. + _ASSERTE(m_storageKind == StorageKind::Explicit); return m_pVersionNode; } diff --git a/src/vm/comcallablewrapper.cpp b/src/vm/comcallablewrapper.cpp index e2ba05fb37f4..060519a91a9b 100644 --- a/src/vm/comcallablewrapper.cpp +++ b/src/vm/comcallablewrapper.cpp @@ -44,7 +44,6 @@ #include "caparser.h" #include "appdomain.inl" #include "rcwwalker.h" -#include "windowsruntimebufferhelper.h" #include "winrttypenameconverter.h" #include "typestring.h" @@ -1085,25 +1084,13 @@ VOID SimpleComCallWrapper::Cleanup() m_pWrap = NULL; m_pMT = NULL; - if (HasOverlappedRef()) + if (m_pCPList) { - if (m_operlappedPtr) - { - WindowsRuntimeBufferHelper::ReleaseOverlapped(m_operlappedPtr); - m_operlappedPtr = NULL; - } - UnMarkOverlappedRef(); - } - else - { - if (m_pCPList) // enum_HasOverlappedRef - { - for (UINT i = 0; i < m_pCPList->Size(); i++) - delete (*m_pCPList)[i]; + for (UINT i = 0; i < m_pCPList->Size(); i++) + delete (*m_pCPList)[i]; - delete m_pCPList; - m_pCPList = NULL; - } + delete m_pCPList; + m_pCPList = NULL; } // if this object was made agile, then we will have stashed away the original handle @@ -1426,8 +1413,6 @@ void SimpleComCallWrapper::SetUpCPList() CQuickArray SrcItfList; - _ASSERTE(!HasOverlappedRef()); - // If the list has already been set up, then return. if (m_pCPList) return; @@ -1450,8 +1435,6 @@ void SimpleComCallWrapper::SetUpCPListHelper(MethodTable **apSrcItfMTs, int cSrc PRECONDITION(CheckPointer(apSrcItfMTs)); } CONTRACTL_END; - - _ASSERTE(!HasOverlappedRef()); CPListHolder pCPList = NULL; ComCallWrapper *pWrap = GetMainWrapper(); @@ -1941,18 +1924,9 @@ IUnknown* SimpleComCallWrapper::QIStandardInterface(REFIID riid) CASE_IID_INLINE( enum_IAgileObject ,0x94ea2b94,0xe9cc,0x49e0,0xc0,0xff,0xee,0x64,0xca,0x8f,0x5b,0x90) { - // Don't implement IAgileObject if we are aggregated, if we are in a non AppX process, if the object explicitly implements IMarshal, - // or if its ICustomQI returns Failed or Handled for IID_IMarshal (compat). - // - // The AppX check was primarily done to ensure that we dont break VS in classic mode when it loads the desktop CLR since it needs - // objects to be non-Agile. In Apollo, we had objects agile in CoreCLR and even though we introduced AppX support in PhoneBlue, - // we should not constrain object agility using the desktop constraint, especially since VS does not rely on CoreCLR for its - // desktop execution. - // - // Keeping the Apollo behaviour also ensures that we allow SL 8.1 scenarios (which do not pass the AppX flag like the modern host) - // to use CorDispatcher for async, in the expected manner, as the OS implementation for CoreDispatcher expects objects to be Agile. - if (!IsAggregated() - ) + // Don't implement IAgileObject if we are aggregated, if the object explicitly implements IMarshal, or if its ICustomQI returns + // Failed or Handled for IID_IMarshal (compat). + if (!IsAggregated()) { ComCallWrapperTemplate *pTemplate = GetComCallWrapperTemplate(); if (!pTemplate->ImplementsIMarshal()) @@ -2046,9 +2020,7 @@ BOOL SimpleComCallWrapper::FindConnectionPoint(REFIID riid, IConnectionPoint **p PRECONDITION(CheckPointer(ppCP)); } CONTRACTL_END; - - _ASSERTE(!HasOverlappedRef()); - + // If the connection point list hasn't been set up yet, then set it up now. if (!m_pCPList) SetUpCPList(); @@ -2085,8 +2057,6 @@ void SimpleComCallWrapper::EnumConnectionPoints(IEnumConnectionPoints **ppEnumCP } CONTRACTL_END; - _ASSERTE(!HasOverlappedRef()); - // If the connection point list hasn't been set up yet, then set it up now. if (!m_pCPList) SetUpCPList(); diff --git a/src/vm/comcallablewrapper.h b/src/vm/comcallablewrapper.h index 1a68135e779e..152830e90757 100644 --- a/src/vm/comcallablewrapper.h +++ b/src/vm/comcallablewrapper.h @@ -1493,7 +1493,7 @@ struct SimpleComCallWrapper enum_IsObjectTP = 0x8, enum_IsAgile = 0x10, enum_IsPegged = 0x80, - enum_HasOverlappedRef = 0x100, + // unused = 0x100, enum_CustomQIRespondsToIMarshal = 0x200, enum_CustomQIRespondsToIMarshal_Inited = 0x400, }; @@ -1795,14 +1795,7 @@ public : FastInterlockAnd((ULONG*)&m_flags, ~enum_IsPegged); } - - inline BOOL HasOverlappedRef() - { - LIMITED_METHOD_DAC_CONTRACT; - - return m_flags & enum_HasOverlappedRef; - } - + // Used for the creation and deletion of simple wrappers static SimpleComCallWrapper* CreateSimpleWrapper(); @@ -2161,14 +2154,6 @@ public : return pWeakRef; } - void StoreOverlappedPointer(LPOVERLAPPED lpOverlapped) - { - LIMITED_METHOD_CONTRACT; - - this->m_operlappedPtr = lpOverlapped; - MarkOverlappedRef(); - } - // Returns TRUE if the ICustomQI implementation returns Handled or Failed for IID_IMarshal. BOOL CustomQIRespondsToIMarshal(); @@ -2210,14 +2195,7 @@ public : // QI for well known interfaces from within the runtime based on an IID. IUnknown* QIStandardInterface(REFIID riid); - // These values are never used at the same time, so we can save a few bytes for each CCW by using a union. - // Use the inline methods HasOverlappedRef(), MarkOverlappedRef(), and UnMarkOverlappedRef() to differentiate - // how this union is to be interpreted. - union - { - CQuickArray* m_pCPList; - LPOVERLAPPED m_operlappedPtr; - }; + CQuickArray* m_pCPList; // syncblock for the ObjecRef SyncBlock* m_pSyncBlock; @@ -2250,21 +2228,7 @@ public : // This maintains both COM ref and Jupiter ref in 64-bit LONGLONG m_llRefCount; - - inline void MarkOverlappedRef() - { - LIMITED_METHOD_CONTRACT; - - FastInterlockOr((ULONG*)&m_flags, enum_HasOverlappedRef); - } - - inline void UnMarkOverlappedRef() - { - LIMITED_METHOD_CONTRACT; - - FastInterlockAnd((ULONG*)&m_flags, ~enum_HasOverlappedRef); - } -}; + }; inline OBJECTHANDLE ComCallWrapper::GetObjectHandle() { diff --git a/src/vm/common.h b/src/vm/common.h index 044ebb017dd9..29311dbf9b13 100644 --- a/src/vm/common.h +++ b/src/vm/common.h @@ -66,6 +66,7 @@ #include +#include #include diff --git a/src/vm/compile.cpp b/src/vm/compile.cpp index b1c3f8cadbbd..52440523bd9e 100644 --- a/src/vm/compile.cpp +++ b/src/vm/compile.cpp @@ -68,6 +68,7 @@ #include "versionresilienthashcode.h" #include "inlinetracking.h" +#include "jithost.h" #ifdef CROSSGEN_COMPILE CompilationDomain * theDomain; @@ -1112,6 +1113,11 @@ void CEECompileInfo::CompressDebugInfo( CompressDebugInfo::CompressBoundariesAndVars(pOffsetMapping, iOffsetMapping, pNativeVarInfo, iNativeVarInfo, pDebugInfoBuffer, NULL); } +ICorJitHost* CEECompileInfo::GetJitHost() +{ + return JitHost::getJitHost(); +} + HRESULT CEECompileInfo::GetBaseJitFlags( IN CORINFO_METHOD_HANDLE hMethod, OUT CORJIT_FLAGS *pFlags) diff --git a/src/vm/compile.h b/src/vm/compile.h index 5be78c27bb79..fb664249c53a 100644 --- a/src/vm/compile.h +++ b/src/vm/compile.h @@ -355,6 +355,8 @@ class CEECompileInfo : public ICorCompileInfo IN CORINFO_METHOD_HANDLE hMethod, OUT CORJIT_FLAGS *pFlags); + ICorJitHost* GetJitHost(); + void* GetStubSize(void *pStubAddress, DWORD *pSizeToCopy); HRESULT GetStubClone(void *pStub, BYTE *pBuffer, DWORD dwBufferSize); diff --git a/src/vm/comthreadpool.cpp b/src/vm/comthreadpool.cpp index fcb51dc30139..b6d4106f9c85 100644 --- a/src/vm/comthreadpool.cpp +++ b/src/vm/comthreadpool.cpp @@ -559,7 +559,6 @@ struct BindIoCompletion_Args DWORD ErrorCode; DWORD numBytesTransferred; LPOVERLAPPED lpOverlapped; - BOOL *pfProcessed; }; void SetAsyncResultProperties( @@ -589,7 +588,6 @@ VOID BindIoCompletionCallBack_Worker(LPVOID args) OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(lpOverlapped)); GCPROTECT_BEGIN(overlapped); - *(((BindIoCompletion_Args *)args)->pfProcessed) = TRUE; // we set processed to TRUE, now it's our responsibility to guarantee proper cleanup #ifdef _DEBUG @@ -597,7 +595,7 @@ VOID BindIoCompletionCallBack_Worker(LPVOID args) LogCall(pMeth,"IOCallback"); #endif - if (overlapped->m_iocb != NULL) + if (overlapped->m_callback != NULL) { // Caution: the args are not protected, we have to garantee there's no GC from here till PREPARE_NONVIRTUAL_CALLSITE(METHOD__IOCB_HELPER__PERFORM_IOCOMPLETION_CALLBACK); @@ -612,7 +610,7 @@ VOID BindIoCompletionCallBack_Worker(LPVOID args) else { // no user delegate to callback - _ASSERTE((overlapped->m_iocbHelper == NULL) || !"This is benign, but should be optimized"); + _ASSERTE((overlapped->m_callback == NULL) || !"This is benign, but should be optimized"); SetAsyncResultProperties(overlapped, ErrorCode, numBytesTransferred); @@ -652,33 +650,8 @@ void __stdcall BindIoCompletionCallbackStubEx(DWORD ErrorCode, GCX_COOP(); - // NOTE: there is a potential race between the time we retrieve the app domain pointer, - // and the time which this thread enters the domain. - // - // To solve the race, we rely on the fact that there is a thread sync (via GC) - // between releasing an app domain's handle, and destroying the app domain. Thus - // it is important that we not go into preemptive gc mode in that window. - // - - //IMPORTANT - do not gc protect overlapped here - it belongs to another appdomain - //so if it stops being pinned it should be able to go away - OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(lpOverlapped)); - AppDomainFromIDHolder appDomain(ADID(overlapped->GetAppDomainId()), TRUE); - BOOL fProcessed = FALSE; - if (!appDomain.IsUnloaded()) - { - // this holder resets our thread's security state when exiting this scope, - // but only if setStack is TRUE. - Thread* pHolderThread = NULL; - if (setStack) - { - pHolderThread = pThread; - } - - BindIoCompletion_Args args = {ErrorCode, numBytesTransferred, lpOverlapped, &fProcessed}; - appDomain.Release(); - ManagedThreadBase::ThreadPool(ADID(overlapped->GetAppDomainId()), BindIoCompletionCallBack_Worker, &args); - } + BindIoCompletion_Args args = {ErrorCode, numBytesTransferred, lpOverlapped}; + ManagedThreadBase::ThreadPool((ADID)DefaultADID, BindIoCompletionCallBack_Worker, &args); LOG((LF_INTEROP, LL_INFO10000, "Leaving IO_CallBackStub thread 0x%x retCode 0x%x, overlap 0x%x\n", pThread, ErrorCode, lpOverlapped)); // We should have released all locks. @@ -751,7 +724,7 @@ FCIMPL1(FC_BOOL_RET, ThreadPoolNative::CorPostQueuedCompletionStatus, LPOVERLAPP HELPER_METHOD_FRAME_BEGIN_RET_1(overlapped); // Eventually calls BEGIN_SO_INTOLERANT_CODE_NOTHROW // OS doesn't signal handle, so do it here - overlapped->Internal = 0; + lpOverlapped->Internal = 0; if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, ThreadPoolIOEnqueue)) FireEtwThreadPoolIOEnqueue(lpOverlapped, OBJECTREFToObject(overlapped), false, GetClrInstanceId()); diff --git a/src/vm/crossgen/CMakeLists.txt b/src/vm/crossgen/CMakeLists.txt index fe1f7a38c9e9..75742b599ff0 100644 --- a/src/vm/crossgen/CMakeLists.txt +++ b/src/vm/crossgen/CMakeLists.txt @@ -45,6 +45,7 @@ set(VM_CROSSGEN_SOURCES ../invokeutil.cpp ../inlinetracking.cpp ../contractimpl.cpp + ../jithost.cpp ../jitinterface.cpp ../loaderallocator.cpp ../memberload.cpp diff --git a/src/vm/dataimage.cpp b/src/vm/dataimage.cpp index 4e276fe46031..c0e737a1bbac 100644 --- a/src/vm/dataimage.cpp +++ b/src/vm/dataimage.cpp @@ -749,8 +749,10 @@ FORCEINLINE static CorCompileSection GetSectionForNodeType(ZapNodeType type) return CORCOMPILE_SECTION_READONLY_WARM; case NodeTypeForItemKind(DataImage::ITEM_DICTIONARY): + return CORCOMPILE_SECTION_READONLY_DICTIONARY; + case NodeTypeForItemKind(DataImage::ITEM_VTABLE_CHUNK): - return CORCOMPILE_SECTION_READONLY_VCHUNKS_AND_DICTIONARY; + return CORCOMPILE_SECTION_READONLY_VCHUNKS; // SECTION_CLASS_COLD case NodeTypeForItemKind(DataImage::ITEM_PARAM_TYPEDESC): @@ -1465,7 +1467,7 @@ void DataImage::FixupTypeHandlePointer(TypeHandle th, PVOID p, SSIZE_T offset, Z { if (CanEagerBindToTypeHandle(th) && CanHardBindToZapModule(th.GetLoaderModule())) { - FixupField(p, offset, th.AsTypeDesc(), 2); + FixupField(p, offset, th.AsTypeDesc(), 2, type); } else { diff --git a/src/vm/ecalllist.h b/src/vm/ecalllist.h index df69bef58a9f..25bc85abce7d 100644 --- a/src/vm/ecalllist.h +++ b/src/vm/ecalllist.h @@ -433,6 +433,7 @@ FCFuncStart(gCOMClassWriter) QCFuncElement("SetFieldLayoutOffset", COMDynamicWrite::SetFieldLayoutOffset) QCFuncElement("SetClassLayout", COMDynamicWrite::SetClassLayout) QCFuncElement("SetParamInfo", COMDynamicWrite::SetParamInfo) + QCFuncElement("SetPInvokeData", COMDynamicWrite::SetPInvokeData) QCFuncElement("SetConstantValue", COMDynamicWrite::SetConstantValue) QCFuncElement("DefineCustomAttribute", COMDynamicWrite::DefineCustomAttribute) FCFuncEnd() @@ -460,7 +461,6 @@ FCFuncStart(gAppDomainFuncs) FCFuncElement("GetOrInternString", AppDomainNative::GetOrInternString) QCFuncElement("nSetupBindingPaths", AppDomainNative::SetupBindingPaths) QCFuncElement("nSetNativeDllSearchDirectories", AppDomainNative::SetNativeDllSearchDirectories) - FCFuncElement("IsFinalizingForUnload", AppDomainNative::IsFinalizingForUnload) FCFuncElement("PublishAnonymouslyHostedDynamicMethodsAssembly", AppDomainNative::PublishAnonymouslyHostedDynamicMethodsAssembly) #ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING FCFuncElement("nEnableMonitoring", AppDomainNative::EnableMonitoring) @@ -740,7 +740,6 @@ FCFuncEnd() FCFuncStart(gNumberFuncs) FCFuncElement("DoubleToNumber", COMNumber::DoubleToNumberFC) FCFuncElement("NumberToDouble", COMNumber::NumberToDoubleFC) - FCFuncElement("NumberBufferToDecimal", COMNumber::NumberBufferToDecimal) FCFuncEnd() #ifdef FEATURE_COMINTEROP @@ -760,26 +759,6 @@ FCFuncStart(gOAVariantFuncs) FCFuncEnd() #endif // FEATURE_COMINTEROP -FCFuncStart(gDecimalFuncs) - FCFuncElementSig(COR_CTOR_METHOD_NAME, &gsig_IM_Flt_RetVoid, COMDecimal::InitSingle) - FCFuncElementSig(COR_CTOR_METHOD_NAME, &gsig_IM_Dbl_RetVoid, COMDecimal::InitDouble) - FCFuncElement("FCallAddSub", COMDecimal::DoAddSubThrow) - FCFuncElement("FCallMultiply", COMDecimal::DoMultiplyThrow) - FCFuncElement("FCallDivide", COMDecimal::DoDivideThrow) - FCFuncElement("FCallCompare", COMDecimal::DoCompare) - FCFuncElement("FCallFloor", COMDecimal::DoFloor) - FCFuncElement("FCallRound", COMDecimal::DoRound) - FCFuncElement("FCallToCurrency", COMDecimal::DoToCurrency) - FCFuncElement("FCallToInt32", COMDecimal::ToInt32) - FCFuncElement("ToDouble", COMDecimal::ToDouble) - FCFuncElement("ToSingle", COMDecimal::ToSingle) - FCFuncElement("FCallTruncate", COMDecimal::DoTruncate) -FCFuncEnd() - -FCFuncStart(gCurrencyFuncs) - FCFuncElement("FCallToDecimal", COMCurrency::DoToDecimal) -FCFuncEnd() - FCFuncStart(gClrConfig) QCFuncElement("GetConfigBoolValue", ClrConfigNative::GetConfigBoolValue) FCFuncEnd() @@ -1054,11 +1033,6 @@ FCFuncStart(gUriMarshalerFuncs) FCFuncElement("CreateNativeUriInstanceHelper", StubHelpers::UriMarshaler__CreateNativeUriInstance) FCFuncEnd() -FCFuncStart(gEventArgsMarshalerFuncs) - QCFuncElement("CreateNativeNCCEventArgsInstanceHelper", StubHelpers::EventArgsMarshaler__CreateNativeNCCEventArgsInstance) - QCFuncElement("CreateNativePCEventArgsInstance", StubHelpers::EventArgsMarshaler__CreateNativePCEventArgsInstance) -FCFuncEnd() - FCFuncStart(gMngdSafeArrayMarshalerFuncs) FCFuncElement("CreateMarshaler", MngdSafeArrayMarshaler::CreateMarshaler) FCFuncElement("ConvertSpaceToNative", MngdSafeArrayMarshaler::ConvertSpaceToNative) @@ -1127,7 +1101,6 @@ FCFuncStart(gStubHelperFuncs) FCFuncElement("ProfilerEndTransitionCallback", StubHelpers::ProfilerEndTransitionCallback) #endif FCFuncElement("CreateCustomMarshalerHelper", StubHelpers::CreateCustomMarshalerHelper) - FCFuncElement("DecimalCanonicalizeInternal", StubHelpers::DecimalCanonicalizeInternal) FCFuncElement("FmtClassUpdateNativeInternal", StubHelpers::FmtClassUpdateNativeInternal) FCFuncElement("FmtClassUpdateCLRInternal", StubHelpers::FmtClassUpdateCLRInternal) FCFuncElement("LayoutDestroyNativeInternal", StubHelpers::LayoutDestroyNativeInternal) @@ -1185,8 +1158,10 @@ FCFuncStart(gEventPipeInternalFuncs) QCFuncElement("DefineEvent", EventPipeInternal::DefineEvent) QCFuncElement("DeleteProvider", EventPipeInternal::DeleteProvider) QCFuncElement("EventActivityIdControl", EventPipeInternal::EventActivityIdControl) + QCFuncElement("GetProvider", EventPipeInternal::GetProvider) QCFuncElement("WriteEvent", EventPipeInternal::WriteEvent) QCFuncElement("WriteEventData", EventPipeInternal::WriteEventData) + QCFuncElement("GetNextEvent", EventPipeInternal::GetNextEvent) FCFuncEnd() #endif // FEATURE_PERFTRACING @@ -1272,13 +1247,11 @@ FCClassElement("Buffer", "System", gBufferFuncs) FCClassElement("CLRConfig", "System", gClrConfig) FCClassElement("CompatibilitySwitch", "System.Runtime.Versioning", gCompatibilitySwitchFuncs) FCClassElement("CriticalHandle", "System.Runtime.InteropServices", gCriticalHandleFuncs) -FCClassElement("Currency", "System", gCurrencyFuncs) FCClassElement("CustomAttribute", "System.Reflection", gCOMCustomAttributeFuncs) FCClassElement("CustomAttributeEncodedArgument", "System.Reflection", gCustomAttributeEncodedArgument) FCClassElement("DateMarshaler", "System.StubHelpers", gDateMarshalerFuncs) FCClassElement("DateTime", "System", gDateTimeFuncs) FCClassElement("Debugger", "System.Diagnostics", gDiagnosticsDebugger) -FCClassElement("Decimal", "System", gDecimalFuncs) FCClassElement("DefaultBinder", "System", gCOMDefaultBinderFuncs) FCClassElement("Delegate", "System", gDelegateFuncs) FCClassElement("DependentHandle", "System.Runtime.CompilerServices", gDependentHandleFuncs) @@ -1287,9 +1260,6 @@ FCClassElement("EncodingTable", "System.Text", gEncodingTableFuncs) #endif // !defined(FEATURE_COREFX_GLOBALIZATION) FCClassElement("Enum", "System", gEnumFuncs) FCClassElement("Environment", "System", gEnvironmentFuncs) -#ifdef FEATURE_COMINTEROP -FCClassElement("EventArgsMarshaler", "System.StubHelpers", gEventArgsMarshalerFuncs) -#endif // FEATURE_COMINTEROP #if defined(FEATURE_PERFTRACING) FCClassElement("EventPipeInternal", "System.Diagnostics.Tracing", gEventPipeInternalFuncs) #endif // FEATURE_PERFTRACING diff --git a/src/vm/eeconfig.cpp b/src/vm/eeconfig.cpp index d9e7a06b8337..da4df9431920 100644 --- a/src/vm/eeconfig.cpp +++ b/src/vm/eeconfig.cpp @@ -1253,8 +1253,22 @@ HRESULT EEConfig::sync() { tieredCompilation_tier1CallCountThreshold = 1; } + tieredCompilation_tier1CallCountingDelayMs = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Tier1CallCountingDelayMs); + if (CPUGroupInfo::HadSingleProcessorAtStartup()) + { + DWORD delayMultiplier = + CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Tier1DelaySingleProcMultiplier); + if (delayMultiplier > 1) + { + DWORD newDelay = tieredCompilation_tier1CallCountingDelayMs * delayMultiplier; + if (newDelay / delayMultiplier == tieredCompilation_tier1CallCountingDelayMs) + { + tieredCompilation_tier1CallCountingDelayMs = newDelay; + } + } + } #endif #if defined(FEATURE_GDBJIT) && defined(_DEBUG) diff --git a/src/vm/eetwain.cpp b/src/vm/eetwain.cpp index cde9fe6fde2a..2be3781931b4 100644 --- a/src/vm/eetwain.cpp +++ b/src/vm/eetwain.cpp @@ -36,7 +36,8 @@ #define X86_INSTR_PUSH_EBP 0x55 // push ebp #define X86_INSTR_W_MOV_EBP_ESP 0xEC8B // mov ebp, esp #define X86_INSTR_POP_ECX 0x59 // pop ecx -#define X86_INSTR_RET 0xC2 // ret +#define X86_INSTR_RET 0xC2 // ret imm16 +#define X86_INSTR_RETN 0xC3 // ret #define X86_INSTR_w_LEA_ESP_EBP_BYTE_OFFSET 0x658d // lea esp, [ebp-bOffset] #define X86_INSTR_w_LEA_ESP_EBP_DWORD_OFFSET 0xa58d // lea esp, [ebp-dwOffset] #define X86_INSTR_JMP_NEAR_REL32 0xE9 // near jmp rel32 @@ -3880,19 +3881,9 @@ bool UnwindEbpDoubleAlignFrame( // epilog: add esp, 12 // ret // SP alignment padding should be added for all instructions except the first one and the last one. - TADDR funcletStart = pCodeInfo->GetJitManager()->GetFuncletStartAddress(pCodeInfo); - - const ULONG32 funcletLastInstSize = 1; // 0xc3, ret - BOOL atFuncletLastInst = (pCodeInfo->GetRelOffset() + funcletLastInstSize) >= info->methodSize; - if (!atFuncletLastInst) - { - EECodeInfo nextCodeInfo; - nextCodeInfo.Init(pCodeInfo->GetCodeAddress() + funcletLastInstSize); - atFuncletLastInst = !nextCodeInfo.IsValid() || !nextCodeInfo.IsFunclet() || - nextCodeInfo.GetJitManager()->GetFuncletStartAddress(&nextCodeInfo) != funcletStart; - } - - if (!atFuncletLastInst && funcletStart != pCodeInfo->GetCodeAddress()) + // Epilog may not exist (unreachable), so we need to check the instruction code. + const TADDR funcletStart = pCodeInfo->GetJitManager()->GetFuncletStartAddress(pCodeInfo); + if (funcletStart != pCodeInfo->GetCodeAddress() && methodStart[pCodeInfo->GetRelOffset()] != X86_INSTR_RETN) baseSP += 12; pContext->PCTAddr = baseSP; diff --git a/src/vm/eventpipe.cpp b/src/vm/eventpipe.cpp index fb112db72baa..955c757790d9 100644 --- a/src/vm/eventpipe.cpp +++ b/src/vm/eventpipe.cpp @@ -221,6 +221,7 @@ void EventPipe::EnableOnStartup() // Create a new session. EventPipeSession *pSession = new EventPipeSession( + EventPipeSessionType::File, 1024 /* 1 GB circular buffer */, NULL, /* pProviders */ 0 /* numProviders */); @@ -293,7 +294,11 @@ void EventPipe::Enable( CONTRACTL_END; // Create a new session. - EventPipeSession *pSession = s_pConfig->CreateSession(circularBufferSizeInMB, pProviders, static_cast(numProviders)); + EventPipeSession *pSession = s_pConfig->CreateSession( + (strOutputPath != NULL) ? EventPipeSessionType::File : EventPipeSessionType::Streaming, + circularBufferSizeInMB, + pProviders, + static_cast(numProviders)); // Enable the session. Enable(strOutputPath, pSession); @@ -329,8 +334,13 @@ void EventPipe::Enable(LPCWSTR strOutputPath, EventPipeSession *pSession) CrstHolder _crst(GetLock()); // Create the event pipe file. - SString eventPipeFileOutputPath(strOutputPath); - s_pFile = new EventPipeFile(eventPipeFileOutputPath); + // A NULL output path means that we should not write the results to a file. + // This is used in the EventListener streaming case. + if (strOutputPath != NULL) + { + SString eventPipeFileOutputPath(strOutputPath); + s_pFile = new EventPipeFile(eventPipeFileOutputPath); + } #ifdef _DEBUG if((CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EnableEventPipe) & 2) == 2) @@ -395,39 +405,39 @@ void EventPipe::Disable() FlushProcessWriteBuffers(); // Write to the file. - LARGE_INTEGER disableTimeStamp; - QueryPerformanceCounter(&disableTimeStamp); - s_pBufferManager->WriteAllBuffersToFile(s_pFile, disableTimeStamp); - - if(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeRundown) > 0) + if(s_pFile != NULL) { - // Before closing the file, do rundown. - const unsigned int numRundownProviders = 2; - EventPipeProviderConfiguration rundownProviders[] = - { - { W("Microsoft-Windows-DotNETRuntime"), 0x80020138, static_cast(EventPipeEventLevel::Verbose) }, // Public provider. - { W("Microsoft-Windows-DotNETRuntimeRundown"), 0x80020138, static_cast(EventPipeEventLevel::Verbose) } // Rundown provider. - }; - // The circular buffer size doesn't matter because all events are written synchronously during rundown. - s_pSession = s_pConfig->CreateSession(1 /* circularBufferSizeInMB */, rundownProviders, numRundownProviders); - s_pConfig->EnableRundown(s_pSession); - - // Ask the runtime to emit rundown events. - if(g_fEEStarted && !g_fEEShutDown) + LARGE_INTEGER disableTimeStamp; + QueryPerformanceCounter(&disableTimeStamp); + s_pBufferManager->WriteAllBuffersToFile(s_pFile, disableTimeStamp); + + if(CLRConfig::GetConfigValue(CLRConfig::INTERNAL_EventPipeRundown) > 0) { - ETW::EnumerationLog::EndRundown(); - } + // Before closing the file, do rundown. + const unsigned int numRundownProviders = 2; + EventPipeProviderConfiguration rundownProviders[] = + { + { W("Microsoft-Windows-DotNETRuntime"), 0x80020138, static_cast(EventPipeEventLevel::Verbose) }, // Public provider. + { W("Microsoft-Windows-DotNETRuntimeRundown"), 0x80020138, static_cast(EventPipeEventLevel::Verbose) } // Rundown provider. + }; + // The circular buffer size doesn't matter because all events are written synchronously during rundown. + s_pSession = s_pConfig->CreateSession(EventPipeSessionType::File, 1 /* circularBufferSizeInMB */, rundownProviders, numRundownProviders); + s_pConfig->EnableRundown(s_pSession); + + // Ask the runtime to emit rundown events. + if(g_fEEStarted && !g_fEEShutDown) + { + ETW::EnumerationLog::EndRundown(); + } - // Disable the event pipe now that rundown is complete. - s_pConfig->Disable(s_pSession); + // Disable the event pipe now that rundown is complete. + s_pConfig->Disable(s_pSession); - // Delete the rundown session. - s_pConfig->DeleteSession(s_pSession); - s_pSession = NULL; - } + // Delete the rundown session. + s_pConfig->DeleteSession(s_pSession); + s_pSession = NULL; + } - if(s_pFile != NULL) - { delete(s_pFile); s_pFile = NULL; } @@ -486,6 +496,25 @@ EventPipeProvider* EventPipe::CreateProvider(const SString &providerName, EventP } +EventPipeProvider* EventPipe::GetProvider(const SString &providerName) +{ + CONTRACTL + { + THROWS; + GC_NOTRIGGER; + MODE_ANY; + } + CONTRACTL_END; + + EventPipeProvider *pProvider = NULL; + if (s_pConfig != NULL) + { + pProvider = s_pConfig->GetProvider(providerName); + } + + return pProvider; +} + void EventPipe::DeleteProvider(EventPipeProvider *pProvider) { CONTRACTL @@ -756,7 +785,7 @@ bool EventPipe::WalkManagedStackForThread(Thread *pThread, StackContents &stackC StackWalkAction swaRet = pThread->StackWalkFrames( (PSTACKWALKFRAMESCALLBACK) &StackWalkCallback, &stackContents, - ALLOW_ASYNC_STACK_WALK | FUNCTIONSONLY | HANDLESKIPPEDFRAMES); + ALLOW_ASYNC_STACK_WALK | FUNCTIONSONLY | HANDLESKIPPEDFRAMES | ALLOW_INVALID_OBJECTS); return ((swaRet == SWA_DONE) || (swaRet == SWA_CONTINUE)); } @@ -975,6 +1004,28 @@ void EventPipe::SaveCommandLine(LPCWSTR pwzAssemblyPath, int argc, LPCWSTR *argv #endif } +EventPipeEventInstance* EventPipe::GetNextEvent() +{ + CONTRACTL + { + THROWS; + GC_TRIGGERS; + MODE_PREEMPTIVE; + } + CONTRACTL_END; + + EventPipeEventInstance *pInstance = NULL; + + // Only fetch the next event if a tracing session exists. + // The buffer manager is not disposed until the process is shutdown. + if (s_pSession != NULL) + { + pInstance = s_pBufferManager->GetNextEvent(); + } + + return pInstance; +} + void QCALLTYPE EventPipeInternal::Enable( __in_z LPCWSTR outputFile, UINT32 circularBufferSizeInMB, @@ -1041,6 +1092,22 @@ INT_PTR QCALLTYPE EventPipeInternal::DefineEvent( return reinterpret_cast(pEvent); } +INT_PTR QCALLTYPE EventPipeInternal::GetProvider( + __in_z LPCWSTR providerName) +{ + QCALL_CONTRACT; + + EventPipeProvider *pProvider = NULL; + + BEGIN_QCALL; + + pProvider = EventPipe::GetProvider(providerName); + + END_QCALL; + + return reinterpret_cast(pProvider); +} + void QCALLTYPE EventPipeInternal::DeleteProvider( INT_PTR provHandle) { @@ -1153,4 +1220,27 @@ void QCALLTYPE EventPipeInternal::WriteEventData( END_QCALL; } +bool QCALLTYPE EventPipeInternal::GetNextEvent( + EventPipeEventInstanceData *pInstance) +{ + QCALL_CONTRACT; + + EventPipeEventInstance *pNextInstance = NULL; + BEGIN_QCALL; + + _ASSERTE(pInstance != NULL); + + pNextInstance = EventPipe::GetNextEvent(); + if (pNextInstance) + { + pInstance->ProviderID = pNextInstance->GetEvent()->GetProvider(); + pInstance->EventID = pNextInstance->GetEvent()->GetEventID(); + pInstance->Payload = pNextInstance->GetData(); + pInstance->PayloadLength = pNextInstance->GetDataLength(); + } + + END_QCALL; + return pNextInstance != NULL; +} + #endif // FEATURE_PERFTRACING diff --git a/src/vm/eventpipe.h b/src/vm/eventpipe.h index 2becb5c0b876..1904d45d6cef 100644 --- a/src/vm/eventpipe.h +++ b/src/vm/eventpipe.h @@ -12,6 +12,7 @@ class CrstStatic; class CrawlFrame; class EventPipeConfiguration; class EventPipeEvent; +class EventPipeEventInstance; class EventPipeFile; class EventPipeJsonFile; class EventPipeBuffer; @@ -250,6 +251,9 @@ class EventPipe // Create a provider. static EventPipeProvider* CreateProvider(const SString &providerName, EventPipeCallback pCallbackFunction = NULL, void *pCallbackData = NULL); + // Get a provider. + static EventPipeProvider* GetProvider(const SString &providerName); + // Delete a provider. static void DeleteProvider(EventPipeProvider *pProvider); @@ -273,6 +277,9 @@ class EventPipe // Save the command line for the current process. static void SaveCommandLine(LPCWSTR pwzAssemblyPath, int argc, LPCWSTR *argv); + // Get next event. + static EventPipeEventInstance* GetNextEvent(); + protected: // The counterpart to WriteEvent which after the payload is constructed @@ -373,6 +380,15 @@ class EventPipeInternal EVENT_ACTIVITY_CONTROL_CREATE_SET_ID = 5 }; + struct EventPipeEventInstanceData + { + public: + void *ProviderID; + unsigned int EventID; + const BYTE *Payload; + unsigned int PayloadLength; + }; + public: static void QCALLTYPE Enable( @@ -397,6 +413,9 @@ class EventPipeInternal void *pMetadata, UINT32 metadataLength); + static INT_PTR QCALLTYPE GetProvider( + __in_z LPCWSTR providerName); + static void QCALLTYPE DeleteProvider( INT_PTR provHandle); @@ -417,6 +436,9 @@ class EventPipeInternal EventData *pEventData, UINT32 eventDataCount, LPCGUID pActivityId, LPCGUID pRelatedActivityId); + + static bool QCALLTYPE GetNextEvent( + EventPipeEventInstanceData *pInstance); }; #endif // FEATURE_PERFTRACING diff --git a/src/vm/eventpipebuffermanager.cpp b/src/vm/eventpipebuffermanager.cpp index 5f09295e95c7..060707bb3f87 100644 --- a/src/vm/eventpipebuffermanager.cpp +++ b/src/vm/eventpipebuffermanager.cpp @@ -29,6 +29,7 @@ EventPipeBufferManager::EventPipeBufferManager() m_numBuffersStolen = 0; m_numBuffersLeaked = 0; m_numEventsStored = 0; + m_numEventsDropped = 0; m_numEventsWritten = 0; #endif // _DEBUG } @@ -76,7 +77,7 @@ EventPipeBufferManager::~EventPipeBufferManager() } } -EventPipeBuffer* EventPipeBufferManager::AllocateBufferForThread(Thread *pThread, unsigned int requestSize) +EventPipeBuffer* EventPipeBufferManager::AllocateBufferForThread(EventPipeSession &session, Thread *pThread, unsigned int requestSize) { CONTRACTL { @@ -133,11 +134,14 @@ EventPipeBuffer* EventPipeBufferManager::AllocateBufferForThread(Thread *pThread } } + // Only steal buffers from other threads if the session being written to is a + // file-based session. Streaming sessions will simply drop events. + // TODO: Add dropped events telemetry here. EventPipeBuffer *pNewBuffer = NULL; - if(!allocateNewBuffer) + if(!allocateNewBuffer && (session.GetSessionType() == EventPipeSessionType::File)) { // We can't allocate a new buffer. - // Find the oldest buffer, zero it, and re-purpose it for this thread. + // Find the oldest buffer, de-allocate it, and re-purpose it for this thread. // Find the thread that contains the oldest stealable buffer, and get its list of buffers. EventPipeBufferList *pListToStealFrom = FindThreadToStealFrom(); @@ -179,7 +183,7 @@ EventPipeBuffer* EventPipeBufferManager::AllocateBufferForThread(Thread *pThread // Pick the base buffer size based. Debug builds have a smaller size to stress the allocate/steal path more. unsigned int baseBufferSize = #ifdef _DEBUG - 5 * 1024; // 5K + 30 * 1024; // 30K #else 100 * 1024; // 100K #endif @@ -192,6 +196,13 @@ EventPipeBuffer* EventPipeBufferManager::AllocateBufferForThread(Thread *pThread bufferSize = requestSize; } + // Don't allow the buffer size to exceed 1MB. + const unsigned int maxBufferSize = 1024 * 1024; + if(bufferSize > maxBufferSize) + { + bufferSize = maxBufferSize; + } + // EX_TRY is used here as opposed to new (nothrow) because // the constructor also allocates a private buffer, which // could throw, and cannot be easily checked @@ -363,7 +374,7 @@ bool EventPipeBufferManager::WriteEvent(Thread *pThread, EventPipeSession &sessi // to switch to preemptive mode here. unsigned int requestSize = sizeof(EventPipeEventInstance) + payload.GetSize(); - pBuffer = AllocateBufferForThread(pThread, requestSize); + pBuffer = AllocateBufferForThread(session, pThread, requestSize); } // Try to write the event after we allocated (or stole) a buffer. @@ -382,6 +393,10 @@ bool EventPipeBufferManager::WriteEvent(Thread *pThread, EventPipeSession &sessi { InterlockedIncrement(&m_numEventsStored); } + else + { + InterlockedIncrement(&m_numEventsDropped); + } #endif // _DEBUG return !allocNewBuffer; } @@ -458,6 +473,64 @@ void EventPipeBufferManager::WriteAllBuffersToFile(EventPipeFile *pFile, LARGE_I } } +EventPipeEventInstance* EventPipeBufferManager::GetNextEvent() +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + MODE_ANY; + } + CONTRACTL_END; + + // Take the lock before walking the buffer list. + SpinLockHolder _slh(&m_lock); + + // Naively walk the circular buffer, getting the event stream in timestamp order. + LARGE_INTEGER stopTimeStamp; + QueryPerformanceCounter(&stopTimeStamp); + while (true) + { + EventPipeEventInstance *pOldestInstance = NULL; + EventPipeBuffer *pOldestContainingBuffer = NULL; + EventPipeBufferList *pOldestContainingList = NULL; + SListElem *pElem = m_pPerThreadBufferList->GetHead(); + while (pElem != NULL) + { + EventPipeBufferList *pBufferList = pElem->GetValue(); + + // Peek the next event out of the list. + EventPipeBuffer *pContainingBuffer = NULL; + EventPipeEventInstance *pNext = pBufferList->PeekNextEvent(stopTimeStamp, &pContainingBuffer); + if (pNext != NULL) + { + // If it's the oldest event we've seen, then save it. + if ((pOldestInstance == NULL) || + (pOldestInstance->GetTimeStamp()->QuadPart > pNext->GetTimeStamp()->QuadPart)) + { + pOldestInstance = pNext; + pOldestContainingBuffer = pContainingBuffer; + pOldestContainingList = pBufferList; + } + } + + pElem = m_pPerThreadBufferList->GetNext(pElem); + } + + if (pOldestInstance == NULL) + { + // We're done. There are no more events. + return NULL; + } + + // Pop the event from the buffer. + pOldestContainingList->PopNextEvent(stopTimeStamp); + + // Return the oldest event that hasn't yet been processed. + return pOldestInstance; + } +} + void EventPipeBufferManager::DeAllocateBuffers() { CONTRACTL @@ -777,25 +850,22 @@ EventPipeEventInstance* EventPipeBufferList::PopNextEvent(LARGE_INTEGER beforeTi EventPipeBuffer *pContainingBuffer = NULL; EventPipeEventInstance *pNext = PeekNextEvent(beforeTimeStamp, &pContainingBuffer); - // If the event is non-NULL, pop it. - if(pNext != NULL && pContainingBuffer != NULL) + // Check to see if we need to clean-up the buffer that contained the previously popped event. + if(pContainingBuffer->GetPrevious() != NULL) { - pContainingBuffer->PopNext(beforeTimeStamp); - - // If the buffer is not the last buffer in the list and it has been drained, de-allocate it. - if((pContainingBuffer->GetNext() != NULL) && (pContainingBuffer->PeekNext(beforeTimeStamp) == NULL)) - { - // This buffer must be the head node of the list. - _ASSERTE(pContainingBuffer->GetPrevious() == NULL); + // Remove the previous node. The previous node should always be the head node. EventPipeBuffer *pRemoved = GetAndRemoveHead(); - _ASSERTE(pRemoved == pContainingBuffer); + _ASSERTE(pRemoved != pContainingBuffer); + _ASSERTE(pContainingBuffer == GetHead()); // De-allocate the buffer. m_pManager->DeAllocateBuffer(pRemoved); + } - // Reset the read buffer so that it becomes the head node on next peek or pop operation. - m_pReadBuffer = NULL; - } + // If the event is non-NULL, pop it. + if(pNext != NULL && pContainingBuffer != NULL) + { + pContainingBuffer->PopNext(beforeTimeStamp); } return pNext; diff --git a/src/vm/eventpipebuffermanager.h b/src/vm/eventpipebuffermanager.h index 87502ed6fc1b..b72648a764fe 100644 --- a/src/vm/eventpipebuffermanager.h +++ b/src/vm/eventpipebuffermanager.h @@ -43,13 +43,14 @@ class EventPipeBufferManager unsigned int m_numBuffersStolen; unsigned int m_numBuffersLeaked; Volatile m_numEventsStored; + Volatile m_numEventsDropped; LONG m_numEventsWritten; #endif // _DEBUG // Allocate a new buffer for the specified thread. // This function will store the buffer in the thread's buffer list for future use and also return it here. // A NULL return value means that a buffer could not be allocated. - EventPipeBuffer* AllocateBufferForThread(Thread *pThread, unsigned int requestSize); + EventPipeBuffer* AllocateBufferForThread(EventPipeSession &session, Thread *pThread, unsigned int requestSize); // Add a buffer to the thread buffer list. void AddBufferToThreadBufferList(EventPipeBufferList *pThreadBuffers, EventPipeBuffer *pBuffer); @@ -82,6 +83,9 @@ class EventPipeBufferManager // to free their buffer for a very long time. void DeAllocateBuffers(); + // Get next event. This is used to dispatch events to EventListener. + EventPipeEventInstance* GetNextEvent(); + #ifdef _DEBUG bool EnsureConsistency(); #endif // _DEBUG diff --git a/src/vm/eventpipeconfiguration.cpp b/src/vm/eventpipeconfiguration.cpp index 74d9f44abce0..571b0f11b171 100644 --- a/src/vm/eventpipeconfiguration.cpp +++ b/src/vm/eventpipeconfiguration.cpp @@ -309,7 +309,7 @@ size_t EventPipeConfiguration::GetCircularBufferSize() const return ret; } -EventPipeSession* EventPipeConfiguration::CreateSession(unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders) +EventPipeSession* EventPipeConfiguration::CreateSession(EventPipeSessionType sessionType, unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders) { CONTRACTL { @@ -319,7 +319,7 @@ EventPipeSession* EventPipeConfiguration::CreateSession(unsigned int circularBuf } CONTRACTL_END; - return new EventPipeSession(circularBufferSizeInMB, pProviders, numProviders); + return new EventPipeSession(sessionType, circularBufferSizeInMB, pProviders, numProviders); } void EventPipeConfiguration::DeleteSession(EventPipeSession *pSession) diff --git a/src/vm/eventpipeconfiguration.h b/src/vm/eventpipeconfiguration.h index 0f500bd73a0b..22b5cf9cc36a 100644 --- a/src/vm/eventpipeconfiguration.h +++ b/src/vm/eventpipeconfiguration.h @@ -15,6 +15,7 @@ class EventPipeEventInstance; class EventPipeProvider; struct EventPipeProviderConfiguration; class EventPipeSession; +enum class EventPipeSessionType; class EventPipeSessionProvider; enum class EventPipeEventLevel @@ -53,7 +54,7 @@ class EventPipeConfiguration EventPipeProvider* GetProvider(const SString &providerID); // Create a new session. - EventPipeSession* CreateSession(unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders); + EventPipeSession* CreateSession(EventPipeSessionType sessionType, unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders); // Delete a session. void DeleteSession(EventPipeSession *pSession); diff --git a/src/vm/eventpipesession.cpp b/src/vm/eventpipesession.cpp index 7fd7ac11cc96..5f6e415662ba 100644 --- a/src/vm/eventpipesession.cpp +++ b/src/vm/eventpipesession.cpp @@ -10,6 +10,7 @@ #ifdef FEATURE_PERFTRACING EventPipeSession::EventPipeSession( + EventPipeSessionType sessionType, unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders) @@ -22,6 +23,7 @@ EventPipeSession::EventPipeSession( } CONTRACTL_END; + m_sessionType = sessionType; m_circularBufferSizeInBytes = circularBufferSizeInMB * 1024 * 1024; // 1MB; m_rundownEnabled = false; m_pProviderList = new EventPipeSessionProviderList( diff --git a/src/vm/eventpipesession.h b/src/vm/eventpipesession.h index ba91c60aaa40..c8c2e1ff1b94 100644 --- a/src/vm/eventpipesession.h +++ b/src/vm/eventpipesession.h @@ -12,6 +12,12 @@ struct EventPipeProviderConfiguration; class EventPipeSessionProviderList; class EventPipeSessionProvider; +enum class EventPipeSessionType +{ + File, + Streaming +}; + class EventPipeSession { private: @@ -24,10 +30,15 @@ class EventPipeSession // True if rundown is enabled. Volatile m_rundownEnabled; + // The type of the session. + // This determines behavior within the system (e.g. policies around which events to drop, etc.) + EventPipeSessionType m_sessionType; + public: // TODO: This needs to be exposed via EventPipe::CreateSession() and EventPipe::DeleteSession() to avoid memory ownership issues. EventPipeSession( + EventPipeSessionType sessionType, unsigned int circularBufferSizeInMB, EventPipeProviderConfiguration *pProviders, unsigned int numProviders); @@ -37,6 +48,13 @@ class EventPipeSession // Determine if the session is valid or not. Invalid sessions can be detected before they are enabled. bool IsValid() const; + // Get the session type. + EventPipeSessionType GetSessionType() const + { + LIMITED_METHOD_CONTRACT; + return m_sessionType; + } + // Get the configured size of the circular buffer. size_t GetCircularBufferSize() const { diff --git a/src/vm/field.h b/src/vm/field.h index 8d5b17fb71ec..4962fce61860 100644 --- a/src/vm/field.h +++ b/src/vm/field.h @@ -80,9 +80,6 @@ class FieldDesc #endif #ifdef _DEBUG - struct { - unsigned m_isDangerousAppDomainAgileField : 1; - }; LPUTF8 m_debugName; #endif @@ -106,8 +103,6 @@ class FieldDesc m_type = sourceField.m_type; #ifdef _DEBUG - m_isDangerousAppDomainAgileField = sourceField.m_isDangerousAppDomainAgileField; - m_debugName = sourceField.m_debugName; #endif // _DEBUG } @@ -313,22 +308,6 @@ class FieldDesc ); } -#if defined(_DEBUG) - BOOL IsDangerousAppDomainAgileField() - { - LIMITED_METHOD_CONTRACT; - - return m_isDangerousAppDomainAgileField; - } - - void SetDangerousAppDomainAgileField() - { - LIMITED_METHOD_CONTRACT; - - m_isDangerousAppDomainAgileField = TRUE; - } -#endif - BOOL IsRVA() const // Has an explicit RVA associated with it { LIMITED_METHOD_DAC_CONTRACT; diff --git a/src/vm/fieldmarshaler.cpp b/src/vm/fieldmarshaler.cpp index 1015657bac3b..50f12a838d32 100644 --- a/src/vm/fieldmarshaler.cpp +++ b/src/vm/fieldmarshaler.cpp @@ -4200,12 +4200,7 @@ VOID FieldMarshaler_Currency::ScalarUpdateCLRImpl(const VOID *pNative, LPVOID pC // no need to switch to preemptive mode because it's very primitive operaion, doesn't take // long and is guaranteed not to call 3rd party code. // But if we do need to switch to preemptive mode, we can't pass the managed pointer to native code directly - HRESULT hr = VarDecFromCy( *(CURRENCY*)pNative, (DECIMAL *)pCLR ); - if (FAILED(hr)) - COMPlusThrowHR(hr); - - if (FAILED(DecimalCanonicalize((DECIMAL*)pCLR))) - COMPlusThrow(kOverflowException, W("Overflow_Currency")); + VarDecFromCyCanonicalize( *(CURRENCY*)pNative, (DECIMAL *)pCLR ); } VOID FieldMarshaler_DateTimeOffset::ScalarUpdateNativeImpl(LPVOID pCLR, LPVOID pNative) const diff --git a/src/vm/finalizerthread.cpp b/src/vm/finalizerthread.cpp index 48164f6279c1..62816ebacb2d 100644 --- a/src/vm/finalizerthread.cpp +++ b/src/vm/finalizerthread.cpp @@ -7,12 +7,12 @@ #include "finalizerthread.h" #include "threadsuspend.h" +#include "jithost.h" #ifdef FEATURE_COMINTEROP #include "runtimecallablewrapper.h" #endif - #ifdef FEATURE_PROFAPI_ATTACH_DETACH #include "profattach.h" #endif // FEATURE_PROFAPI_ATTACH_DETACH @@ -583,6 +583,8 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args) bPriorityBoosted = TRUE; } + JitHost::Reclaim(); + GetFinalizerThread()->DisablePreemptiveGC(); #ifdef _DEBUG diff --git a/src/vm/gccover.cpp b/src/vm/gccover.cpp index ed7b037d921b..2ba76d379169 100644 --- a/src/vm/gccover.cpp +++ b/src/vm/gccover.cpp @@ -913,7 +913,7 @@ bool replaceInterruptibleRangesWithGcStressInstr (UINT32 startOffset, UINT32 sto // We cannot insert GCStress instruction at this call // For arm64 & arm (R2R) call to jithelpers happens via a stub. // For other architectures call does not happen via stub. -// For other architecures we can get the target directly by calling getTargetOfCall(). +// For other architectures we can get the target directly by calling getTargetOfCall(). // This is not the case for arm64/arm so need to decode the stub // instruction to find the actual jithelper target. // For other architecture we detect call to JIT_RareDisableHelper diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index daf6fe8dbfbf..7f9d269432b2 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -1371,17 +1371,13 @@ void GCToEEInterface::WalkAsyncPinnedForPromotion(Object* object, ScanContext* s OverlappedDataObject *pOverlapped = (OverlappedDataObject *)object; if (pOverlapped->m_userObject != NULL) { - //callback(OBJECTREF_TO_UNCHECKED_OBJECTREF(pOverlapped->m_userObject), (ScanContext *)lp1, GC_CALL_PINNED); - if (pOverlapped->m_isArray) + if (pOverlapped->m_userObject->GetGCSafeMethodTable() == g_pPredefinedArrayTypes[ELEMENT_TYPE_OBJECT]->GetMethodTable()) { // OverlappedDataObject is very special. An async pin handle keeps it alive. // During GC, we also make sure // 1. m_userObject itself does not move if m_userObject is not array // 2. Every object pointed by m_userObject does not move if m_userObject is array - // We do not want to pin m_userObject if it is array. But m_userObject may be updated - // during relocation phase before OverlappedDataObject is doing relocation. - // m_userObjectInternal is used to track the location of the m_userObject before it is updated. - pOverlapped->m_userObjectInternal = static_cast(OBJECTREFToObject(pOverlapped->m_userObject)); + // We do not want to pin m_userObject if it is array. ArrayBase* pUserObject = (ArrayBase*)OBJECTREFToObject(pOverlapped->m_userObject); Object **ppObj = (Object**)pUserObject->GetDataPtr(TRUE); size_t num = pUserObject->GetNumComponents(); @@ -1395,11 +1391,6 @@ void GCToEEInterface::WalkAsyncPinnedForPromotion(Object* object, ScanContext* s callback(&OBJECTREF_TO_UNCHECKED_OBJECTREF(pOverlapped->m_userObject), (ScanContext *)sc, GC_CALL_PINNED); } } - - if (pOverlapped->GetAppDomainId() != DefaultADID && pOverlapped->GetAppDomainIndex().m_dwIndex == DefaultADID) - { - OverlappedDataObject::MarkCleanupNeededFromGC(); - } } void GCToEEInterface::WalkAsyncPinned(Object* object, void* context, void (*callback)(Object*, Object*, void*)) @@ -1419,7 +1410,7 @@ void GCToEEInterface::WalkAsyncPinned(Object* object, void* context, void (*call { Object * pUserObject = OBJECTREFToObject(pOverlapped->m_userObject); callback(object, pUserObject, context); - if (pOverlapped->m_isArray) + if (pOverlapped->m_userObject->GetGCSafeMethodTable() == g_pPredefinedArrayTypes[ELEMENT_TYPE_OBJECT]->GetMethodTable()) { ArrayBase* pUserArrayObject = (ArrayBase*)pUserObject; Object **pObj = (Object**)pUserArrayObject->GetDataPtr(TRUE); diff --git a/src/vm/generics.cpp b/src/vm/generics.cpp index 4ff877ed4394..b68054985ed3 100644 --- a/src/vm/generics.cpp +++ b/src/vm/generics.cpp @@ -324,7 +324,7 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation( // If none, we need to allocate space for the slots if (!canShareVtableChunks) { - allocSize += S_SIZE_T( cSlots ) * S_SIZE_T( sizeof(PCODE) ); + allocSize += S_SIZE_T( cSlots ) * S_SIZE_T( sizeof(MethodTable::VTableIndir2_t) ); } if (allocSize.IsOverflow()) @@ -446,7 +446,7 @@ ClassLoader::CreateTypeHandleForNonCanonicalGenericInstantiation( else { // Use the locally allocated chunk - it.SetIndirectionSlot((PTR_PCODE)(pMemory+offsetOfUnsharedVtableChunks)); + it.SetIndirectionSlot((MethodTable::VTableIndir2_t *)(pMemory+offsetOfUnsharedVtableChunks)); offsetOfUnsharedVtableChunks += it.GetSize(); } } diff --git a/src/vm/ilmarshalers.cpp b/src/vm/ilmarshalers.cpp index a72276ef4ad9..11b3e0b8d61b 100644 --- a/src/vm/ilmarshalers.cpp +++ b/src/vm/ilmarshalers.cpp @@ -1332,11 +1332,6 @@ void ILCurrencyMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* pslILEmit EmitLoadNativeValue(pslILEmit); pslILEmit->EmitCALL(METHOD__DECIMAL__CURRENCY_CTOR, 2, 0); - - EmitLoadManagedHomeAddr(pslILEmit); - - // static void System.StubHelpers.DecimalCanonicalizeInternal(ref Decimal dec); - pslILEmit->EmitCALL(METHOD__STUBHELPERS__DECIMAL_CANONICALIZE_INTERNAL, 1, 0); } diff --git a/src/vm/interopconverter.cpp b/src/vm/interopconverter.cpp index cb42f9cdfed7..e98d4addc977 100644 --- a/src/vm/interopconverter.cpp +++ b/src/vm/interopconverter.cpp @@ -574,7 +574,7 @@ void GetObjectRefFromComIP(OBJECTREF* pObjOut, IUnknown **ppUnk, MethodTable *pM } else { - *pObjOut = marshaler.FindOrCreateObjectRef(pUnk, pItfMT); + *pObjOut = marshaler.FindOrCreateObjectRef(pUnk, pItfMT); } } } diff --git a/src/vm/jithost.cpp b/src/vm/jithost.cpp new file mode 100644 index 000000000000..4a7783ef64fc --- /dev/null +++ b/src/vm/jithost.cpp @@ -0,0 +1,182 @@ +// 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. + +#include "common.h" + +#include "utilcode.h" +#include "corjit.h" +#include "jithost.h" + +void* JitHost::allocateMemory(size_t size) +{ + WRAPPER_NO_CONTRACT; + + return ClrAllocInProcessHeap(0, S_SIZE_T(size)); +} + +void JitHost::freeMemory(void* block) +{ + WRAPPER_NO_CONTRACT; + + ClrFreeInProcessHeap(0, block); +} + +int JitHost::getIntConfigValue(const wchar_t* name, int defaultValue) +{ + WRAPPER_NO_CONTRACT; + + // Translate JIT call into runtime configuration query + CLRConfig::ConfigDWORDInfo info{ name, defaultValue, CLRConfig::EEConfig_default }; + + // Perform a CLRConfig look up on behalf of the JIT. + return CLRConfig::GetConfigValue(info); +} + +const wchar_t* JitHost::getStringConfigValue(const wchar_t* name) +{ + WRAPPER_NO_CONTRACT; + + // Translate JIT call into runtime configuration query + CLRConfig::ConfigStringInfo info{ name, CLRConfig::EEConfig_default }; + + // Perform a CLRConfig look up on behalf of the JIT. + return CLRConfig::GetConfigValue(info); +} + +void JitHost::freeStringConfigValue(const wchar_t* value) +{ + WRAPPER_NO_CONTRACT; + + CLRConfig::FreeConfigString(const_cast(value)); +} + +// +// Pool memory blocks for JIT to avoid frequent commit/decommit. The frequent commit/decommit has been +// shown to slow down the JIT significantly (10% or more). The memory blocks used by the JIT tend to be too big +// to be covered by pooling done by the default malloc. +// +// - Keep up to some limit worth of memory, with loose affinization of memory blocks to threads. +// - On finalizer thread, release the extra memory that was not used recently. +// + +void* JitHost::allocateSlab(size_t size, size_t* pActualSize) +{ + size = max(size, sizeof(Slab)); + + Thread* pCurrentThread = GetThread(); + if (m_pCurrentCachedList != NULL || m_pPreviousCachedList != NULL) + { + CrstHolder lock(&m_jitSlabAllocatorCrst); + Slab** ppCandidate = NULL; + + for (Slab ** ppList = &m_pCurrentCachedList; *ppList != NULL; ppList = &(*ppList)->pNext) + { + Slab* p = *ppList; + if (p->size >= size && p->size <= 4 * size) // Avoid wasting more than 4x memory + { + ppCandidate = ppList; + if (p->affinity == pCurrentThread) + break; + } + } + + if (ppCandidate == NULL) + { + for (Slab ** ppList = &m_pPreviousCachedList; *ppList != NULL; ppList = &(*ppList)->pNext) + { + Slab* p = *ppList; + if (p->size == size) // Allocation from previous list requires exact match + { + ppCandidate = ppList; + if (p->affinity == pCurrentThread) + break; + } + } + } + + if (ppCandidate != NULL) + { + Slab* p = *ppCandidate; + *ppCandidate = p->pNext; + + m_totalCached -= p->size; + *pActualSize = p->size; + + return p; + } + } + + *pActualSize = size; + return ClrAllocInProcessHeap(0, S_SIZE_T(size)); +} + +void JitHost::freeSlab(void* slab, size_t actualSize) +{ + _ASSERTE(actualSize >= sizeof(Slab)); + + if (actualSize < 0x100000) // Do not cache blocks that are more than 1MB + { + CrstHolder lock(&m_jitSlabAllocatorCrst); + + if (m_totalCached < 0x1000000) // Do not cache more than 16MB + { + m_totalCached += actualSize; + + Slab* pSlab = (Slab*)slab; + pSlab->size = actualSize; + pSlab->affinity = GetThread(); + pSlab->pNext = m_pCurrentCachedList; + m_pCurrentCachedList = pSlab; + return; + } + } + + ClrFreeInProcessHeap(0, slab); +} + +void JitHost::init() +{ + m_jitSlabAllocatorCrst.Init(CrstLeafLock); +} + +void JitHost::reclaim() +{ + if (m_pCurrentCachedList != NULL || m_pPreviousCachedList != NULL) + { + DWORD ticks = ::GetTickCount(); + + if (m_lastFlush == 0) // Just update m_lastFlush first time around + { + m_lastFlush = ticks; + return; + } + + if ((DWORD)(ticks - m_lastFlush) < 2000) // Flush the free lists every 2 seconds + return; + m_lastFlush = ticks; + + // Flush all slabs in m_pPreviousCachedList + for (;;) + { + Slab* slabToDelete = NULL; + + { + CrstHolder lock(&m_jitSlabAllocatorCrst); + slabToDelete = m_pPreviousCachedList; + if (slabToDelete == NULL) + { + m_pPreviousCachedList = m_pCurrentCachedList; + m_pCurrentCachedList = NULL; + break; + } + m_totalCached -= slabToDelete->size; + m_pPreviousCachedList = slabToDelete->pNext; + } + + ClrFreeInProcessHeap(0, slabToDelete); + } + } +} + +JitHost JitHost::s_theJitHost; diff --git a/src/inc/jithost.h b/src/vm/jithost.h similarity index 50% rename from src/inc/jithost.h rename to src/vm/jithost.h index 73ad3343b597..b2ec67b3dee3 100644 --- a/src/inc/jithost.h +++ b/src/vm/jithost.h @@ -9,20 +9,41 @@ class JitHost : public ICorJitHost { private: - static JitHost theJitHost; + static JitHost s_theJitHost; + + struct Slab + { + Slab * pNext; + size_t size; + Thread* affinity; + }; + + CrstStatic m_jitSlabAllocatorCrst; + Slab* m_pCurrentCachedList; + Slab* m_pPreviousCachedList; + size_t m_totalCached; + DWORD m_lastFlush; JitHost() {} JitHost(const JitHost& other) = delete; JitHost& operator=(const JitHost& other) = delete; + void init(); + void reclaim(); + public: - virtual void* allocateMemory(size_t size, bool usePageAllocator); - virtual void freeMemory(void* block, bool usePageAllocator); + virtual void* allocateMemory(size_t size); + virtual void freeMemory(void* block); virtual int getIntConfigValue(const wchar_t* name, int defaultValue); virtual const wchar_t* getStringConfigValue(const wchar_t* name); virtual void freeStringConfigValue(const wchar_t* value); + virtual void* allocateSlab(size_t size, size_t* pActualSize); + virtual void freeSlab(void* slab, size_t actualSize); + + static void Init() { s_theJitHost.init(); } + static void Reclaim() { s_theJitHost.reclaim(); } - static ICorJitHost* getJitHost(); + static ICorJitHost* getJitHost() { return &s_theJitHost; } }; #endif // __JITHOST_H__ diff --git a/src/vm/jitinterface.cpp b/src/vm/jitinterface.cpp index ff8a89d26fc6..42cbc010b650 100644 --- a/src/vm/jitinterface.cpp +++ b/src/vm/jitinterface.cpp @@ -489,12 +489,14 @@ CEEInfo::ConvToJitSig( IfFailThrow(sig.GetCallingConvInfo(&data)); sigRet->callConv = (CorInfoCallConv) data; +#ifdef PLATFORM_UNIX if ((isCallConv(sigRet->callConv, IMAGE_CEE_CS_CALLCONV_VARARG)) || (isCallConv(sigRet->callConv, IMAGE_CEE_CS_CALLCONV_NATIVEVARARG))) { // This signature corresponds to a method that uses varargs, which are not supported. COMPlusThrow(kInvalidProgramException, IDS_EE_VARARG_NOT_SUPPORTED); } +#endif // PLATFORM_UNIX // Skip number of type arguments if (sigRet->callConv & IMAGE_CEE_CS_CALLCONV_GENERIC) @@ -1456,12 +1458,12 @@ static CorInfoHelpFunc getInstanceFieldHelper(FieldDesc * pField, CORINFO_ACCESS break; case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: - IN_WIN32(default:) + IN_TARGET_32BIT(default:) helper = CORINFO_HELP_GETFIELD32; break; case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: - IN_WIN64(default:) + IN_TARGET_64BIT(default:) helper = CORINFO_HELP_GETFIELD64; break; case ELEMENT_TYPE_R4: @@ -7045,7 +7047,8 @@ bool getILIntrinsicImplementationForUnsafe(MethodDesc * ftn, } else if (tk == MscorlibBinder::GetMethod(METHOD__UNSAFE__BYREF_AS)->GetMemberDef() || tk == MscorlibBinder::GetMethod(METHOD__UNSAFE__OBJECT_AS)->GetMemberDef() || - tk == MscorlibBinder::GetMethod(METHOD__UNSAFE__AS_REF)->GetMemberDef()) + tk == MscorlibBinder::GetMethod(METHOD__UNSAFE__AS_REF_POINTER)->GetMemberDef() || + tk == MscorlibBinder::GetMethod(METHOD__UNSAFE__AS_REF_IN)->GetMemberDef()) { // Return the argument that was passed in. static const BYTE ilcode[] = { CEE_LDARG_0, CEE_RET }; @@ -7301,9 +7304,9 @@ bool getILIntrinsicImplementationForVolatile(MethodDesc * ftn, // The implementation in mscorlib already does this, so we will only substitute a new // IL body if we're running on a 64-bit platform. // - IN_WIN64(VOLATILE_IMPL(Long, CEE_LDIND_I8, CEE_STIND_I8)) - IN_WIN64(VOLATILE_IMPL(ULong, CEE_LDIND_I8, CEE_STIND_I8)) - IN_WIN64(VOLATILE_IMPL(Dbl, CEE_LDIND_R8, CEE_STIND_R8)) + IN_TARGET_64BIT(VOLATILE_IMPL(Long, CEE_LDIND_I8, CEE_STIND_I8)) + IN_TARGET_64BIT(VOLATILE_IMPL(ULong, CEE_LDIND_I8, CEE_STIND_I8)) + IN_TARGET_64BIT(VOLATILE_IMPL(Dbl, CEE_LDIND_R8, CEE_STIND_R8)) }; mdMethodDef md = ftn->GetMemberDef(); @@ -8753,8 +8756,9 @@ void CEEInfo::getMethodVTableOffset (CORINFO_METHOD_HANDLE methodHnd, _ASSERTE(method->GetSlot() < method->GetMethodTable()->GetNumVirtuals()); *pOffsetOfIndirection = MethodTable::GetVtableOffset() + MethodTable::GetIndexOfVtableIndirection(method->GetSlot()) * sizeof(MethodTable::VTableIndir_t); - *pOffsetAfterIndirection = MethodTable::GetIndexAfterVtableIndirection(method->GetSlot()) * sizeof(PCODE); + *pOffsetAfterIndirection = MethodTable::GetIndexAfterVtableIndirection(method->GetSlot()) * sizeof(MethodTable::VTableIndir2_t); *isRelative = MethodTable::VTableIndir_t::isRelative ? 1 : 0; + _ASSERTE(MethodTable::VTableIndir_t::isRelative == MethodTable::VTableIndir2_t::isRelative); EE_TO_JIT_TRANSITION_LEAF(); } @@ -9132,8 +9136,17 @@ void CEEInfo::getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftnHnd, _ASSERTE((accessFlags & CORINFO_ACCESS_THIS) || !ftn->IsRemotingInterceptedViaVirtualDispatch()); - ret = ftn->GetAddrOfSlot(); - accessType = IAT_PVALUE; + ret = (void *)ftn->GetAddrOfSlot(); + + if (MethodTable::VTableIndir2_t::isRelative + && ftn->IsVtableSlot()) + { + accessType = IAT_RELPVALUE; + } + else + { + accessType = IAT_PVALUE; + } } @@ -13744,6 +13757,11 @@ void* CEEInfo::getTailCallCopyArgsThunk(CORINFO_SIG_INFO *pSig, return ftn; } +bool CEEInfo::convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, bool fMustConvert) +{ + return false; +} + void CEEInfo::allocMem ( ULONG hotCodeSize, /* IN */ ULONG coldCodeSize, /* IN */ diff --git a/src/vm/jitinterface.h b/src/vm/jitinterface.h index 1e4c8472041b..ebe64edbb9f4 100644 --- a/src/vm/jitinterface.h +++ b/src/vm/jitinterface.h @@ -950,6 +950,9 @@ class CEEInfo : public ICorJitInfo void* getTailCallCopyArgsThunk(CORINFO_SIG_INFO *pSig, CorInfoHelperTailCallSpecialHandling flags); + bool convertPInvokeCalliToCall(CORINFO_RESOLVED_TOKEN * pResolvedToken, + bool fMustConvert); + void getFunctionEntryPoint(CORINFO_METHOD_HANDLE ftn, /* IN */ CORINFO_CONST_LOOKUP * pResult, /* OUT */ CORINFO_ACCESS_FLAGS accessFlags = CORINFO_ACCESS_ANY); diff --git a/src/vm/metasig.h b/src/vm/metasig.h index 49e26f17e9cc..b3a4139a7c8a 100644 --- a/src/vm/metasig.h +++ b/src/vm/metasig.h @@ -290,6 +290,8 @@ DEFINE_METASIG(GM(RefByte_T_RetVoid, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, r(b) M(0) DEFINE_METASIG(GM(PtrVoid_RetT, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, P(v), M(0))) DEFINE_METASIG(GM(PtrVoid_T_RetVoid, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, P(v) M(0), v)) +DEFINE_METASIG(GM(RefT_RetRefT, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, r(M(0)), r(M(0)))) +DEFINE_METASIG(GM(VoidPtr_RetRefT, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, P(v), r(M(0)))) DEFINE_METASIG(GM(RefTFrom_RetRefTTo, IMAGE_CEE_CS_CALLCONV_DEFAULT, 2, r(M(0)), r(M(1)))) DEFINE_METASIG(GM(Obj_RetT, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, j, M(0))) DEFINE_METASIG(GM(RefT_Int_RetRefT, IMAGE_CEE_CS_CALLCONV_DEFAULT, 1, r(M(0)) i, r(M(0)))) diff --git a/src/vm/method.cpp b/src/vm/method.cpp index 815f9d217a26..68f54233ed0a 100644 --- a/src/vm/method.cpp +++ b/src/vm/method.cpp @@ -563,7 +563,7 @@ PCODE MethodDesc::GetMethodEntryPoint() return GetMethodTable_NoLogging()->GetSlot(GetSlot()); } -PTR_PCODE MethodDesc::GetAddrOfSlot() +TADDR MethodDesc::GetAddrOfSlot() { CONTRACTL { @@ -584,7 +584,7 @@ PTR_PCODE MethodDesc::GetAddrOfSlot() SIZE_T size = GetBaseSize(); - return PTR_PCODE(dac_cast(this) + size); + return dac_cast(this) + size; } _ASSERTE(GetMethodTable()->IsCanonicalMethodTable()); @@ -2342,7 +2342,15 @@ void MethodDesc::Reset() InterlockedUpdateFlags2(enum_flag2_HasStableEntryPoint | enum_flag2_HasPrecode, FALSE); - *GetAddrOfSlot() = GetTemporaryEntryPoint(); + TADDR slot = GetAddrOfSlot(); + if (IsVtableSlot()) + { + ((MethodTable::VTableIndir2_t *) slot)->SetValue(GetTemporaryEntryPoint()); + } + else + { + *((PCODE *) slot) = GetTemporaryEntryPoint(); + } } if (HasNativeCodeSlot()) @@ -4711,9 +4719,19 @@ void MethodDesc::SetTemporaryEntryPoint(LoaderAllocator *pLoaderAllocator, Alloc GetMethodDescChunk()->EnsureTemporaryEntryPointsCreated(pLoaderAllocator, pamTracker); - PTR_PCODE pSlot = GetAddrOfSlot(); - _ASSERTE(*pSlot == NULL); - *pSlot = GetTemporaryEntryPoint(); + TADDR slot = GetAddrOfSlot(); + if (IsVtableSlot()) + { + MethodTable::VTableIndir2_t *slotPtr = ((MethodTable::VTableIndir2_t *) slot); + _ASSERTE(slotPtr->IsNull()); + slotPtr->SetValue(GetTemporaryEntryPoint()); + } + else + { + PCODE *slotPtr = (PCODE *) slot; + _ASSERTE(*slotPtr == NULL); + *slotPtr = GetTemporaryEntryPoint(); + } if (RequiresStableEntryPoint()) { @@ -4776,7 +4794,7 @@ Precode* MethodDesc::GetOrCreatePrecode() return GetPrecode(); } - PTR_PCODE pSlot = GetAddrOfSlot(); + TADDR pSlot = GetAddrOfSlot(); PCODE tempEntry = GetTemporaryEntryPoint(); PrecodeType requiredType = GetPrecodeType(); @@ -4796,14 +4814,40 @@ Precode* MethodDesc::GetOrCreatePrecode() AllocMemTracker amt; Precode* pPrecode = Precode::Allocate(requiredType, this, GetLoaderAllocator(), &amt); - if (FastInterlockCompareExchangePointer(EnsureWritablePages(pSlot), pPrecode->GetEntryPoint(), tempEntry) == tempEntry) + PCODE newVal; + PCODE oldVal; + TADDR *slotAddr; + + if (IsVtableSlot()) + { + newVal = MethodTable::VTableIndir2_t::GetRelative(pSlot, pPrecode->GetEntryPoint()); + oldVal = MethodTable::VTableIndir2_t::GetRelative(pSlot, tempEntry); + slotAddr = (TADDR *) EnsureWritablePages((MethodTable::VTableIndir2_t *) pSlot); + } + else + { + newVal = pPrecode->GetEntryPoint(); + oldVal = tempEntry; + slotAddr = (TADDR *) EnsureWritablePages((PCODE *) pSlot); + } + + if (FastInterlockCompareExchangePointer(slotAddr, (TADDR) newVal, (TADDR) oldVal) == oldVal) amt.SuppressRelease(); } // Set the flags atomically InterlockedUpdateFlags2(enum_flag2_HasStableEntryPoint | enum_flag2_HasPrecode, TRUE); - return Precode::GetPrecodeFromEntryPoint(*pSlot); + PCODE addr; + if (IsVtableSlot()) + { + addr = ((MethodTable::VTableIndir2_t *)pSlot)->GetValue(); + } + else + { + addr = *((PCODE *)pSlot); + } + return Precode::GetPrecodeFromEntryPoint(addr); } //******************************************************************************* @@ -4857,10 +4901,28 @@ BOOL MethodDesc::SetStableEntryPointInterlocked(PCODE addr) _ASSERTE(!HasPrecode()); PCODE pExpected = GetTemporaryEntryPoint(); - PTR_PCODE pSlot = GetAddrOfSlot(); - EnsureWritablePages(pSlot); + TADDR pSlot = GetAddrOfSlot(); + + BOOL fResult; + + TADDR *slotAddr; + PCODE newVal; + PCODE oldVal; + + if (IsVtableSlot()) + { + newVal = MethodTable::VTableIndir2_t::GetRelative(pSlot, addr); + oldVal = MethodTable::VTableIndir2_t::GetRelative(pSlot, pExpected); + slotAddr = (TADDR *) EnsureWritablePages((MethodTable::VTableIndir2_t *) pSlot); + } + else + { + newVal = addr; + oldVal = pExpected; + slotAddr = (TADDR *) EnsureWritablePages((PCODE *) pSlot); + } - BOOL fResult = FastInterlockCompareExchangePointer(pSlot, addr, pExpected) == pExpected; + fResult = FastInterlockCompareExchangePointer(slotAddr, (TADDR) newVal, (TADDR) oldVal) == oldVal; InterlockedUpdateFlags2(enum_flag2_HasStableEntryPoint, TRUE); diff --git a/src/vm/method.hpp b/src/vm/method.hpp index fd91631214b1..3817b05fc312 100644 --- a/src/vm/method.hpp +++ b/src/vm/method.hpp @@ -1133,7 +1133,16 @@ class MethodDesc } } - PTR_PCODE GetAddrOfSlot(); + inline BOOL IsVirtualSlot() + { + return GetSlot() < GetMethodTable()->GetNumVirtuals(); + } + inline BOOL IsVtableSlot() + { + return IsVirtualSlot() && !HasNonVtableSlot(); + } + + TADDR GetAddrOfSlot(); PTR_MethodDesc GetDeclMethodDesc(UINT32 slotNumber); @@ -2574,7 +2583,7 @@ class NDirectMethodDesc : public MethodDesc }; // The writeable part of the methoddesc. -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativePointer m_pWriteableData; #else PlainPointer m_pWriteableData; @@ -3390,7 +3399,7 @@ class InstantiatedMethodDesc : public MethodDesc // // For generic method definitions that are not the typical method definition (e.g. C.m) // this field is null; to obtain the instantiation use LoadMethodInstantiation -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativePointer m_pPerInstInfo; //SHARED #else PlainPointer m_pPerInstInfo; //SHARED diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 75b4c6ce4912..aeb0c766f115 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -4297,7 +4297,8 @@ void MethodTable::Save(DataImage *image, DWORD profilingFlags) { if (!image->IsStored(it.GetIndirectionSlot())) { - if (CanInternVtableChunk(image, it)) + if (!MethodTable::VTableIndir2_t::isRelative + && CanInternVtableChunk(image, it)) image->StoreInternedStructure(it.GetIndirectionSlot(), it.GetSize(), DataImage::ITEM_VTABLE_CHUNK); else image->StoreStructure(it.GetIndirectionSlot(), it.GetSize(), DataImage::ITEM_VTABLE_CHUNK); @@ -4989,7 +4990,7 @@ void MethodTable::Fixup(DataImage *image) // Virtual slots live in chunks pointed to by vtable indirections slotBase = (PVOID) GetVtableIndirections()[GetIndexOfVtableIndirection(slotNumber)].GetValueMaybeNull(); - slotOffset = GetIndexAfterVtableIndirection(slotNumber) * sizeof(PCODE); + slotOffset = GetIndexAfterVtableIndirection(slotNumber) * sizeof(MethodTable::VTableIndir2_t); } else if (HasSingleNonVirtualSlot()) { @@ -5016,7 +5017,7 @@ void MethodTable::Fixup(DataImage *image) if (pMD->GetMethodTable() == this) { ZapRelocationType relocType; - if (slotNumber >= GetNumVirtuals()) + if (slotNumber >= GetNumVirtuals() || MethodTable::VTableIndir2_t::isRelative) relocType = IMAGE_REL_BASED_RelativePointer; else relocType = IMAGE_REL_BASED_PTR; @@ -5039,9 +5040,15 @@ void MethodTable::Fixup(DataImage *image) _ASSERTE(pSourceMT->GetMethodDescForSlot(slotNumber) == pMD); #endif + ZapRelocationType relocType; + if (MethodTable::VTableIndir2_t::isRelative) + relocType = IMAGE_REL_BASED_RELPTR; + else + relocType = IMAGE_REL_BASED_PTR; + if (image->CanEagerBindToMethodDesc(pMD) && pMD->GetLoaderModule() == pZapModule) { - pMD->FixupSlot(image, slotBase, slotOffset); + pMD->FixupSlot(image, slotBase, slotOffset, relocType); } else { @@ -5050,7 +5057,7 @@ void MethodTable::Fixup(DataImage *image) ZapNode * importThunk = image->GetVirtualImportThunk(pMD->GetMethodTable(), pMD, slotNumber); // On ARM, make sure that the address to the virtual thunk that we write into the // vtable "chunk" has the Thumb bit set. - image->FixupFieldToNode(slotBase, slotOffset, importThunk ARM_ARG(THUMB_CODE)); + image->FixupFieldToNode(slotBase, slotOffset, importThunk ARM_ARG(THUMB_CODE) NOT_ARM_ARG(0), relocType); } else { @@ -9790,7 +9797,15 @@ void MethodTable::SetSlot(UINT32 slotNumber, PCODE slotCode) _ASSERTE(IsThumbCode(slotCode)); #endif - *GetSlotPtrRaw(slotNumber) = slotCode; + TADDR slot = GetSlotPtrRaw(slotNumber); + if (slotNumber < GetNumVirtuals()) + { + ((MethodTable::VTableIndir2_t *) slot)->SetValueMaybeNull(slotCode); + } + else + { + *((PCODE *)slot) = slotCode; + } } //========================================================================================== diff --git a/src/vm/methodtable.h b/src/vm/methodtable.h index edb92f809903..98702961f35d 100644 --- a/src/vm/methodtable.h +++ b/src/vm/methodtable.h @@ -111,7 +111,7 @@ struct InterfaceInfo_t #endif // Method table of the interface -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativeFixupPointer m_pMethodTable; #else FixupPointer m_pMethodTable; @@ -1542,13 +1542,18 @@ class MethodTable WRAPPER_NO_CONTRACT; STATIC_CONTRACT_SO_TOLERANT; CONSISTENCY_CHECK(slotNumber < GetNumVtableSlots()); - PTR_PCODE pSlot = GetSlotPtrRaw(slotNumber); - if (IsZapped() && slotNumber >= GetNumVirtuals()) + + TADDR pSlot = GetSlotPtrRaw(slotNumber); + if (slotNumber < GetNumVirtuals()) + { + return VTableIndir2_t::GetValueMaybeNullAtPtr(pSlot); + } + else if (IsZapped() && slotNumber >= GetNumVirtuals()) { // Non-virtual slots in NGened images are relative pointers - return RelativePointer::GetValueAtPtr(dac_cast(pSlot)); + return RelativePointer::GetValueAtPtr(pSlot); } - return *pSlot; + return *dac_cast(pSlot); } // Special-case for when we know that the slot number corresponds @@ -1562,10 +1567,11 @@ class MethodTable DWORD index = GetIndexOfVtableIndirection(slotNum); TADDR base = dac_cast(&(GetVtableIndirections()[index])); - return *(VTableIndir_t::GetValueMaybeNullAtPtr(base) + GetIndexAfterVtableIndirection(slotNum)); + DPTR(VTableIndir2_t) baseAfterInd = VTableIndir_t::GetValueMaybeNullAtPtr(base) + GetIndexAfterVtableIndirection(slotNum); + return VTableIndir2_t::GetValueMaybeNullAtPtr(dac_cast(baseAfterInd)); } - PTR_PCODE GetSlotPtrRaw(UINT32 slotNum) + TADDR GetSlotPtrRaw(UINT32 slotNum) { WRAPPER_NO_CONTRACT; STATIC_CONTRACT_SO_TOLERANT; @@ -1576,25 +1582,26 @@ class MethodTable // Virtual slots live in chunks pointed to by vtable indirections DWORD index = GetIndexOfVtableIndirection(slotNum); TADDR base = dac_cast(&(GetVtableIndirections()[index])); - return VTableIndir_t::GetValueMaybeNullAtPtr(base) + GetIndexAfterVtableIndirection(slotNum); + DPTR(VTableIndir2_t) baseAfterInd = VTableIndir_t::GetValueMaybeNullAtPtr(base) + GetIndexAfterVtableIndirection(slotNum); + return dac_cast(baseAfterInd); } else if (HasSingleNonVirtualSlot()) { // Non-virtual slots < GetNumVtableSlots live in a single chunk pointed to by an optional member, // except when there is only one in which case it lives in the optional member itself _ASSERTE(slotNum == GetNumVirtuals()); - return dac_cast(GetNonVirtualSlotsPtr()); + return GetNonVirtualSlotsPtr(); } else { // Non-virtual slots < GetNumVtableSlots live in a single chunk pointed to by an optional member _ASSERTE(HasNonVirtualSlotsArray()); g_IBCLogger.LogMethodTableNonVirtualSlotsAccess(this); - return GetNonVirtualSlotsArray() + (slotNum - GetNumVirtuals()); + return dac_cast(GetNonVirtualSlotsArray() + (slotNum - GetNumVirtuals())); } } - PTR_PCODE GetSlotPtr(UINT32 slotNum) + TADDR GetSlotPtr(UINT32 slotNum) { WRAPPER_NO_CONTRACT; STATIC_CONTRACT_SO_TOLERANT; @@ -1660,10 +1667,12 @@ class MethodTable #define VTABLE_SLOTS_PER_CHUNK 8 #define VTABLE_SLOTS_PER_CHUNK_LOG2 3 -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) - typedef RelativePointer VTableIndir_t; +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) + typedef RelativePointer VTableIndir2_t; + typedef RelativePointer VTableIndir_t; #else - typedef PlainPointer VTableIndir_t; + typedef PlainPointer VTableIndir2_t; + typedef PlainPointer VTableIndir_t; #endif static DWORD GetIndexOfVtableIndirection(DWORD slotNum); @@ -1692,10 +1701,10 @@ class MethodTable BOOL Finished(); DWORD GetIndex(); DWORD GetOffsetFromMethodTable(); - PTR_PCODE GetIndirectionSlot(); + DPTR(VTableIndir2_t) GetIndirectionSlot(); #ifndef DACCESS_COMPILE - void SetIndirectionSlot(PTR_PCODE pChunk); + void SetIndirectionSlot(DPTR(VTableIndir2_t) pChunk); #endif DWORD GetStartSlot(); @@ -2173,7 +2182,7 @@ class MethodTable // THE METHOD TABLE PARENT (SUPERCLASS/BASE CLASS) // -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) #define PARENT_MT_FIXUP_OFFSET (-FIXUP_POINTER_INDIRECTION) typedef RelativeFixupPointer ParentMT_t; #else @@ -2205,7 +2214,7 @@ class MethodTable inline static PTR_VOID GetParentMethodTableOrIndirection(PTR_VOID pMT) { WRAPPER_NO_CONTRACT; -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) PTR_MethodTable pMethodTable = dac_cast(pMT); PTR_MethodTable pParentMT = ReadPointerMaybeNull((MethodTable*) pMethodTable, &MethodTable::m_pParentMethodTable); return dac_cast(pParentMT); @@ -3111,7 +3120,7 @@ class MethodTable // must have a dictionary entry. On the other hand, for instantiations shared with Dict the opposite holds. // -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) typedef RelativePointer PerInstInfoElem_t; typedef RelativePointer PerInstInfo_t; #else @@ -4182,7 +4191,7 @@ public : RelativePointer m_pLoaderModule; // LoaderModule. It is equal to the ZapModule in ngened images -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativePointer m_pWriteableData; #else PlainPointer m_pWriteableData; @@ -4198,7 +4207,7 @@ public : static const TADDR UNION_MASK = 3; union { -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativePointer m_pEEClass; RelativePointer m_pCanonMT; #else @@ -4233,7 +4242,7 @@ public : public: union { -#if defined(PLATFORM_UNIX) && defined(_TARGET_ARM_) +#if defined(FEATURE_NGEN_RELOCS_OPTIMIZATIONS) RelativePointer m_pInterfaceMap; #else PlainPointer m_pInterfaceMap; diff --git a/src/vm/methodtable.inl b/src/vm/methodtable.inl index 4fa81c931b06..9e5df0262c94 100644 --- a/src/vm/methodtable.inl +++ b/src/vm/methodtable.inl @@ -955,7 +955,7 @@ inline DWORD MethodTable::VtableIndirectionSlotIterator::GetOffsetFromMethodTabl } //========================================================================================== -inline PTR_PCODE MethodTable::VtableIndirectionSlotIterator::GetIndirectionSlot() +inline DPTR(MethodTable::VTableIndir2_t) MethodTable::VtableIndirectionSlotIterator::GetIndirectionSlot() { LIMITED_METHOD_DAC_CONTRACT; PRECONDITION(m_i != (DWORD) -1 && m_i < m_count); @@ -965,7 +965,7 @@ inline PTR_PCODE MethodTable::VtableIndirectionSlotIterator::GetIndirectionSlot( //========================================================================================== #ifndef DACCESS_COMPILE -inline void MethodTable::VtableIndirectionSlotIterator::SetIndirectionSlot(PTR_PCODE pChunk) +inline void MethodTable::VtableIndirectionSlotIterator::SetIndirectionSlot(DPTR(MethodTable::VTableIndir2_t) pChunk) { LIMITED_METHOD_CONTRACT; m_pSlot->SetValueMaybeNull(pChunk); diff --git a/src/vm/methodtablebuilder.cpp b/src/vm/methodtablebuilder.cpp index 0c1302eda183..ef9c37c5d578 100644 --- a/src/vm/methodtablebuilder.cpp +++ b/src/vm/methodtablebuilder.cpp @@ -1920,13 +1920,6 @@ MethodTableBuilder::BuildMethodTableThrowing( SetFinalizationSemantics(); -#if defined(_DEBUG) - // Figure out if we're domain agile.. - // Note that this checks a bunch of field directly on the class & method table, - // so it needs to come late in the game. - EEClass::SetAppDomainAgileAttribute(pMT); -#endif - // Allocate dynamic slot if necessary if (bmtProp->fDynamicStatics) { @@ -3870,8 +3863,8 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList, case ELEMENT_TYPE_I4: case ELEMENT_TYPE_U4: - IN_WIN32(case ELEMENT_TYPE_I:) - IN_WIN32(case ELEMENT_TYPE_U:) + IN_TARGET_32BIT(case ELEMENT_TYPE_I:) + IN_TARGET_32BIT(case ELEMENT_TYPE_U:) case ELEMENT_TYPE_R4: { dwLog2FieldSize = 2; @@ -3901,8 +3894,8 @@ VOID MethodTableBuilder::InitializeFieldDescs(FieldDesc *pFieldDescList, case ELEMENT_TYPE_I8: case ELEMENT_TYPE_U8: - IN_WIN64(case ELEMENT_TYPE_I:) - IN_WIN64(case ELEMENT_TYPE_U:) + IN_TARGET_64BIT(case ELEMENT_TYPE_I:) + IN_TARGET_64BIT(case ELEMENT_TYPE_U:) { #ifdef FEATURE_64BIT_ALIGNMENT // Record that this field requires alignment for Int64/UInt64. @@ -7458,7 +7451,7 @@ MethodTableBuilder::PlaceInterfaceMethods() else { // Iterate through the methods on the interface, and if they have a slot which was filled in - // on an equivalent interface inherited from the parent fill in the approrpriate slot. + // on an equivalent interface inherited from the parent fill in the appropriate slot. // This code path is only used when there is an implicit implementation of an interface // that was not implemented on a parent type, but there was an equivalent interface implemented // on a parent type. @@ -7726,7 +7719,7 @@ VOID MethodTableBuilder::PlaceRegularStaticFields() if (bmtProp->fDynamicStatics) { _ASSERTE(dwNonGCOffset == 0 || // no statics at all - dwNonGCOffset == DomainLocalModule::DynamicEntry::GetOffsetOfDataBlob()); // We need space to point to the GC statics + dwNonGCOffset == OFFSETOF__DomainLocalModule__NormalDynamicEntry__m_pDataBlob); // We need space to point to the GC statics bmtProp->dwNonGCRegularStaticFieldBytes = dwCumulativeStaticFieldPos; } else @@ -7848,7 +7841,7 @@ VOID MethodTableBuilder::PlaceThreadStaticFields() if (bmtProp->fDynamicStatics) { _ASSERTE(dwNonGCOffset == 0 || // no thread statics at all - dwNonGCOffset == ThreadLocalModule::DynamicEntry::GetOffsetOfDataBlob()); // We need space to point to the GC statics + dwNonGCOffset == OFFSETOF__ThreadLocalModule__DynamicEntry__m_pDataBlob); // We need space to point to the GC statics bmtProp->dwNonGCThreadStaticFieldBytes = dwCumulativeStaticFieldPos; } else @@ -7924,7 +7917,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach for (i = 0; i < MAX_LOG2_PRIMITIVE_FIELD_SIZE; i++) { DWORD j; - if (IS_ALIGNED(dwCumulativeInstanceFieldPos, 1<<(i+1))) + if (IS_ALIGNED(dwCumulativeInstanceFieldPos, size_t{ 1 } << (i + 1))) continue; // check whether there are any bigger fields @@ -7976,7 +7969,7 @@ VOID MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach } // Place the field - dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, 1 << i); + dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, size_t{ 1 } << i); pFieldDescList[j].SetOffset(dwCumulativeInstanceFieldPos - dwOffsetBias); dwCumulativeInstanceFieldPos += (1 << i); @@ -9986,7 +9979,7 @@ MethodTable * MethodTableBuilder::AllocateNewMT(Module *pLoaderModule, else { // Use the locally allocated chunk - it.SetIndirectionSlot((PTR_PCODE)(pData+dwCurrentUnsharedSlotOffset)); + it.SetIndirectionSlot((MethodTable::VTableIndir2_t *)(pData+dwCurrentUnsharedSlotOffset)); dwCurrentUnsharedSlotOffset += it.GetSize(); } } @@ -10552,7 +10545,7 @@ MethodTableBuilder::SetupMethodTable2( if (pMD->HasNonVtableSlot()) { - *pMD->GetAddrOfSlot() = addr; + *((PCODE *)pMD->GetAddrOfSlot()) = addr; } else { diff --git a/src/vm/methodtablebuilder.h b/src/vm/methodtablebuilder.h index 3054432c3579..a2275af24f5a 100644 --- a/src/vm/methodtablebuilder.h +++ b/src/vm/methodtablebuilder.h @@ -230,7 +230,6 @@ class MethodTableBuilder BOOL HasExplicitSize() { WRAPPER_NO_CONTRACT; return GetHalfBakedClass()->HasExplicitSize(); } #ifdef _DEBUG - BOOL IsAppDomainAgilityDone() { WRAPPER_NO_CONTRACT; return GetHalfBakedClass()->IsAppDomainAgilityDone(); } LPCUTF8 GetDebugClassName() { WRAPPER_NO_CONTRACT; return GetHalfBakedClass()->GetDebugClassName(); } #endif // _DEBUG Assembly *GetAssembly() { WRAPPER_NO_CONTRACT; return GetModule()->GetAssembly(); } diff --git a/src/vm/mlinfo.cpp b/src/vm/mlinfo.cpp index e5138db97ff7..12be6d3b95f1 100644 --- a/src/vm/mlinfo.cpp +++ b/src/vm/mlinfo.cpp @@ -894,7 +894,6 @@ void *EventArgsMarshalingInfo::operator new(size_t size, LoaderHeap *pHeap) RETURN mem; } - void EventArgsMarshalingInfo::operator delete(void *pMem) { LIMITED_METHOD_CONTRACT; @@ -912,10 +911,6 @@ EventArgsMarshalingInfo::EventArgsMarshalingInfo() } CONTRACTL_END; - // Create on-demand as we don't want to create the factories in NGEN time - m_pNCCEventArgsFactory = NULL; - m_pPCEventArgsFactory = NULL; - // Load the System.Collections.Specialized.NotifyCollectionChangedEventArgs class. SString qualifiedNCCEventArgsTypeName(SString::Utf8, NCCEVENTARGS_ASM_QUAL_TYPE_NAME); m_hndSystemNCCEventArgsType = TypeName::GetTypeFromAsmQualifiedName(qualifiedNCCEventArgsTypeName.GetUnicode(), FALSE); @@ -953,25 +948,7 @@ EventArgsMarshalingInfo::EventArgsMarshalingInfo() EventArgsMarshalingInfo::~EventArgsMarshalingInfo() { - CONTRACTL - { - NOTHROW; - GC_TRIGGERS; - MODE_ANY; - } - CONTRACTL_END; - - if (m_pNCCEventArgsFactory) - { - SafeRelease(m_pNCCEventArgsFactory); - m_pNCCEventArgsFactory = NULL; - } - - if (m_pPCEventArgsFactory) - { - SafeRelease(m_pPCEventArgsFactory); - m_pPCEventArgsFactory = NULL; - } + LIMITED_METHOD_CONTRACT; } void *UriMarshalingInfo::operator new(size_t size, LoaderHeap *pHeap) diff --git a/src/vm/mlinfo.h b/src/vm/mlinfo.h index d1b46065e413..b27dcc01c390 100644 --- a/src/vm/mlinfo.h +++ b/src/vm/mlinfo.h @@ -225,58 +225,6 @@ class EventArgsMarshalingInfo return m_hndSystemPCEventArgsType; } - ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *GetNCCEventArgsFactory() - { - CONTRACTL - { - THROWS; - GC_TRIGGERS; // For potential COOP->PREEMP->COOP switch - MODE_ANY; - PRECONDITION(!GetAppDomain()->IsCompilationDomain()); - } - CONTRACTL_END; - - if (m_pNCCEventArgsFactory.Load() == NULL) - { - GCX_PREEMP(); - SafeComHolderPreemp pNCCEventArgsFactory; - - IfFailThrow(clr::winrt::GetActivationFactory(g_WinRTNotifyCollectionChangedEventArgsNameW, (ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory **)&pNCCEventArgsFactory)); - _ASSERTE_MSG(pNCCEventArgsFactory, "Got NULL NCCEventArgs factory!"); - - if (InterlockedCompareExchangeT(&m_pNCCEventArgsFactory, (ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *)pNCCEventArgsFactory, NULL) == NULL) - pNCCEventArgsFactory.SuppressRelease(); - } - - return m_pNCCEventArgsFactory; - } - - ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *GetPCEventArgsFactory() - { - CONTRACTL - { - THROWS; - GC_TRIGGERS; // For potential COOP->PREEMP->COOP switch - MODE_ANY; - PRECONDITION(!GetAppDomain()->IsCompilationDomain()); - } - CONTRACTL_END; - - if (m_pPCEventArgsFactory.Load() == NULL) - { - GCX_PREEMP(); - SafeComHolderPreemp pPCEventArgsFactory; - - IfFailThrow(clr::winrt::GetActivationFactory(g_WinRTPropertyChangedEventArgsNameW, (ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory **)&pPCEventArgsFactory)); - _ASSERTE_MSG(pPCEventArgsFactory, "Got NULL PCEventArgs factory!"); - - if (InterlockedCompareExchangeT(&m_pPCEventArgsFactory, (ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *)pPCEventArgsFactory, NULL) == NULL) - pPCEventArgsFactory.SuppressRelease(); - } - - return m_pPCEventArgsFactory; - } - MethodDesc *GetSystemNCCEventArgsToWinRTNCCEventArgsMD() { LIMITED_METHOD_CONTRACT; @@ -310,9 +258,6 @@ class EventArgsMarshalingInfo MethodDesc *m_pWinRTNCCEventArgsToSystemNCCEventArgsMD; MethodDesc *m_pSystemPCEventArgsToWinRTPCEventArgsMD; MethodDesc *m_pWinRTPCEventArgsToSystemPCEventArgsMD; - - VolatilePtr m_pNCCEventArgsFactory; - VolatilePtr m_pPCEventArgsFactory; }; class UriMarshalingInfo diff --git a/src/vm/mscorlib.cpp b/src/vm/mscorlib.cpp index 53c3044f1a00..a526ebd35cb4 100644 --- a/src/vm/mscorlib.cpp +++ b/src/vm/mscorlib.cpp @@ -41,8 +41,6 @@ #include "comsynchronizable.h" #include "floatdouble.h" #include "floatsingle.h" -#include "decimal.h" -#include "currency.h" #include "comdatetime.h" #include "number.h" #include "compatibilityswitch.h" @@ -86,10 +84,6 @@ #include "multicorejit.h" #endif -#ifdef FEATURE_COMINTEROP -#include "windowsruntimebufferhelper.h" -#endif - #if defined(FEATURE_EVENTSOURCE_XPLAT) #include "nativeeventsource.h" #include "eventpipe.h" diff --git a/src/vm/mscorlib.h b/src/vm/mscorlib.h index 52dee0c81222..d6caea23a7c1 100644 --- a/src/vm/mscorlib.h +++ b/src/vm/mscorlib.h @@ -677,16 +677,15 @@ DEFINE_CLASS(OLE_AUT_BINDER, System, OleAutBinder) DEFINE_CLASS(MONITOR, Threading, Monitor) DEFINE_METHOD(MONITOR, ENTER, Enter, SM_Obj_RetVoid) -// Note: The size of the OverlappedData can be inflated by the CLR host -DEFINE_CLASS_U(Threading, OverlappedData, NoClass) -DEFINE_FIELD_U(m_asyncResult, OverlappedDataObject, m_asyncResult) -DEFINE_FIELD_U(m_iocb, OverlappedDataObject, m_iocb) -DEFINE_FIELD_U(m_iocbHelper, OverlappedDataObject, m_iocbHelper) -DEFINE_FIELD_U(m_overlapped, OverlappedDataObject, m_overlapped) -DEFINE_FIELD_U(m_userObject, OverlappedDataObject, m_userObject) -DEFINE_FIELD_U(m_pinSelf, OverlappedDataObject, m_pinSelf) -DEFINE_FIELD_U(m_AppDomainId, OverlappedDataObject, m_AppDomainId) -DEFINE_FIELD_U(m_isArray, OverlappedDataObject, m_isArray) +DEFINE_CLASS_U(Threading, OverlappedData, OverlappedDataObject) +DEFINE_FIELD_U(_asyncResult, OverlappedDataObject, m_asyncResult) +DEFINE_FIELD_U(_callback, OverlappedDataObject, m_callback) +DEFINE_FIELD_U(_overlapped, OverlappedDataObject, m_overlapped) +DEFINE_FIELD_U(_userObject, OverlappedDataObject, m_userObject) +DEFINE_FIELD_U(_pNativeOverlapped, OverlappedDataObject, m_pNativeOverlapped) +DEFINE_FIELD_U(_offsetLow, OverlappedDataObject, m_offsetLow) +DEFINE_FIELD_U(_offsetHigh, OverlappedDataObject, m_offsetHigh) +DEFINE_FIELD_U(_eventHandle, OverlappedDataObject, m_eventHandle) DEFINE_CLASS(OVERLAPPEDDATA, Threading, OverlappedData) DEFINE_CLASS(NATIVEOVERLAPPED, Threading, NativeOverlapped) @@ -776,7 +775,8 @@ DEFINE_METHOD(JIT_HELPERS, GET_RAW_SZ_ARRAY_DATA, GetRawSzArrayData, N DEFINE_CLASS(UNSAFE, InternalCompilerServices, Unsafe) DEFINE_METHOD(UNSAFE, AS_POINTER, AsPointer, NoSig) -DEFINE_METHOD(UNSAFE, AS_REF, AsRef, NoSig) +DEFINE_METHOD(UNSAFE, AS_REF_IN, AsRef, GM_RefT_RetRefT) +DEFINE_METHOD(UNSAFE, AS_REF_POINTER, AsRef, GM_VoidPtr_RetRefT) DEFINE_METHOD(UNSAFE, SIZEOF, SizeOf, NoSig) DEFINE_METHOD(UNSAFE, BYREF_AS, As, GM_RefTFrom_RetRefTTo) DEFINE_METHOD(UNSAFE, OBJECT_AS, As, GM_Obj_RetT) @@ -982,7 +982,7 @@ DEFINE_FIELD_U(m_handle, WeakReferenceObject, m_Handle) DEFINE_CLASS(WEAKREFERENCE, System, WeakReference) DEFINE_CLASS_U(Threading, WaitHandle, WaitHandleBase) -DEFINE_FIELD_U(safeWaitHandle, WaitHandleBase, m_safeHandle) +DEFINE_FIELD_U(_waitHandle, WaitHandleBase, m_safeHandle) DEFINE_FIELD_U(waitHandle, WaitHandleBase, m_handle) DEFINE_FIELD_U(hasThreadAffinity, WaitHandleBase, m_hasThreadAffinity) @@ -1041,7 +1041,6 @@ DEFINE_METHOD(STUBHELPERS, GET_HR_EXCEPTION_OBJECT, GetHRExceptionObjec DEFINE_METHOD(STUBHELPERS, CREATE_CUSTOM_MARSHALER_HELPER, CreateCustomMarshalerHelper, SM_IntPtr_Int_IntPtr_RetIntPtr) DEFINE_METHOD(STUBHELPERS, CHECK_STRING_LENGTH, CheckStringLength, SM_Int_RetVoid) -DEFINE_METHOD(STUBHELPERS, DECIMAL_CANONICALIZE_INTERNAL, DecimalCanonicalizeInternal, SM_RefDec_RetVoid) DEFINE_METHOD(STUBHELPERS, FMT_CLASS_UPDATE_NATIVE_INTERNAL, FmtClassUpdateNativeInternal, SM_Obj_PtrByte_RefCleanupWorkList_RetVoid) DEFINE_METHOD(STUBHELPERS, FMT_CLASS_UPDATE_CLR_INTERNAL, FmtClassUpdateCLRInternal, SM_Obj_PtrByte_RetVoid) diff --git a/src/vm/nativeoverlapped.cpp b/src/vm/nativeoverlapped.cpp index 6f053ea2673d..94e61c63fd46 100644 --- a/src/vm/nativeoverlapped.cpp +++ b/src/vm/nativeoverlapped.cpp @@ -22,11 +22,6 @@ #include "comthreadpool.h" #include "marshalnative.h" -LONG OverlappedDataObject::s_CleanupRequestCount = 0; -BOOL OverlappedDataObject::s_CleanupInProgress = FALSE; -BOOL OverlappedDataObject::s_GCDetectsCleanup = FALSE; -BOOL OverlappedDataObject::s_CleanupFreeHandle = FALSE; - // //The function is called from managed code to quicly check if a packet is available. //This is a perf-critical function. Even helper method frames are not created. We fall @@ -38,7 +33,6 @@ FCIMPL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, #ifndef FEATURE_PAL Thread *pThread = GetThread(); - DWORD adid = pThread->GetDomain()->GetId().m_dwId; size_t key=0; _ASSERTE(pThread); @@ -46,7 +40,7 @@ FCIMPL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, //Poll and wait if GC is in progress, to avoid blocking GC for too long. FC_GC_POLL(); - *lpOverlapped = ThreadpoolMgr::CompletionPortDispatchWorkWithinAppDomain(pThread, errorCode, numBytes, &key, adid); + *lpOverlapped = ThreadpoolMgr::CompletionPortDispatchWorkWithinAppDomain(pThread, errorCode, numBytes, &key, DefaultADID); if(*lpOverlapped == NULL) { return; @@ -54,17 +48,10 @@ FCIMPL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(*lpOverlapped)); - _ASSERTE(overlapped->GetAppDomainId() == adid); - - if(overlapped->m_iocb == NULL) + if (overlapped->m_callback == NULL) { - // no user delegate to callback - _ASSERTE((overlapped->m_iocbHelper == NULL) || !"This is benign, but should be optimized"); - - { - //We're not initialized yet, go back to the Vm, and process the packet there. - ThreadpoolMgr::StoreOverlappedInfoInThread(pThread, *errorCode, *numBytes, key, *lpOverlapped); - } + //We're not initialized yet, go back to the Vm, and process the packet there. + ThreadpoolMgr::StoreOverlappedInfoInThread(pThread, *errorCode, *numBytes, key, *lpOverlapped); *lpOverlapped = NULL; return; @@ -94,7 +81,7 @@ FCIMPL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, // if this will be "dispatched" to the managed callback fire the IODequeue event: if (*lpOverlapped != NULL && ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, ThreadPoolIODequeue)) - FireEtwThreadPoolIODequeue(*lpOverlapped, (BYTE*)(*lpOverlapped) - offsetof(OverlappedDataObject, Internal), GetClrInstanceId()); + FireEtwThreadPoolIODequeue(*lpOverlapped, OverlappedDataObject::GetOverlapped(*lpOverlapped), GetClrInstanceId()); #else // !FEATURE_PAL *lpOverlapped = NULL; @@ -104,17 +91,17 @@ FCIMPL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, } FCIMPLEND -FCIMPL1(void*, AllocateNativeOverlapped, OverlappedDataObject* overlappedUNSAFE) +FCIMPL1(LPOVERLAPPED, AllocateNativeOverlapped, OverlappedDataObject* overlappedUNSAFE) { FCALL_CONTRACT; + LPOVERLAPPED lpOverlapped; + OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(overlappedUNSAFE); OBJECTREF userObject = overlapped->m_userObject; HELPER_METHOD_FRAME_BEGIN_RET_ATTRIB_2(Frame::FRAME_ATTR_NONE, overlapped, userObject); - AsyncPinningHandleHolder handle; - if (g_pOverlappedDataClass == NULL) { g_pOverlappedDataClass = MscorlibBinder::GetClass(CLASS__OVERLAPPEDDATA); @@ -126,11 +113,9 @@ FCIMPL1(void*, AllocateNativeOverlapped, OverlappedDataObject* overlappedUNSAFE) CONSISTENCY_CHECK(overlapped->GetMethodTable() == g_pOverlappedDataClass); - overlapped->m_AppDomainId = GetAppDomain()->GetId().m_dwId; - if (userObject != NULL) { - if (overlapped->m_isArray == 1) + if (userObject->GetMethodTable() == g_pPredefinedArrayTypes[ELEMENT_TYPE_OBJECT]->GetMethodTable()) { BASEARRAYREF asArray = (BASEARRAYREF) userObject; OBJECTREF *pObj = (OBJECTREF*)(asArray->GetDataPtr()); @@ -140,33 +125,32 @@ FCIMPL1(void*, AllocateNativeOverlapped, OverlappedDataObject* overlappedUNSAFE) { ValidatePinnedObject(pObj[i]); } - for (i = 0; i < num; i ++) - { - asArray = (BASEARRAYREF) userObject; - AddMTForPinHandle(pObj[i]); - } } else { ValidatePinnedObject(userObject); - AddMTForPinHandle(userObject); } - } - handle = GetAppDomain()->CreateTypedHandle(overlapped, HNDTYPE_ASYNCPINNED); + NewHolder overlappedHolder(new NATIVEOVERLAPPED_AND_HANDLE()); + overlappedHolder->m_handle = GetAppDomain()->CreateTypedHandle(overlapped, HNDTYPE_ASYNCPINNED); + lpOverlapped = &(overlappedHolder.Extract()->m_overlapped); + lpOverlapped->Internal = 0; + lpOverlapped->InternalHigh = 0; + lpOverlapped->Offset = overlapped->m_offsetLow; + lpOverlapped->OffsetHigh = overlapped->m_offsetHigh; + lpOverlapped->hEvent = (HANDLE)overlapped->m_eventHandle; - handle.SuppressRelease(); - overlapped->m_pinSelf = handle; + overlapped->m_pNativeOverlapped = lpOverlapped; HELPER_METHOD_FRAME_END(); LOG((LF_INTEROP, LL_INFO10000, "In AllocNativeOperlapped thread 0x%x\n", GetThread())); if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, ThreadPoolIODequeue)) - FireEtwThreadPoolIOPack(&overlapped->Internal, overlappedUNSAFE, GetClrInstanceId()); + FireEtwThreadPoolIOPack(lpOverlapped, overlappedUNSAFE, GetClrInstanceId()); - return &overlapped->Internal; + return lpOverlapped; } FCIMPLEND @@ -176,28 +160,11 @@ FCIMPL1(void, FreeNativeOverlapped, LPOVERLAPPED lpOverlapped) HELPER_METHOD_FRAME_BEGIN_0(); - OVERLAPPEDDATAREF overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(lpOverlapped)); - CONSISTENCY_CHECK(g_pOverlappedDataClass && (overlapped->GetMethodTable() == g_pOverlappedDataClass)); + CONSISTENCY_CHECK(g_pOverlappedDataClass && (OverlappedDataObject::GetOverlapped(lpOverlapped)->GetMethodTable() == g_pOverlappedDataClass)); - // We don't want to call HasCompleted in the default domain, because we don't have - // overlapped handle support. - if ((!overlapped->HasCompleted ())) - { -#ifdef MDA_SUPPORTED - MdaOverlappedFreeError *pFreeError = MDA_GET_ASSISTANT(OverlappedFreeError); - if (pFreeError) - { - pFreeError->ReportError((LPVOID) OVERLAPPEDDATAREFToObject(overlapped)); - - // If we entered ReportError then our overlapped OBJECTREF became technically invalid, - // since a gc can be triggered. That causes an assert from FreeAsyncPinHandles() below. - // (I say technically because the object is pinned and won't really move) - overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(lpOverlapped)); - } -#endif // MDA_SUPPORTED - } + DestroyAsyncPinningHandle(((NATIVEOVERLAPPED_AND_HANDLE*)lpOverlapped)->m_handle); + delete lpOverlapped; - overlapped->FreeAsyncPinHandles(); HELPER_METHOD_FRAME_END(); } FCIMPLEND @@ -211,331 +178,3 @@ FCIMPL1(OverlappedDataObject*, GetOverlappedFromNative, LPOVERLAPPED lpOverlappe return OverlappedDataObject::GetOverlapped(lpOverlapped); } FCIMPLEND - -namespace -{ - -// Sets up an enumeration of all async pinned handles, such that all enumerated -// async pinned handles are processed by calling HandleAsyncPinHandle on the -// underlying overlapped instance. -BOOL HandleAsyncPinHandles() -{ - auto callback = [](Object* value, void*) - { - _ASSERTE (value->GetMethodTable() == g_pOverlappedDataClass); - OVERLAPPEDDATAREF overlapped = (OVERLAPPEDDATAREF)(ObjectToOBJECTREF(value)); - if (overlapped->GetAppDomainId() != DefaultADID && overlapped->HasCompleted()) - { - overlapped->HandleAsyncPinHandle(); - return true; - } - - return false; - }; - - IGCHandleManager* mgr = GCHandleUtilities::GetGCHandleManager(); - return mgr->GetGlobalHandleStore()->EnumerateAsyncPinnedHandles(callback, nullptr); -} - -} // anonymous namespace - -void OverlappedDataObject::FreeAsyncPinHandles() -{ - CONTRACTL - { - NOTHROW; - GC_NOTRIGGER; - MODE_COOPERATIVE; - SO_TOLERANT; - } - CONTRACTL_END; - - // This cannot throw or return error, and cannot force SO because it is called - // from CCLRIoCompletionManager::OnComplete which probes. - CONTRACT_VIOLATION(SOToleranceViolation); - - CONSISTENCY_CHECK(g_pOverlappedDataClass && (this->GetMethodTable() == g_pOverlappedDataClass)); - - _ASSERTE(GetThread() != NULL); - - if (m_pinSelf) - { - OBJECTHANDLE h = m_pinSelf; - if (FastInterlockCompareExchangePointer(&m_pinSelf, static_cast(NULL), h) == h) - { - DestroyAsyncPinningHandle(h); - } - } - - EventHandle = 0; -} - - -void OverlappedDataObject::StartCleanup() -{ - CONTRACTL - { - NOTHROW; - if (GetThread()) {MODE_COOPERATIVE;} else {DISABLED(MODE_COOPERATIVE);} - GC_TRIGGERS; - } - CONTRACTL_END; - - if (s_CleanupRequestCount == 0) - { - return; - } - - LONG curCount = s_CleanupRequestCount; - if (FastInterlockExchange((LONG*)&s_CleanupInProgress, TRUE) == FALSE) - { - { - BOOL HasJob = HandleAsyncPinHandles(); - if (!HasJob) - { - s_CleanupInProgress = FALSE; - FastInterlockExchangeAdd (&s_CleanupRequestCount, -curCount); - return; - } - } - - if (!ThreadpoolMgr::DrainCompletionPortQueue()) - { - s_CleanupInProgress = FALSE; - } - else - { - FastInterlockExchangeAdd (&s_CleanupRequestCount, -curCount); - } - } -} - - -void OverlappedDataObject::FinishCleanup(bool wasDrained) -{ - WRAPPER_NO_CONTRACT; - - if (wasDrained) - { - GCX_COOP(); - - s_CleanupFreeHandle = TRUE; - HandleAsyncPinHandles(); - s_CleanupFreeHandle = FALSE; - - s_CleanupInProgress = FALSE; - if (s_CleanupRequestCount > 0) - { - StartCleanup(); - } - } - else - { - s_CleanupInProgress = FALSE; - } -} - - -void OverlappedDataObject::HandleAsyncPinHandle() -{ - WRAPPER_NO_CONTRACT; - - _ASSERTE (s_CleanupInProgress); - if (m_toBeCleaned || !ThreadpoolMgr::IsCompletionPortInitialized()) - { - OBJECTHANDLE h = m_pinSelf; - if (h) - { - if (FastInterlockCompareExchangePointer(&m_pinSelf, (OBJECTHANDLE)NULL, h) == h) - { - DestroyAsyncPinningHandle(h); - } - } - } - else if (!s_CleanupFreeHandle) - { - m_toBeCleaned = 1; - } -} - - -// A hash table to track size of objects that may be moved to default domain -typedef EEHashTable, FALSE> EEHashTableOfMT; -EEHashTableOfMT *s_pPinHandleTable; - -CrstStatic s_PinHandleTableCrst; - -void InitializePinHandleTable() -{ - WRAPPER_NO_CONTRACT; - - s_PinHandleTableCrst.Init(CrstPinHandle); - LockOwner lock = {&s_PinHandleTableCrst, IsOwnerOfCrst}; - s_pPinHandleTable = new EEHashTableOfMT(); - s_pPinHandleTable->Init(10, &lock); -} - -// We can not fail due to OOM when we move an object to default domain during AD unload. -// If we may need a dummy MethodTable later, we allocate the MethodTable here. -void AddMTForPinHandle(OBJECTREF obj) -{ - CONTRACTL - { - THROWS; - WRAPPER(GC_TRIGGERS); - } - CONTRACTL_END; - - if (obj == NULL) - { - return; - } - - _ASSERTE (g_pOverlappedDataClass != NULL); - - SSIZE_T size = 0; - MethodTable *pMT = obj->GetMethodTable(); - - if (pMT->GetLoaderModule()->IsSystem()) - { - return; - } - - if (pMT->IsArray()) - { -#ifdef _DEBUG - BASEARRAYREF asArray = (BASEARRAYREF) obj; - TypeHandle th = asArray->GetArrayElementTypeHandle(); - _ASSERTE (!th.IsTypeDesc()); - MethodTable *pElemMT = th.AsMethodTable(); - _ASSERTE (pElemMT->IsValueType() && pElemMT->IsBlittable()); - _ASSERTE (!pElemMT->GetLoaderModule()->IsSystem()); -#endif - - // Create an ArrayMethodTable that has the same element size - // Use negative number for arrays of structs - it assumes that - // the maximum type base size is less than 2GB. - size = - (SSIZE_T)pMT->GetComponentSize(); - _ASSERTE(size < 0); - } - else - { - size = pMT->GetBaseSize(); - _ASSERTE(size >= 0); - } - - HashDatum data; - if (s_pPinHandleTable->GetValue(size, &data) == FALSE) - { - CrstHolder csh(&s_PinHandleTableCrst); - if (s_pPinHandleTable->GetValue(size, &data) == FALSE) - { - // We do not need to include GCDescr here, since this - // methodtable does not contain pointers. - BYTE *buffer = new BYTE[sizeof(MethodTable)]; - memset (buffer, 0, sizeof(MethodTable)); - MethodTable *pNewMT = (MethodTable *)buffer; - NewArrayHolder pMTHolder(buffer); - pNewMT->SetIsAsyncPinType(); - if (size >= 0) - { - pNewMT->SetBaseSize(static_cast(size)); - } - else - { - pNewMT->SetBaseSize(ARRAYBASE_BASESIZE); - pNewMT->SetComponentSize(static_cast(-size)); - } - s_pPinHandleTable->InsertValue(size, (HashDatum)pNewMT); - pMTHolder.SuppressRelease(); - } - } -} - -// We need to ensure that the MethodTable of an object is valid in default domain when the object -// is move to default domain duing AD unload. -void BashMTForPinnedObject(OBJECTREF obj) -{ - CONTRACTL - { - GC_NOTRIGGER; - NOTHROW; - } - CONTRACTL_END; - - if (obj == NULL) - { - return; - } - - ADIndex adIndx = obj->GetAppDomainIndex(); - ADIndex defaultAdIndx = SystemDomain::System()->DefaultDomain()->GetIndex(); - if (adIndx.m_dwIndex != 0 && adIndx != defaultAdIndx) - { - obj->GetHeader()->ResetAppDomainIndexNoFailure(defaultAdIndx); - } - SSIZE_T size = 0; - MethodTable *pMT = obj->GetMethodTable(); - - if (pMT == g_pOverlappedDataClass) - { - // Managed Overlapped - OVERLAPPEDDATAREF overlapped = (OVERLAPPEDDATAREF)(obj); - overlapped->m_asyncResult = NULL; - overlapped->m_iocb = NULL; - overlapped->m_iocbHelper = NULL; - overlapped->m_overlapped = NULL; - - if (overlapped->m_userObject != NULL) - { - if (overlapped->m_isArray == 1) - { - BASEARRAYREF asArray = (BASEARRAYREF) (overlapped->m_userObject); - OBJECTREF *pObj = (OBJECTREF*)asArray->GetDataPtr (TRUE); - SIZE_T num = asArray->GetNumComponents(); - for (SIZE_T i = 0; i < num; i ++) - { - BashMTForPinnedObject(pObj[i]); - } - } - else - { - BashMTForPinnedObject(overlapped->m_userObject); - } - } - STRESS_LOG1 (LF_APPDOMAIN | LF_GC, LL_INFO100, "OverlappedData %p:MT is bashed\n", OBJECTREFToObject (overlapped)); - return; - } - - if (pMT->GetLoaderModule()->IsSystem()) - { - return; - } - - if (pMT->IsArray()) - { -#ifdef _DEBUG - BASEARRAYREF asArray = (BASEARRAYREF) obj; - TypeHandle th = asArray->GetArrayElementTypeHandle(); - _ASSERTE (!th.IsTypeDesc()); - MethodTable *pElemMT = th.AsMethodTable(); - _ASSERTE (pElemMT->IsValueType() && pElemMT->IsBlittable()); - _ASSERTE (!pElemMT->GetLoaderModule()->IsSystem()); -#endif - - // Create an ArrayMethodTable that has the same element size - size = - (SSIZE_T)pMT->GetComponentSize(); - } - else - { - _ASSERTE (pMT->IsBlittable()); - size = pMT->GetBaseSize(); - } - - HashDatum data = NULL; - BOOL fRet; - fRet = s_pPinHandleTable->GetValue(size, &data); - _ASSERTE(fRet); - PREFIX_ASSUME(data != NULL); - obj->SetMethodTable((MethodTable*)data); -} diff --git a/src/vm/nativeoverlapped.h b/src/vm/nativeoverlapped.h index 7f12f477e85d..e1ffb886b6b5 100644 --- a/src/vm/nativeoverlapped.h +++ b/src/vm/nativeoverlapped.h @@ -16,118 +16,50 @@ #ifndef _OVERLAPPED_H #define _OVERLAPPED_H +struct NATIVEOVERLAPPED_AND_HANDLE +{ + OVERLAPPED m_overlapped; + OBJECTHANDLE m_handle; +}; + // This should match the managed Overlapped object. // If you make any change here, you need to change the managed part Overlapped. class OverlappedDataObject : public Object { public: - OBJECTREF m_asyncResult; - OBJECTREF m_iocb; - OBJECTREF m_iocbHelper; - OBJECTREF m_overlapped; - OBJECTREF m_userObject; - - // - // NOTE! WCF directly accesses m_pinSelf from managed code, using a hard-coded negative - // offset from the Internal member, below. They need this so they can modify the - // contents of m_userObject; after such modification, they need to update this handle - // to be in the correct GC generation. - // - // If you need to add or remove fields between this one and Internal, be sure that - // you also fix the hard-coded offsets in ndp\cdf\src\WCF\ServiceModel\System\ServiceModel\Channels\OverlappedContext.cs. - // - OBJECTHANDLE m_pinSelf; - // OverlappedDataObject is very special. An async pin handle keeps it alive. // During GC, we also make sure // 1. m_userObject itself does not move if m_userObject is not array // 2. Every object pointed by m_userObject does not move if m_userObject is array - // We do not want to pin m_userObject if it is array. But m_userObject may be updated - // during relocation phase before OverlappedDataObject is doing relocation. - // m_userObjectInternal is used to track the location of the m_userObject before it is updated. - void *m_userObjectInternal; - DWORD m_AppDomainId; - unsigned char m_isArray; - unsigned char m_toBeCleaned; - - ULONG_PTR Internal; - ULONG_PTR InternalHigh; - int OffsetLow; - int OffsetHigh; - ULONG_PTR EventHandle; - - static OverlappedDataObject* GetOverlapped (LPOVERLAPPED nativeOverlapped) + OBJECTREF m_asyncResult; + OBJECTREF m_callback; + OBJECTREF m_overlapped; + OBJECTREF m_userObject; + LPOVERLAPPED m_pNativeOverlapped; + ULONG_PTR m_eventHandle; + int m_offsetLow; + int m_offsetHigh; + +#ifndef DACCESS_COMPILE + static OverlappedDataObject* GetOverlapped(LPOVERLAPPED nativeOverlapped) { LIMITED_METHOD_CONTRACT; STATIC_CONTRACT_SO_TOLERANT; _ASSERTE (nativeOverlapped != NULL); - _ASSERTE (GCHeapUtilities::GetGCHeap()->IsHeapPointer((BYTE *) nativeOverlapped)); - - return (OverlappedDataObject*)((BYTE*)nativeOverlapped - offsetof(OverlappedDataObject, Internal)); + return (OverlappedDataObject*)OBJECTREFToObject(ObjectFromHandle(((NATIVEOVERLAPPED_AND_HANDLE*)nativeOverlapped)->m_handle)); } - DWORD GetAppDomainId() - { - return m_AppDomainId; - } - - void HandleAsyncPinHandle(); - - void FreeAsyncPinHandles(); - - BOOL HasCompleted() + // Return the raw OverlappedDataObject* without going into cooperative mode for tracing + static OverlappedDataObject* GetOverlappedForTracing(LPOVERLAPPED nativeOverlapped) { LIMITED_METHOD_CONTRACT; -#ifndef FEATURE_PAL - return HasOverlappedIoCompleted((LPOVERLAPPED) &Internal); -#else // !FEATURE_PAL - return FALSE; -#endif // !FEATURE_PAL - } - -private: - static LONG s_CleanupRequestCount; - static BOOL s_CleanupInProgress; - static BOOL s_GCDetectsCleanup; - static BOOL s_CleanupFreeHandle; - -public: - static void RequestCleanup() - { - WRAPPER_NO_CONTRACT; - - FastInterlockIncrement(&s_CleanupRequestCount); - if (!s_CleanupInProgress) - { - StartCleanup(); - } - } - static void StartCleanup(); - - static void FinishCleanup(bool wasDrained); - - static void MarkCleanupNeededFromGC() - { - LIMITED_METHOD_CONTRACT; - s_GCDetectsCleanup = TRUE; - } - - static BOOL CleanupNeededFromGC() - { - return s_GCDetectsCleanup; - } - - static void RequestCleanupFromGC() - { - WRAPPER_NO_CONTRACT; + STATIC_CONTRACT_SO_TOLERANT; - if (s_GCDetectsCleanup) - { - s_GCDetectsCleanup = FALSE; - RequestCleanup(); - } + _ASSERTE(nativeOverlapped != NULL); + return *(OverlappedDataObject**)(((NATIVEOVERLAPPED_AND_HANDLE*)nativeOverlapped)->m_handle); } +#endif // DACCESS_COMPILE }; #ifdef USE_CHECKED_OBJECTREFS @@ -145,12 +77,8 @@ typedef OverlappedDataObject* OVERLAPPEDDATAREF; #endif FCDECL3(void, CheckVMForIOPacket, LPOVERLAPPED* lpOverlapped, DWORD* errorCode, DWORD* numBytes); -FCDECL1(void*, AllocateNativeOverlapped, OverlappedDataObject* overlapped); +FCDECL1(LPOVERLAPPED, AllocateNativeOverlapped, OverlappedDataObject* overlapped); FCDECL1(void, FreeNativeOverlapped, LPOVERLAPPED lpOverlapped); FCDECL1(OverlappedDataObject*, GetOverlappedFromNative, LPOVERLAPPED lpOverlapped); -void InitializePinHandleTable(); -void AddMTForPinHandle(OBJECTREF obj); -void BashMTForPinnedObject(OBJECTREF obj); - #endif diff --git a/src/vm/olevariant.cpp b/src/vm/olevariant.cpp index 4f62be6bdf9c..330710bf3725 100644 --- a/src/vm/olevariant.cpp +++ b/src/vm/olevariant.cpp @@ -3770,11 +3770,7 @@ void OleVariant::MarshalCurrencyVariantOleToCom(VARIANT *pOleVariant, DECIMAL DecVal; // Convert the currency to a decimal. - HRESULT hr = VarDecFromCy(V_CY(pOleVariant), &DecVal); - IfFailThrow(hr); - - if (FAILED(DecimalCanonicalize(&DecVal))) - COMPlusThrow(kOverflowException, W("Overflow_Currency")); + VarDecFromCyCanonicalize(V_CY(pOleVariant), &DecVal); // Store the value into the unboxes decimal and store the decimal in the variant. *(DECIMAL *) pDecimalRef->UnBox() = DecVal; @@ -3822,11 +3818,7 @@ void OleVariant::MarshalCurrencyVariantOleRefToCom(VARIANT *pOleVariant, DECIMAL DecVal; // Convert the currency to a decimal. - HRESULT hr = VarDecFromCy(*V_CYREF(pOleVariant), &DecVal); - IfFailThrow(hr); - - if (FAILED(DecimalCanonicalize(&DecVal))) - COMPlusThrow(kOverflowException, W("Overflow_Currency")); + VarDecFromCyCanonicalize(*V_CYREF(pOleVariant), &DecVal); // Store the value into the unboxes decimal and store the decimal in the variant. *(DECIMAL *) pDecimalRef->UnBox() = DecVal; @@ -3856,11 +3848,7 @@ void OleVariant::MarshalCurrencyArrayOleToCom(void *oleArray, BASEARRAYREF *pCom while (pOle < pOleEnd) { - IfFailThrow(VarDecFromCy(*pOle++, pCom)); - if (FAILED(DecimalCanonicalize(pCom))) - COMPlusThrow(kOverflowException, W("Overflow_Currency")); - - pCom++; + VarDecFromCyCanonicalize(*pOle++, pCom++); } } diff --git a/src/vm/prestub.cpp b/src/vm/prestub.cpp index 721de3c4ad38..60c3afb12e93 100644 --- a/src/vm/prestub.cpp +++ b/src/vm/prestub.cpp @@ -743,15 +743,6 @@ PCODE MethodDesc::JitCompileCodeLockedEventWrapper(PrepareCodeConfig* pConfig, J } -#ifdef FEATURE_TIERED_COMPILATION - if (g_pConfig->TieredCompilation() && flags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_TIER0)) - { - // The flag above is only set (in TieredCompilationManager::GetJitFlags()) when this method was eligible for tiered - // compilation at the time when it was checked, and a tier 0 JIT was requested for this method - GetAppDomain()->GetTieredCompilationManager()->OnTier0JitInvoked(); - } -#endif // FEATURE_TIERED_COMPILATION - #ifdef FEATURE_STACK_SAMPLING StackSampler::RecordJittingInfo(this, flags); #endif // FEATURE_STACK_SAMPLING @@ -1990,7 +1981,7 @@ PCODE TheVarargNDirectStub(BOOL hasRetBuffArg) { LIMITED_METHOD_CONTRACT; -#if !defined(_TARGET_X86_) +#if !defined(_TARGET_X86_) && !defined(_TARGET_ARM64_) if (hasRetBuffArg) { return GetEEFuncEntryPoint(VarargPInvokeStub_RetBuffArg); diff --git a/src/vm/reflectioninvocation.cpp b/src/vm/reflectioninvocation.cpp index 6dea9b760c46..742a26e7a4f6 100644 --- a/src/vm/reflectioninvocation.cpp +++ b/src/vm/reflectioninvocation.cpp @@ -2272,7 +2272,7 @@ void ExecuteCodeWithGuaranteedCleanupHelper (ECWGC_GC *gc) // ExecuteCodeWithGuaranteedCleanup ensures that we will call the backout code delegate even if an SO occurs. We do this by calling the // try delegate from within an EX_TRY/EX_CATCH block that will catch any thrown exceptions and thus cause the stack to be unwound. This // guarantees that the backout delegate is called with at least DEFAULT_ENTRY_PROBE_SIZE pages of stack. After the backout delegate is called, -// we re-raise any exceptions that occurred inside the try delegate. Note that any CER that uses large or arbitraty amounts of stack in +// we re-raise any exceptions that occurred inside the try delegate. Note that any CER that uses large or arbitrary amounts of stack in // it's try block must use ExecuteCodeWithGuaranteedCleanup. // // ExecuteCodeWithGuaranteedCleanup also guarantees that the backount code will be run before any filters higher up on the stack. This diff --git a/src/vm/stackwalk.cpp b/src/vm/stackwalk.cpp index d324e411d7dd..345a67074da3 100644 --- a/src/vm/stackwalk.cpp +++ b/src/vm/stackwalk.cpp @@ -1231,7 +1231,7 @@ BOOL StackFrameIterator::Init(Thread * pThread, } INDEBUG(m_pRealStartFrame = m_crawl.pFrame); - if (m_crawl.pFrame != FRAME_TOP) + if (m_crawl.pFrame != FRAME_TOP && !(m_flags & SKIP_GSCOOKIE_CHECK)) { m_crawl.SetCurGSCookie(Frame::SafeGetGSCookiePtr(m_crawl.pFrame)); } @@ -1324,7 +1324,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, _ASSERTE(m_crawl.pFrame != NULL); } - if (m_crawl.pFrame != FRAME_TOP) + if (m_crawl.pFrame != FRAME_TOP && !(m_flags & SKIP_GSCOOKIE_CHECK)) { m_crawl.SetCurGSCookie(Frame::SafeGetGSCookiePtr(m_crawl.pFrame)); } @@ -3151,7 +3151,7 @@ void StackFrameIterator::PreProcessingForManagedFrames(void) &m_crawl.codeManState); #endif // !DACCESS_COMPILE - if (m_pCachedGSCookie) + if (!(m_flags & SKIP_GSCOOKIE_CHECK) && m_pCachedGSCookie) { m_crawl.SetCurGSCookie(m_pCachedGSCookie); } diff --git a/src/vm/stubhelpers.cpp b/src/vm/stubhelpers.cpp index d43c065362cc..0be8be33a672 100644 --- a/src/vm/stubhelpers.cpp +++ b/src/vm/stubhelpers.cpp @@ -807,63 +807,6 @@ FCIMPL2(IUnknown*, StubHelpers::UriMarshaler__CreateNativeUriInstance, WCHAR* pR } FCIMPLEND -ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs* QCALLTYPE -StubHelpers::EventArgsMarshaler__CreateNativeNCCEventArgsInstance -(int action, ABI::Windows::UI::Xaml::Interop::IBindableVector *newItem, ABI::Windows::UI::Xaml::Interop::IBindableVector *oldItem, int newIndex, int oldIndex) -{ - QCALL_CONTRACT; - - ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs *pArgsRC = NULL; - - BEGIN_QCALL; - - EventArgsMarshalingInfo *marshalingInfo = GetAppDomain()->GetMarshalingData()->GetEventArgsMarshalingInfo(); - ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgsFactory *pFactory = marshalingInfo->GetNCCEventArgsFactory(); - - SafeComHolderPreemp pInner; - HRESULT hr; - hr = pFactory->CreateInstanceWithAllParameters( - (ABI::Windows::UI::Xaml::Interop::NotifyCollectionChangedAction)action, - (ABI::Windows::UI::Xaml::Interop::IBindableVector *)newItem, - (ABI::Windows::UI::Xaml::Interop::IBindableVector *)oldItem, - newIndex, - oldIndex, - NULL, - &pInner, - &pArgsRC); - IfFailThrow(hr); - - END_QCALL; - - return pArgsRC; -} - -ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs* QCALLTYPE - StubHelpers::EventArgsMarshaler__CreateNativePCEventArgsInstance(HSTRING name) -{ - QCALL_CONTRACT; - - ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs *pArgsRC = NULL; - - BEGIN_QCALL; - - EventArgsMarshalingInfo *marshalingInfo = GetAppDomain()->GetMarshalingData()->GetEventArgsMarshalingInfo(); - ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgsFactory *pFactory = marshalingInfo->GetPCEventArgsFactory(); - - SafeComHolderPreemp pInner; - HRESULT hr; - hr = pFactory->CreateInstance( - name, - NULL, - &pInner, - &pArgsRC); - IfFailThrow(hr); - - END_QCALL; - - return pArgsRC; -} - // A helper to convert an IP to object using special flags. FCIMPL1(Object *, StubHelpers::InterfaceMarshaler__ConvertToManagedWithoutUnboxing, IUnknown *pNative) { @@ -1753,17 +1696,6 @@ FCIMPL1(Object*, StubHelpers::AllocateInternal, EnregisteredTypeHandle pRegister } FCIMPLEND -FCIMPL1(void, StubHelpers::DecimalCanonicalizeInternal, DECIMAL *pDec) -{ - FCALL_CONTRACT; - - if (FAILED(DecimalCanonicalize(pDec))) - { - FCThrowResVoid(kOverflowException, W("Overflow_Currency")); - } -} -FCIMPLEND - FCIMPL1(int, StubHelpers::AnsiStrlen, __in_z char* pszStr) { FCALL_CONTRACT; diff --git a/src/vm/stubhelpers.h b/src/vm/stubhelpers.h index 4c4bc8b71cdb..e5376f73c3f1 100644 --- a/src/vm/stubhelpers.h +++ b/src/vm/stubhelpers.h @@ -74,12 +74,6 @@ class StubHelpers static FCDECL1(StringObject*, UriMarshaler__GetRawUriFromNative, ABI::Windows::Foundation::IUriRuntimeClass* pIUriRC); static FCDECL2(IUnknown*, UriMarshaler__CreateNativeUriInstance, __in_ecount(strLen) CLR_CHAR* pRawUriObj, UINT strLen); - static ABI::Windows::UI::Xaml::Interop::INotifyCollectionChangedEventArgs* QCALLTYPE - EventArgsMarshaler__CreateNativeNCCEventArgsInstance - (int action, ABI::Windows::UI::Xaml::Interop::IBindableVector *newItem, ABI::Windows::UI::Xaml::Interop::IBindableVector *oldItem, int newIndex, int oldIndex); - - static ABI::Windows::UI::Xaml::Data::IPropertyChangedEventArgs* QCALLTYPE EventArgsMarshaler__CreateNativePCEventArgsInstance(HSTRING name); - static FCDECL1(MethodDesc *, GetDelegateInvokeMethod, DelegateObject *pThisUNSAFE); static FCDECL2(IInspectable *, GetWinRTFactoryReturnValue, Object *pThisUNSAFE, PCODE pCtorEntry); static FCDECL2(IInspectable *, GetOuterInspectable, Object *pThisUNSAFE, MethodDesc *pCtorMD); @@ -105,7 +99,6 @@ class StubHelpers static FCDECL3(void*, CreateCustomMarshalerHelper, MethodDesc* pMD, mdToken paramToken, TypeHandle hndManagedType); - static FCDECL1(void, DecimalCanonicalizeInternal, DECIMAL *pDec); static FCDECL3(void, FmtClassUpdateNativeInternal, Object* pObjUNSAFE, BYTE* pbNative, OBJECTREF *ppCleanupWorkListOnStack); static FCDECL2(void, FmtClassUpdateCLRInternal, Object* pObjUNSAFE, BYTE* pbNative); static FCDECL2(void, LayoutDestroyNativeInternal, BYTE* pbNative, MethodTable* pMT); diff --git a/src/vm/stubmgr.cpp b/src/vm/stubmgr.cpp index bc6f47aab54f..2a36908d3f3f 100644 --- a/src/vm/stubmgr.cpp +++ b/src/vm/stubmgr.cpp @@ -1997,7 +1997,7 @@ static BOOL IsVarargPInvokeStub(PCODE stubStartAddress) if (stubStartAddress == GetEEFuncEntryPoint(VarargPInvokeStub)) return TRUE; -#ifndef _TARGET_X86_ +#if !defined(_TARGET_X86_) && !defined(_TARGET_ARM64_) if (stubStartAddress == GetEEFuncEntryPoint(VarargPInvokeStub_RetBuffArg)) return TRUE; #endif diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp index 5042e52b78a7..ddf31f4f5b52 100644 --- a/src/vm/threads.cpp +++ b/src/vm/threads.cpp @@ -6777,7 +6777,7 @@ HRESULT Thread::CLRSetThreadStackGuarantee(SetThreadStackGuaranteeScope fScope) // // -plus we might need some more for debugger EH dispatch, Watson, etc... // -also need to take into account that we can lose up to 1 page of the guard region - // -additionally, we need to provide some region to hosts to allow for lock aquisition in a hosted scenario + // -additionally, we need to provide some region to hosts to allow for lock acquisition in a hosted scenario // EXTRA_PAGES = 3; INDEBUG(EXTRA_PAGES += 1); @@ -8546,7 +8546,6 @@ BOOL Thread::HaveExtraWorkForFinalizer() LIMITED_METHOD_CONTRACT; return m_ThreadTasks - || OverlappedDataObject::CleanupNeededFromGC() || ThreadpoolMgr::HaveTimerInfosToFlush() || ExecutionManager::IsCacheCleanupRequired() || Thread::CleanupNeededForFinalizedThread() @@ -8606,8 +8605,6 @@ void Thread::DoExtraWorkForFinalizer() ExecutionManager::ClearCaches(); } - OverlappedDataObject::RequestCleanupFromGC(); - // If there were any TimerInfos waiting to be released, they'll get flushed now ThreadpoolMgr::FlushQueueOfTimerInfos(); diff --git a/src/vm/threads.h b/src/vm/threads.h index 5cafc61bdb8e..e4b6487f5574 100644 --- a/src/vm/threads.h +++ b/src/vm/threads.h @@ -3360,6 +3360,14 @@ class Thread: public IUnknown // Refer to StackFrameIterator::Filter for detailed comments on this flag. #define GC_FUNCLET_REFERENCE_REPORTING 0x8000 + // Stackwalking normally checks GS cookies on the fly, but there are cases in which the JIT reports + // incorrect epilog information. This causes the debugger to request stack walks in the epilog, checking + // an now invalid cookie. This flag allows the debugger stack walks to disable GS cookie checking. + + // This is a workaround for the debugger stackwalking. In general, the stackwalker and CrawlFrame + // may still execute GS cookie tracking/checking code paths. + #define SKIP_GSCOOKIE_CHECK 0x10000 + StackWalkAction StackWalkFramesEx( PREGDISPLAY pRD, // virtual register set at crawl start PSTACKWALKFRAMESCALLBACK pCallback, @@ -4831,16 +4839,26 @@ class Thread: public IUnknown { LIMITED_METHOD_CONTRACT; BYTE* dest = VolatileLoad(&m_pbDestCode); - CONSISTENCY_CHECK((NULL == dest) || (NULL != VolatileLoadWithoutBarrier(&m_pbSrcCode))); return dest != NULL; } - void ClearGCStressInstructionUpdate() + bool TryClearGCStressInstructionUpdate(BYTE** ppbDestCode, BYTE** ppbSrcCode) { LIMITED_METHOD_CONTRACT; - PRECONDITION(HasPendingGCStressInstructionUpdate()); + bool result = false; - VolatileStoreWithoutBarrier(&m_pbDestCode, NULL); - VolatileStore(&m_pbSrcCode, NULL); + if(HasPendingGCStressInstructionUpdate()) + { + *ppbDestCode = FastInterlockExchangePointer(&m_pbDestCode, NULL); + + if(*ppbDestCode != NULL) + { + result = true; + *ppbSrcCode = FastInterlockExchangePointer(&m_pbSrcCode, NULL); + + CONSISTENCY_CHECK(*ppbSrcCode != NULL); + } + } + return result; } #if defined(GCCOVER_TOLERATE_SPURIOUS_AV) void SetLastAVAddress(LPVOID address) diff --git a/src/vm/threadstatics.h b/src/vm/threadstatics.h index 970f730234c3..3e61049f5958 100644 --- a/src/vm/threadstatics.h +++ b/src/vm/threadstatics.h @@ -440,6 +440,12 @@ struct ThreadLocalModule }; // struct ThreadLocalModule +#define OFFSETOF__ThreadLocalModule__m_pDataBlob (3 * TARGET_POINTER_SIZE /* m_pDynamicClassTable + m_aDynamicEntries + m_pGCStatics */) +#ifdef FEATURE_64BIT_ALIGNMENT +#define OFFSETOF__ThreadLocalModule__DynamicEntry__m_pDataBlob (TARGET_POINTER_SIZE /* m_pGCStatics */ + TARGET_POINTER_SIZE /* m_padding */) +#else +#define OFFSETOF__ThreadLocalModule__DynamicEntry__m_pDataBlob TARGET_POINTER_SIZE /* m_pGCStatics */ +#endif typedef DPTR(struct TLMTableEntry) PTR_TLMTableEntry; diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp index 65a3841525f3..aa7fae3a915e 100644 --- a/src/vm/threadsuspend.cpp +++ b/src/vm/threadsuspend.cpp @@ -5050,30 +5050,34 @@ void Thread::CommitGCStressInstructionUpdate() } CONTRACTL_END; - if (HasPendingGCStressInstructionUpdate()) + BYTE* pbDestCode = NULL; + BYTE* pbSrcCode = NULL; + + if (TryClearGCStressInstructionUpdate(&pbDestCode, &pbSrcCode)) { + assert(pbDestCode != NULL); + assert(pbSrcCode != NULL); + #if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) - *m_pbDestCode = *m_pbSrcCode; + *pbDestCode = *pbSrcCode; #elif defined(_TARGET_ARM_) - if (GetARMInstructionLength(m_pbDestCode) == 2) - *(WORD*)m_pbDestCode = *(WORD*)m_pbSrcCode; + if (GetARMInstructionLength(pbDestCode) == 2) + *(WORD*)pbDestCode = *(WORD*)pbSrcCode; else - *(DWORD*)m_pbDestCode = *(DWORD*)m_pbSrcCode; + *(DWORD*)pbDestCode = *(DWORD*)pbSrcCode; #elif defined(_TARGET_ARM64_) - *(DWORD*)m_pbDestCode = *(DWORD*)m_pbSrcCode; + *(DWORD*)pbDestCode = *(DWORD*)pbSrcCode; #else - *m_pbDestCode = *m_pbSrcCode; + *pbDestCode = *pbSrcCode; #endif - - ClearGCStressInstructionUpdate(); } } diff --git a/src/vm/tieredcompilation.cpp b/src/vm/tieredcompilation.cpp index b87d01af8d59..7945973aa9ff 100644 --- a/src/vm/tieredcompilation.cpp +++ b/src/vm/tieredcompilation.cpp @@ -71,17 +71,16 @@ // Called at AppDomain construction TieredCompilationManager::TieredCompilationManager() : + m_lock(CrstTieredCompilation), m_isAppDomainShuttingDown(FALSE), m_countOptimizationThreadsRunning(0), m_callCountOptimizationThreshhold(1), m_optimizationQuantumMs(50), m_methodsPendingCountingForTier1(nullptr), - m_tier1CountingDelayTimerHandle(nullptr), - m_wasTier0JitInvokedSinceCountingDelayReset(false) + m_tieringDelayTimerHandle(nullptr), + m_tier1CallCountingCandidateMethodRecentlyRecorded(false) { - LIMITED_METHOD_CONTRACT; - m_lock.Init(LOCK_TYPE_DEFAULT); - + WRAPPER_NO_CONTRACT; // On Unix, we can reach here before EEConfig is initialized, so defer config-based initialization to Init() } @@ -90,73 +89,17 @@ void TieredCompilationManager::Init(ADID appDomainId) { CONTRACTL { - NOTHROW; GC_NOTRIGGER; CAN_TAKE_LOCK; MODE_PREEMPTIVE; } CONTRACTL_END; - SpinLockHolder holder(&m_lock); + CrstHolder holder(&m_lock); m_domainId = appDomainId; m_callCountOptimizationThreshhold = g_pConfig->TieredCompilation_Tier1CallCountThreshold(); } -void TieredCompilationManager::InitiateTier1CountingDelay() -{ - WRAPPER_NO_CONTRACT; - _ASSERTE(g_pConfig->TieredCompilation()); - _ASSERTE(m_methodsPendingCountingForTier1 == nullptr); - _ASSERTE(m_tier1CountingDelayTimerHandle == nullptr); - - DWORD delayMs = g_pConfig->TieredCompilation_Tier1CallCountingDelayMs(); - if (delayMs == 0) - { - return; - } - - m_tier1CountingDelayLock.Init(LOCK_TYPE_DEFAULT); - - NewHolder> methodsPendingCountingHolder = new(nothrow) SArray(); - if (methodsPendingCountingHolder == nullptr) - { - return; - } - - NewHolder timerContextHolder = new(nothrow) ThreadpoolMgr::TimerInfoContext(); - if (timerContextHolder == nullptr) - { - return; - } - - timerContextHolder->AppDomainId = m_domainId; - timerContextHolder->TimerId = 0; - if (!ThreadpoolMgr::CreateTimerQueueTimer( - &m_tier1CountingDelayTimerHandle, - Tier1DelayTimerCallback, - timerContextHolder, - delayMs, - (DWORD)-1 /* Period, non-repeating */, - 0 /* flags */)) - { - _ASSERTE(m_tier1CountingDelayTimerHandle == nullptr); - return; - } - - m_methodsPendingCountingForTier1 = methodsPendingCountingHolder.Extract(); - timerContextHolder.SuppressRelease(); // the timer context is automatically deleted by the timer infrastructure -} - -void TieredCompilationManager::OnTier0JitInvoked() -{ - LIMITED_METHOD_CONTRACT; - - if (m_methodsPendingCountingForTier1 != nullptr) - { - m_wasTier0JitInvokedSinceCountingDelayReset = true; - } -} - // Called each time code in this AppDomain has been run. This is our sole entrypoint to begin // tiered compilation for now. Returns TRUE if no more notifications are necessary, but // more notifications may come anyways. @@ -175,7 +118,13 @@ void TieredCompilationManager::OnMethodCalled( _ASSERTE(wasPromotedToTier1Ref != nullptr); *shouldStopCountingCallsRef = - m_methodsPendingCountingForTier1 != nullptr || currentCallCount >= m_callCountOptimizationThreshhold; + // Stop call counting when the delay is in effect + IsTieringDelayActive() || + // Initiate the delay on tier 0 activity (when a new eligible method is called the first time) + (currentCallCount == 1 && g_pConfig->TieredCompilation_Tier1CallCountingDelayMs() != 0) || + // Stop call counting when ready for tier 1 promotion + currentCallCount >= m_callCountOptimizationThreshhold; + *wasPromotedToTier1Ref = currentCallCount >= m_callCountOptimizationThreshhold; if (currentCallCount == m_callCountOptimizationThreshhold) @@ -195,17 +144,53 @@ void TieredCompilationManager::OnMethodCallCountingStoppedWithoutTier1Promotion( return; } + while (true) { - SpinLockHolder holder(&m_tier1CountingDelayLock); - if (m_methodsPendingCountingForTier1 != nullptr) + bool attemptedToInitiateDelay = false; + if (!IsTieringDelayActive()) + { + if (!TryInitiateTieringDelay()) + { + break; + } + attemptedToInitiateDelay = true; + } + { + CrstHolder holder(&m_lock); + + SArray* methodsPendingCountingForTier1 = m_methodsPendingCountingForTier1; + if (methodsPendingCountingForTier1 == nullptr) + { + // Timer tick callback race, try again + continue; + } + // Record the method to resume counting later (see Tier1DelayTimerCallback) - m_methodsPendingCountingForTier1->Append(pMethodDesc); - return; + bool success = false; + EX_TRY + { + methodsPendingCountingForTier1->Append(pMethodDesc); + success = true; + } + EX_CATCH + { + } + EX_END_CATCH(RethrowTerminalExceptions); + if (!success) + { + break; + } + + if (!attemptedToInitiateDelay) + { + // Delay call counting for currently recoded methods further + m_tier1CallCountingCandidateMethodRecentlyRecorded = true; + } } + return; } - // Rare race condition with the timer callback ResumeCountingCalls(pMethodDesc); } @@ -252,18 +237,14 @@ void TieredCompilationManager::AsyncPromoteMethodToTier1(MethodDesc* pMethodDesc // Insert the method into the optimization queue and trigger a thread to service // the queue if needed. // - // Terminal exceptions escape as exceptions, but all other errors should gracefully - // return to the caller. Non-terminal error conditions should be rare (ie OOM, - // OS failure to create thread) and we consider it reasonable for some methods - // to go unoptimized or have their optimization arbitrarily delayed under these - // circumstances. Note an error here could affect concurrent threads running this + // Note an error here could affect concurrent threads running this // code. Those threads will observe m_countOptimizationThreadsRunning > 0 and return, // then QueueUserWorkItem fails on this thread lowering the count and leaves them // unserviced. Synchronous retries appear unlikely to offer any material improvement // and complicating the code to narrow an already rare error case isn't desirable. { SListElem* pMethodListItem = new (nothrow) SListElem(t1NativeCodeVersion); - SpinLockHolder holder(&m_lock); + CrstHolder holder(&m_lock); if (pMethodListItem != NULL) { m_methodsToOptimize.InsertTail(pMethodListItem); @@ -273,92 +254,202 @@ void TieredCompilationManager::AsyncPromoteMethodToTier1(MethodDesc* pMethodDesc pMethodDesc, pMethodDesc->m_pszDebugClassName, pMethodDesc->m_pszDebugMethodName, t1NativeCodeVersion.GetVersionId())); - if (0 == m_countOptimizationThreadsRunning && !m_isAppDomainShuttingDown) - { - // Our current policy throttles at 1 thread, but in the future we - // could experiment with more parallelism. - IncrementWorkerThreadCount(); - } - else + if (!IncrementWorkerThreadCountIfNeeded()) { return; } } - EX_TRY + if (!TryAsyncOptimizeMethods()) { - if (!ThreadpoolMgr::QueueUserWorkItem(StaticOptimizeMethodsCallback, this, QUEUE_ONLY, TRUE)) - { - SpinLockHolder holder(&m_lock); - DecrementWorkerThreadCount(); - STRESS_LOG1(LF_TIEREDCOMPILATION, LL_WARNING, "TieredCompilationManager::OnMethodCalled: " - "ThreadpoolMgr::QueueUserWorkItem returned FALSE (no thread will run), method=%pM\n", - pMethodDesc); - } - } - EX_CATCH - { - SpinLockHolder holder(&m_lock); + CrstHolder holder(&m_lock); DecrementWorkerThreadCount(); - STRESS_LOG2(LF_TIEREDCOMPILATION, LL_WARNING, "TieredCompilationManager::OnMethodCalled: " - "Exception queuing work item to threadpool, hr=0x%x, method=%pM\n", - GET_EXCEPTION()->GetHR(), pMethodDesc); } - EX_END_CATCH(RethrowTerminalExceptions); - - return; } void TieredCompilationManager::Shutdown() { STANDARD_VM_CONTRACT; - SpinLockHolder holder(&m_lock); + CrstHolder holder(&m_lock); m_isAppDomainShuttingDown = TRUE; } -VOID WINAPI TieredCompilationManager::Tier1DelayTimerCallback(PVOID parameter, BOOLEAN timerFired) +bool TieredCompilationManager::IsTieringDelayActive() +{ + LIMITED_METHOD_CONTRACT; + return m_methodsPendingCountingForTier1 != nullptr; +} + +bool TieredCompilationManager::TryInitiateTieringDelay() +{ + WRAPPER_NO_CONTRACT; + _ASSERTE(g_pConfig->TieredCompilation()); + _ASSERTE(g_pConfig->TieredCompilation_Tier1CallCountingDelayMs() != 0); + + NewHolder> methodsPendingCountingHolder = new(nothrow) SArray(); + if (methodsPendingCountingHolder == nullptr) + { + return false; + } + + bool success = false; + EX_TRY + { + methodsPendingCountingHolder->Preallocate(64); + success = true; + } + EX_CATCH + { + } + EX_END_CATCH(RethrowTerminalExceptions); + if (!success) + { + return false; + } + + NewHolder timerContextHolder = new(nothrow) ThreadpoolMgr::TimerInfoContext(); + if (timerContextHolder == nullptr) + { + return false; + } + timerContextHolder->AppDomainId = m_domainId; + timerContextHolder->TimerId = 0; + + { + CrstHolder holder(&m_lock); + + if (IsTieringDelayActive()) + { + return true; + } + + // The timer is created inside the lock to avoid some unnecessary additional complexity that would otherwise arise from + // there being a failure point after the timer is successfully created. For instance, if the timer is created outside + // the lock and then inside the lock it is found that another thread beat us to it, there would be two active timers + // that may tick before the extra timer is deleted, along with additional concurrency issues. + _ASSERTE(m_tieringDelayTimerHandle == nullptr); + success = false; + EX_TRY + { + if (ThreadpoolMgr::CreateTimerQueueTimer( + &m_tieringDelayTimerHandle, + TieringDelayTimerCallback, + timerContextHolder, + g_pConfig->TieredCompilation_Tier1CallCountingDelayMs(), + (DWORD)-1 /* Period, non-repeating */, + 0 /* flags */)) + { + success = true; + } + } + EX_CATCH + { + } + EX_END_CATCH(RethrowTerminalExceptions); + if (!success) + { + _ASSERTE(m_tieringDelayTimerHandle == nullptr); + return false; + } + + m_methodsPendingCountingForTier1 = methodsPendingCountingHolder.Extract(); + _ASSERTE(IsTieringDelayActive()); + } + + timerContextHolder.SuppressRelease(); // the timer context is automatically deleted by the timer infrastructure + return true; +} + +void WINAPI TieredCompilationManager::TieringDelayTimerCallback(PVOID parameter, BOOLEAN timerFired) { WRAPPER_NO_CONTRACT; _ASSERTE(timerFired); - GCX_COOP(); ThreadpoolMgr::TimerInfoContext* timerContext = (ThreadpoolMgr::TimerInfoContext*)parameter; - ManagedThreadBase::ThreadPool(timerContext->AppDomainId, Tier1DelayTimerCallbackInAppDomain, nullptr); + EX_TRY + { + GCX_COOP(); + ManagedThreadBase::ThreadPool(timerContext->AppDomainId, TieringDelayTimerCallbackInAppDomain, nullptr); + } + EX_CATCH + { + STRESS_LOG1(LF_TIEREDCOMPILATION, LL_ERROR, "TieredCompilationManager::Tier1DelayTimerCallback: " + "Unhandled exception, hr=0x%x\n", + GET_EXCEPTION()->GetHR()); + } + EX_END_CATCH(RethrowTerminalExceptions); } -void TieredCompilationManager::Tier1DelayTimerCallbackInAppDomain(LPVOID parameter) +void TieredCompilationManager::TieringDelayTimerCallbackInAppDomain(LPVOID parameter) { WRAPPER_NO_CONTRACT; - GetAppDomain()->GetTieredCompilationManager()->Tier1DelayTimerCallbackWorker(); + GetAppDomain()->GetTieredCompilationManager()->TieringDelayTimerCallbackWorker(); } -void TieredCompilationManager::Tier1DelayTimerCallbackWorker() +void TieredCompilationManager::TieringDelayTimerCallbackWorker() { WRAPPER_NO_CONTRACT; + _ASSERTE(GetAppDomain()->GetId() == m_domainId); - // Reschedule the timer if a tier 0 JIT has been invoked since the timer was started to further delay call counting - if (m_wasTier0JitInvokedSinceCountingDelayReset) + HANDLE tieringDelayTimerHandle; + bool tier1CallCountingCandidateMethodRecentlyRecorded; { - m_wasTier0JitInvokedSinceCountingDelayReset = false; + // It's possible for the timer to tick before it is recorded that the delay is in effect. This lock guarantees that the + // delay is in effect. + CrstHolder holder(&m_lock); + _ASSERTE(IsTieringDelayActive()); + + tieringDelayTimerHandle = m_tieringDelayTimerHandle; + _ASSERTE(tieringDelayTimerHandle != nullptr); + + tier1CallCountingCandidateMethodRecentlyRecorded = m_tier1CallCountingCandidateMethodRecentlyRecorded; + if (tier1CallCountingCandidateMethodRecentlyRecorded) + { + m_tier1CallCountingCandidateMethodRecentlyRecorded = false; + } + } - _ASSERTE(m_tier1CountingDelayTimerHandle != nullptr); - if (ThreadpoolMgr::ChangeTimerQueueTimer( - m_tier1CountingDelayTimerHandle, - g_pConfig->TieredCompilation_Tier1CallCountingDelayMs(), - (DWORD)-1 /* Period, non-repeating */)) + // Reschedule the timer if there has been recent tier 0 activity (when a new eligible method is called the first time) to + // further delay call counting + if (tier1CallCountingCandidateMethodRecentlyRecorded) + { + bool success = false; + EX_TRY + { + if (ThreadpoolMgr::ChangeTimerQueueTimer( + tieringDelayTimerHandle, + g_pConfig->TieredCompilation_Tier1CallCountingDelayMs(), + (DWORD)-1 /* Period, non-repeating */)) + { + success = true; + } + } + EX_CATCH + { + } + EX_END_CATCH(RethrowTerminalExceptions); + if (success) { return; } } - // Exchange the list of methods pending counting for tier 1 + // Exchange information into locals inside the lock SArray* methodsPendingCountingForTier1; + bool optimizeMethods; { - SpinLockHolder holder(&m_tier1CountingDelayLock); + CrstHolder holder(&m_lock); + methodsPendingCountingForTier1 = m_methodsPendingCountingForTier1; _ASSERTE(methodsPendingCountingForTier1 != nullptr); m_methodsPendingCountingForTier1 = nullptr; + + _ASSERTE(tieringDelayTimerHandle == m_tieringDelayTimerHandle); + m_tieringDelayTimerHandle = nullptr; + + _ASSERTE(!IsTieringDelayActive()); + optimizeMethods = IncrementWorkerThreadCountIfNeeded(); } // Install call counters @@ -370,10 +461,12 @@ void TieredCompilationManager::Tier1DelayTimerCallbackWorker() } delete methodsPendingCountingForTier1; - // Delete the timer - _ASSERTE(m_tier1CountingDelayTimerHandle != nullptr); - ThreadpoolMgr::DeleteTimerQueueTimer(m_tier1CountingDelayTimerHandle, nullptr); - m_tier1CountingDelayTimerHandle = nullptr; + ThreadpoolMgr::DeleteTimerQueueTimer(tieringDelayTimerHandle, nullptr); + + if (optimizeMethods) + { + OptimizeMethods(); + } } void TieredCompilationManager::ResumeCountingCalls(MethodDesc* pMethodDesc) @@ -385,6 +478,39 @@ void TieredCompilationManager::ResumeCountingCalls(MethodDesc* pMethodDesc) pMethodDesc->GetPrecode()->ResetTargetInterlocked(); } +bool TieredCompilationManager::TryAsyncOptimizeMethods() +{ + WRAPPER_NO_CONTRACT; + _ASSERTE(DebugGetWorkerThreadCount() != 0); + + // Terminal exceptions escape as exceptions, but all other errors should gracefully + // return to the caller. Non-terminal error conditions should be rare (ie OOM, + // OS failure to create thread) and we consider it reasonable for some methods + // to go unoptimized or have their optimization arbitrarily delayed under these + // circumstances. + bool success = false; + EX_TRY + { + if (ThreadpoolMgr::QueueUserWorkItem(StaticOptimizeMethodsCallback, this, QUEUE_ONLY, TRUE)) + { + success = true; + } + else + { + STRESS_LOG0(LF_TIEREDCOMPILATION, LL_WARNING, "TieredCompilationManager::OnMethodCalled: " + "ThreadpoolMgr::QueueUserWorkItem returned FALSE (no thread will run)\n"); + } + } + EX_CATCH + { + STRESS_LOG1(LF_TIEREDCOMPILATION, LL_WARNING, "TieredCompilationManager::OnMethodCalled: " + "Exception queuing work item to threadpool, hr=0x%x\n", + GET_EXCEPTION()->GetHR()); + } + EX_END_CATCH(RethrowTerminalExceptions); + return success; +} + // This is the initial entrypoint for the background thread, called by // the threadpool. DWORD WINAPI TieredCompilationManager::StaticOptimizeMethodsCallback(void *args) @@ -397,23 +523,16 @@ DWORD WINAPI TieredCompilationManager::StaticOptimizeMethodsCallback(void *args) return 0; } -//This method will process one or more methods from optimization queue -// on a background thread. Each such method will be jitted with code -// optimizations enabled and then installed as the active implementation -// of the method entrypoint. -// -// We need to be carefuly not to work for too long in a single invocation -// of this method or we could starve the threadpool and force -// it to create unnecessary additional threads. void TieredCompilationManager::OptimizeMethodsCallback() { STANDARD_VM_CONTRACT; + _ASSERTE(DebugGetWorkerThreadCount() != 0); // This app domain shutdown check isn't required for correctness // but it should reduce some unneeded exceptions trying // to enter a closed AppDomain { - SpinLockHolder holder(&m_lock); + CrstHolder holder(&m_lock); if (m_isAppDomainShuttingDown) { DecrementWorkerThreadCount(); @@ -421,52 +540,86 @@ void TieredCompilationManager::OptimizeMethodsCallback() } } - ULONGLONG startTickCount = CLRGetTickCount64(); - NativeCodeVersion nativeCodeVersion; EX_TRY { GCX_COOP(); ENTER_DOMAIN_ID(m_domainId); { - GCX_PREEMP(); - while (true) + OptimizeMethods(); + } + END_DOMAIN_TRANSITION; + } + EX_CATCH + { + STRESS_LOG1(LF_TIEREDCOMPILATION, LL_ERROR, "TieredCompilationManager::OptimizeMethodsCallback: " + "Unhandled exception on domain transition, hr=0x%x\n", + GET_EXCEPTION()->GetHR()); + } + EX_END_CATCH(RethrowTerminalExceptions); +} + +//This method will process one or more methods from optimization queue +// on a background thread. Each such method will be jitted with code +// optimizations enabled and then installed as the active implementation +// of the method entrypoint. +// +// We need to be carefuly not to work for too long in a single invocation +// of this method or we could starve the threadpool and force +// it to create unnecessary additional threads. +void TieredCompilationManager::OptimizeMethods() +{ + WRAPPER_NO_CONTRACT; + _ASSERTE(DebugGetWorkerThreadCount() != 0); + _ASSERTE(GetAppDomain()->GetId() == m_domainId); + + ULONGLONG startTickCount = CLRGetTickCount64(); + NativeCodeVersion nativeCodeVersion; + EX_TRY + { + GCX_PREEMP(); + while (true) + { { + CrstHolder holder(&m_lock); + + if (IsTieringDelayActive() || m_isAppDomainShuttingDown) { - SpinLockHolder holder(&m_lock); - nativeCodeVersion = GetNextMethodToOptimize(); - if (nativeCodeVersion.IsNull() || - m_isAppDomainShuttingDown) - { - DecrementWorkerThreadCount(); - break; - } - + DecrementWorkerThreadCount(); + break; } - OptimizeMethod(nativeCodeVersion); - // If we have been running for too long return the thread to the threadpool and queue another event - // This gives the threadpool a chance to service other requests on this thread before returning to - // this work. - ULONGLONG currentTickCount = CLRGetTickCount64(); - if (currentTickCount >= startTickCount + m_optimizationQuantumMs) + nativeCodeVersion = GetNextMethodToOptimize(); + if (nativeCodeVersion.IsNull()) { - if (!ThreadpoolMgr::QueueUserWorkItem(StaticOptimizeMethodsCallback, this, QUEUE_ONLY, TRUE)) - { - SpinLockHolder holder(&m_lock); - DecrementWorkerThreadCount(); - STRESS_LOG0(LF_TIEREDCOMPILATION, LL_WARNING, "TieredCompilationManager::OptimizeMethodsCallback: " - "ThreadpoolMgr::QueueUserWorkItem returned FALSE (no thread will run)\n"); - } + DecrementWorkerThreadCount(); break; } } + OptimizeMethod(nativeCodeVersion); + + // If we have been running for too long return the thread to the threadpool and queue another event + // This gives the threadpool a chance to service other requests on this thread before returning to + // this work. + ULONGLONG currentTickCount = CLRGetTickCount64(); + if (currentTickCount >= startTickCount + m_optimizationQuantumMs) + { + if (!TryAsyncOptimizeMethods()) + { + CrstHolder holder(&m_lock); + DecrementWorkerThreadCount(); + } + break; + } } - END_DOMAIN_TRANSITION; } EX_CATCH { - STRESS_LOG2(LF_TIEREDCOMPILATION, LL_ERROR, "TieredCompilationManager::OptimizeMethodsCallback: " - "Unhandled exception during method optimization, hr=0x%x, last method=%pM\n", + { + CrstHolder holder(&m_lock); + DecrementWorkerThreadCount(); + } + STRESS_LOG2(LF_TIEREDCOMPILATION, LL_ERROR, "TieredCompilationManager::OptimizeMethods: " + "Unhandled exception during method optimization, hr=0x%x, last method=%p\n", GET_EXCEPTION()->GetHR(), nativeCodeVersion.GetMethodDesc()); } EX_END_CATCH(RethrowTerminalExceptions); @@ -581,22 +734,43 @@ NativeCodeVersion TieredCompilationManager::GetNextMethodToOptimize() return NativeCodeVersion(); } -void TieredCompilationManager::IncrementWorkerThreadCount() +bool TieredCompilationManager::IncrementWorkerThreadCountIfNeeded() { - STANDARD_VM_CONTRACT; - //m_lock should be held + WRAPPER_NO_CONTRACT; + // m_lock should be held - m_countOptimizationThreadsRunning++; + if (0 == m_countOptimizationThreadsRunning && + !m_isAppDomainShuttingDown && + !m_methodsToOptimize.IsEmpty() && + !IsTieringDelayActive()) + { + // Our current policy throttles at 1 thread, but in the future we + // could experiment with more parallelism. + m_countOptimizationThreadsRunning++; + return true; + } + return false; } void TieredCompilationManager::DecrementWorkerThreadCount() { STANDARD_VM_CONTRACT; - //m_lock should be held + // m_lock should be held + _ASSERTE(m_countOptimizationThreadsRunning != 0); m_countOptimizationThreadsRunning--; } +#ifdef _DEBUG +DWORD TieredCompilationManager::DebugGetWorkerThreadCount() +{ + WRAPPER_NO_CONTRACT; + + CrstHolder holder(&m_lock); + return m_countOptimizationThreadsRunning; +} +#endif + //static CORJIT_FLAGS TieredCompilationManager::GetJitFlags(NativeCodeVersion nativeCodeVersion) { diff --git a/src/vm/tieredcompilation.h b/src/vm/tieredcompilation.h index 2665ad4abfa2..b208f26256e0 100644 --- a/src/vm/tieredcompilation.h +++ b/src/vm/tieredcompilation.h @@ -26,9 +26,7 @@ class TieredCompilationManager void Init(ADID appDomainId); - void InitiateTier1CountingDelay(); - void OnTier0JitInvoked(); - +public: void OnMethodCalled(MethodDesc* pMethodDesc, DWORD currentCallCount, BOOL* shouldStopCountingCallsRef, BOOL* wasPromotedToTier1Ref); void OnMethodCallCountingStoppedWithoutTier1Promotion(MethodDesc* pMethodDesc); void AsyncPromoteMethodToTier1(MethodDesc* pMethodDesc); @@ -36,34 +34,38 @@ class TieredCompilationManager static CORJIT_FLAGS GetJitFlags(NativeCodeVersion nativeCodeVersion); private: - - static VOID WINAPI Tier1DelayTimerCallback(PVOID parameter, BOOLEAN timerFired); - static void Tier1DelayTimerCallbackInAppDomain(LPVOID parameter); - void Tier1DelayTimerCallbackWorker(); + bool IsTieringDelayActive(); + bool TryInitiateTieringDelay(); + static void WINAPI TieringDelayTimerCallback(PVOID parameter, BOOLEAN timerFired); + static void TieringDelayTimerCallbackInAppDomain(LPVOID parameter); + void TieringDelayTimerCallbackWorker(); static void ResumeCountingCalls(MethodDesc* pMethodDesc); + bool TryAsyncOptimizeMethods(); static DWORD StaticOptimizeMethodsCallback(void* args); void OptimizeMethodsCallback(); + void OptimizeMethods(); void OptimizeMethod(NativeCodeVersion nativeCodeVersion); NativeCodeVersion GetNextMethodToOptimize(); BOOL CompileCodeVersion(NativeCodeVersion nativeCodeVersion); void ActivateCodeVersion(NativeCodeVersion nativeCodeVersion); - void IncrementWorkerThreadCount(); + bool IncrementWorkerThreadCountIfNeeded(); void DecrementWorkerThreadCount(); +#ifdef _DEBUG + DWORD DebugGetWorkerThreadCount(); +#endif - SpinLock m_lock; + Crst m_lock; SList> m_methodsToOptimize; ADID m_domainId; BOOL m_isAppDomainShuttingDown; DWORD m_countOptimizationThreadsRunning; DWORD m_callCountOptimizationThreshhold; DWORD m_optimizationQuantumMs; - - SpinLock m_tier1CountingDelayLock; SArray* m_methodsPendingCountingForTier1; - HANDLE m_tier1CountingDelayTimerHandle; - bool m_wasTier0JitInvokedSinceCountingDelayReset; + HANDLE m_tieringDelayTimerHandle; + bool m_tier1CallCountingCandidateMethodRecentlyRecorded; CLREvent m_asyncWorkDoneEvent; }; diff --git a/src/vm/typehandle.cpp b/src/vm/typehandle.cpp index c8c6362dd670..405be60543e9 100644 --- a/src/vm/typehandle.cpp +++ b/src/vm/typehandle.cpp @@ -1442,101 +1442,6 @@ OBJECTREF TypeHandle::GetManagedClassObjectFast() const #endif // #ifndef DACCESS_COMPILE -#if defined(_DEBUG) - -BOOL TypeHandle::IsAppDomainAgile() const -{ - LIMITED_METHOD_CONTRACT; - - if (!IsTypeDesc()) - { - MethodTable *pMT = AsMethodTable(); - return pMT->GetClass()->IsAppDomainAgile(); - } - else if (IsArray()) - { - TypeHandle th = AsArray()->GetArrayElementTypeHandle(); - return th.IsArrayOfElementsAppDomainAgile(); - } - else - { - // @todo: consider other types of type handles agile? - return FALSE; - } -} - -BOOL TypeHandle::IsCheckAppDomainAgile() const -{ - LIMITED_METHOD_CONTRACT; - - if (!IsTypeDesc()) - { - MethodTable *pMT = AsMethodTable(); - return pMT->GetClass()->IsCheckAppDomainAgile(); - } - else if (IsArray()) - { - TypeHandle th = AsArray()->GetArrayElementTypeHandle(); - return th.IsArrayOfElementsCheckAppDomainAgile(); - } - else - { - // @todo: consider other types of type handles agile? - return FALSE; - } -} - -BOOL TypeHandle::IsArrayOfElementsAppDomainAgile() const -{ - LIMITED_METHOD_CONTRACT; - - if (!IsTypeDesc()) - { - MethodTable *pMT = AsMethodTable(); - return (pMT->GetClass()->IsSealed()) && pMT->GetClass()->IsAppDomainAgile(); - } - else - if (IsArray()) - { - return AsArray()->GetArrayElementTypeHandle().IsArrayOfElementsAppDomainAgile(); - } - else - { - // I'm not sure how to prove a typedesc is sealed, so - // just bail and return FALSE here rather than recursing. - - return FALSE; - } -} - -BOOL TypeHandle::IsArrayOfElementsCheckAppDomainAgile() const -{ - LIMITED_METHOD_CONTRACT; - - if (!IsTypeDesc()) - { - MethodTable *pMT = AsMethodTable(); - return (pMT->GetClass()->IsAppDomainAgile() - && (pMT->GetClass()->IsSealed()) == 0) - || pMT->GetClass()->IsCheckAppDomainAgile(); - } - else - if (IsArray()) - { - return AsArray()->GetArrayElementTypeHandle().IsArrayOfElementsCheckAppDomainAgile(); - } - else - { - // I'm not sure how to prove a typedesc is sealed, so - // just bail and return FALSE here rather than recursing. - - return FALSE; - } -} - -#endif // defined(_DEBUG) - - BOOL TypeHandle::IsByRef() const { LIMITED_METHOD_CONTRACT; diff --git a/src/vm/typehandle.h b/src/vm/typehandle.h index 5cb9eaa7a644..c8f0747d6a1f 100644 --- a/src/vm/typehandle.h +++ b/src/vm/typehandle.h @@ -574,14 +574,6 @@ class TypeHandle INDEBUGIMPL(BOOL Verify();) // DEBUGGING Make certain this is a valid type handle -#if defined(_DEBUG) - BOOL IsAppDomainAgile() const; - BOOL IsCheckAppDomainAgile() const; - - BOOL IsArrayOfElementsAppDomainAgile() const; - BOOL IsArrayOfElementsCheckAppDomainAgile() const; -#endif - #ifdef DACCESS_COMPILE void EnumMemoryRegions(CLRDataEnumMemoryFlags flags); #endif diff --git a/src/vm/win32threadpool.cpp b/src/vm/win32threadpool.cpp index 7f9953a0f955..644e2324c6c1 100644 --- a/src/vm/win32threadpool.cpp +++ b/src/vm/win32threadpool.cpp @@ -1297,7 +1297,6 @@ ThreadpoolMgr::CallbackForInitiateDrainageOfCompletionPortQueue( } FastInterlockAnd(&g_fCompletionPortDrainNeeded, 0); - OverlappedDataObject::FinishCleanup(!fTryNextTime); #endif // !FEATURE_PAL } @@ -3459,7 +3458,9 @@ DWORD WINAPI ThreadpoolMgr::CompletionPortThreadStart(LPVOID lpArgs) // abstraction level for managed IO we can remove the IODequeues fired here if (ETW_EVENT_ENABLED(MICROSOFT_WINDOWS_DOTNETRUNTIME_PROVIDER_Context, ThreadPoolIODequeue) && !AreEtwIOQueueEventsSpeciallyHandled((LPOVERLAPPED_COMPLETION_ROUTINE)key) && pOverlapped != NULL) - FireEtwThreadPoolIODequeue(pOverlapped, (BYTE*)pOverlapped - offsetof(OverlappedDataObject, Internal), GetClrInstanceId()); + { + FireEtwThreadPoolIODequeue(pOverlapped, OverlappedDataObject::GetOverlappedForTracing(pOverlapped), GetClrInstanceId()); + } bool enterRetirement; @@ -3766,7 +3767,7 @@ LPOVERLAPPED ThreadpoolMgr::CompletionPortDispatchWorkWithinAppDomain( overlapped = ObjectToOVERLAPPEDDATAREF(OverlappedDataObject::GetOverlapped(lpOverlapped)); } - if (ManagedCallback && (overlapped->GetAppDomainId() == adid)) + if (ManagedCallback) { _ASSERTE(*pKey != 0); // should be a valid function address @@ -3775,7 +3776,6 @@ LPOVERLAPPED ThreadpoolMgr::CompletionPortDispatchWorkWithinAppDomain( //Application Bug. return NULL; } - } else { diff --git a/src/zap/common.h b/src/zap/common.h index 3db0b84eafa2..b2dbfee7af22 100644 --- a/src/zap/common.h +++ b/src/zap/common.h @@ -13,11 +13,11 @@ #define __COMMON_H__ #include +#include #include #include #include #include -#include #include #include @@ -27,9 +27,14 @@ #endif #endif // !_TARGET_X86_ || FEATURE_PAL +#ifdef _TARGET_64BIT_ +typedef unsigned __int64 TARGET_POINTER_TYPE; +#else +typedef unsigned int TARGET_POINTER_TYPE; +#endif + #include "utilcode.h" #include "corjit.h" -#include "jithost.h" #include "corcompile.h" #include "iceefilegen.h" #include "corpriv.h" diff --git a/src/zap/nativeformatwriter.cpp b/src/zap/nativeformatwriter.cpp index 9e1b8196cba8..4986605b7b37 100644 --- a/src/zap/nativeformatwriter.cpp +++ b/src/zap/nativeformatwriter.cpp @@ -259,7 +259,7 @@ namespace NativeFormat bool fFirstIsLeaf = false, fSecondIsLeaf = false; Vertex * pFirst = ExpandBlock(index, depth - 1, false, &fFirstIsLeaf); - Vertex * pSecond = ExpandBlock(index + (1 << (depth - 1)), depth - 1, true, &fSecondIsLeaf); + Vertex * pSecond = ExpandBlock(index + (size_t{ 1 } << (depth - 1)), depth - 1, true, &fSecondIsLeaf); Vertex * pPop; diff --git a/src/zap/zapimage.cpp b/src/zap/zapimage.cpp index 4472cab23bf5..7cde51d9eaeb 100644 --- a/src/zap/zapimage.cpp +++ b/src/zap/zapimage.cpp @@ -572,7 +572,8 @@ void ZapImage::AllocateVirtualSections() #endif // defined(WIN64EXCEPTIONS) m_pPreloadSections[CORCOMPILE_SECTION_READONLY_WARM] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); - m_pPreloadSections[CORCOMPILE_SECTION_READONLY_VCHUNKS_AND_DICTIONARY] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_VCHUNKS] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); + m_pPreloadSections[CORCOMPILE_SECTION_READONLY_DICTIONARY] = NewVirtualSection(pTextSection, IBCProfiledSection | WarmRange | ReadonlySection, TARGET_POINTER_SIZE); // // GC Info for methods which were not touched in profiling diff --git a/src/zap/zapimport.cpp b/src/zap/zapimport.cpp index 49ec13797312..e35d0b9de32e 100644 --- a/src/zap/zapimport.cpp +++ b/src/zap/zapimport.cpp @@ -362,12 +362,12 @@ void ZapImport::Save(ZapWriter * pZapWriter) { if (IsReadyToRunCompilation()) { - SIZE_T value = 0; + TARGET_POINTER_TYPE value = 0; pZapWriter->Write(&value, sizeof(value)); return; } - SIZE_T token = CORCOMPILE_TAG_TOKEN(GetBlob()->GetRVA()); + TARGET_POINTER_TYPE token = CORCOMPILE_TAG_TOKEN(GetBlob()->GetRVA()); pZapWriter->Write(&token, sizeof(token)); } @@ -639,7 +639,7 @@ class ZapStubDispatchCell : public ZapImport { ZapImage * pImage = ZapImage::GetImage(pZapWriter); - PVOID cell; + TARGET_POINTER_TYPE cell; pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR); pZapWriter->Write(&cell, sizeof(cell)); } @@ -745,7 +745,7 @@ class ZapExternalMethodCell : public ZapImport { ZapImage * pImage = ZapImage::GetImage(pZapWriter); - PVOID cell; + TARGET_POINTER_TYPE cell; pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR); pZapWriter->Write(&cell, sizeof(cell)); } @@ -1725,7 +1725,7 @@ class ZapDynamicHelperCell : public ZapImport { ZapImage * pImage = ZapImage::GetImage(pZapWriter); - PVOID cell; + TARGET_POINTER_TYPE cell; pImage->WriteReloc(&cell, 0, m_pDelayLoadHelper, 0, IMAGE_REL_BASED_PTR); pZapWriter->Write(&cell, sizeof(cell)); } diff --git a/src/zap/zapinfo.cpp b/src/zap/zapinfo.cpp index 725a326e0611..40ab579e020b 100644 --- a/src/zap/zapinfo.cpp +++ b/src/zap/zapinfo.cpp @@ -1690,6 +1690,13 @@ void* ZapInfo::getTailCallCopyArgsThunk ( return m_pImage->GetWrappers()->GetStub(pStub); } +bool ZapInfo::convertPInvokeCalliToCall( + CORINFO_RESOLVED_TOKEN * pResolvedToken, + bool fMustConvert) +{ + return false; +} + #ifdef FEATURE_READYTORUN_COMPILER ReadyToRunHelper MapReadyToRunHelper(CorInfoHelpFunc func, bool * pfOptimizeForSize) { @@ -2567,7 +2574,7 @@ void ZapInfo::recordRelocation(void *location, void *target, break; case IMAGE_REL_BASED_PTR: - *(UNALIGNED TADDR *)location = (TADDR)targetOffset; + *(UNALIGNED TARGET_POINTER_TYPE *)location = (TARGET_POINTER_TYPE)targetOffset; break; #if defined(_TARGET_X86_) || defined(_TARGET_AMD64_) diff --git a/src/zap/zapinfo.h b/src/zap/zapinfo.h index 0e2bf9dcaf11..8b5ad1d4e86c 100644 --- a/src/zap/zapinfo.h +++ b/src/zap/zapinfo.h @@ -360,6 +360,10 @@ class ZapInfo CORINFO_SIG_INFO *pSig, CorInfoHelperTailCallSpecialHandling flags); + bool convertPInvokeCalliToCall( + CORINFO_RESOLVED_TOKEN * pResolvedToken, + bool fMustConvert); + void getFunctionEntryPoint( CORINFO_METHOD_HANDLE ftn, /* IN */ CORINFO_CONST_LOOKUP * pResult, /* OUT */ diff --git a/src/zap/zapper.cpp b/src/zap/zapper.cpp index 683805eacf6b..090b54582611 100644 --- a/src/zap/zapper.cpp +++ b/src/zap/zapper.cpp @@ -525,7 +525,7 @@ void Zapper::LoadAndInitializeJITForNgen(LPCWSTR pwzJitName, OUT HINSTANCE* phJi pJitStartup jitStartupFn = (pJitStartup)GetProcAddress(*phJit, "jitStartup"); if (jitStartupFn != nullptr) { - jitStartupFn(JitHost::getJitHost()); + jitStartupFn(m_pEECompileInfo->GetJitHost()); } //get the appropriate compiler interface @@ -599,7 +599,7 @@ void Zapper::InitEE(BOOL fForceDebug, BOOL fForceProfile, BOOL fForceInstrument) // #ifdef FEATURE_MERGE_JIT_AND_ENGINE - jitStartup(JitHost::getJitHost()); + jitStartup(m_pEECompileInfo->GetJitHost()); m_pJitCompiler = getJit(); if (m_pJitCompiler == NULL) diff --git a/src/zap/zaprelocs.cpp b/src/zap/zaprelocs.cpp index 3718f2c99eea..abfa76b30c78 100644 --- a/src/zap/zaprelocs.cpp +++ b/src/zap/zaprelocs.cpp @@ -48,7 +48,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta // Misaligned relocs disable ASLR on ARM. We should never ever emit them. _ASSERTE(IS_ALIGNED(rva, TARGET_POINTER_SIZE)); #endif - *(UNALIGNED TADDR *)pLocation = pActualTarget; + *(UNALIGNED TARGET_POINTER_TYPE *)pLocation = (TARGET_POINTER_TYPE)pActualTarget; break; case IMAGE_REL_BASED_RELPTR: @@ -92,7 +92,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta // description of IMAGE_REL_BASED_REL_THUMB_MOV32_PCREL const UINT32 offsetCorrection = 12; - UINT32 imm32 = pActualTarget - (pSite + offsetCorrection); + UINT32 imm32 = UINT32(pActualTarget - (pSite + offsetCorrection)); PutThumb2Mov32((UINT16 *)pLocation, imm32); @@ -122,7 +122,7 @@ void ZapBaseRelocs::WriteReloc(PVOID pSrc, int offset, ZapNode * pTarget, int ta } // IMAGE_REL_BASED_THUMB_BRANCH24 does not need base reloc entry return; -#endif +#endif // defined(_TARGET_ARM_) #if defined(_TARGET_ARM64_) case IMAGE_REL_ARM64_BRANCH26: { diff --git a/sync.sh b/sync.sh index ab0fb578c5cb..8d8b16734f48 100755 --- a/sync.sh +++ b/sync.sh @@ -13,7 +13,9 @@ working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" unprocessedBuildArgs= # Parse arguments -if [ $# == 0 ]; then +# Assume the default '-p' argument if the only arguments specified are specified after double dash. +# Only position parameters can be specified after the double dash. +if [ $# == 0 ] || [ $1 == '--' ]; then buildArgs="-p" fi diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 078d9b855287..e667e598418d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,7 +36,21 @@ endif() # Compile options if (WIN32) - add_compile_options(-wd4100 -wd4514 -wd4668 -wd4710 -wd4711 -wd4820) + # 4100 - unreferenced formal parameter + # 4514 - unreferenced inline function has been removed + # 4625 - copy constructor was implicitly defined as deleted because a base class copy constructor is inaccessible or deleted + # 4626 - assignment operator was implicitly defined as deleted because a base class assignment operator is inaccessible or deleted + # 4668 - 'symbol' is not defined as a preprocessor macro, replacing with '0' for 'directives' + # 4710 - function not inlined + # 4711 - 'function' selected for inline expansion + # 4774 - format string expected in argument number is not a string literal + # 4820 - bytes padding added after construct 'member_name' + # 5025 - move assignment operator was implicitly defined as deleted + # 5026 - move constructor was implicitly defined as deleted + # 5027 - move assignment operator was implicitly defined as deleted + # 5039 - pointer or reference to potentially throwing function passed to extern C function under -EHc. Undefined behavior may occur if this function throws an exception. + add_compile_options(-wd4100 -wd4514 -wd4625 -wd4626 -wd4668 -wd4710 -wd4711 -wd4774 -wd4820 -wd5025 -wd5026 -wd5027 -wd5039) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") endif() if(CLR_CMAKE_PLATFORM_UNIX) diff --git a/tests/CoreFX/CoreFX.issues.json b/tests/CoreFX/CoreFX.issues.json new file mode 100644 index 000000000000..3021d1d051e9 --- /dev/null +++ b/tests/CoreFX/CoreFX.issues.json @@ -0,0 +1,481 @@ +[ + { + "name": "System.Console.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "WindowAndCursorProps.SetWindowPosition_GetWindowPosition_ReturnsExpected", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\r\\n ↓ (pos 0)\\r\\nExpected: top\\r\\nActual: left\\r\\n ↑ (pos 0)" + }, + { + "name": "WindowAndCursorProps.GetCursorPosition", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\r\\nExpected: 12\\r\\nActual: 13" + } + ] + } + }, + { + "name": "System.Diagnostics.DiagnosticSource.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Diagnostics.Tests.DiagnosticSourceEventSourceBridgeTests.TestShortcutKeywords", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\n ↓ (pos 0)\\nExpected: Activity1Start\\nActual: Event\\n ↑ (pos 0)" + } + ] + } + }, + { + "name": "System.Diagnostics.Tracing.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "BasicEventSourceTests.TestsUserErrors.Test_BadEventSource_MismatchedIds", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\nExpected: 2\\nActual: 1" + } + ] + } + }, + { + "name": "System.Drawing.Common.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Drawing.Tests.GraphicsTests.InterpolationMode_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-2) is invalid for Enum type 'InterpolationMode'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.CompositingQuality_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-2) is invalid for Enum type 'CompositingQuality'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.PixelOffsetMode_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-2) is invalid for Enum type 'PixelOffsetMode'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.PageUnit_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-1) is invalid for Enum type 'GraphicsUnit'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.SmoothingMode_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-2) is invalid for Enum type 'SmoothingMode'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.CompositingMode_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-1) is invalid for Enum type 'CompositingMode'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.GraphicsTests.TextRenderingHint_SetInvalid_ThrowsInvalidEnumArgumentException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ComponentModel.InvalidEnumArgumentException)\\nActual: typeof(System.ComponentModel.InvalidEnumArgumentException): The value of argument 'value' (-1) is invalid for Enum type 'TextRenderingHint'.\\nParameter name: value" + }, + { + "name": "System.Drawing.Tests.Graphics_DrawBezierTests.DrawBezier_PointFs", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\r\\nExpected: Byte[] [208, 0, 8, 33, 6, ...]\\r\\nActual: Byte[] [153, 27, 131, 228, 197, ...]" + }, + { + "name": "System.Drawing.Tests.Graphics_DrawLineTests.DrawLines_PointFs", + "reason": "Xunit.Sdk.EqualException Assert.Equal() Failure\\r\\nExpected: Byte[] [142, 194, 251, 180, 222, ...]\\r\\nActual: Byte[] [212, 29, 140, 217, 143, ...]" + }, + { + "name": "System.Drawing.Tests.FontTests.ToLogFont_NullLogFont_ThrowsArgumentNullException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\r\\nExpected: typeof(System.ArgumentNullException)\\r\\nActual: typeof(System.AccessViolationException): Attempted to read or write protected memory. This is often an indication that other memory is corrupt." + } + ] + } + }, + { + "name": "System.Data.SqlClient.ManualTesting.Tests", + "enabled": false, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": null + } + }, + { + "name": "System.Data.SqlClient.Stress.Tests", + "enabled": false, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": null + } + }, + { + "name": "System.Data.SqlClient.Tests", + "enabled": false, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": null + } + }, + { + "name": "System.IO.Pipes.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutRead_ClientInOutWrite.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutWrite_ClientInOutRead.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOut_ClientIn.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOut_ClientOut.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerOut_ClientIn.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerIn_ClientOut.Server_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutRead_ClientInOutWrite.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOutWrite_ClientInOutRead.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOut_ClientIn.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerInOut_ClientOut.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerOut_ClientIn.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + }, + { + "name": "System.IO.Pipes.Tests.NamedPipeTest_Simple_ServerIn_ClientOut.Client_ReadWriteCancelledToken_Throws_OperationCanceledException", + "reason": "https://github.com/dotnet/corefx/issues/16934" + } + ] + } + }, + { + "name": "System.Net.Http.Functional.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Net.Http.Functional.Tests.PlatformHandler_DiagnosticsTest.SendAsync_ExpectedDiagnosticSourceActivityLogging", + "reason": "System.Diagnostics.RemoteExecutorTestBase+RemoteInvokeHandle+RemoteExecutionException System.Diagnostics.RemoteExecutorTestBase+RemoteInvokeHandle+RemoteExecutionException : Remote process failed with an unhandled exception." + }, + { + "name": "System.Net.Http.Functional.Tests.SocketsHttpHandler_DiagnosticsTest.SendAsync_ExpectedDiagnosticSourceActivityLogging", + "reason": "System.Diagnostics.RemoteExecutorTestBase+RemoteInvokeHandle+RemoteExecutionException System.Diagnostics.RemoteExecutorTestBase+RemoteInvokeHandle+RemoteExecutionException : Remote process failed with an unhandled exception." + } + ] + } + }, + { + "name": "System.Net.HttpListener.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Net.Tests.HttpRequestStreamTests.Read_NullBuffer_ThrowsArgumentNullException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ArgumentNullException)\\nActual: typeof(System.NullReferenceException): Object reference not set to an instance of an object." + }, + { + "name": "System.Net.Tests.HttpResponseStreamTests.Write_NullBuffer_ThrowsArgumentNullException", + "reason": "Xunit.Sdk.ThrowsException Assert.Throws() Failure\\nExpected: typeof(System.ArgumentNullException)\\nActual: typeof(System.NullReferenceException): Object reference not set to an instance of an object." + } + ] + } + }, + { + "name": "System.Runtime.InteropServices.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Runtime.InteropServices.MarshalTests.SetComObjectData", + "reason": "outdated" + }, + { + "name": "System.Runtime.InteropServices.MarshalTests.GetComObjectData", + "reason": "outdated" + }, + { + "name": "System.Runtime.InteropServices.Tests.ComAwareEventInfoTests.AddEventHandler_DispIdAttribute_ThrowsPlatformNotSupportedException", + "reason": "outdated" + }, + { + "name": "System.Runtime.InteropServices.Tests.ComEventsHelperTests.Remove_NonNullRcw_ThrowsPlatformNotSupportedException", + "reason": "outdated" + }, + { + "name": "System.Runtime.InteropServices.Tests.ComEventsHelperTests.AddEventHandler_DispIdAttribute_ThrowsPlatformNotSupportedException", + "reason": "outdated" + }, + { + "name": "System.Runtime.InteropServices.Tests.ComEventsHelperTests.Combine_NonNullRcw_ThrowsPlatformNotSupportedException", + "reason": "outdated" + }, + ] + } + }, + { + "name": "System.Security.Cryptography.X509Certificates.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Security.Cryptography.X509Certificates.Tests.X509StoreTests.Constructor_DefaultStoreName", + "reason": "Assert.Equal() Failure ↓ (pos 1) Expected: My Actual: MY ↑ (pos 1)" + } + ] + } + }, + { + "name": "System.Threading.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Threading.Tests.EventWaitHandleTests.Ctor_InvalidMode", + "reason": "Assert.Equal() Failure Expected: (null) Actual: mode" + } + ] + } + }, + { + "name": "System.Xml.Xsl.XslTransformApi.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Xml.Tests.CXmlResolverTest.TC_AbsolutePath_Transform", + "reason": "Xunit.Sdk.TrueException Assert.True() Failure\\nExpected: True\\nActual: False" + }, + { + "name": "System.Xml.Tests.CTransformResolverTest.TC_AbsolutePath_Transform", + "reason": "Xunit.Sdk.TrueException Assert.True() Failure\\nExpected: True\\nActual: False" + } + ] + } + }, + { + "name": "System.Collections.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_string_string.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_SimpleInt_int_With_Comparer_WrapStructural_SimpleInt.IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_Generic_Tests_int_int.IEnumerable_Generic_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedBeforeEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedDuringEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_Reset_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + }, + { + "name": "System.Collections.Tests.Dictionary_IDictionary_NonGeneric_Tests.IEnumerable_NonGeneric_Enumerator_MoveNext_ModifiedAfterEnumeration_ThrowsInvalidOperationException", + "reason": "Assert.All() Failure: 1 out of 4 items in the collection did not pass.\r\n" + } + ] + } + }, + { + "name": "System.Linq.Parallel.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Linq.Parallel.Tests.GetEnumeratorTests.GetEnumerator", + "reason": "outdated" + }, + { + "name": "System.Linq.Parallel.Tests.GetEnumeratorTests.GetEnumerator_Unordered", + "reason": "outdated" + } + ] + } + }, + { + "name": "System.Linq.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "System.Linq.Tests.EmptyEnumerableTest.CastToIListGeneric", + "reason": "outdated" + }, + { + "name": "System.Linq.Tests.EmptyEnumerableTest.EmptyEnumerableIsIndeedEmpty", + "reason": "outdated" + }, + { + "name": "System.Linq.Tests.EmptyEnumerableTest.CastToArray", + "reason": "outdated" + }, + { + "name": "System.Linq.Tests.EmptyEnumerableTest.CastToIList", + "reason": "outdated" + }, + { + "name": "System.Linq.Tests.EmptyPartitionTests.CantResetEnumerator", + "reason": "outdated" + } + ] + } + }, + { + "name": "System.ComponentModel.Composition.Tests", + "enabled": false, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": null + } + }, + { + "name": "Microsoft.VisualBasic.Tests", + "enabled": true, + "exclusions": { + "namespaces": null, + "classes": null, + "methods": [ + { + "name": "Microsoft.VisualBasic.Tests.StringsTests.ChrW_CharCodeOutOfRange_ThrowsArgumentException", + "reason": "outdated" + }, + { + "name": "Microsoft.VisualBasic.Tests.StringsTests.AscW_NullOrEmpty_ThrowsArgumentException", + "reason": "outdated" + } + ] + } + } +] diff --git a/tests/CoreFX/CoreFXTestListURL.txt b/tests/CoreFX/CoreFXTestListURL.txt new file mode 100644 index 000000000000..926cf3c8f3e1 --- /dev/null +++ b/tests/CoreFX/CoreFXTestListURL.txt @@ -0,0 +1 @@ +https://cloudcijobs.blob.core.windows.net/coreclrci/CoreFXArchives/TestList.json \ No newline at end of file diff --git a/tests/CoreFX/CoreFXTestListURL_Linux.txt b/tests/CoreFX/CoreFXTestListURL_Linux.txt new file mode 100644 index 000000000000..29b8c2615b04 --- /dev/null +++ b/tests/CoreFX/CoreFXTestListURL_Linux.txt @@ -0,0 +1 @@ +https://cloudcijobs.blob.core.windows.net/coreclrci/CoreFXArchives_Linux/TestList.json \ No newline at end of file diff --git a/tests/CoreFX/CoreFXTestListURL_OSX.txt b/tests/CoreFX/CoreFXTestListURL_OSX.txt new file mode 100644 index 000000000000..bb4b850f685a --- /dev/null +++ b/tests/CoreFX/CoreFXTestListURL_OSX.txt @@ -0,0 +1 @@ +https://cloudcijobs.blob.core.windows.net/coreclrci/CoreFXArchives_OSX/TestList.json \ No newline at end of file diff --git a/tests/arm/Tests.lst b/tests/arm/Tests.lst index 148d63b8fd32..24a6a39bc3bd 100644 --- a/tests/arm/Tests.lst +++ b/tests/arm/Tests.lst @@ -2001,7 +2001,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest772\Generate WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest772\Generated772 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [_il_dbgldc_mul.cmd_252] @@ -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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [_relnative.cmd_718] @@ -13185,7 +13185,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest759\Generate WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest759\Generated759 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [GCSimulator_26.cmd_1659] @@ -17897,7 +17897,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1387\Generat WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1387\Generated1387 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [_il_dbgtest_2b.cmd_2249] @@ -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_FAIL;13731 +Categories=EXPECTED_PASS HostStyle=0 [r8rem_cs_r.cmd_2785] @@ -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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [StringConcat4.cmd_3396] @@ -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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [lim_002.cmd_4194] @@ -35609,7 +35609,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1219\Generat WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest1219\Generated1219 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;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_FAIL;13731 +Categories=EXPECTED_PASS 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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;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_FAIL;13731 +Categories=EXPECTED_PASS 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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [Double_No_Op_cs_r.cmd_4702] @@ -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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [invocation_do.cmd_6009] @@ -48428,14 +48428,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;Pri1 HostStyle=0 -[varargsupport_r.cmd_6076] -RelativePath=baseservices\varargs\varargsupport_r\varargsupport_r.cmd -WorkingDir=baseservices\varargs\varargsupport_r -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS -HostStyle=0 - [_il_relcatchfault_tail.cmd_6077] RelativePath=JIT\Methodical\Invoke\SEH\_il_relcatchfault_tail\_il_relcatchfault_tail.cmd WorkingDir=JIT\Methodical\Invoke\SEH\_il_relcatchfault_tail @@ -49225,7 +49217,7 @@ RelativePath=JIT\jit64\opt\cse\HugeArray\HugeArray.cmd WorkingDir=JIT\jit64\opt\cse\HugeArray Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [b11762.cmd_6176] @@ -53649,7 +53641,7 @@ RelativePath=CoreMangLib\cti\system\collections\generic\dictionary\DictionaryICo WorkingDir=CoreMangLib\cti\system\collections\generic\dictionary\DictionaryICollectionIsReadOnly2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [PulseNull.cmd_6730] @@ -62185,7 +62177,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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [b92713.cmd_7805] @@ -70969,7 +70961,7 @@ RelativePath=CoreMangLib\cti\system\runtime\interopservices\safehandle\SafeHandl WorkingDir=CoreMangLib\cti\system\runtime\interopservices\safehandle\SafeHandleHandle_PSC Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [b62498.cmd_8908] @@ -71809,7 +71801,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest574\Generate WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest574\Generated574 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [_il_relisinst_calli.cmd_9013] @@ -74412,14 +74404,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS HostStyle=0 -[varargsupport.cmd_9339] -RelativePath=baseservices\varargs\varargsupport\varargsupport.cmd -WorkingDir=baseservices\varargs\varargsupport -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS -HostStyle=0 - [uint8_d.cmd_9340] RelativePath=JIT\Directed\shift\uint8_d\uint8_d.cmd WorkingDir=JIT\Directed\shift\uint8_d @@ -83601,7 +83585,7 @@ RelativePath=JIT\Methodical\Boxing\misc\_dbgenum_cs\_dbgenum_cs.cmd WorkingDir=JIT\Methodical\Boxing\misc\_dbgenum_cs Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731 +Categories=EXPECTED_PASS HostStyle=0 [throwinnestedtryfinally_d.cmd_10500] @@ -83673,7 +83657,7 @@ RelativePath=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest323\Generate WorkingDir=Loader\classloader\TypeGeneratorTests\TypeGeneratorTest323\Generated323 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [ListInsertRange.cmd_10510] @@ -86465,7 +86449,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_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [Class2_ImplicitOverrideVirtual.cmd_10859] @@ -87577,7 +87561,7 @@ RelativePath=JIT\Methodical\Invoke\fptr\_speed_relrecurse\_speed_relrecurse.cmd WorkingDir=JIT\Methodical\Invoke\fptr\_speed_relrecurse Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [jaggedarr_cs_d.cmd_10999] @@ -88793,7 +88777,7 @@ RelativePath=CoreMangLib\cti\system\convert\ConvertToInt32_5\ConvertToInt32_5.cm WorkingDir=CoreMangLib\cti\system\convert\ConvertToInt32_5 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;13731;Pri1 +Categories=EXPECTED_PASS;Pri1 HostStyle=0 [Generated1317.cmd_11153] @@ -90892,14 +90876,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;NEW;EXCLUDED HostStyle=0 -[MaskLoad_r.cmd_11417] -RelativePath=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_r\MaskLoad_r.cmd -WorkingDir=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_r -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW;EXCLUDED -HostStyle=0 - [sharedgenerics_r.cmd_11418] RelativePath=Loader\classloader\DefaultInterfaceMethods\sharedgenerics\sharedgenerics_r\sharedgenerics_r.cmd WorkingDir=Loader\classloader\DefaultInterfaceMethods\sharedgenerics\sharedgenerics_r @@ -91804,14 +91780,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;NEW;EXCLUDED HostStyle=0 -[MaskLoad_ro.cmd_11531] -RelativePath=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_ro\MaskLoad_ro.cmd -WorkingDir=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_ro -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW;EXCLUDED -HostStyle=0 - [UnpackLow_ro.cmd_11532] RelativePath=JIT\HardwareIntrinsics\X86\Sse2\UnpackLow_ro\UnpackLow_ro.cmd WorkingDir=JIT\HardwareIntrinsics\X86\Sse2\UnpackLow_ro @@ -94740,3 +94708,131 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;Pri1;NEW HostStyle=0 +[GitHub_18482.cmd_11899] +RelativePath=JIT\Regression\JitBlue\GitHub_18482\GitHub_18482\GitHub_18482.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18482\GitHub_18482 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18295.cmd_11900] +RelativePath=JIT\Regression\JitBlue\GitHub_18295\GitHub_18295\GitHub_18295.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18295\GitHub_18295 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18235_1.cmd_11901] +RelativePath=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_1\GitHub_18235_1.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_1 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18235_2.cmd_11902] +RelativePath=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_2\GitHub_18235_2.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_2 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522.cmd_11903] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522\GitHub_18522.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_1.cmd_11904] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_1\GitHub_18522_1.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_1 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_2.cmd_11905] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_2\GitHub_18522_2.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_2 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_3.cmd_11906] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_3\GitHub_18522_3.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_3 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_4.cmd_11907] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_4\GitHub_18522_4.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_4 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_5.cmd_11908] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_5\GitHub_18522_5.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_5 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_6.cmd_11909] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_6\GitHub_18522_6.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_6 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_7.cmd_11910] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_7\GitHub_18522_7.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_7 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18362.cmd_11911] +RelativePath=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362\GitHub_18362.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[DevDiv_590771.cmd_11912] +RelativePath=JIT\Regression\JitBlue\DevDiv_590771\DevDiv_590771\DevDiv_590771.cmd +WorkingDir=JIT\Regression\JitBlue\DevDiv_590771\DevDiv_590771 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_8.cmd_11913] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_8\GitHub_18522_8.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_8 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18780.cmd_11914] +RelativePath=JIT\Regression\JitBlue\GitHub_18780\GitHub_18780\GitHub_18780.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18780\GitHub_18780 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + diff --git a/tests/arm/corefx_linux_test_exclusions.txt b/tests/arm/corefx_linux_test_exclusions.txt index 3c9d8af9d203..5ccb459f63cc 100644 --- a/tests/arm/corefx_linux_test_exclusions.txt +++ b/tests/arm/corefx_linux_test_exclusions.txt @@ -3,13 +3,10 @@ System.Data.SqlClient.Tests # https://github.com/dotnet/coreclr/issues/ System.Diagnostics.Process.Tests # https://github.com/dotnet/coreclr/issues/16001 System.Diagnostics.StackTrace.Tests # https://github.com/dotnet/coreclr/issues/17557 -- JitStress=1; https://github.com/dotnet/coreclr/issues/17558 -- JitStress=2 System.Drawing.Common.Tests # https://github.com/dotnet/coreclr/issues/16001 -System.Dynamic.Runtime.Tests # https://github.com/dotnet/coreclr/issues/18295 System.IO.FileSystem.Tests # https://github.com/dotnet/coreclr/issues/16001 System.IO.Ports.Tests # https://github.com/dotnet/coreclr/issues/16001 System.Linq.Expressions.Tests # https://github.com/dotnet/corefx/issues/29421 -- timeout System.Management.Tests # https://github.com/dotnet/coreclr/issues/16001 System.Net.Http.Functional.Tests # https://github.com/dotnet/coreclr/issues/17739 System.Net.NameResolution.Pal.Tests # https://github.com/dotnet/coreclr/issues/17740 -System.Net.NetworkInformation.Functional.Tests # https://github.com/dotnet/coreclr/issues/17753 -- segmentation fault -System.Net.Sockets.Tests # https://github.com/dotnet/coreclr/issues/17753 -- segmentation fault System.Text.RegularExpressions.Tests # https://github.com/dotnet/coreclr/issues/17754 -- timeout -- JitMinOpts only diff --git a/tests/arm/corefx_test_exclusions.txt b/tests/arm/corefx_test_exclusions.txt index 8b4f4fccf804..a14d45626bb5 100644 --- a/tests/arm/corefx_test_exclusions.txt +++ b/tests/arm/corefx_test_exclusions.txt @@ -6,13 +6,10 @@ System.Diagnostics.Process.Tests # https://github.com/dotnet/coreclr/issues/ System.Diagnostics.PerformanceCounter.Tests # https://github.com/dotnet/coreclr/issues/17799 System.Diagnostics.StackTrace.Tests # https://github.com/dotnet/coreclr/issues/17557 -- JitStress=1; https://github.com/dotnet/coreclr/issues/17558 -- JitStress=2 System.Drawing.Common.Tests # https://github.com/dotnet/coreclr/issues/16001 -System.Dynamic.Runtime.Tests # https://github.com/dotnet/coreclr/issues/18295 System.IO.FileSystem.Tests # https://github.com/dotnet/coreclr/issues/16001 System.IO.Ports.Tests # https://github.com/dotnet/coreclr/issues/16001 -System.Linq.Expressions.Tests # https://github.com/dotnet/coreclr/issues/18295 -- JitStress=2 System.Management.Tests # https://github.com/dotnet/coreclr/issues/16001 System.Net.HttpListener.Tests # https://github.com/dotnet/coreclr/issues/17584 System.Runtime.Numerics.Tests # https://github.com/dotnet/coreclr/issues/18362 -- JitStress=1 JitStress=2 System.Runtime.Tests # https://github.com/dotnet/coreclr/issues/17585 -System.Security.Cryptography.X509Certificates.Tests # https://github.com/dotnet/coreclr/issues/17801 System.Text.RegularExpressions.Tests # https://github.com/dotnet/coreclr/issues/17754 -- timeout -- JitMinOpts only diff --git a/tests/arm64/Tests.lst b/tests/arm64/Tests.lst index be9e7a813263..126b545d97b2 100644 --- a/tests/arm64/Tests.lst +++ b/tests/arm64/Tests.lst @@ -3857,7 +3857,7 @@ RelativePath=baseservices\threading\regressions\beta2\437044\437044.cmd WorkingDir=baseservices\threading\regressions\beta2\437044 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;Pri1 +Categories=EXPECTED_PASS;Pri1;15381;GCSTRESS_EXCLUDE HostStyle=0 [test489437.cmd_482] @@ -4612,22 +4612,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;Pri1 HostStyle=0 -[varargsupport.cmd_576] -RelativePath=baseservices\varargs\varargsupport\varargsupport.cmd -WorkingDir=baseservices\varargs\varargsupport -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS -HostStyle=0 - -[varargsupport_r.cmd_577] -RelativePath=baseservices\varargs\varargsupport_r\varargsupport_r.cmd -WorkingDir=baseservices\varargs\varargsupport_r -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS -HostStyle=0 - [Co9600Ctor.cmd_578] RelativePath=CoreMangLib\components\stopwatch\Co9600Ctor\Co9600Ctor.cmd WorkingDir=CoreMangLib\components\stopwatch\Co9600Ctor @@ -5305,7 +5289,7 @@ RelativePath=CoreMangLib\cti\system\array\ArraySort3b\ArraySort3b.cmd WorkingDir=CoreMangLib\cti\system\array\ArraySort3b Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_PASS +Categories=Pri1;RT;EXPECTED_PASS;15381;GCSTRESS_EXCLUDE HostStyle=0 [ArraySort4.cmd_663] @@ -18009,7 +17993,7 @@ RelativePath=CoreMangLib\cti\system\string\StringCompare9\StringCompare9.cmd WorkingDir=CoreMangLib\cti\system\string\StringCompare9 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_PASS +Categories=Pri1;RT;EXPECTED_PASS;15381;GCSTRESS_EXCLUDE HostStyle=0 [StringCompareOrdinal1.cmd_2464] @@ -18153,7 +18137,7 @@ RelativePath=CoreMangLib\cti\system\string\StringEquals6\StringEquals6.cmd WorkingDir=CoreMangLib\cti\system\string\StringEquals6 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_PASS +Categories=Pri1;RT;EXPECTED_PASS;15381;GCSTRESS_EXCLUDE HostStyle=0 [StringFormat1.cmd_2482] @@ -18161,7 +18145,7 @@ RelativePath=CoreMangLib\cti\system\string\StringFormat1\StringFormat1.cmd WorkingDir=CoreMangLib\cti\system\string\StringFormat1 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_FAIL;10115 +Categories=Pri1;RT;EXPECTED_PASS HostStyle=0 [StringFormat2.cmd_2483] @@ -18169,7 +18153,7 @@ RelativePath=CoreMangLib\cti\system\string\StringFormat2\StringFormat2.cmd WorkingDir=CoreMangLib\cti\system\string\StringFormat2 Expected=0 MaxAllowedDurationSeconds=600 -Categories=Pri1;RT;EXPECTED_FAIL;10115 +Categories=Pri1;RT;EXPECTED_PASS HostStyle=0 [StringGetEnumerator.cmd_2484] @@ -21737,7 +21721,7 @@ RelativePath=GC\Features\LOHCompaction\lohcompactapi\lohcompactapi.cmd WorkingDir=GC\Features\LOHCompaction\lohcompactapi Expected=0 MaxAllowedDurationSeconds=600 -Categories=UNSTABLE;EXPECTED_PASS +Categories=UNSTABLE;EXPECTED_PASS;LONG_RUNNING HostStyle=0 [lohcompactapi2.cmd_2949] @@ -39961,7 +39945,7 @@ RelativePath=JIT\jit64\opt\cse\HugeArray\HugeArray.cmd WorkingDir=JIT\jit64\opt\cse\HugeArray Expected=0 MaxAllowedDurationSeconds=600 -Categories=JIT;EXPECTED_PASS;Pri1 +Categories=JIT;EXPECTED_PASS;Pri1;GCSTRESS_EXCLUDE HostStyle=0 [HugeArray1.cmd_5296] @@ -57977,7 +57961,7 @@ RelativePath=JIT\Methodical\refany\_speed_dbgstress1\_speed_dbgstress1.cmd WorkingDir=JIT\Methodical\refany\_speed_dbgstress1 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;15381;GCSTRESS_EXCLUDE HostStyle=0 [_speed_dbgstress3.cmd_7563] @@ -68609,7 +68593,7 @@ RelativePath=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b426654\b426654\b426654.cmd WorkingDir=JIT\Regression\CLR-x86-JIT\V2.0-Beta2\b426654\b426654 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS +Categories=EXPECTED_PASS;15381;GCSTRESS_EXCLUDE HostStyle=0 [b441487.cmd_8927] @@ -90601,7 +90585,7 @@ RelativePath=GC\API\NoGCRegion\NoGC\NoGC.cmd WorkingDir=GC\API\NoGCRegion\NoGC Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW;GCSTRESS_EXCLUDE +Categories=EXPECTED_PASS;NEW;GCSTRESS_EXCLUDE;LONG_RUNNING HostStyle=0 [DevDiv_397793.cmd_11701] @@ -90900,14 +90884,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;NEW;EXCLUDED HostStyle=0 -[MaskLoad_r.cmd_11736] -RelativePath=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_r\MaskLoad_r.cmd -WorkingDir=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_r -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW;EXCLUDED -HostStyle=0 - [sharedgenerics_r.cmd_11737] RelativePath=Loader\classloader\DefaultInterfaceMethods\sharedgenerics\sharedgenerics_r\sharedgenerics_r.cmd WorkingDir=Loader\classloader\DefaultInterfaceMethods\sharedgenerics\sharedgenerics_r @@ -91796,14 +91772,6 @@ MaxAllowedDurationSeconds=600 Categories=EXPECTED_PASS;NEW;EXCLUDED HostStyle=0 -[MaskLoad_ro.cmd_11848] -RelativePath=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_ro\MaskLoad_ro.cmd -WorkingDir=JIT\HardwareIntrinsics\X86\Avx\MaskLoad_ro -Expected=0 -MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW;EXCLUDED -HostStyle=0 - [UnpackLow_ro.cmd_11849] RelativePath=JIT\HardwareIntrinsics\X86\Sse2\UnpackLow_ro\UnpackLow_ro.cmd WorkingDir=JIT\HardwareIntrinsics\X86\Sse2\UnpackLow_ro @@ -91889,7 +91857,7 @@ RelativePath=GC\API\GC\GetAllocatedBytesForCurrentThread\GetAllocatedBytesForCur WorkingDir=GC\API\GC\GetAllocatedBytesForCurrentThread Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW +Categories=EXPECTED_PASS;NEW;LONG_RUNNING HostStyle=0 [VectorRet_ro.cmd_11860] @@ -93585,7 +93553,7 @@ RelativePath=JIT\HardwareIntrinsics\Arm64\Simd\Simd.cmd WorkingDir=JIT\HardwareIntrinsics\Arm64\Simd Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_PASS;NEW +Categories=EXPECTED_FAIL;18895;NEW HostStyle=0 [Sqrt_r.cmd_12072] @@ -94761,6 +94729,125 @@ RelativePath=JIT\Regression\JitBlue\DevDiv_590771\DevDiv_590771\DevDiv_590771.cm WorkingDir=JIT\Regression\JitBlue\DevDiv_590771\DevDiv_590771 Expected=0 MaxAllowedDurationSeconds=600 -Categories=EXPECTED_FAIL;17967;EXCLUDED +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18482.cmd_12219] +RelativePath=JIT\Regression\JitBlue\GitHub_18482\GitHub_18482\GitHub_18482.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18482\GitHub_18482 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS HostStyle=0 +[GitHub_18295.cmd_12220] +RelativePath=JIT\Regression\JitBlue\GitHub_18295\GitHub_18295\GitHub_18295.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18295\GitHub_18295 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18235_1.cmd_12221] +RelativePath=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_1\GitHub_18235_1.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_1 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18235_2.cmd_12222] +RelativePath=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_2\GitHub_18235_2.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18235\GitHub_18235_2 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522.cmd_12223] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522\GitHub_18522.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_1.cmd_12224] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_1\GitHub_18522_1.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_1 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_2.cmd_12225] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_2\GitHub_18522_2.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_2 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_3.cmd_12226] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_3\GitHub_18522_3.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_3 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_4.cmd_12227] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_4\GitHub_18522_4.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_4 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_5.cmd_12228] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_5\GitHub_18522_5.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_5 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_6.cmd_12229] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_6\GitHub_18522_6.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_6 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_7.cmd_12230] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_7\GitHub_18522_7.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_7 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18362.cmd_12231] +RelativePath=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362\GitHub_18362.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18362\GitHub_18362 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18522_8.cmd_12232] +RelativePath=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_8\GitHub_18522_8.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18522\GitHub_18522_8 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 + +[GitHub_18780.cmd_12233] +RelativePath=JIT\Regression\JitBlue\GitHub_18780\GitHub_18780\GitHub_18780.cmd +WorkingDir=JIT\Regression\JitBlue\GitHub_18780\GitHub_18780 +Expected=0 +MaxAllowedDurationSeconds=600 +Categories=EXPECTED_PASS +HostStyle=0 diff --git a/tests/arm64/corefx_test_exclusions.txt b/tests/arm64/corefx_test_exclusions.txt index 6b00a5897829..660069ecc645 100644 --- a/tests/arm64/corefx_test_exclusions.txt +++ b/tests/arm64/corefx_test_exclusions.txt @@ -1,3 +1,13 @@ Invariant.Tests -System.Diagnostics.Process.Tests +System.ComponentModel.Composition.Tests # https://github.com/dotnet/coreclr/issues/18913 +System.Diagnostics.Process.Tests # https://github.com/dotnet/coreclr/issues/16001 +System.Drawing.Common.Tests # https://github.com/dotnet/coreclr/issues/18886 +System.Linq.Expressions.Tests # JitStress=1 JitStress=2 https://github.com/dotnet/coreclr/issues/18886 +System.Management.Tests # https://github.com/dotnet/coreclr/issues/18886 +System.Net.HttpListener.Tests # https://github.com/dotnet/coreclr/issues/17584 +System.Numerics.Vectors.Tests # https://github.com/dotnet/coreclr/issues/18886 +System.Runtime.InteropServices.RuntimeInformation.Tests # VM assert -- https://github.com/dotnet/coreclr/issues/18886 +System.Runtime.Serialization.Formatters.Tests # long running? https://github.com/dotnet/coreclr/issues/18886 +System.Runtime.Tests # https://github.com/dotnet/coreclr/issues/18914 +System.Text.RegularExpressions.Tests # https://github.com/dotnet/coreclr/issues/18912 -- timeout -- JitMinOpts only System.ValueTuple.Tests diff --git a/tests/build.proj b/tests/build.proj index aede1317a1c3..a421b130b605 100644 --- a/tests/build.proj +++ b/tests/build.proj @@ -31,7 +31,6 @@ - diff --git a/tests/dir.common.props b/tests/dir.common.props new file mode 100644 index 000000000000..5c596c0fed86 --- /dev/null +++ b/tests/dir.common.props @@ -0,0 +1,28 @@ + + + + + + + $(BuildOS).$(Platform).$(Configuration) + + $(CoreclrDir)/tests/src + $([System.String]::Copy('$(MSBuildProjectDirectary)').Replace($(TestSrcDir),''))/$(MSBuildProjectName) + + + $(CoreclrDir)/bin/tests/obj/$(OSPlatformConfig)/Managed/$(BuildProjectRelativeDir) + $(BaseIntermediateOutputPath) + + $(CoreclrDir)/bin/tests/$(OSPlatformConfig)/$(BuildProjectRelativeDir) + $(BaseOutputPath) + + + + diff --git a/tests/dir.props b/tests/dir.props index b29983cfbe9e..5b0713610d98 100644 --- a/tests/dir.props +++ b/tests/dir.props @@ -34,7 +34,6 @@ $(BuildToolsTargetsDesktop) true true - false @@ -47,7 +46,6 @@ $(ToolsDir)dotnetcli\ $(ToolsDir)net46\ $(DotnetCliPath)dotnet - $(ToolsDir)\Microsoft.CSharp.Core.targets <_TargetFrameworkDirectories Condition="'$(BuildToolsTargetsDesktop)' != 'true'">$(MSBuildThisFileDirectory)/Documentation @@ -105,8 +103,7 @@ - - + diff --git a/tests/dir.sdkbuild.props b/tests/dir.sdkbuild.props new file mode 100644 index 000000000000..b5a0fdd07662 --- /dev/null +++ b/tests/dir.sdkbuild.props @@ -0,0 +1,14 @@ + + + + + + + netcoreapp2.0 + false + false + + + diff --git a/tests/helixprep.proj b/tests/helixprep.proj index 2d08e91b13c6..1cbf0ed0f8bf 100644 --- a/tests/helixprep.proj +++ b/tests/helixprep.proj @@ -38,7 +38,7 @@ Inputs="@(XunitDlls)" Outputs="$(TestWorkingDir)archive\**" > - @@ -85,8 +85,8 @@ set CORE_ROOT=%HELIX_CORRELATION_PAYLOAD% $(CmdCrossgenVar) ECHO BEGIN EXECUTION -ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing -%HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.netcore.exe %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing +ECHO %HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.dll %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing +%HELIX_CORRELATION_PAYLOAD%\CoreRun.exe %HELIX_WORKITEM_PAYLOAD%\xunit.console.dll %HELIX_WORKITEM_PAYLOAD%\$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing echo Finished running tests. Exit code = %ERRORLEVEL% EXIT /B %ERRORLEVEL% @@ -149,8 +149,8 @@ EXIT /B %ERRORLEVEL% $(WrapperShContents)%0a $(WrapperShContents)echo BEGIN EXECUTION%0a - $(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a - $(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.netcore.exe %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a + $(WrapperShContents)echo "%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.dll %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a + $(WrapperShContents)"%24{HELIX_CORRELATION_PAYLOAD}/corerun" %24HELIX_WORKITEM_PAYLOAD/xunit.console.dll %24HELIX_WORKITEM_PAYLOAD/$(ProjectName) -noshadow -xml testResults.xml -notrait category=outerloop -notrait category=failing%0a $(WrapperShContents)ErrorLevel=%24%3F%0a $(WrapperShContents)%0a $(WrapperShContents)echo Finished running tests. Exit code = %24ErrorLevel%0a diff --git a/tests/issues.targets b/tests/issues.targets index aed787dd136b..145c16a04975 100644 --- a/tests/issues.targets +++ b/tests/issues.targets @@ -190,6 +190,12 @@ 18056 + + Varargs supported on this platform + + + Varargs supported on this platform + @@ -210,9 +216,6 @@ 2420. x86 JIT doesn't support implicit tail call optimization or tail. call pop ret sequence - - 7163 - 11469, The test causes OutOfMemory exception in crossgen mode. @@ -232,15 +235,6 @@ - - 17968 - - - 17966 - - - 17967 - diff --git a/tests/override.targets b/tests/override.targets index 0e7f82bf77be..d4c07a0f00bf 100644 --- a/tests/override.targets +++ b/tests/override.targets @@ -3,10 +3,6 @@ Overrides for all other targets (including build tools) can go in this file. --> - - - + + 9.9.9 + $(BinDir)testhost\ + $(TestHostRootPath)host\fxr\$(NETCoreAppTestSharedFxVersion)\ + $(TestHostRootPath)shared\Microsoft.NETCore.App\$(NETCoreAppTestSharedFxVersion)\ + + <_SkipTestDir Include="@(DisabledTestDir)" /> @@ -67,63 +74,34 @@ $(_XunitEpilog) - + + + - - Debug - AnyCPU - $(XunitWrapper) - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Library - .NETFramework - v4.5 - net45 - true - true - {786C830F-07A1-408B-BD7F-6EE04809D6DB}%3B{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - BuildOnly - true - - - - - + $(XUnitTestBinBase)\$(CategoryWithSlash) + + + + - - - - - {8ffe99c0-22f8-4462-b839-970eac1b3472} - coreclr - - - {8ffe99c0-22f8-4462-b839-970eac1b3472} - coreclr - + - - - + + - - - $(XunitTestBinBase)\$(CategoryWithSlash)\ - %24(TestWrappersPackagesConfigFileDirectory)obj/project.assets.json - + + + - ]]> +]]> - @@ -143,7 +121,7 @@ $(_XunitEpilog) - + @@ -158,7 +136,6 @@ $(_XunitEpilog) $([System.String]::Copy('$(CategoryWithSlash)').Replace('/','.')) $(Category).XUnitWrapper $(XunitWrapperGeneratedCSDirBase)$(Category) - $(XunitWrapperOutputIntermediatedDirBase)$(Category) <_XunitProlog Condition=" '$(_XunitProlog)'=='' "> @@ -183,7 +160,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). { reportBase = System.Environment.GetEnvironmentVariable(%22XunitTestReportDirBase%22)%3B testBinaryBase = System.IO.Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath)%3B - coreRoot = System.IO.Path.GetFullPath(System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22))%3B + coreRoot = System.Environment.GetEnvironmentVariable(%22CORE_ROOT%22)%3B if (String.IsNullOrEmpty(reportBase)) { reportBase = System.IO.Path.Combine(testBinaryBase, "Reports")%3B @@ -197,6 +174,8 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). throw new ArgumentException("Environment variable CORE_ROOT is not set")%3B } + coreRoot = System.IO.Path.GetFullPath(coreRoot)%3B + string operatingSystem = System.Environment.GetEnvironmentVariable("OS")%3B runningInWindows = (operatingSystem != null && operatingSystem.StartsWith("Windows"))%3B } @@ -250,7 +229,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). try { CoreclrTestWrapperLib wrapper = new CoreclrTestWrapperLib()%3B - string testSubfolder = @"\$(Category)\$([System.String]::Copy('%(AllCMDs.RelativeDir)').Replace("$(_CMDDIR)\",''))"%3B + string testSubfolder = @"\$(Category)\$([System.String]::Copy('%(AllCMDs.RelativeDir)').Replace("$(_CMDDIR)$([System.IO.Path]::DirectorySeparatorChar)",''))"%3B outputFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).output.txt")%3B errorFile = System.IO.Path.GetFullPath(_Global.reportBase + testSubfolder + @"%(AllCMDs.FileName).error.txt")%3B testExecutable = System.IO.Path.GetFullPath(_Global.testBinaryBase + @"$([System.String]::Copy('%(AllCMDs.FullPath)').Replace("$(_CMDDIR)",''))")%3B @@ -293,7 +272,7 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). outputText = "Unable to read output file: " + outputFile%3B } - string msg = infraEx != null ? "Test Infrastructure Failure: " + infraEx.Message + string msg = infraEx != null ? "Test Infrastructure Failure: " + infraEx.ToString() : sErrorText + "\n\n" + "Return code: " + ret + "\n" + "Raw output file: " + outputFile + "\n" + @@ -321,7 +300,8 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). - + + @@ -363,6 +343,98 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). Condition=" '$(BuildTestsAgainstPackages)'=='true' " /> + + + + + + + + + + + + + + + + + + + <_sharedFrameworkDepsJson Include="$(ToolsDir)dotnetcli\shared\Microsoft.NETCore.App\*\Microsoft.NETCore.App.deps.json" /> + + + + <_OriginalDepsJsonPath>%(_sharedFrameworkDepsJson.FullPath) + <_OutputTestSharedFrameworkDepsPath>$(NETCoreAppTestSharedFrameworkPath)\Microsoft.NETCore.App.deps.json + + + + + + + + + hostfxr + dll + dotnet.exe + hostpolicy + dll + + + + libhostfxr + so + dylib + libhostpolicy + $(HostFxrFileExtension) + dotnet + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -396,11 +468,15 @@ namespace $([System.String]::Copy($(Category)).Replace(".","_").Replace("\",""). Targets="CreateTestOverlay" Condition=" '$(GenerateRuntimeLayout)'=='true' "/> + + - + diff --git a/tests/runtest.py b/tests/runtest.py new file mode 100755 index 000000000000..7cadfb4b1089 --- /dev/null +++ b/tests/runtest.py @@ -0,0 +1,441 @@ +#!/usr/bin/env python +################################################################################ +################################################################################ +# +# Module: runtest.py +# +# Notes: +# +# Universal script to setup and run the xunit msbuild test runner. +# +# Use the instructions here: +# https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-test-instructions.md +# https://github.com/dotnet/coreclr/blob/master/Documentation/building/unix-test-instructions.md +# +################################################################################ +################################################################################ + +import argparse +import json +import os +import platform +import shutil +import subprocess +import sys +import tempfile + +from collections import defaultdict +from sys import platform as _platform + +################################################################################ +# Argument Parser +################################################################################ + +description = ("""Simple script that essentially sets up and runs either runtest.cmd + or runtests.sh. This wrapper is necessary to do all the setup work. + + Note that this is required because there is not a unified test runner + for coreclr.""") + +# Use either - or / to designate switches. +parser = argparse.ArgumentParser(description=description, prefix_chars='-/') + +parser.add_argument("-arch", dest="arch", nargs='?', default="x64") +parser.add_argument("-build_type", dest="build_type", nargs='?', default="Debug") +parser.add_argument("-test_location", dest="test_location", nargs="?", default=None) +parser.add_argument("-core_root", dest="core_root", nargs='?', default=None) +parser.add_argument("-coreclr_repo_location", dest="coreclr_repo_location", default=os.getcwd()) + +# Only used on Unix +parser.add_argument("-test_native_bin_location", dest="test_native_bin_location", nargs='?', default=None) + +################################################################################ +# Helper Functions +################################################################################ + +def create_and_use_test_env(_os, env, func): + """ Create a test env based on the env passed + + Args: + _os(str) : OS name + env(defaultdict(lambda: None)) : complus variables, key,value dict + func(lambda) : lambda to call, after creating the + : test_env + + Notes: + Using the env passed, create a temporary file to use as the + test_env to be passed for runtest.cmd. Note that this only happens + on windows, until xunit is used on unix there is no managed code run + in runtest.sh. + """ + + complus_vars = defaultdict(lambda: None) + + for key in env: + value = env[key] + if "complus" in key.lower(): + complus_vars[key] = value + + if len(complus_vars.keys()) > 0: + print "Found COMPlus variables in the current environment" + print + + file_header = None + + if _os == "Windows_NT": + file_header = \ +"""@echo off +REM Temporary test env for test run. + +""" + else: + file_header = \ +"""# Temporary test env for test run. + +""" + + with tempfile.NamedTemporaryFile() as test_env: + with open(test_env.name, 'w') as file_handle: + file_handle.write(file_header) + + for key in complus_vars: + value = complus_vars[key] + command = None + if _os == "Windows_NT": + command = "set" + else: + command = "export" + + print "Unset %s" % key + os.environ[key] = "" + + file_handle.write("%s %s=%s%s" % (command, key, value, os.linesep)) + + contents = None + with open(test_env.name) as file_handle: + contents = file_handle.read() + + print + print "TestEnv: %s" % test_env.name + print + print "Contents:" + print + print contents + print + + func(test_env.name) + + else: + func(None) + +def get_environment(): + """ Get all the COMPlus_* Environment variables + + Notes: + Windows uses msbuild for its test runner. Therefore, all COMPlus + variables will need to be captured as a test_env script and passed + to runtest.cmd. + """ + + complus_vars = defaultdict(lambda: "") + + for key in os.environ: + if "complus" in key.lower(): + complus_vars[key] = os.environ[key] + os.environ[key] = '' + elif "superpmi" in key.lower(): + complus_vars[key] = os.environ[key] + os.environ[key] = '' + + return complus_vars + +def call_msbuild(coreclr_repo_location, + msbuild_location, + host_os, + arch, + build_type, + sequential=False): + """ Call msbuild to run the tests built. + + Args: + coreclr_repo_location(str) : path to coreclr repo + msbuild_location(str) : path to msbuild + sequential(bool) : run sequentially if True + + host_os(str) : os + arch(str) : architecture + build_type(str) : configuration + + Notes: + At this point the environment should be setup correctly, including + the test_env, should it need to be passed. + + """ + + common_msbuild_arguments = ["/nologo", "/nodeReuse:false", "/p:Platform=%s" % arch] + + if sequential: + common_msbuild_arguments += ["/p:ParallelRun=false"] + else: + common_msbuild_arguments += ["/maxcpucount"] + + logs_dir = os.path.join(coreclr_repo_location, "bin", "Logs") + if not os.path.isdir(logs_dir): + os.makedirs(logs_dir) + + command = [msbuild_location, + os.path.join(coreclr_repo_location, "tests", "runtest.proj"), + "/p:Runtests=true", + "/clp:showcommandline"] + + log_path = os.path.join(logs_dir, "TestRunResults_%s_%s_%s" % (host_os, arch, build_type)) + build_log = log_path + ".log" + wrn_log = log_path + ".wrn" + err_log = log_path + ".err" + + msbuild_log_args = ["/fileloggerparameters:\"Verbosity=normal;LogFile=%s\"" % build_log, + "/fileloggerparameters1:\"WarningsOnly;LogFile=%s\"" % wrn_log, + "/fileloggerparameters2:\"ErrorsOnly;LogFile=%s\"" % err_log, + "/consoleloggerparameters:Summary", + "/verbosity:diag"] + + command += msbuild_log_args + + command += ["/p:__BuildOS=%s" % host_os, + "/p:__BuildArch=%s" % arch, + "/p:__BuildType=%s" % build_type, + "/p:__LogsDir=%s" % logs_dir] + + if host_os != "Windows_NT": + command = ["bash"] + command + + print " ".join(command) + subprocess.check_output(command) + +def copy_native_test_bin_to_core_root(host_os, path, core_root): + """ Recursively copy all files to core_root + + Args: + host_os(str) : os + path(str) : native test bin location + core_root(str) : core_root location + """ + assert os.path.isdir(path) or os.path.isfile(path) + assert os.path.isdir(core_root) + + extension = "so" if host_os == "Linux" else "dylib" + + if os.path.isdir(path): + for item in os.listdir(path): + copy_native_test_bin_to_core_root(host_os, os.path.join(path, item), core_root) + elif path.endswith(extension): + print "cp -p %s %s" % (path, core_root) + shutil.copy2(path, core_root) + +def run_tests(host_os, + arch, + build_type, + core_root, + coreclr_repo_location, + test_location, + test_native_bin_location, + test_env=None, + is_long_gc=False, + is_gcsimulator=False, + is_jitdasm=False, + is_ilasm=False, + run_sequential=False): + """ Run the coreclr tests + + Args: + host_os(str) : os + arch(str) : arch + build_type(str) : configuration + coreclr_repo_location(str) : path to the root of the repo + core_root(str) : Core_Root path + test_location(str) : Test bin, location + test_native_bin_location : Native test components, None and windows. + test_env(str) : path to the test_env to be used + """ + + # Copy all the native libs to core_root + if host_os != "Windows_NT": + copy_native_test_bin_to_core_root(host_os, os.path.join(test_native_bin_location, "src"), core_root) + + # Setup the msbuild location + msbuild_location = os.path.join(coreclr_repo_location, "Tools", "msbuild.%s" % ("cmd" if host_os == "Windows_NT" else "sh")) + + # Setup the environment + if is_long_gc: + print "Running Long GC Tests, extending timeout to 20 minutes." + os.environ["__TestTimeout"] = "1200000" # 1,200,000 + os.environ["RunningLongGCTests"] = "1" + + if is_gcsimulator: + print "Running GCSimulator tests, extending timeout to one hour." + os.environ["__TestTimeout"] = "3600000" # 3,600,000 + os.environ["RunningGCSimulatorTests"] = "1" + + if is_jitdasm: + print "Running jit disasm on framework and test assemblies." + os.environ["RunningJitDisasm"] = "1" + + if is_ilasm: + print "Running ILasm round trip." + os.environ["RunningIlasmRoundTrip"] = "1" + + # Set Core_Root + os.environ["CORE_ROOT"] = core_root + + # Call msbuild. + call_msbuild(coreclr_repo_location, + msbuild_location, + host_os, + arch, + build_type, + sequential=run_sequential) + + +def setup_args(args): + """ Setup the args based on the argparser obj + + Args: + args(ArgParser): Parsed arguments + + Notes: + If there is no core_root, or test location passed, create a default + location using the build type and the arch. + """ + + host_os = None + arch = args.arch + build_type = args.build_type + + test_location = args.test_location + core_root = args.core_root + test_native_bin_location = args.test_native_bin_location + + coreclr_repo_location = args.coreclr_repo_location + if os.path.basename(coreclr_repo_location) == "tests": + coreclr_repo_location = os.path.dirname(coreclr_repo_location) + + if _platform == "linux" or _platform == "linux2": + host_os = "Linux" + elif _platform == "darwin": + host_os = "OSX" + elif _platform == "win32": + host_os = "Windows_NT" + else: + print "Unknown OS: %s" % host_os + sys.exit(1) + + assert os.path.isdir(coreclr_repo_location) + + if test_location is None: + print "Using default test location." + test_location = os.path.join(coreclr_repo_location, "bin", "tests", "%s.%s.%s" % (host_os, arch, build_type)) + print "TestLocation: %s" % test_location + print + + if core_root is None: + print "Using default location for core_root." + core_root = os.path.join(test_location, "Tests", "Core_Root") + print "Core_Root: %s" % core_root + print + + if host_os != "Windows_NT": + if test_native_bin_location is None: + print "Using default location for test_native_bin_location." + test_native_bin_location = os.path.join(os.path.join(coreclr_repo_location, "bin", "obj", "%s.%s.%s" % (host_os, arch, build_type), "tests")) + print "Native bin location: %s" % test_native_bin_location + print + + valid_arches = ["x64", "x86", "arm", "arm64"] + if not arch in valid_arches: + print "Unsupported architecture: %s." % arch + print "Supported architectures: %s" % "[%s]" % ", ".join(valid_arches) + sys.exit(1) + + valid_build_types = ["Debug", "Checked", "Release"] + if not build_type in valid_build_types: + print "Unsupported configuration: %s." % build_type + print "Supported configurations: %s" % "[%s]" % ", ".join(valid_build_types) + sys.exit(1) + + if not os.path.isdir(test_location): + print "Error, test location: %s, does not exist." % test_location + sys.exit(1) + + if not os.path.isdir(core_root): + print "Error, core_root: %s, does not exist." % core_root + sys.exit(1) + + if host_os != "Windows_NT": + if not os.path.isdir(test_native_bin_location): + print "Error, test_native_bin_location: %s, does not exist." % test_native_bin_location + sys.exit(1) + + return host_os, arch, build_type, coreclr_repo_location, core_root, test_location, test_native_bin_location + +def setup_tools(host_os, coreclr_repo_location): + """ Setup the tools for the repo + + Args: + host_os(str) : os + coreclr_repo_location(str) : path to coreclr repo + + """ + + # Is the tools dir setup + setup = False + tools_dir = os.path.join(coreclr_repo_location, "Tools") + + is_windows = host_os == "Windows_NT" + + if os.path.isfile(os.path.join(tools_dir, "msbuild.%s" % ("cmd" if is_windows else "sh"))): + setup = True + + # init the tools for the repo + if not setup: + command = None + if is_windows: + command = [os.path.join(coreclr_repo_location, "init_tools.cmd")] + else: + command = ["sh", os.path.join(coreclr_repo_location, "init_tools.sh")] + + print " ".join(command) + subprocess.check_output(command) + + setup = True + + return setup + +################################################################################ +# Main +################################################################################ + +def main(args): + host_os, arch, build_type, coreclr_repo_location, core_root, test_location, test_native_bin_location = setup_args(args) + + # Setup the tools for the repo. + setup_tools(host_os, coreclr_repo_location) + + env = get_environment() + ret_code = create_and_use_test_env(host_os, + env, + lambda path: run_tests(host_os, + arch, + build_type, + core_root, + coreclr_repo_location, + test_location, + test_native_bin_location, + test_env=path)) + +################################################################################ +# __main__ +################################################################################ + +if __name__ == "__main__": + args = parser.parse_args() + sys.exit(main(args)) \ No newline at end of file diff --git a/tests/runtest.sh b/tests/runtest.sh index c63ed4a30bb3..a4631a72c93c 100755 --- a/tests/runtest.sh +++ b/tests/runtest.sh @@ -67,6 +67,13 @@ function print_usage { echo ' is zero when launching this script. This option is intended for use in CI.' echo ' --xunitOutputPath= : Create xUnit XML report at the specifed path (default: /coreclrtests.xml)' echo '' + echo 'CoreFX Test Options ' + echo ' --corefxtests : Runs CoreFX tests' + echo ' --corefxtestsall : Runs all available CoreFX tests' + echo ' --corefxtestlist= : Runs the CoreFX tests specified in the passed list' + echo ' --testHostDir= : Directory containing a built test host including core binaries, test dependencies' + echo ' and a dotnet executable' + echo '' echo 'Runtime Code Coverage options:' echo ' --coreclr-coverage : Optional argument to get coreclr code coverage reports' echo ' --coreclr-objs= : Location of root of the object directory' @@ -407,9 +414,6 @@ function create_core_overlay { if [ ! -d "$coreClrBinDir" ]; then exit_with_error "$errorSource" "Directory specified by --coreClrBinDir does not exist: $coreClrBinDir" fi - if [ -z "$coreFxBinDir" ]; then - exit_with_error "$errorSource" "One of --coreOverlayDir or --coreFxBinDir must be specified." "$printUsage" - fi # Create the overlay coreOverlayDir=$testRootDir/Tests/coreoverlay @@ -437,6 +441,81 @@ function create_core_overlay { copy_test_native_bin_to_test_root $coreOverlayDir } +function create_testhost +{ + if [ ! -d "$testHostDir" ]; then + exit_with_error "$errorSource" "Did not find the test host directory: $testHostDir" + fi + + # Initialize test variables + local buildToolsDir=$coreClrSrc/Tools + local dotnetExe=$buildToolsDir/dotnetcli/dotnet + local coreClrSrcTestDir=$coreClrSrc/tests + + if [ -z $coreClrBinDir ]; then + local coreClrBinDir=${coreClrSrc}/bin + export __CoreFXTestDir=${coreClrSrc}/bin/tests/CoreFX + else + export __CoreFXTestDir=${coreClrBinDir}/tests/CoreFX + fi + + local coreFXTestSetupUtilityName=CoreFX.TestUtils.TestFileSetup + local coreFXTestSetupUtility="${coreClrSrcTestDir}/src/Common/CoreFX/TestFileSetup/${coreFXTestSetupUtilityName}.csproj" + local coreFXTestSetupUtilityOutputPath=${__CoreFXTestDir}/TestUtilities + local coreFXTestBinariesOutputPath=${__CoreFXTestDir}/tests_downloaded + + if [ -z $CoreFXTestList]; then + local CoreFXTestList="${coreClrSrcTestDir}/CoreFX/CoreFX.issues.json" + fi + + case "${OSName}" in + # Check if we're running under OSX + Darwin) + local coreFXTestRemoteURL=$(<${coreClrSrcTestDir}/CoreFX/CoreFXTestListURL_OSX.txt) + local coreFXTestExclusionDef=nonosxtests + ;; + # Default to Linux + *) + local coreFXTestRemoteURL=$(<${coreClrSrcTestDir}/CoreFX/CoreFXTestListURL_Linux.txt) + local coreFXTestExclusionDef=nonlinuxtests + ;; + esac + + local coreFXTestExecutable=xunit.console.netcore.exe + local coreFXLogDir=${coreClrBinDir}/Logs/CoreFX/ + local coreFXTestExecutableArgs="--notrait category=nonnetcoreapptests --notrait category=${coreFXTestExclusionDef} --notrait category=failing --notrait category=IgnoreForCI --notrait category=OuterLoop --notrait Benchmark=true" + + chmod +x ${dotnetExe} + resetCommandArgs=("msbuild /t:Restore ${coreFXTestSetupUtility}") + echo "${dotnetExe} $resetCommandArgs" + "${dotnetExe}" $resetCommandArgs + + buildCommandArgs=("msbuild ${coreFXTestSetupUtility} /p:OutputPath=${coreFXTestSetupUtilityOutputPath} /p:Platform=${_arch} /p:Configuration=Release") + echo "${dotnetExe} $buildCommandArgs" + "${dotnetExe}" $buildCommandArgs + + if [ "${RunCoreFXTestsAll}" == "1" ]; then + local coreFXRunCommand=--runAllTests + else + local coreFXRunCommand=--runSpecifiedTests + fi + + local buildTestSetupUtilArgs=("${coreFXTestSetupUtilityOutputPath}/${coreFXTestSetupUtilityName}.dll --clean --outputDirectory ${coreFXTestBinariesOutputPath} --testListJsonPath ${CoreFXTestList} ${coreFXRunCommand} --dotnetPath ${testHostDir}/dotnet --testUrl ${coreFXTestRemoteURL} --executable ${coreFXTestExecutable} --log ${coreFXLogDir} ${coreFXTestExecutableArgs}") + echo "${dotnetExe} $buildTestSetupUtilArgs" + "${dotnetExe}" $buildTestSetupUtilArgs + + local exitCode=$? + if [ $exitCode != 0 ]; then + echo Running CoreFX tests finished with failures + else + echo Running CoreFX tests finished successfully + fi + + echo Check ${coreFXLogDir} for test run logs + + exit ${exitCode} +} + declare -a skipCrossGenFiles function is_skip_crossgen_test { @@ -1168,6 +1247,20 @@ do --runcrossgentests) export RunCrossGen=1 ;; + --corefxtests) + export RunCoreFXTests=1 + ;; + --corefxtestsall) + export RunCoreFXTests=1 + export RunCoreFXTestsAll=1 + ;; + --corefxtestlist) + export RunCoreFXTests=1 + export CoreFXTestList=${i#*=} + ;; + --testHostDir=*) + export testHostDir=${i#*=} + ;; --sequential) ((maxProcesses = 1)) ;; @@ -1238,6 +1331,36 @@ fi export COMPlus_gcServer="$serverGC" +if [ "$RunCoreFXTests" == 1 ]; +then + if [ -z "$coreClrSrc" ] + then + echo "Coreclr src files are required to run CoreFX tests" + echo "Coreclr src files root path can be passed using '--coreclr-src' argument" + print_usage + exit $EXIT_CODE_EXCEPTION + fi + + if [ -z "$testHostDir" ]; then + echo "--testHostDir is required to run CoreFX tests" + print_usage + exit $EXIT_CODE_EXCEPTION + fi + + if [ ! -f "$testHostDir/dotnet" ]; then + echo "Executable dotnet not found in $testHostDir" + exit $EXIT_CODE_EXCEPTION + fi + + if [ ! -d "$testHostDir" ]; then + echo "Directory specified by --testHostDir does not exist: $testRootDir" + exit $EXIT_CODE_EXCEPTION + fi + + create_testhost + exit 0 +fi + if [ -z "$testRootDir" ]; then echo "--testRootDir is required." print_usage diff --git a/tests/scripts/arm32_ci_script.sh b/tests/scripts/arm32_ci_script.sh index 06431f2ef212..51a54947e01e 100755 --- a/tests/scripts/arm32_ci_script.sh +++ b/tests/scripts/arm32_ci_script.sh @@ -265,10 +265,10 @@ function cross_build_coreclr_with_docker { # For armel Tizen, we are going to construct RootFS on the fly. case $__linuxCodeName in tizen) - __dockerImage=" gbalykov/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-4.0m2" + __dockerImage=" tizendotnet/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-5.0m1" __skipRootFS=1 __dockerEnvironmentVariables+=" -e ROOTFS_DIR=/crossrootfs/armel.tizen.build" - __runtimeOS="tizen.4.0.0" + __runtimeOS="tizen.5.0.0" ;; *) echo "ERROR: $__linuxCodeName is not a supported linux name for $__buildArch" @@ -388,7 +388,7 @@ function run_tests_using_docker { elif [ "$__buildArch" == "armel" ]; then case $__linuxCodeName in tizen) - __dockerImage=" gbalykov/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-4.0m2" + __dockerImage=" tizendotnet/dotnet-buildtools-prereqs:ubuntu-16.04-cross-e435274-20180426002255-tizen-rootfs-5.0m1" __skipRootFS=1 __dockerEnvironmentVariables=" -e ROOTFS_DIR=/crossrootfs/armel.tizen.test" ;; diff --git a/tests/scripts/run-corefx-tests.bat b/tests/scripts/run-corefx-tests.bat index 32103f201d3a..b77644f44ed1 100644 --- a/tests/scripts/run-corefx-tests.bat +++ b/tests/scripts/run-corefx-tests.bat @@ -5,17 +5,19 @@ goto start :usage echo Usage: run-corefx-tests.bat ^ ^ ^ echo. -echo Runs the corefx tests on a Windows ARM device, by searching for all relevant corefx +echo Runs the corefx tests on a Windows ARM/ARM64 device, by searching for all relevant corefx echo RunTests.cmd files in the ^ tree, and running each one in turn. This -echo script is typically run on a Windows ARM machine after the run-corefx-test.py script +echo script is typically run on a Windows ARM/ARM64 machine after the run-corefx-test.py script echo is run on a Windows x64 machine with the `-no_run_tests` argument, to build the echo corefx tree, including tests, and then copying the built runtime layout and tests -echo to the ARM machine. +echo to the ARM/ARM64 machine. echo. echo Arguments: -echo ^ -- Path to corefx-built runtime "layout", e.g. _\fx\bin\testhost\netcoreapp-Windows_NT-Release-arm -echo ^ -- Path to corefx test tree, e.g., _\fx\bin\tests +echo ^ -- Path to corefx-built runtime "layout", e.g. _\fx\bin\testhost\netcoreapp-Windows_NT-Release-arm +echo ^ -- Path to corefx test tree, e.g., _\fx\bin\tests echo ^ -- Path to test exclusion file, e.g., C:\coreclr\tests\arm\corefx_test_exclusions.txt +echo ^ -- Architecture to run, either ARM or ARM64. (We can't depend on PROCESSOR_ARCHITECTURE because +echo the batch script might be invoked with an ARM64 CMD but we need to run ARM.) echo. echo The ^ is a file with a list of assemblies for which the echo tests should not be run. This allows excluding failing tests by excluding the @@ -26,23 +28,22 @@ echo. echo System.Console.Tests echo System.Data.SqlClient.Tests echo System.Diagnostics.Process.Tests -echo. -echo This script only works for Windows ARM, but perhaps should be extended to work -echo for Windows ARM64 as well. goto :eof :start -if "%3"=="" goto usage -if not "%4"=="" goto usage +if "%4"=="" goto usage +if not "%5"=="" goto usage set _runtime_path=%1 set _tests_dir=%2 set _exclusion_file=%3 +set _architecture=%4 echo Running CoreFX tests echo Using runtime: %_runtime_path% echo Using tests: %_tests_dir% echo Using test exclusion file: %_exclusion_file% +echo Using architecture: %_architecture% set _pass=0 set _fail=0 @@ -50,7 +51,7 @@ set _skipped=0 set _total=0 pushd %_tests_dir% -for /F %%i in ('dir /s /b /A:D netcoreapp-Windows_NT-Release-arm') do ( +for /F %%i in ('dir /s /b /A:D netcoreapp-Windows_NT-Release-%_architecture%') do ( if exist %%i\RunTests.cmd call :one %%i ) popd @@ -69,7 +70,11 @@ REM From this, we want System.Management.Tests to compare against the exclusion REM of test names to skip. set _t1=%1 -set _t2=%_t1:\netcoreapp-Windows_NT-Release-arm=% +if /i %_architecture%==arm ( + set _t2=%_t1:\netcoreapp-Windows_NT-Release-arm=% +) else ( + set _t2=%_t1:\netcoreapp-Windows_NT-Release-arm64=% +) for /F %%j in ("%_t2%") do set _t3=%%~nxj findstr /i %_t3% %_exclusion_file% >nul if %errorlevel% EQU 0 ( diff --git a/tests/scripts/run-corefx-tests.py b/tests/scripts/run-corefx-tests.py index 4acd5d2f0847..944b8eb619bc 100644 --- a/tests/scripts/run-corefx-tests.py +++ b/tests/scripts/run-corefx-tests.py @@ -70,6 +70,7 @@ def del_rw(action, name, exc): parser.add_argument('-fx_commit', dest='fx_commit', default=None) parser.add_argument('-env_script', dest='env_script', default=None) parser.add_argument('-no_run_tests', dest='no_run_tests', action="store_true", default=False) +parser.add_argument('-toolset_dir', dest='toolset_dir', default='c:\\ats2') ########################################################################## @@ -81,8 +82,8 @@ def validate_args(args): Args: args (argparser.ArgumentParser): Args parsed by the argument parser. Returns: - (arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests) - (str, str, str, str, str, str, str, str) + (arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests, toolset_dir) + (str, str, str, str, str, str, str, str, str) Notes: If the arguments are valid then return them all in a tuple. If not, raise an exception stating x argument is incorrect. @@ -97,6 +98,7 @@ def validate_args(args): fx_commit = args.fx_commit env_script = args.env_script no_run_tests = args.no_run_tests + toolset_dir = args.toolset_dir def validate_arg(arg, check): """ Validate an individual arg @@ -142,7 +144,7 @@ def validate_arg(arg, check): validate_arg(env_script, lambda item: os.path.isfile(env_script)) env_script = os.path.abspath(env_script) - args = (arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests) + args = (arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests, toolset_dir) log('Configuration:') log(' arch: %s' % arch) @@ -154,6 +156,7 @@ def validate_arg(arg, check): log(' fx_commit: %s' % fx_commit) log(' env_script: %s' % env_script) log(' no_run_tests: %s' % no_run_tests) + log(' toolset_dir: %s' % toolset_dir) return args @@ -215,7 +218,7 @@ def main(args): global Unix_name_map global testing - arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests = validate_args( + arch, ci_arch, build_type, clr_root, fx_root, fx_branch, fx_commit, env_script, no_run_tests, toolset_dir = validate_args( args) clr_os = 'Windows_NT' if Is_windows else Unix_name_map[os.uname()[0]] @@ -276,11 +279,8 @@ def main(args): os.makedirs(fx_home) os.putenv('HOME', fx_home) log('HOME=' + fx_home) - - # Determine the RID to specify the to corefix build scripts. This seems to - # be way harder than it ought to be. - # Gather up some arguments to pass to both build and build-tests. + # Gather up some arguments to pass to build-managed, build-native, and build-tests scripts. config_args = '-Release -os:%s -buildArch:%s' % (clr_os, arch) @@ -300,17 +300,23 @@ def main(args): # Cross build corefx for arm32 on x86. build_native_args = '' + if not Is_windows and arch == 'arm' : # We need to force clang5.0; we are building in a docker container that doesn't have # clang3.9, which is currently the default used by build-native.sh. We need to pass # "-cross", but we also pass "-portable", which build-native.sh normally passes # (there doesn't appear to be a way to pass these individually). - build_native_args = '-AdditionalArgs:"-portable -cross" -Clang:clang5.0' + build_native_args += ' -AdditionalArgs:"-portable -cross" -Clang:clang5.0' if not Is_windows and arch == 'arm64' : # We need to pass "-cross", but we also pass "-portable", which build-native.sh normally # passes (there doesn't appear to be a way to pass these individually). - build_native_args = '-AdditionalArgs:"-portable -cross"' + build_native_args += ' -AdditionalArgs:"-portable -cross"' + + if Is_windows and arch == 'arm64' : + # We need to pass toolsetDir to specify the arm64 private toolset. + # This is temporary, until private toolset is no longer used. So hard-code the CI toolset dir. + build_native_args += ' -ToolSetDir:"toolsetDir=%s"' % toolset_dir command = ' '.join(('build-native.cmd' if Is_windows else './build-native.sh', config_args, @@ -318,12 +324,14 @@ def main(args): log(command) returncode = 0 if testing else os.system(command) if returncode != 0: + log('Error: exit code %s' % returncode) sys.exit(1) command = ' '.join(('build-managed.cmd' if Is_windows else './build-managed.sh', config_args)) log(command) returncode = 0 if testing else os.system(command) if returncode != 0: + log('Error: exit code %s' % returncode) sys.exit(1) # Override the built corefx runtime (which it picked up by copying from packages determined @@ -353,20 +361,36 @@ def main(args): # If we're doing altjit testing, then don't run any tests that don't work with altjit. if ci_arch is not None and (ci_arch == 'x86_arm_altjit' or ci_arch == 'x64_arm64_altjit'): - # The property value we need to specify is a semicolon separated list of two values, - # so the two values must be enclosed in double quotes. Without the quotes, msbuild - # thinks the item after the semicolon is a different named property. Also, the double - # quotes need preceeding backslashes or else run.exe (invoked from build-tests.cmd) - # will eat them. They need to be double backslashes so Python preserves the backslashes. - without_categories = '/p:WithoutCategories=\\"IgnoreForCI;XsltcExeRequired\\"' + # The property value we need to specify for the WithoutCategories property is a semicolon + # separated list of two values, so the two values must be enclosed in double quotes, namely: + # + # /p:WithoutCategories="IgnoreForCI;XsltcExeRequired" + # + # Without the quotes, msbuild interprets the semicolon as separating two name/value pairs, + # which is incorrect (and causes an error). + # + # If we pass this on the command-line, it requires an extraordinary number of backslashes + # to prevent special Python, dotnet CLI, CMD, and other command-line processing, as the command + # filters through batch files, the RUN tool, dotnet CLI, and finally gets to msbuild. To avoid + # this, and make it simpler and hopefully more resilient to scripting changes, we create an + # msbuild response file with the required text and pass the response file on to msbuild. + + without_categories_filename = os.path.join(fx_root, 'msbuild_commands.rsp') + without_categories_string = '/p:WithoutCategories="IgnoreForCI;XsltcExeRequired"' + with open(without_categories_filename, "w") as without_categories_file: + without_categories_file.write(without_categories_string) + without_categories = "-- @%s" % without_categories_filename + + log('Response file %s contents:' % without_categories_filename) + log('%s' % without_categories_string) + log('[end response file contents]') else: - without_categories = '/p:WithoutCategories=IgnoreForCI' + without_categories = '-- /p:WithoutCategories=IgnoreForCI' command = ' '.join(( command, config_args, '-SkipTests' if no_run_tests else '', - '--', without_categories )) @@ -381,6 +405,7 @@ def main(args): log(command) returncode = 0 if testing else os.system(command) if returncode != 0: + log('Error: exit code %s' % returncode) sys.exit(1) sys.exit(0) diff --git a/tests/scripts/scripts.csproj b/tests/scripts/scripts.csproj index b1a1aab6e54e..e803a60a37b0 100644 --- a/tests/scripts/scripts.csproj +++ b/tests/scripts/scripts.csproj @@ -14,8 +14,8 @@ 1.0.0-alpha-build0040 - - 1.0.2-prerelease-00177 + + $(XunitPackageVersion) 1.0.0-prerelease-00629-04 diff --git a/tests/setup-stress-dependencies.cmd b/tests/setup-stress-dependencies.cmd index 0770e858a5ad..5c7977084b4a 100644 --- a/tests/setup-stress-dependencies.cmd +++ b/tests/setup-stress-dependencies.cmd @@ -81,7 +81,7 @@ if errorlevel 1 goto Fail REM Get downloaded dll path echo Locating coredistools.dll -FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s ^| findstr /R "runtime.win[0-9]*-%__Arch%"') DO set __LibPath=%%i +FOR /F "delims=" %%i IN ('dir %__PackageDir%\coredistools.dll /b/s ^| findstr /R "win-%__Arch%"') DO set __LibPath=%%i echo CoreDisTools library path: %__LibPath% if not exist "%__LibPath%" ( echo Failed to locate the downloaded library: %__LibPath% @@ -114,4 +114,4 @@ echo. echo Usage: echo %__ThisScriptShort% /arch ^ /outputdir ^ echo. -exit /b 1 \ No newline at end of file +exit /b 1 diff --git a/tests/src/Common/CoreFX/CoreFX.depproj b/tests/src/Common/CoreFX/CoreFX.depproj new file mode 100644 index 000000000000..e64aeb770541 --- /dev/null +++ b/tests/src/Common/CoreFX/CoreFX.depproj @@ -0,0 +1,185 @@ + + + + + $(SourceDir)Common\CoreFX\obj + C# + .NETCoreApp,Version=v3.0 + netcoreapp3.0 + true + SharedLibrary + false + + 1.3.0-preview3-26501-04 + 2.2.0-preview1-02902-01 + + 2.0.1 + 2.2.0-beta2-build3300 + 2.0.19 + 2.1.0 + + + + + win-x64 + linux-x64 + osx-x64 + $(RuntimeIdentifier) + + + + + $(CoreFXXUnitPackageVersion) + + + $(CoreFXXUnitPackageVersion) + + + $(CoreFXXUnitPackageVersion) + + + $(XUnitAbstractionsVersion) + + + $(CoreFXXUnitPackageVersion) + + + $(CoreFXXUnitPackageVersion) + + + $(CoreFXXUnitPackageVersion) + + + $(XUnitNetcoreExtensionsVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(SystemCompositionVersions) + + + $(SystemCompositionVersions) + + + $(SystemCompositionVersions) + + + $(SystemCompositionVersions) + + + $(SystemCompositionVersions) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + + + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftPrivateCoreFxNETCoreAppPackageVersion) + + + $(MicrosoftDiagnosticsTracingTraceVentVersion) + + + + + + $(MicrosoftDotnetPlatformAbstractionsVersion) + + + + + + + + + $(SourceDir)Common\CoreFX\obj\project.assets.json + + diff --git a/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj b/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj new file mode 100644 index 000000000000..751b3ab8d37d --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/CoreFX.TestUtils.TestFileSetup.csproj @@ -0,0 +1,36 @@ + + + + false + 0.1.0-e160909-1 + 11.0.2 + 3.0.10 + 2.3.0-beta1-build3642 + + 2.2.0-beta2-build3300 + 2.0.1 + 2.1.0-preview2-02516-02 + 4.5.0-preview2-26219-0 + $(RestoreSources);https://dotnet.myget.org/F/dotnet-corefxlab/api/v3/index.json + + + + netcoreapp2.0 + Exe + 99.9 + + + + + $(NewtonsoftJsonVersion) + + + $(NewtonsoftJsonSchemaVersion) + + + + $(SystemCommandLineVersion) + + + diff --git a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs new file mode 100644 index 000000000000..e6e2c4ed6c1d --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestFileHelper.cs @@ -0,0 +1,326 @@ +// 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.Collections.Generic; +using System.CommandLine; +using System.Diagnostics; +using System.IO; +using System.IO.Compression; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Schema; +using Newtonsoft.Json.Schema.Generation; + +namespace CoreFX.TestUtils.TestFileSetup.Helpers +{ + /// + /// Defines the set of flags that represent exit codes + /// + [Flags] + public enum ExitCode : int + { + Success = 0, + TestFailure = 1, + HttpError = 2, + IOError = 3, + JsonSchemaValidationError = 4, + UnknownError = 10 + + } + + /// + /// This helper class is used to fetch CoreFX tests from a specified URL, unarchive them and create a flat directory structure + /// through which to iterate. + /// + public class TestFileHelper + { + private HttpClient httpClient; + public HttpClient HttpClient + { + get + { + if (httpClient == null) + { + httpClient = new HttpClient(); + } + return httpClient; + } + set{ httpClient = value; } + } + + private HashSet disabledTests; + + /// + /// Default constructor - initialize list of disabled tests + /// + public TestFileHelper() { + disabledTests = new HashSet(); + } + + /// + /// Deserialize a list of JSON objects defining test assemblies + /// + /// The path on disk to the test list. The test list must conform to a schema generated from XUnitTestAssembly + /// + public Dictionary DeserializeTestJson(string testDefinitionFilePath) + { + JSchemaGenerator jsonGenerator = new JSchemaGenerator(); + + // Generate a JSON schema from the XUnitTestAssembly class against which to validate the test list + JSchema testDefinitionSchema = jsonGenerator.Generate(typeof(IList)); + IList testAssemblies = new List(); + + IList validationMessages = new List(); + + using (var sr = new StreamReader(testDefinitionFilePath)) + using (var jsonReader = new JsonTextReader(sr)) + using (var jsonValidationReader = new JSchemaValidatingReader(jsonReader)) + { + // Create schema validator + jsonValidationReader.Schema = testDefinitionSchema; + jsonValidationReader.ValidationEventHandler += (o, a) => validationMessages.Add(a.Message); + + // Deserialize json test assembly definitions + JsonSerializer serializer = new JsonSerializer(); + try + { + testAssemblies = serializer.Deserialize>(jsonValidationReader); + } + catch (JsonSerializationException ex) + { + // Invalid definition + throw new AggregateException(ex); + } + } + + if (validationMessages.Count != 0) + { + StringBuilder aggregateExceptionMessage = new StringBuilder(); + foreach (string validationMessage in validationMessages) + { + aggregateExceptionMessage.Append("JSON Validation Error: "); + aggregateExceptionMessage.Append(validationMessage); + aggregateExceptionMessage.AppendLine(); + } + + throw new AggregateException(new JSchemaValidationException(aggregateExceptionMessage.ToString())); + + } + // Generate a map of test assembly names to their object representations - this is used to download and match them to their on-disk representations + var nameToTestAssemblyDef = new Dictionary(); + + // Map test names to their definitions + foreach (XUnitTestAssembly assembly in testAssemblies) + { + // Filter disabled tests + if(assembly.IsEnabled) + nameToTestAssemblyDef.Add(assembly.Name, assembly); + else + disabledTests.Add(assembly.Name); + } + + return nameToTestAssemblyDef; + } + + /// + /// Layout tests on disk. This method sets up every downloaded test as it would appear after running build-test.[cmd/sh] in CoreFX + /// + /// URL to a test list - we expect a test list, which conforms to the Helix layout + /// Directory to which the tests are downloaded + /// The mapping of tests parsed from a test definition list to their names + /// Optional argument, which denotes whether all tests available in the test list downloaded from jsonUrl should be run + /// + public async Task SetupTests(string jsonUrl, string destinationDirectory, Dictionary testDefinitions = null, bool runAllTests = false) + { + Debug.Assert(Directory.Exists(destinationDirectory)); + // testDefinitions should not be empty unless we're running all tests with no exclusions + Debug.Assert(runAllTests || testDefinitions != null); + + // Download archives to a temporary directory + string tempDirPath = Path.Combine(destinationDirectory, "temp"); + if (!Directory.Exists(tempDirPath)) + { + Directory.CreateDirectory(tempDirPath); + } + // Map test names to their URLs, specified by the test list found at jsonUrl + Dictionary testPayloads = await GetTestUrls(jsonUrl, testDefinitions, runAllTests); + + // If none were found or the testList did not have the expected format - return + if (testPayloads == null) + { + return; + } + + // Download and unzip tests + await GetTestArchives(testPayloads, tempDirPath); + ExpandArchivesInDirectory(tempDirPath, destinationDirectory); + + // Generate response file for each tests + RSPGenerator rspGenerator = new RSPGenerator(); + foreach (XUnitTestAssembly assembly in testDefinitions.Values) + { + rspGenerator.GenerateRSPFile(assembly, Path.Combine(destinationDirectory, assembly.Name)); + } + + Directory.Delete(tempDirPath); + } + + /// + /// Maps test names to their respective URLs as found in the test list found at the specified URL + /// + /// URL to a test list - we expect a test list, which conforms to the Helix layout + /// The mapping of tests parsed from a test definition list to their names + /// Optional argument, which denotes whether all tests available in the test list downloaded from jsonUrl should be run + /// + public async Task> GetTestUrls(string jsonUrl, Dictionary testDefinitions = null, bool runAllTests = false) + { + // testDefinitions should not be empty unless we're running all tests with no exclusions + Debug.Assert(runAllTests || testDefinitions != null); + // Set up the json stream reader + using (var responseStream = await HttpClient.GetStreamAsync(jsonUrl)) + using (var streamReader = new StreamReader(responseStream)) + using (var jsonReader = new JsonTextReader(streamReader)) + { + // Manual parsing - we only need to key-value pairs from each object and this avoids deserializing all of the work items into objects + string markedTestName = string.Empty; + string currentPropertyName = string.Empty; + + // The expected layout is produced by regular Helix runs - this allows us to parse and run tests from any Helix test list without special considerations + // The expected fields are + // { "WorkItemId": "" , "PayloadUri":"" } + + while (jsonReader.Read()) + { + if (jsonReader.Value != null) + { + switch (jsonReader.TokenType) + { + case JsonToken.PropertyName: + currentPropertyName = jsonReader.Value.ToString(); + break; + case JsonToken.String: + // Test Name Value + if (currentPropertyName.Equals("WorkItemId")) + { + string currentTestName = jsonReader.Value.ToString(); + + // If the test has been marked as disabled in the test list - ignore it + if ((runAllTests || testDefinitions.ContainsKey(currentTestName)) && !disabledTests.Contains(currentTestName)) + { + markedTestName = currentTestName; + } + } + // Test URL value + else if (currentPropertyName.Equals("PayloadUri") && markedTestName != string.Empty) + { + if (!testDefinitions.ContainsKey(markedTestName)) + { + testDefinitions[markedTestName] = new XUnitTestAssembly() { Name = markedTestName }; + } + testDefinitions[markedTestName].Url = jsonReader.Value.ToString(); + markedTestName = string.Empty; + } + break; + } + } + } + + } + return testDefinitions; + } + + /// + /// Download each test from its specified URL + /// + /// The mapping of tests parsed from a test definition list to their names. The test definitions are populated with test URLs + /// Directory to which to download tests + /// + public async Task GetTestArchives(Dictionary testPayloads, string downloadDir) + { + foreach (string testName in testPayloads.Keys) + { + string payloadUri = testPayloads[testName].Url; + + // Check URL for validity + if (!Uri.IsWellFormedUriString(payloadUri, UriKind.Absolute)) + continue; + Console.WriteLine("Downloading " + testName + " from " + payloadUri); + // Download tests from specified URL + using (var response = await HttpClient.GetStreamAsync(payloadUri)) + { + if (response.CanRead) + { + // Create the test setup directory if it doesn't exist + if (!Directory.Exists(downloadDir)) + { + Directory.CreateDirectory(downloadDir); + } + + // CoreFX test archives are output as .zip regardless of platform + string archivePath = Path.Combine(downloadDir, testName + ".zip"); + + // Copy to a temp folder + using (FileStream file = new FileStream(archivePath, FileMode.Create)) + { + await response.CopyToAsync(file); + } + + } + } + } + } + + /// + /// Expand Archives + /// + /// Directory containing archives + /// Directory to which to unpack archives + /// Optional parameter stating, whether archives should be deleted once downloaded + public void ExpandArchivesInDirectory(string archiveDirectory, string destinationDirectory, bool cleanup = true) + { + Debug.Assert(Directory.Exists(archiveDirectory)); + Debug.Assert(Directory.Exists(destinationDirectory)); + + // Get all archives in the directory + string[] archives = Directory.GetFiles(archiveDirectory, "*.zip", SearchOption.TopDirectoryOnly); + + foreach (string archivePath in archives) + { + string destinationDirName = Path.Combine(destinationDirectory, Path.GetFileNameWithoutExtension(archivePath)); + + ZipFile.ExtractToDirectory(archivePath, destinationDirName); + + // Delete archives if cleanup was + if (cleanup) + { + File.Delete(archivePath); + } + } + } + + /// + /// Cleans build directory + /// + /// Directory the contents of which to delete. + public void CleanBuild(string directoryToClean) + { + Debug.Assert(Directory.Exists(directoryToClean)); + DirectoryInfo dirInfo = new DirectoryInfo(directoryToClean); + + foreach (FileInfo file in dirInfo.EnumerateFiles()) + { + file.Delete(); + } + + foreach (DirectoryInfo dir in dirInfo.EnumerateDirectories()) + { + dir.Delete(true); + } + } + + } +} diff --git a/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.cs new file mode 100644 index 000000000000..a8a97916c501 --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/Helpers/TestRunHelper.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. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace CoreFX.TestUtils.TestFileSetup.Helpers +{ + /// + /// A class which runs all tests conforming to the current format of CoreFX tests - + /// Each folder: + /// is named for the test it contains - e.g. System.Collections.Tests + /// contains a test assembly named for the library it tests - e.g. System.Collections.Tests.dll + /// contains a test executable with the specified name - e.g. xunit.console.netcore.exe + /// + public class NetCoreTestRunHelper + { + + public string DotnetExecutablePath { get; set; } + + public string logRootOutputPath { get; set; } + + /// + /// Default Constructor + /// + /// Path to the dotnet executable, which is used to run the test executable In CoreFX tests this will be the built test host + /// Path to which to output test run logs + public NetCoreTestRunHelper(string DotnetExecutablePath, string logRootOutputPath) + { + this.DotnetExecutablePath = DotnetExecutablePath; + this.logRootOutputPath = logRootOutputPath; + } + + /// + /// Run a single test executabke + /// + /// Directory from which to start the test executable + /// Name of the test executable + /// Test trait exclusions to pass to the runner. + /// Path to which to output the single test run's results + /// 0 if single test run is succesful; 1 if not + public int RunExecutable(string workingDirectory, string executableName, IReadOnlyList xunitTestTraits, string logOutputPath) + { + // Calculate and create the path to the test log + string logPath = Path.Combine(logOutputPath, Path.GetFileName(workingDirectory)); + if (!Directory.Exists(logPath)) + Directory.CreateDirectory(logPath); + + // Calculate the arguments to pass to the test runner + string arguments = CalculateCommandLineArguments(workingDirectory, executableName, xunitTestTraits, Path.Combine(logPath,"testResults.xml")); + + // Create and initialize the test executable process + ProcessStartInfo startInfo = new ProcessStartInfo(DotnetExecutablePath, arguments) + { + Arguments = arguments, + WorkingDirectory = workingDirectory + }; + + + Process executableProcess = new Process(); + executableProcess.StartInfo = startInfo; + executableProcess.EnableRaisingEvents = true; + executableProcess.Start(); + executableProcess.WaitForExit(); + + return executableProcess.ExitCode; + } + /// + /// Run all test executables conforming to the specified pattern in a directory + /// + /// Directory containing tests to run + /// Name of the test executable contained in folders + /// Test trait exclusions to pass to the runner. + /// Maximum number of tests to run in parallel + /// Root path to which to output the all test runs' results + /// 0 if entire test run is succesful; 1 if not + public int RunAllExecutablesInDirectory(string rootDirectory, string executableName, IReadOnlyList xunitTestTraits, int processLimit, string logRootOutputPath = null) + { + int result = 0; + // Do a Depth-First Search to find and run executables with the same name + Stack directories = new Stack(); + List testDirectories = new List(); + // Push rootdir + directories.Push(rootDirectory); + + while (directories.Count > 0) + { + string currentDirectory = directories.Pop(); + + // If a directory contains an executable with the specified name - add it + if (File.Exists(Path.Combine(currentDirectory, executableName))) + testDirectories.Add(currentDirectory); + + foreach (string subDir in Directory.GetDirectories(currentDirectory)) + directories.Push(subDir); + } + + // Initialize max degree of parallelism + ParallelOptions parallelOptions = new ParallelOptions(); + parallelOptions.MaxDegreeOfParallelism = processLimit; + + Parallel.ForEach(testDirectories, parallelOptions, + (testDirectory) => + { + if (RunExecutable(testDirectory, executableName, xunitTestTraits, logRootOutputPath) != 0) + { + // If any tests fail mark the whole run as failed + Console.WriteLine("Test Run Failed " + testDirectory); + result = 1; + } + } + ); + return result; + } + + /// + /// Calculate the commandline arguments to pass to the test executable + /// + /// Current test directory name - assumed to have the same name as the test + /// >Name of the test executable contained in the folder + /// Test trait exclusions to pass to the runner. + /// Path to which to output the single test run's results + /// A string representing command line arguments to be passed to the console test runner + private string CalculateCommandLineArguments(string testDirectory, string executableName, IReadOnlyList xunitTestTraits, string logPath) + { + StringBuilder arguments = new StringBuilder(); + + // Append test executable name + arguments.Append($"\"{Path.Combine(testDirectory, Path.GetFileName(executableName))}\" "); + + // Append test name dll\ + arguments.Append($"\"{Path.Combine(testDirectory, Path.GetFileName(testDirectory))}.dll\" "); + + // Append RSP file + arguments.Append($"@\"{Path.Combine(testDirectory, Path.GetFileName(testDirectory))}.rsp\" "); + + if (!String.IsNullOrEmpty(logPath)) + { + // Add logging information + arguments.Append($"-xml {logPath} "); + } + + // Append all additional arguments + foreach (string traitToExclude in xunitTestTraits) + { + arguments.Append($"-notrait {traitToExclude} "); + } + + return arguments.ToString(); + } + } +} diff --git a/tests/src/Common/CoreFX/TestFileSetup/Program.cs b/tests/src/Common/CoreFX/TestFileSetup/Program.cs new file mode 100644 index 000000000000..599dd6d717b9 --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/Program.cs @@ -0,0 +1,174 @@ +// 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.Collections.Generic; +using System.CommandLine; +using System.IO; +using System.Net.Http; +using System.Text; +using CoreFX.TestUtils.TestFileSetup.Helpers; +using Newtonsoft.Json; +using Newtonsoft.Json.Schema; + +namespace CoreFX.TestUtils.TestFileSetup +{ + /// + /// This is a driver class, which downloads archived CoreFX test assemblies from a specified URL, lays out their contents + /// and subsequently runs them in parallel. + /// This is invoked from .tests/runtests.[cmd|sh] and depends on a test host (CoreCLR components with a dotnet executable) being present + /// + public class Program + { + // Helper class to lay out files on disk + private static TestFileHelper testFileHelper; + // Helper class to run tests in parallel + private static NetCoreTestRunHelper testRunHelper; + + // Test Set-up Options + private static string outputDir; + private static string testUrl; + private static string testListPath; + private static bool cleanTestBuild; + + // Test Run Options + private static string dotnetPath; + private static bool runSpecifiedTests; + private static bool runAllTests; + private static int maximumDegreeOfParalellization; + private static string logRootOutputPath; + + private static ExitCode exitCode; + private static string executableName; + private static IReadOnlyList traitExclusions = Array.Empty(); + + public static void Main(string[] args) + { + // Initialize default options + exitCode = ExitCode.Success; + maximumDegreeOfParalellization = Environment.ProcessorCount; + runSpecifiedTests = false; + runAllTests = false; + cleanTestBuild = false; + + ArgumentSyntax argSyntax = ParseCommandLine(args); + try + { + // Download and lay out files on disk + SetupTests(runAllTests); + + // Only run tests if the relevant commandline switch is passed + if (runSpecifiedTests || runAllTests) + exitCode = RunTests(); + } + catch (AggregateException e) + { + // Handle failure cases and exit gracefully + e.Handle(innerExc => + { + + if (innerExc is HttpRequestException) + { + exitCode = ExitCode.HttpError; + Console.WriteLine("Error downloading tests from: " + testUrl); + Console.WriteLine(innerExc.Message); + return true; + } + else if (innerExc is IOException) + { + exitCode = ExitCode.IOError; + Console.WriteLine(innerExc.Message); + return true; + } + else if (innerExc is JSchemaValidationException || innerExc is JsonSerializationException) + { + exitCode = ExitCode.JsonSchemaValidationError; + Console.WriteLine("Error validating test list: "); + Console.WriteLine(innerExc.Message); + return true; + } + else + { + exitCode = ExitCode.UnknownError; + } + + return false; + }); + } + + Environment.Exit((int)exitCode); + } + + /// + /// Parse passed Command Line arguments + /// + /// + /// + private static ArgumentSyntax ParseCommandLine(string[] args) + { + ArgumentSyntax argSyntax = ArgumentSyntax.Parse(args, syntax => + { + syntax.DefineOption("out|outDir|outputDirectory", ref outputDir, "Directory where tests are downloaded"); + syntax.DefineOption("testUrl", ref testUrl, "URL, pointing to the list of tests"); + syntax.DefineOption("testListJsonPath", ref testListPath, "JSON-formatted list of test assembly names to download"); + syntax.DefineOption("clean|cleanOutputDir", ref cleanTestBuild, "Clean test assembly output directory"); + syntax.DefineOption("runSpecified|runSpecifiedTests", ref runSpecifiedTests, "Run specified Tests after setup"); + syntax.DefineOption("runAll|runAllTests", ref runAllTests, "Run All available Tests in the specified TestList"); + syntax.DefineOption("dotnet|dotnetPath", ref dotnetPath, "Path to dotnet executable used to run tests."); + syntax.DefineOption("executable|executableName", ref executableName, "Name of the test executable to start"); + syntax.DefineOption("log|logPath|logRootOutputPath", ref logRootOutputPath, "Run Tests after setup"); + syntax.DefineOption("maxProcessCount|numberOfParallelTests|maximumDegreeOfParalellization", ref maximumDegreeOfParalellization, "Maximum number of concurrently executing processes"); + syntax.DefineOptionList("notrait", ref traitExclusions, "Traits to be excluded from test runs"); + + }); + + if (runSpecifiedTests || runAllTests) + { + if (String.IsNullOrEmpty(dotnetPath)) + throw new ArgumentException("Please supply a test host location to run tests."); + + if (!File.Exists(dotnetPath)) + throw new ArgumentException("Invalid testhost path. Please supply a test host location to run tests."); + } + + return argSyntax; + } + + /// + /// Method, which calls into the Test File Setup helper class to download and layout test assemblies on disk + /// + /// Specifies whether all tests available in the test list should be run + private static void SetupTests(bool runAll = false) + { + testFileHelper = new TestFileHelper(); + + if (!Directory.Exists(outputDir)) + Directory.CreateDirectory(outputDir); + + // If the --clean switch has been specified delete existing assemblies + if (cleanTestBuild) + { + testFileHelper.CleanBuild(outputDir); + } + + // Map test names to their definitions + Dictionary testAssemblyDefinitions = testFileHelper.DeserializeTestJson(testListPath); + + testFileHelper.SetupTests(testUrl, outputDir, testAssemblyDefinitions, runAll).Wait(); + } + + /// + /// Runs all tests in a directory + /// Only tests, the executable driver of which has the same name as the passed argument are executed - e.g. xunit.console.netcore.exe + /// + /// + private static ExitCode RunTests() + { + testRunHelper = new NetCoreTestRunHelper(dotnetPath, logRootOutputPath); + int result = testRunHelper.RunAllExecutablesInDirectory(outputDir, executableName, traitExclusions, maximumDegreeOfParalellization, logRootOutputPath); + + return result == 0 ? ExitCode.Success : ExitCode.TestFailure; + } + } +} diff --git a/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs b/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs new file mode 100644 index 000000000000..ae323026ca29 --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/RSPGenerator.cs @@ -0,0 +1,83 @@ +// 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.Collections.Generic; +using System.IO; +using System.Text; + +namespace CoreFX.TestUtils.TestFileSetup +{ + /// + /// A class which generates .rsp files to be passed to the test executable + /// The file contains a list of methods, classes and namespaces to be excluded from running. + /// + public class RSPGenerator + { + /// + /// Generate an rsp file from an XUnitTestAssembly class + /// + /// The XUnitTestAssembly object parsed from a specified test list + /// Path to which to output a .rsp file + public void GenerateRSPFile(XUnitTestAssembly testDefinition, string outputPath) + { + if (!Directory.Exists(outputPath)) + { + Directory.CreateDirectory(outputPath); + } + string rspFilePath = Path.Combine(outputPath, testDefinition.Name + ".rsp"); + + if (File.Exists(rspFilePath)) + File.Delete(rspFilePath); + + // Write RSP file to disk + using (StreamWriter sr = File.CreateText(rspFilePath)) + { + // If no exclusions are defined, we don't need to generate an .rsp file + if (testDefinition.Exclusions == null) + return; + + // Method exclusions + if (testDefinition.Exclusions.Methods != null) + { + foreach (Exclusion exclusion in testDefinition.Exclusions.Methods) + { + if (String.IsNullOrWhiteSpace(exclusion.Name)) + continue; + sr.Write("-skipmethod "); + sr.Write(exclusion.Name); + sr.WriteLine(); + } + } + + // Class exclusions + if (testDefinition.Exclusions.Classes != null) + { + foreach (Exclusion exclusion in testDefinition.Exclusions.Classes) + { + if (String.IsNullOrWhiteSpace(exclusion.Name)) + continue; + sr.Write("-skipclass "); + sr.Write(exclusion.Name); + sr.WriteLine(); + } + + } + + // Namespace exclusions + if (testDefinition.Exclusions.Namespaces != null) + { + foreach (Exclusion exclusion in testDefinition.Exclusions.Namespaces) + { + if (String.IsNullOrWhiteSpace(exclusion.Name)) + continue; + sr.Write("-skipnamespace "); + sr.Write(exclusion.Name); + sr.WriteLine(); + } + } + } + } + } +} diff --git a/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs b/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs new file mode 100644 index 000000000000..efe78853c8ec --- /dev/null +++ b/tests/src/Common/CoreFX/TestFileSetup/XUnit/XUnitTestAssembly.cs @@ -0,0 +1,63 @@ +// 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.Collections.Generic; +using System.Text; +using Newtonsoft.Json; + +namespace CoreFX.TestUtils.TestFileSetup +{ + /// + /// A class representing a CoreFX test assembly to be run + /// + public class XUnitTestAssembly + { + [JsonRequired] + [JsonProperty("name")] + public string Name; + + [JsonRequired] + [JsonProperty("enabled")] + public bool IsEnabled; + + [JsonRequired] + [JsonProperty("exclusions")] + public Exclusions Exclusions; + + // Used to assign a test url or to override it via the json file definition - mark it as optional in the test definition + [JsonIgnore] + [JsonProperty(Required = Required.Default)] + public string Url; + + } + /// + /// Class representing a collection of test exclusions + /// + public class Exclusions + { + [JsonProperty("namespaces")] + public Exclusion[] Namespaces; + + [JsonProperty("classes")] + public Exclusion[] Classes; + + [JsonProperty("methods")] + public Exclusion[] Methods; + } + + /// + /// Class representing a single test exclusion + /// + public class Exclusion + { + [JsonRequired] + [JsonProperty("name", Required = Required.DisallowNull)] + public string Name; + + [JsonRequired] + [JsonProperty("reason", Required = Required.DisallowNull)] + public string Reason; + } +} diff --git a/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj b/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj index 2e7abfe1bcee..77629e65545e 100644 --- a/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj +++ b/tests/src/Common/Coreclr.TestWrapper/Coreclr.TestWrapper.csproj @@ -1,35 +1,17 @@ - - - + + + + + + - Debug - AnyCPU - CoreclrTestWrapperLib - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Library - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - BuildOnly - false - BuildOnly true - - - - - - - - False - - + - - - - + + + diff --git a/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj b/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj deleted file mode 100644 index b26c89370ba0..000000000000 --- a/tests/src/Common/Desktop.Coreclr.TestWrapper/Desktop.Coreclr.TestWrapper.csproj +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - Debug - AnyCPU - {5259DD45-EA34-4EE7-B5C5-430B80384544} - Library - Coreclr.TestWrapper - Coreclr.TestWrapper - .NETFramework - v4.5 - true - BuildOnly - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - 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 fac75781a5c8..e4b1af713020 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 @@ -25,7 +25,7 @@ - netcoreapp2.2 + netcoreapp3.0 .NETCoreApp $(PackageTargetFallback);portable-net45+win8 win-arm;win-arm64;win-x64;win-x86;$(TargetRid) diff --git a/tests/src/Common/external/external.depproj b/tests/src/Common/external/external.depproj index 46d753cdf019..aedcfe01fefb 100644 --- a/tests/src/Common/external/external.depproj +++ b/tests/src/Common/external/external.depproj @@ -12,8 +12,8 @@ win7-x64 true $(TargetingPackPath) - xunit.console.netcore - xunit.runner.console + xunit.runner.console + netcoreapp1.0 SharedLibrary false @@ -45,8 +45,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) @@ -75,7 +75,6 @@ - @@ -84,14 +83,14 @@ $(SourceDir)Common\external\obj\project.assets.json - - + false $(XUnitRunnerPackageId) @@ -99,4 +98,4 @@ - \ No newline at end of file + diff --git a/tests/src/Common/stress_dependencies/stress_dependencies.csproj b/tests/src/Common/stress_dependencies/stress_dependencies.csproj index e33ee1efd33f..410c79561bfa 100644 --- a/tests/src/Common/stress_dependencies/stress_dependencies.csproj +++ b/tests/src/Common/stress_dependencies/stress_dependencies.csproj @@ -18,7 +18,7 @@ netcoreapp2.0 .NETCoreApp $(PackageTargetFallback);dnxcore50 - win7-x64;ubuntu.14.04-x64;osx.10.10-x64;win7-x86;ubuntu.14.04-x86;osx.10.10-x86 + win-x64;ubuntu.14.04-x64;osx.10.10-x64;win-x86;ubuntu.14.04-x86;osx.10.10-x86 true false diff --git a/tests/src/Common/test_dependencies/test_dependencies.csproj b/tests/src/Common/test_dependencies/test_dependencies.csproj index 3bdca6de208f..cc4d1a7ff8f4 100644 --- a/tests/src/Common/test_dependencies/test_dependencies.csproj +++ b/tests/src/Common/test_dependencies/test_dependencies.csproj @@ -5,8 +5,8 @@ Debug AnyCPU BuildOnly - .NETCoreApp,Version=v2.2 - netcoreapp2.2 + .NETCoreApp,Version=v3.0 + netcoreapp3.0 false @@ -30,7 +30,7 @@ - netcoreapp2.2 + netcoreapp3.0 .NETCoreApp $(PackageTargetFallback);dnxcore50;netcoreapp1.1;portable-net45+win8 win-arm;win-arm64;win-x64;win-x86;$(TargetRid) diff --git a/tests/src/Common/test_runtime/test_runtime.csproj b/tests/src/Common/test_runtime/test_runtime.csproj index 7405edcbff7c..761d44d4c6a0 100644 --- a/tests/src/Common/test_runtime/test_runtime.csproj +++ b/tests/src/Common/test_runtime/test_runtime.csproj @@ -5,8 +5,8 @@ Debug AnyCPU BuildOnly - .NETCoreApp,Version=v2.2 - netcoreapp2.2 + .NETCoreApp,Version=v3.0 + netcoreapp3.0 false @@ -27,7 +27,7 @@ - netcoreapp2.2 + netcoreapp3.0 .NETCoreApp $(PackageTargetFallback);dnxcore50;portable-net45+win8 win-arm;win-arm64;win-x64;win-x86;$(TargetRid) diff --git a/tests/src/GC/API/GC/KeepAlive.cs b/tests/src/GC/API/GC/KeepAlive.cs index c5dd55d10c7f..badc54a04a84 100644 --- a/tests/src/GC/API/GC/KeepAlive.cs +++ b/tests/src/GC/API/GC/KeepAlive.cs @@ -56,8 +56,10 @@ public static void RunTest2() } - public static void RunTest() + public static bool RunTest() { + bool success = false; + Dummy obj = new Dummy(); RunTest2(); @@ -71,14 +73,18 @@ public static void RunTest() GC.Collect(); //} + success = (visited1 == false) && (visited2 == true); + GC.KeepAlive(obj); // will keep obj alive until this point + + return success; } public static int Main() { - RunTest(); + bool success = RunTest(); - if ((visited1 == false) && (visited2 == true)) + if (success) { Console.WriteLine("Test for KeepAlive() passed!"); return 100; @@ -86,8 +92,6 @@ public static int Main() else { Console.WriteLine("Test for KeepAlive() failed!"); - - return 1; } } diff --git a/tests/src/GC/Coverage/smalloom.csproj b/tests/src/GC/Coverage/smalloom.csproj index b65e2b36643e..5d12fc2fb70f 100644 --- a/tests/src/GC/Coverage/smalloom.csproj +++ b/tests/src/GC/Coverage/smalloom.csproj @@ -9,6 +9,7 @@ Exe {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ + true 1 @@ -28,4 +29,4 @@ - \ No newline at end of file + diff --git a/tests/src/Interop/CMakeLists.txt b/tests/src/Interop/CMakeLists.txt index 87800101544e..04ec8aaa0e51 100644 --- a/tests/src/Interop/CMakeLists.txt +++ b/tests/src/Interop/CMakeLists.txt @@ -1,10 +1,10 @@ if(WIN32) - if(CLR_CMAKE_HOST_ARCH STREQUAL arm) - list(APPEND LINK_LIBRARIES_ADDITIONAL - ole32.lib - ) - endif(CLR_CMAKE_HOST_ARCH STREQUAL arm) + if(CLR_CMAKE_HOST_ARCH STREQUAL arm) + list(APPEND LINK_LIBRARIES_ADDITIONAL + ole32.lib + ) + endif(CLR_CMAKE_HOST_ARCH STREQUAL arm) endif(WIN32) include_directories(common) @@ -26,7 +26,10 @@ add_subdirectory(StringMarshalling/UTF8) add_subdirectory(MarshalAPI/FunctionPointer) add_subdirectory(MarshalAPI/IUnknown) add_subdirectory(SizeConst) -add_subdirectory(ClassicCOM) add_subdirectory(DllImportAttribute/ExeFile) add_subdirectory(DllImportAttribute/FileNameContainDot) add_subdirectory(DllImportAttribute/Simple) + +if(WIN32) + add_subdirectory(COM/NativeServer) +endif(WIN32) diff --git a/tests/src/Interop/COM/NETClients/Primitives/App.manifest b/tests/src/Interop/COM/NETClients/Primitives/App.manifest new file mode 100644 index 000000000000..37b4f6580471 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/App.manifest @@ -0,0 +1,18 @@ + + + + + + + + + + + + diff --git a/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs b/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.cs new file mode 100644 index 000000000000..188126324200 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/ArrayTests.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. + +namespace NetClient +{ + using CoreFXTestLibrary; + using System; + using System.Collections.Generic; + using System.Linq; + + class ArrayTests + { + static private readonly IEnumerable BaseData = Enumerable.Range(0, 10); + + private readonly Server.Contract.Servers.ArrayTesting server; + private readonly double expectedMean; + + public ArrayTests() + { + this.server = (Server.Contract.Servers.ArrayTesting)new Server.Contract.Servers.ArrayTestingClass(); + + double acc = 0.0; + int[] rawData = BaseData.ToArray(); + foreach (var d in rawData) + { + acc += d; + } + + expectedMean = acc / rawData.Length; + } + + public void Run() + { + this.Marshal_ByteArray(); + this.Marshal_ShortArray(); + this.Marshal_UShortArray(); + this.Marshal_IntArray(); + this.Marshal_UIntArray(); + this.Marshal_LongArray(); + this.Marshal_ULongArray(); + this.Marshal_FloatArray(); + this.Marshal_DoubleArray(); + } + + static private bool EqualByBound(double expected, double actual) + { + double low = expected - 0.00001; + double high = expected + 0.00001; + double eps = Math.Abs(expected - actual); + bool isEqual = eps < double.Epsilon || (low < actual && actual < high); + if (!isEqual) + { + Console.WriteLine($"{expected} {actual}"); + } + + return isEqual; + } + + private void Marshal_ByteArray() + { + int len; + byte[] data = BaseData.Select(i => (byte)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Byte_LP_PreLen(data.Length, data)), $"Mean_Byte_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Byte_LP_PostLen(data, data.Length)), $"Mean_Byte_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Byte_SafeArray_OutLen(data, out len)), $"Mean_Byte_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_ShortArray() + { + int len; + short[] data = BaseData.Select(i => (short)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Short_LP_PreLen(data.Length, data)), $"Mean_Short_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Short_LP_PostLen(data, data.Length)), $"Mean_Short_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Short_SafeArray_OutLen(data, out len)), $"Mean_Short_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_UShortArray() + { + int len; + ushort[] data = BaseData.Select(i => (ushort)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UShort_LP_PreLen(data.Length, data)), $"Mean_UShort_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UShort_LP_PostLen(data, data.Length)), $"Mean_UShort_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UShort_SafeArray_OutLen(data, out len)), $"Mean_UShort_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_IntArray() + { + int len; + int[] data = BaseData.Select(i => i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Int_LP_PreLen(data.Length, data)), $"Mean_Int_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Int_LP_PostLen(data, data.Length)), $"Mean_Int_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Int_SafeArray_OutLen(data, out len)), $"Mean_Int_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_UIntArray() + { + int len; + uint[] data = BaseData.Select(i => (uint)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UInt_LP_PreLen(data.Length, data)), $"Mean_UInt_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UInt_LP_PostLen(data, data.Length)), $"Mean_UInt_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_UInt_SafeArray_OutLen(data, out len)), $"Mean_UInt_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_LongArray() + { + int len; + long[] data = BaseData.Select(i => (long)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Long_LP_PreLen(data.Length, data)), $"Mean_Long_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Long_LP_PostLen(data, data.Length)), $"Mean_Long_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Long_SafeArray_OutLen(data, out len)), $"Mean_Long_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_ULongArray() + { + int len; + ulong[] data = BaseData.Select(i => (ulong)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_ULong_LP_PreLen(data.Length, data)), $"Mean_ULong_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_ULong_LP_PostLen(data, data.Length)), $"Mean_ULong_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_ULong_SafeArray_OutLen(data, out len)), $"Mean_ULong_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_FloatArray() + { + int len; + float[] data = BaseData.Select(i => (float)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Float_LP_PreLen(data.Length, data)), $"Mean_Float_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Float_LP_PostLen(data, data.Length)), $"Mean_Float_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Float_SafeArray_OutLen(data, out len)), $"Mean_Float_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + + private void Marshal_DoubleArray() + { + int len; + double[] data = BaseData.Select(i => (double)i).ToArray(); + + Console.WriteLine($"{data.GetType().Name} marshalling"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Double_LP_PreLen(data.Length, data)), $"Mean_Double_LP_PreLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Double_LP_PostLen(data, data.Length)), $"Mean_Double_LP_PostLen"); + Assert.IsTrue(EqualByBound(expectedMean, this.server.Mean_Double_SafeArray_OutLen(data, out len)), $"Mean_Double_SafeArray_OutLen"); + Assert.AreEqual(data.Length, len); + } + } +} diff --git a/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs b/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs new file mode 100644 index 000000000000..9694333b549f --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/ErrorTests.cs @@ -0,0 +1,60 @@ +// 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. + +namespace NetClient +{ + using CoreFXTestLibrary; + using System; + using System.Runtime.InteropServices; + + class ErrorTests + { + private readonly Server.Contract.Servers.ErrorMarshalTesting server; + public ErrorTests() + { + this.server = (Server.Contract.Servers.ErrorMarshalTesting)new Server.Contract.Servers.ErrorMarshalTestingClass(); + } + + public void Run() + { + this.VerifyExpectedException(); + this.VerifyReturnHResult(); + } + + private void VerifyExpectedException() + { + Console.WriteLine($"Verify expected exception from HRESULT"); + + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x80004001)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x80004003)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x80070005)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x8007000E)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x80070057)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)0x8000ffff)); }); + Assert.Throws(() => { this.server.Throw_HResult(unchecked((int)-1)); }); + } + + private void VerifyReturnHResult() + { + Console.WriteLine($"Verify preserved function signature"); + + var hrs = new[] + { + unchecked((int)0x80004001), + unchecked((int)0x80004003), + unchecked((int)0x80070005), + unchecked((int)0x80070057), + unchecked((int)0x8000ffff), + -1, + 1, + 2 + }; + + foreach (var hr in hrs) + { + Assert.AreEqual(hr, this.server.Return_As_HResult(hr)); + } + } + } +} diff --git a/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj new file mode 100644 index 000000000000..0bb40d739bfd --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/NETClientPrimitives.csproj @@ -0,0 +1,36 @@ + + + + + Debug + AnyCPU + NETClientPrimitives + 2.0 + {85C57688-DA98-4DE3-AC9B-526E4747434C} + Exe + {209912F9-0DA1-4184-9CC1-8D583BAF4A28};{87799F5D-CEBD-499D-BDBA-B2C6105CD766} + App.manifest + + + true + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs b/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs new file mode 100644 index 000000000000..cff69ec19754 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs @@ -0,0 +1,193 @@ +// 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. + +namespace NetClient +{ + using CoreFXTestLibrary; + using System; + + class NumericTests + { + private readonly int seed; + private readonly Random rng; + private readonly Server.Contract.Servers.NumericTesting server; + + public NumericTests(int seed = 37) + { + this.seed = seed; + Console.WriteLine($"Numeric RNG seed: {this.seed}"); + + this.rng = new Random(this.seed); + this.server = (Server.Contract.Servers.NumericTesting)new Server.Contract.Servers.NumericTestingClass(); + } + + public void Run() + { + int a = this.rng.Next(); + int b = this.rng.Next(); + + this.Marshal_Byte((byte)a, (byte)b); + this.Marshal_Short((short)a, (short)b); + this.Marshal_UShort((ushort)a, (ushort)b); + this.Marshal_Int(a, b); + this.Marshal_UInt((uint)a, (uint)b); + this.Marshal_Long(a, b); + this.Marshal_ULong((ulong)a, (ulong)b); + + this.Marshal_Float(a / 100f, b / 100f); + this.Marshal_Double(a / 100.0, b / 100.0); + } + + static private bool EqualByBound(float expected, float actual) + { + float low = expected - 0.0001f; + float high = expected + 0.0001f; + float eps = Math.Abs(expected - actual); + return eps < float.Epsilon || (low < actual && actual < high); + } + + static private bool EqualByBound(double expected, double actual) + { + double low = expected - 0.00001; + double high = expected + 0.00001; + double eps = Math.Abs(expected - actual); + return eps < double.Epsilon || (low < actual && actual < high); + } + + private void Marshal_Byte(byte a, byte b) + { + var expected = (byte)(a + b); + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_Byte(a, b)); + + var c = byte.MaxValue; + this.server.Add_Byte_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_Byte_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_Short(short a, short b) + { + var expected = (short)(a + b); + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_Short(a, b)); + + var c = short.MaxValue; + this.server.Add_Short_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_Short_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_UShort(ushort a, ushort b) + { + var expected = (ushort)(a + b); + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_UShort(a, b)); + + var c = ushort.MaxValue; + this.server.Add_UShort_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_UShort_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_Int(int a, int b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_Int(a, b)); + + var c = int.MaxValue; + this.server.Add_Int_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_Int_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_UInt(uint a, uint b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_UInt(a, b)); + + var c = uint.MaxValue; + this.server.Add_UInt_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_UInt_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_Long(long a, long b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_Long(a, b)); + + var c = long.MaxValue; + this.server.Add_Long_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_Long_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_ULong(ulong a, ulong b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.AreEqual(expected, this.server.Add_ULong(a, b)); + + var c = ulong.MaxValue; + this.server.Add_ULong_Ref(a, b, ref c); + Assert.AreEqual(expected, c); + + c = 0; + this.server.Add_ULong_Out(a, b, out c); + Assert.AreEqual(expected, c); + } + + private void Marshal_Float(float a, float b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.IsTrue(EqualByBound(expected, this.server.Add_Float(a, b)), $"Add_Float: {this.server.Add_Float(a, b)}"); + + var c = float.MaxValue; + this.server.Add_Float_Ref(a, b, ref c); + Assert.IsTrue(EqualByBound(expected, c), "Add_Float_Ref"); + + c = 0; + this.server.Add_Float_Out(a, b, out c); + Assert.IsTrue(EqualByBound(expected, c), "Add_Float_Out"); + } + + private void Marshal_Double(double a, double b) + { + var expected = a + b; + Console.WriteLine($"{expected.GetType().Name} test invariant: {a} + {b} = {expected}"); + Assert.IsTrue(EqualByBound(expected, this.server.Add_Double(a, b))); + + var c = double.MaxValue; + this.server.Add_Double_Ref(a, b, ref c); + Assert.IsTrue(EqualByBound(expected, c)); + + c = 0; + this.server.Add_Double_Out(a, b, out c); + Assert.IsTrue(EqualByBound(expected, c)); + } + } +} diff --git a/tests/src/Interop/COM/NETClients/Primitives/Program.cs b/tests/src/Interop/COM/NETClients/Primitives/Program.cs new file mode 100644 index 000000000000..4d7641727566 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/Program.cs @@ -0,0 +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. + +namespace NetClient +{ + using System; + + class Program + { + static int Main(string[] doNotUse) + { + try + { + new NumericTests().Run(); + new ArrayTests().Run(); + new StringTests().Run(); + new ErrorTests().Run(); + } + catch (Exception e) + { + Console.WriteLine($"Test Failure: {e.Message}\n{e.StackTrace}"); + return 101; + } + + return 100; + } + } +} diff --git a/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs b/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs new file mode 100644 index 000000000000..ab5271fd73c1 --- /dev/null +++ b/tests/src/Interop/COM/NETClients/Primitives/StringTests.cs @@ -0,0 +1,272 @@ +// 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. + +namespace NetClient +{ + using CoreFXTestLibrary; + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text; + using System.Runtime.InteropServices; + + class StringTests + { + private readonly Server.Contract.Servers.StringTesting server; + + private readonly IEnumerable> addPairs = new Tuple[] + { + Tuple.Create("", ""), + Tuple.Create("", "def"), + Tuple.Create("abc", ""), + Tuple.Create("abc", "def"), + Tuple.Create("", "结合"), + Tuple.Create("结合", ""), + Tuple.Create("a", "结合"), + Tuple.Create("结合", "a"), + Tuple.Create("结合", "结合"), + + // String marshalling is optimized where strings shorter than MAX_PATH are + // allocated on the stack. Longer strings have memory allocated for them. + Tuple.Create("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901", "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901") + }; + + private readonly IEnumerable reversableStrings = new string[] + { + "", + "a", + "abc", + "reversable string", + "Unicode 相反 Unicode", + + // Long string optimization validation + "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" + }; + + public StringTests() + { + this.server = (Server.Contract.Servers.StringTesting)new Server.Contract.Servers.StringTestingClass(); + } + + public void Run() + { + this.Marshal_LPString(); + this.Marshal_LPWString(); + this.Marshal_BStrString(); + } + + static private string Reverse(string s) + { + var chars = s.ToCharArray(); + Array.Reverse(chars); + return new string(chars); + } + + static private bool AllAscii(string s) + { + const int MaxAscii = 0x7f; + return s.ToCharArray().All(c => c <= MaxAscii); + } + + private void Marshal_LPString() + { + Console.WriteLine($"Marshal strings as { UnmanagedType.LPStr }"); + foreach (var p in addPairs) + { + if (!AllAscii(p.Item1) || !AllAscii(p.Item2)) + { + // LPStr doesn't support non-ascii characters + continue; + } + + string expected = p.Item1 + p.Item2; + string actual = this.server.Add_LPStr(p.Item1, p.Item2); + Assert.AreEqual(expected, actual, "Add_String_LPStr (simple)"); + } + + foreach (var s in reversableStrings) + { + if (!AllAscii(s)) + { + // LPStr doesn't support non-ascii characters + continue; + } + + string local = s; + string expected = Reverse(local); + + string actual = this.server.Reverse_LPStr(local); + Assert.AreEqual(expected, actual); + + actual = this.server.Reverse_LPStr_Ref(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(expected, local); + + local = s; + actual = this.server.Reverse_LPStr_InRef(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(s, local); + + this.server.Reverse_LPStr_Out(local, out actual); + Assert.AreEqual(expected, actual); + + actual = local; + this.server.Reverse_LPStr_OutAttr(local, actual); // No-op for strings + Assert.AreEqual(local, actual); + } + + foreach (var s in reversableStrings) + { + if (!AllAscii(s)) + { + // LPStr doesn't support non-ascii characters + continue; + } + + var local = new StringBuilder(s); + string expected = Reverse(local.ToString()); + + StringBuilder actual = this.server.Reverse_SB_LPStr(local); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = this.server.Reverse_SB_LPStr_Ref(ref local); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = this.server.Reverse_SB_LPStr_InRef(ref local); + Assert.AreEqual(expected, actual.ToString()); + + // Palindromes are _always_ equal + if (!string.Equals(s, expected)) + { + Assert.AreNotEqual(expected, local.ToString()); + } + + local = new StringBuilder(s); + actual = new StringBuilder(); + this.server.Reverse_SB_LPStr_Out(local, out actual); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = new StringBuilder(s.Length); + this.server.Reverse_SB_LPStr_OutAttr(local, actual); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + } + } + + private void Marshal_LPWString() + { + Console.WriteLine($"Marshal strings as { UnmanagedType.LPWStr }"); + foreach (var p in addPairs) + { + string expected = p.Item1 + p.Item2; + string actual = this.server.Add_LPWStr(p.Item1, p.Item2); + Assert.AreEqual(expected, actual, "Add_String_LPWStr (simple)"); + } + + foreach (var s in reversableStrings) + { + string local = s; + string expected = Reverse(local); + + string actual = this.server.Reverse_LPWStr(local); + Assert.AreEqual(expected, actual); + + actual = this.server.Reverse_LPWStr_Ref(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(expected, local); + + local = s; + actual = this.server.Reverse_LPWStr_InRef(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(s, local); + + this.server.Reverse_LPWStr_Out(local, out actual); + Assert.AreEqual(expected, actual); + + actual = local; + this.server.Reverse_LPWStr_OutAttr(local, actual); // No-op for strings + Assert.AreEqual(local, actual); + } + + foreach (var s in reversableStrings) + { + var local = new StringBuilder(s); + string expected = Reverse(local.ToString()); + + StringBuilder actual = this.server.Reverse_SB_LPWStr(local); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = this.server.Reverse_SB_LPWStr_Ref(ref local); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = this.server.Reverse_SB_LPWStr_InRef(ref local); + Assert.AreEqual(expected, actual.ToString()); + + // Palindromes are _always_ equal + if (!string.Equals(s, expected)) + { + Assert.AreNotEqual(expected, local.ToString()); + } + + local = new StringBuilder(s); + actual = new StringBuilder(); + this.server.Reverse_SB_LPWStr_Out(local, out actual); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + + local = new StringBuilder(s); + actual = new StringBuilder(s.Length); + this.server.Reverse_SB_LPWStr_OutAttr(local, actual); + Assert.AreEqual(expected, actual.ToString()); + Assert.AreEqual(expected, local.ToString()); + } + } + + private void Marshal_BStrString() + { + Console.WriteLine($"Marshal strings as { UnmanagedType.BStr }"); + foreach (var p in addPairs) + { + string expected = p.Item1 + p.Item2; + string actual = this.server.Add_BStr(p.Item1, p.Item2); + Assert.AreEqual(expected, actual, "Add_String_BStr (simple)"); + } + + foreach (var s in reversableStrings) + { + string local = s; + string expected = Reverse(local); + + string actual = this.server.Reverse_BStr(local); + Assert.AreEqual(expected, actual); + + actual = this.server.Reverse_BStr_Ref(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(expected, local); + + local = s; + actual = this.server.Reverse_BStr_InRef(ref local); + Assert.AreEqual(expected, actual); + Assert.AreEqual(s, local); + + this.server.Reverse_BStr_Out(local, out actual); + Assert.AreEqual(expected, actual); + + actual = local; + this.server.Reverse_BStr_OutAttr(local, actual); // No-op for strings + Assert.AreEqual(local, actual); + } + } + } +} diff --git a/tests/src/Interop/ClassicCOM/COMLib2.cs b/tests/src/Interop/COM/NETServer/ImportedTypes.cs similarity index 97% rename from tests/src/Interop/ClassicCOM/COMLib2.cs rename to tests/src/Interop/COM/NETServer/ImportedTypes.cs index 8f0ec78c4d8f..a8d6e1981ae5 100644 --- a/tests/src/Interop/ClassicCOM/COMLib2.cs +++ b/tests/src/Interop/COM/NETServer/ImportedTypes.cs @@ -7,7 +7,7 @@ using System.Security; using System.Runtime.InteropServices; -namespace COMLib2 +namespace NETServer { [Guid("00020404-0000-0000-C000-000000000046")] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] @@ -31,4 +31,4 @@ public interface IEnumVARIANT public class ContextMenu { } -} +} \ No newline at end of file diff --git a/tests/src/Interop/ClassicCOM/COMLib2.csproj b/tests/src/Interop/COM/NETServer/NETServer.csproj similarity index 92% rename from tests/src/Interop/ClassicCOM/COMLib2.csproj rename to tests/src/Interop/COM/NETServer/NETServer.csproj index 601b94ecf9bc..cf62cc019c2f 100644 --- a/tests/src/Interop/ClassicCOM/COMLib2.csproj +++ b/tests/src/Interop/COM/NETServer/NETServer.csproj @@ -1,10 +1,10 @@ - + Debug AnyCPU - COMLib2 + NETServer 2.0 {C04AB564-CC61-499D-9F4C-AA1A9FDE42C9} library @@ -23,10 +23,10 @@ - + - + \ No newline at end of file diff --git a/tests/src/Interop/COM/NativeServer/ArrayTesting.h b/tests/src/Interop/COM/NativeServer/ArrayTesting.h new file mode 100644 index 000000000000..cbf54cfa9cb7 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/ArrayTesting.h @@ -0,0 +1,347 @@ +// 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. + +#pragma once + +#include +#include "Servers.h" + +class DECLSPEC_UUID("B99ABE6A-DFF6-440F-BFB6-55179B8FE18E") ArrayTesting : public UnknownImpl, public IArrayTesting +{ +private: + template + double Mean(L l, D *d) + { + double t = 0.0; + for (L i = 0; i < l; ++i) + t += d[i]; + + return (t / l); + } + template + HRESULT Mean(SAFEARRAY *d, long *l, double *r) + { + HRESULT hr; + + VARTYPE type; + RETURN_IF_FAILED(::SafeArrayGetVartype(d, &type)); + + if (E != type) + return E_UNEXPECTED; + + LONG upperBoundIndex; + RETURN_IF_FAILED(::SafeArrayGetUBound(d, 1, &upperBoundIndex)); + + // Upper bound is index so add '1' + *l = (upperBoundIndex + 1); + + switch (type) + { + case VT_UI1: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_I2: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_UI2: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_I4: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_UI4: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_I8: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_UI8: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_R4: + *r = Mean(*l, static_cast(d->pvData)); + break; + case VT_R8: + *r = Mean(*l, static_cast(d->pvData)); + break; + default: + return E_INVALIDARG; + } + + return S_OK; + } + +public: // IArrayTesting + DEF_RAWFUNC(Mean_Byte_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ unsigned char * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Short_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ short * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_UShort_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ unsigned short * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Int_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ long * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_UInt_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ unsigned long * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Long_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ __int64 * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_ULong_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ unsigned __int64 * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Float_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ float * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Double_LP_PreLen)( + /*[in]*/ long len, + /*[in]*/ double * d, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Byte_LP_PostLen)( + /*[in]*/ unsigned char * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Short_LP_PostLen)( + /*[in]*/ short * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_UShort_LP_PostLen)( + /*[in]*/ unsigned short * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Int_LP_PostLen)( + /*[in]*/ long * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_UInt_LP_PostLen)( + /*[in]*/ unsigned long * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Long_LP_PostLen)( + /*[in]*/ __int64 * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_ULong_LP_PostLen)( + /*[in]*/ unsigned __int64 * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Float_LP_PostLen)( + /*[in]*/ float * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Double_LP_PostLen)( + /*[in]*/ double * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + *pRetVal = Mean(len, d); + return S_OK; + } + DEF_RAWFUNC(Mean_Byte_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_Short_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_UShort_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_Int_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_UInt_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_Long_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_ULong_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_Float_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + DEF_RAWFUNC(Mean_Double_SafeArray_OutLen)( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal) + { + if (pRetVal == nullptr) + return E_POINTER; + return Mean(d, len, pRetVal); + } + +public: // IUnknown + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + return DoQueryInterface(this, riid, ppvObject); + } + + DEFINE_REF_COUNTING(); +}; diff --git a/tests/src/Interop/COM/NativeServer/CMakeLists.txt b/tests/src/Interop/COM/NativeServer/CMakeLists.txt new file mode 100644 index 000000000000..368248d97232 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required (VERSION 2.6) +project (COMNativeServer) +include_directories( ${INC_PLATFORM_DIR} ) +include_directories( "../ServerContracts" ) +set(SOURCES Servers.cpp stdafx.cpp Exports.def COMNativeServer.X.manifest) + +if (WIN32) + # 4365 - signed/unsigned mismatch + add_compile_options(-wd4365) +endif() + +# add the shared library +add_library (COMNativeServer SHARED ${SOURCES}) +target_link_libraries(COMNativeServer ${LINK_LIBRARIES_ADDITIONAL}) + +# Copy manifest file to project output +file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$/COMNativeServer.X.manifest INPUT ${CMAKE_CURRENT_SOURCE_DIR}/COMNativeServer.X.manifest) + +# add the install targets +install (TARGETS COMNativeServer DESTINATION bin) diff --git a/tests/src/Interop/COM/NativeServer/COMNativeServer.X.manifest b/tests/src/Interop/COM/NativeServer/COMNativeServer.X.manifest new file mode 100644 index 000000000000..13c36c909988 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/COMNativeServer.X.manifest @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/Interop/COM/NativeServer/ComHelpers.h b/tests/src/Interop/COM/NativeServer/ComHelpers.h new file mode 100644 index 000000000000..651ccc5364dd --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/ComHelpers.h @@ -0,0 +1,169 @@ +// 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. + +#pragma once + +#include +#include +#include +#include +#include +#include + +// Common macro for working in COM +#define RETURN_IF_FAILED(exp) { hr = exp; if (FAILED(hr)) { return hr; } } + +namespace Internal +{ + template + HRESULT __QueryInterfaceImpl( + /* [in] */ C *obj, + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + if (riid == __uuidof(I)) + { + *ppvObject = static_cast(obj); + } + else if (riid == __uuidof(IUnknown)) + { + *ppvObject = static_cast(obj); + } + else + { + *ppvObject = nullptr; + return E_NOINTERFACE; + } + + return S_OK; + } + + template + HRESULT __QueryInterfaceImpl( + /* [in] */ C *obj, + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + if (riid == __uuidof(I1)) + { + *ppvObject = static_cast(obj); + return S_OK; + } + + return __QueryInterfaceImpl(obj, riid, ppvObject); + } +} + +// Implementation of IUnknown operations +class UnknownImpl +{ +public: + UnknownImpl() = default; + virtual ~UnknownImpl() = default; + + UnknownImpl(const UnknownImpl&) = delete; + UnknownImpl& operator=(const UnknownImpl&) = delete; + + UnknownImpl(UnknownImpl&&) = default; + UnknownImpl& operator=(UnknownImpl&&) = default; + + template + HRESULT DoQueryInterface( + /* [in] */ C *derived, + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void **ppvObject) + { + assert(derived != nullptr); + if (ppvObject == nullptr) + return E_POINTER; + + HRESULT hr = Internal::__QueryInterfaceImpl(derived, riid, ppvObject); + if (hr == S_OK) + DoAddRef(); + + return hr; + } + + ULONG DoAddRef() + { + assert(_refCount > 0); + return (++_refCount); + } + + ULONG DoRelease() + { + assert(_refCount > 0); + ULONG c = (--_refCount); + if (c == 0) + delete this; + return c; + } + +private: + std::atomic _refCount = 1; +}; + +// Marco to use for defining ref counting impls +#define DEFINE_REF_COUNTING() \ + STDMETHOD_(ULONG, AddRef)(void) { return UnknownImpl::DoAddRef(); } \ + STDMETHOD_(ULONG, Release)(void) { return UnknownImpl::DoRelease(); } + +// Templated class factory +template +class ClassFactoryBasic : public UnknownImpl, public IClassFactory +{ +public: // static + static HRESULT Create(_In_ REFIID riid, _Outptr_ LPVOID FAR* ppv) + { + try + { + auto cf = new ClassFactoryBasic(); + HRESULT hr = cf->QueryInterface(riid, ppv); + cf->Release(); + return hr; + } + catch (const std::bad_alloc&) + { + return E_OUTOFMEMORY; + } + } + +public: // IClassFactory + STDMETHOD(CreateInstance)( + _In_opt_ IUnknown *pUnkOuter, + _In_ REFIID riid, + _COM_Outptr_ void **ppvObject) + { + if (pUnkOuter != nullptr) + return CLASS_E_NOAGGREGATION; + + try + { + auto ti = new T(); + HRESULT hr = ti->QueryInterface(riid, ppvObject); + ti->Release(); + return hr; + } + catch (const std::bad_alloc&) + { + return E_OUTOFMEMORY; + } + } + + STDMETHOD(LockServer)(/* [in] */ BOOL fLock) + { + assert(false && "Not impl"); + return E_NOTIMPL; + } + +public: // IUnknown + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + return DoQueryInterface(this, riid, ppvObject); + } + + DEFINE_REF_COUNTING(); +}; diff --git a/tests/src/Interop/COM/NativeServer/ErrorMarshalTesting.h b/tests/src/Interop/COM/NativeServer/ErrorMarshalTesting.h new file mode 100644 index 000000000000..307abe4a5d6e --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/ErrorMarshalTesting.h @@ -0,0 +1,32 @@ +// 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. + +#pragma once + +#include "Servers.h" + +class DECLSPEC_UUID("71CF5C45-106C-4B32-B418-43A463C6041F") ErrorMarshalTesting : public UnknownImpl, public IErrorMarshalTesting +{ +public: // IErrorMarshalTesting + DEF_RAWFUNC(Throw_HResult)( + /*[in]*/ long hresultToReturn) + { + return HRESULT{ hresultToReturn }; + } + long __stdcall Return_As_HResult( + /*[in]*/ long hresultToReturn) + { + return hresultToReturn; + } + +public: // IUnknown + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + return DoQueryInterface(this, riid, ppvObject); + } + + DEFINE_REF_COUNTING(); +}; diff --git a/tests/src/Interop/COM/NativeServer/Exports.def b/tests/src/Interop/COM/NativeServer/Exports.def new file mode 100644 index 000000000000..2d0de26b056e --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/Exports.def @@ -0,0 +1,4 @@ +EXPORTS + DllGetClassObject PRIVATE + DllRegisterServer PRIVATE + DllUnregisterServer PRIVATE \ No newline at end of file diff --git a/tests/src/Interop/COM/NativeServer/NumericTesting.h b/tests/src/Interop/COM/NativeServer/NumericTesting.h new file mode 100644 index 000000000000..9a80230d96f4 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/NumericTesting.h @@ -0,0 +1,257 @@ +// 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. + +#pragma once + +#include +#include "Servers.h" + +class DECLSPEC_UUID("53169A33-E85D-4E3C-B668-24E438D0929B") NumericTesting : public UnknownImpl, public INumericTesting +{ +public: + DEF_RAWFUNC(Add_Byte)( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[out,retval]*/ unsigned char * pRetVal) + { + *pRetVal = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Short)( + /*[in]*/ short a, + /*[in]*/ short b, + /*[out,retval]*/ short * pRetVal) + { + *pRetVal = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_UShort)( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[out,retval]*/ unsigned short * pRetVal) + { + *pRetVal = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Int)( + /*[in]*/ long a, + /*[in]*/ long b, + /*[out,retval]*/ long * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_UInt)( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[out,retval]*/ unsigned long * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Long)( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[out,retval]*/ __int64 * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_ULong)( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[out,retval]*/ unsigned __int64 * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Float)( + /*[in]*/ float a, + /*[in]*/ float b, + /*[out,retval]*/ float * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Double)( + /*[in]*/ double a, + /*[in]*/ double b, + /*[out,retval]*/ double * pRetVal) + { + *pRetVal = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Byte_Ref)( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[in,out]*/ unsigned char * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Short_Ref)( + /*[in]*/ short a, + /*[in]*/ short b, + /*[in,out]*/ short * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_UShort_Ref)( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[in,out]*/ unsigned short * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Int_Ref)( + /*[in]*/ long a, + /*[in]*/ long b, + /*[in,out]*/ long * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_UInt_Ref)( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[in,out]*/ unsigned long * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Long_Ref)( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[in,out]*/ __int64 * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_ULong_Ref)( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[in,out]*/ unsigned __int64 * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Float_Ref)( + /*[in]*/ float a, + /*[in]*/ float b, + /*[in,out]*/ float * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Double_Ref)( + /*[in]*/ double a, + /*[in]*/ double b, + /*[in,out]*/ double * c) + { + if (*c != std::numeric_limits::type>::max()) + return E_UNEXPECTED; + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Byte_Out)( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[out]*/ unsigned char * c) + { + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Short_Out)( + /*[in]*/ short a, + /*[in]*/ short b, + /*[out]*/ short * c) + { + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_UShort_Out)( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[out]*/ unsigned short * c) + { + *c = static_cast(a + b); + return S_OK; + } + DEF_RAWFUNC(Add_Int_Out)( + /*[in]*/ long a, + /*[in]*/ long b, + /*[out]*/ long * c) + { + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_UInt_Out)( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[out]*/ unsigned long * c) + { + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Long_Out)( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[out]*/ __int64 * c) + { + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_ULong_Out)( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[out]*/ unsigned __int64 * c) + { + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Float_Out)( + /*[in]*/ float a, + /*[in]*/ float b, + /*[out]*/ float * c) + { + *c = a + b; + return S_OK; + } + DEF_RAWFUNC(Add_Double_Out)( + /*[in]*/ double a, + /*[in]*/ double b, + /*[out]*/ double * c) + { + *c = a + b; + return S_OK; + } + +public: // IUnknown + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + return DoQueryInterface(this, riid, ppvObject); + } + + DEFINE_REF_COUNTING(); +}; diff --git a/tests/src/Interop/COM/NativeServer/Servers.cpp b/tests/src/Interop/COM/NativeServer/Servers.cpp new file mode 100644 index 000000000000..27f0d29963a9 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/Servers.cpp @@ -0,0 +1,198 @@ +// 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. + +#include "stdafx.h" +#include "Servers.h" + +namespace +{ + const WCHAR EntryKeyFmt[] = L"SOFTWARE\\Classes\\CLSID\\%s"; + + struct OleStr : public std::unique_ptr::type, decltype(&::CoTaskMemFree)> + { + OleStr(_In_ LPOLESTR raw) + : std::unique_ptr::type, decltype(&::CoTaskMemFree)>(raw, ::CoTaskMemFree) + { } + }; + + struct RegKey : public std::unique_ptr::type, decltype(&::RegCloseKey)> + { + RegKey(_In_ HKEY raw) + : std::unique_ptr::type, decltype(&::RegCloseKey)>(raw, ::RegCloseKey) + { } + }; + + HRESULT RemoveClsid(_In_ REFCLSID clsid) + { + HRESULT hr; + + LPOLESTR clsidAsStrRaw; + RETURN_IF_FAILED(::StringFromCLSID(clsid, &clsidAsStrRaw)); + + OleStr clsidAsStr{ clsidAsStrRaw }; + + WCHAR regKeyPath[1024]; + ::swprintf_s(regKeyPath, EntryKeyFmt, clsidAsStr.get()); + + LSTATUS res; + + // Handle sub keys + { + HKEY toDeleteRaw; + res = ::RegOpenKeyExW(HKEY_LOCAL_MACHINE, regKeyPath, 0, KEY_READ | KEY_WRITE, &toDeleteRaw); + if (ERROR_FILE_NOT_FOUND == res) + { + return S_OK; + } + else if (ERROR_SUCCESS != res) + { + return __HRESULT_FROM_WIN32(res); + } + + RegKey toDelete{ toDeleteRaw }; + res = ::RegDeleteTreeW(toDelete.get(), nullptr); + if (ERROR_SUCCESS != res) + return __HRESULT_FROM_WIN32(res); + } + + res = ::RegDeleteKeyW(HKEY_LOCAL_MACHINE, regKeyPath); + if (ERROR_SUCCESS != res) + return __HRESULT_FROM_WIN32(res); + + return S_OK; + } + + HRESULT RegisterClsid(_In_ REFCLSID clsid, _In_opt_z_ const WCHAR *threadingModel) + { + HRESULT hr; + + // Remove the CLSID in case it exists and has undesirable settings + RETURN_IF_FAILED(RemoveClsid(clsid)); + + LPOLESTR clsidAsStrRaw; + RETURN_IF_FAILED(::StringFromCLSID(clsid, &clsidAsStrRaw)); + + OleStr clsidAsStr{ clsidAsStrRaw }; + + WCHAR regKeyClsidPath[1024]; + ::swprintf_s(regKeyClsidPath, EntryKeyFmt, clsidAsStr.get()); + + HKEY regKeyRaw; + DWORD disp; + LSTATUS res = ::RegCreateKeyExW( + HKEY_LOCAL_MACHINE, + regKeyClsidPath, + 0, + REG_NONE, + REG_OPTION_NON_VOLATILE, + (KEY_READ | KEY_WRITE), + nullptr, + ®KeyRaw, + &disp); + if (res != ERROR_SUCCESS) + return __HRESULT_FROM_WIN32(res); + + RegKey regKey{ regKeyRaw }; + + WCHAR regKeyServerPath[1024]; + ::swprintf_s(regKeyServerPath, L"%s\\InProcServer32", regKeyClsidPath); + + HKEY regServerKeyRaw; + res = ::RegCreateKeyExW( + HKEY_LOCAL_MACHINE, + regKeyServerPath, + 0, + REG_NONE, + REG_OPTION_NON_VOLATILE, + (KEY_READ | KEY_WRITE), + nullptr, + ®ServerKeyRaw, + &disp); + if (res != ERROR_SUCCESS) + return __HRESULT_FROM_WIN32(res); + + regKey.reset(regServerKeyRaw); + + WCHAR fullPath[MAX_PATH + 1]; + + HMODULE mod; + if (FALSE == ::GetModuleHandleExW( + (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT), + reinterpret_cast(&RegisterClsid), + &mod)) + { + return HRESULT_FROM_WIN32(::GetLastError()); + } + + ::GetModuleFileNameW(mod, fullPath, ARRAYSIZE(fullPath)); + + // The default value for the key is the path to the DLL + res = ::RegSetValueExW( + regKey.get(), + nullptr, + 0, + REG_SZ, + reinterpret_cast(fullPath), + static_cast(::wcslen(fullPath) + 1) * sizeof(fullPath[0])); + if (res != ERROR_SUCCESS) + return __HRESULT_FROM_WIN32(res); + + // Set the threading model if provided + if (threadingModel != nullptr) + { + res = ::RegSetValueExW( + regKey.get(), + L"ThreadingModel", + 0, + REG_SZ, + reinterpret_cast(threadingModel), + static_cast(::wcslen(threadingModel) + 1) * sizeof(threadingModel[0])); + if (res != ERROR_SUCCESS) + return __HRESULT_FROM_WIN32(res); + } + + return S_OK; + } +} + +STDAPI DllRegisterServer(void) +{ + HRESULT hr; + + RETURN_IF_FAILED(RegisterClsid(__uuidof(NumericTesting), L"Both")); + RETURN_IF_FAILED(RegisterClsid(__uuidof(ArrayTesting), L"Both")); + RETURN_IF_FAILED(RegisterClsid(__uuidof(StringTesting), L"Both")); + RETURN_IF_FAILED(RegisterClsid(__uuidof(ErrorMarshalTesting), L"Both")); + + return S_OK; +} + +STDAPI DllUnregisterServer(void) +{ + HRESULT hr; + + RETURN_IF_FAILED(RemoveClsid(__uuidof(NumericTesting))); + RETURN_IF_FAILED(RemoveClsid(__uuidof(ArrayTesting))); + RETURN_IF_FAILED(RemoveClsid(__uuidof(StringTesting))); + RETURN_IF_FAILED(RemoveClsid(__uuidof(ErrorMarshalTesting))); + + return S_OK; +} + +STDAPI DllGetClassObject(_In_ REFCLSID rclsid, _In_ REFIID riid, _Out_ LPVOID FAR* ppv) +{ + if (rclsid == __uuidof(NumericTesting)) + return ClassFactoryBasic::Create(riid, ppv); + + if (rclsid == __uuidof(ArrayTesting)) + return ClassFactoryBasic::Create(riid, ppv); + + if (rclsid == __uuidof(StringTesting)) + return ClassFactoryBasic::Create(riid, ppv); + + if (rclsid == __uuidof(ErrorMarshalTesting)) + return ClassFactoryBasic::Create(riid, ppv); + + return CLASS_E_CLASSNOTAVAILABLE; +} diff --git a/tests/src/Interop/COM/NativeServer/Servers.h b/tests/src/Interop/COM/NativeServer/Servers.h new file mode 100644 index 000000000000..5a22e801abe8 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/Servers.h @@ -0,0 +1,18 @@ +// 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. + +#pragma once + +#include "ComHelpers.h" + +//#import "Server.Contract.tlb" no_namespace +#include + +#define DEF_RAWFUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE raw_ ## n +#define DEF_FUNC(n) virtual COM_DECLSPEC_NOTHROW HRESULT STDMETHODCALLTYPE ## n + +#include "NumericTesting.h" +#include "ArrayTesting.h" +#include "StringTesting.h" +#include "ErrorMarshalTesting.h" diff --git a/tests/src/Interop/COM/NativeServer/StringTesting.h b/tests/src/Interop/COM/NativeServer/StringTesting.h new file mode 100644 index 000000000000..7589bf297393 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/StringTesting.h @@ -0,0 +1,321 @@ +// 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. + +#pragma once + +#include "Servers.h" + +class DECLSPEC_UUID("C73C83E8-51A2-47F8-9B5C-4284458E47A6") StringTesting : public UnknownImpl, public IStringTesting +{ +private: + template + bool EqualValue(STRING l, STRING r) + { + STRING tmp = l; + int len = 1; // Include 1 for null + while (*tmp++) + ++len; + + return (0 == ::memcmp(l, r, len * sizeof(l[0]))); + } + + template + STRING ReverseInplace(size_t len, STRING s) + { + std::reverse(s, s + len); + return s; + } + + template + HRESULT Reverse(STRING str, STRING *res) + { + STRING tmp = str; + size_t len = 0; + while (*tmp++) + ++len; + + size_t strDataLen = (len + 1) * sizeof(str[0]); + auto resLocal = (STRING)::CoTaskMemAlloc(strDataLen); + if (resLocal == nullptr) + return E_OUTOFMEMORY; + + ::memcpy_s(resLocal, strDataLen, str, strDataLen); + *res = ReverseInplace(len, resLocal); + + return S_OK; + } + + HRESULT ReverseBstr(BSTR str, BSTR *res) + { + UINT strDataLen = ::SysStringByteLen(str); + BSTR resLocal = ::SysAllocStringByteLen(reinterpret_cast(str), strDataLen); + if (resLocal == nullptr) + return E_OUTOFMEMORY; + + UINT len = ::SysStringLen(str); + *res = ReverseInplace(len, resLocal); + + return S_OK; + } + +public: // IStringTesting + DEF_RAWFUNC(Add_LPStr)( + /*[in]*/ LPSTR a, + /*[in]*/ LPSTR b, + /*[out,retval]*/ LPSTR * pRetVal) + { + if (a == nullptr || b == nullptr) + return E_POINTER; + + size_t aLen = ::strlen(a); + size_t bLen = ::strlen(b); + auto buf = (LPSTR)::CoTaskMemAlloc((aLen + bLen + 1) * sizeof(*b)); + + ::strcpy_s(buf, aLen + 1, a); + ::strcpy_s(buf + aLen, bLen + 1, b); + + *pRetVal = buf; + return S_OK; + } + DEF_RAWFUNC(Add_LPWStr)( + /*[in]*/ LPWSTR a, + /*[in]*/ LPWSTR b, + /*[out,retval]*/ LPWSTR * pRetVal) + { + if (a == nullptr || b == nullptr) + return E_POINTER; + + size_t aLen = ::wcslen(a); + size_t bLen = ::wcslen(b); + auto buf = (LPWSTR)::CoTaskMemAlloc((aLen + bLen + 1) * sizeof(*b)); + + ::wcscpy_s(buf, aLen + 1, a); + ::wcscpy_s(buf + aLen, bLen + 1, b); + + *pRetVal = buf; + return S_OK; + } + DEF_RAWFUNC(Add_BStr)( + /*[in]*/ BSTR a, + /*[in]*/ BSTR b, + /*[out,retval]*/ BSTR * pRetVal) + { + if (a == nullptr || b == nullptr) + return E_POINTER; + + UINT aLen = ::SysStringLen(a); + UINT bLen = ::SysStringLen(b); + BSTR buf = ::SysAllocStringByteLen(nullptr, (aLen + bLen) * sizeof(a[0])); + + ::wcscpy_s(buf, aLen + 1, a); + ::wcscpy_s(buf + aLen, bLen + 1, b); + + *pRetVal = buf; + return S_OK; + } + DEF_RAWFUNC(Reverse_LPStr)( + /*[in]*/ LPSTR a, + /*[out,retval]*/ LPSTR * pRetVal) + { + return Reverse(a, pRetVal); + } + DEF_RAWFUNC(Reverse_LPStr_Ref)( + /*[in,out]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::strlen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_LPStr_InRef)( + /*[in]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal) + { + return Reverse(*a, pRetVal); + } + DEF_RAWFUNC(Reverse_LPStr_Out)( + /*[in]*/ LPSTR a, + /*[out]*/ LPSTR * b) + { + return Reverse(a, b); + } + DEF_RAWFUNC(Reverse_LPStr_OutAttr)( + /*[in]*/ LPSTR a, + /*[out]*/ LPSTR b) + { + ReverseInplace(::strlen(b), b); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPStr)( + /*[in,out]*/ LPSTR a, + /*[out,retval]*/ LPSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(a, pRetVal)); + ReverseInplace(::strlen(a), a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPStr_Ref)( + /*[in,out]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::strlen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPStr_InRef)( + /*[in]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::strlen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPStr_Out)( + /*[in,out]*/ LPSTR a, + /*[out]*/ LPSTR * b) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(a, b)); + ReverseInplace(::strlen(a), a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPStr_OutAttr)( + /*[in,out]*/ LPSTR a, + /*[out]*/ LPSTR b) + { + size_t len = ::strlen(a); + ReverseInplace(len, a); + size_t byteLen = (len + 1) * sizeof(*a); + ::memcpy_s(b, byteLen, a, byteLen); + return S_OK; + } + DEF_RAWFUNC(Reverse_LPWStr)( + /*[in]*/ LPWSTR a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + return Reverse(a, pRetVal); + } + DEF_RAWFUNC(Reverse_LPWStr_Ref)( + /*[in,out]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::wcslen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_LPWStr_InRef)( + /*[in]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + return Reverse(*a, pRetVal); + } + DEF_RAWFUNC(Reverse_LPWStr_Out)( + /*[in]*/ LPWSTR a, + /*[out]*/ LPWSTR * b) + { + return Reverse(a, b); + } + DEF_RAWFUNC(Reverse_LPWStr_OutAttr)( + /*[in]*/ LPWSTR a, + /*[out]*/ LPWSTR b) + { + ReverseInplace(::wcslen(b), b); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPWStr)( + /*[in,out]*/ LPWSTR a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(a, pRetVal)); + ReverseInplace(::wcslen(a), a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPWStr_Ref)( + /*[in,out]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::wcslen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPWStr_InRef)( + /*[in]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(*a, pRetVal)); + ReverseInplace(::wcslen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPWStr_Out)( + /*[in,out]*/ LPWSTR a, + /*[out]*/ LPWSTR * b) + { + HRESULT hr; + RETURN_IF_FAILED(Reverse(a, b)); + ReverseInplace(::wcslen(a), a); + return S_OK; + } + DEF_RAWFUNC(Reverse_SB_LPWStr_OutAttr)( + /*[in,out]*/ LPWSTR a, + /*[out]*/ LPWSTR b) + { + size_t len = ::wcslen(a); + ReverseInplace(len, a); + size_t byteLen = (len + 1) * sizeof(*a); + ::memcpy_s(b, byteLen, a, byteLen); + return S_OK; + } + DEF_RAWFUNC(Reverse_BStr)( + /*[in]*/ BSTR a, + /*[out,retval]*/ BSTR * pRetVal) + { + return ReverseBstr(a, pRetVal); + } + DEF_RAWFUNC(Reverse_BStr_Ref)( + /*[in,out]*/ BSTR * a, + /*[out,retval]*/ BSTR * pRetVal) + { + HRESULT hr; + RETURN_IF_FAILED(ReverseBstr(*a, pRetVal)); + ReverseInplace(::SysStringLen(*a), *a); + return S_OK; + } + DEF_RAWFUNC(Reverse_BStr_InRef)( + /*[in]*/ BSTR * a, + /*[out,retval]*/ BSTR * pRetVal) + { + return ReverseBstr(*a, pRetVal); + } + DEF_RAWFUNC(Reverse_BStr_Out)( + /*[in]*/ BSTR a, + /*[out]*/ BSTR * b) + { + return ReverseBstr(a, b); + } + DEF_RAWFUNC(Reverse_BStr_OutAttr)( + /*[in]*/ BSTR a, + /*[out]*/ BSTR b) + { + ReverseInplace(::SysStringLen(b), b); + return S_OK; + } + +public: // IUnknown + STDMETHOD(QueryInterface)( + /* [in] */ REFIID riid, + /* [iid_is][out] */ _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) + { + return DoQueryInterface(this, riid, ppvObject); + } + + DEFINE_REF_COUNTING(); +}; diff --git a/tests/src/Interop/COM/NativeServer/stdafx.cpp b/tests/src/Interop/COM/NativeServer/stdafx.cpp new file mode 100644 index 000000000000..c87158f32c04 --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/stdafx.cpp @@ -0,0 +1,5 @@ +// 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. + +#include "stdafx.h" diff --git a/tests/src/Interop/COM/NativeServer/stdafx.h b/tests/src/Interop/COM/NativeServer/stdafx.h new file mode 100644 index 000000000000..058ec2ea28cd --- /dev/null +++ b/tests/src/Interop/COM/NativeServer/stdafx.h @@ -0,0 +1,15 @@ +// 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. + +#pragma once + +#define NOMINMAX +#define WIN32_LEAN_AND_MEAN +// Windows Header Files +#include + +#include +#include + + diff --git a/tests/src/Interop/COM/Reflection/Reflection.cs b/tests/src/Interop/COM/Reflection/Reflection.cs new file mode 100644 index 000000000000..bab341a029dc --- /dev/null +++ b/tests/src/Interop/COM/Reflection/Reflection.cs @@ -0,0 +1,144 @@ +// 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.Text; +using System.Security; +using System.Reflection; +using System.Runtime.InteropServices; +using TestLibrary; + +public class Reflection +{ + /// + /// Reflect load ComImport Types amd enumerate them + /// + static bool ReflectionLoad() + { + try + { + Console.WriteLine("Scenario: ReflectionLoad"); + var asm = Assembly.LoadFrom("NETServer.dll"); + foreach (Type t in asm.GetTypes()) + { + Console.WriteLine(t.Name); + } + + return true; + } + catch (Exception e) + { + Console.WriteLine($"Caught unexpected exception: {e}"); + return false; + } + } + + /// + /// Type.IsCOMObject + /// + static bool TypeIsComObject() + { + try + { + Console.WriteLine("Scenario: TypeIsComObject"); + Type classType = typeof(NETServer.ContextMenu); + if (!classType.IsCOMObject) + { + Console.WriteLine("ComImport Class's IsCOMObject should return true"); + return false; + } + + Type interfaceType = typeof(NETServer.IEnumVARIANT); + if (interfaceType.IsCOMObject) + { + Console.WriteLine("ComImport interface's IsCOMObject should return false"); + return false; + } + + return true; + } + catch (Exception e) + { + Console.WriteLine($"Caught unexpected exception: {e}"); + return false; + } + } + + /// + /// Create COM instance via Activator + /// + static bool ActivateCOMType() + { + try + { + Console.WriteLine("Scenario: ActivateCOMType"); + var contextMenu = (NETServer.ContextMenu)Activator.CreateInstance(typeof(NETServer.ContextMenu)); + + // Non-Windows should throw PlatformNotSupportedException + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return false; + } + + if (contextMenu == null) + { + Console.WriteLine("ActivateCOMType failed"); + return false; + } + + return true; + } + catch (TargetInvocationException e) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && e.InnerException is PlatformNotSupportedException) + { + return true; + } + + Console.WriteLine($"Caught unexpected {nameof(PlatformNotSupportedException)}: {e}"); + return false; + } + catch(COMException e) + { + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + return true; + } + + Console.WriteLine($"Caught unexpected {nameof(COMException)}: {e}"); + return false; + } + catch (Exception e) + { + Console.WriteLine($"Caught unexpected exception: {e}"); + return false; + } + } + + [System.Security.SecuritySafeCritical] + static int Main() + { + int failures = 0; + if (!ReflectionLoad()) + { + Console.WriteLine("ReflectionLoad Failed"); + failures++; + } + + if (!TypeIsComObject()) + { + Console.WriteLine("TypeIsComObject Failed"); + failures++; + } + + if (!ActivateCOMType()) + { + Console.WriteLine("ActivateCOMType Failed"); + failures++; + } + + return failures > 0 ? 101 : 100; + } +} \ No newline at end of file diff --git a/tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.csproj b/tests/src/Interop/COM/Reflection/Reflection.csproj similarity index 73% rename from tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.csproj rename to tests/src/Interop/COM/Reflection/Reflection.csproj index 673e216fe9af..ad03388ca9fb 100644 --- a/tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.csproj +++ b/tests/src/Interop/COM/Reflection/Reflection.csproj @@ -1,10 +1,10 @@ - + Debug AnyCPU - ClassicCOMUnitTest + Reflection 2.0 {85C57688-DA98-4DE3-AC9B-526E4747434C} Exe @@ -23,25 +23,17 @@ - + - - - - + {c8c0dc74-fac4-45b1-81fe-70c4808366e0} CoreCLRTestLibrary - - {5FEE5C46-8DD9-49FA-BDC1-AF22867A0704} - COMLib - - + {C04AB564-CC61-499D-9F4C-AA1A9FDE42C9} - COMLib + NETServer - - + \ No newline at end of file diff --git a/tests/src/Interop/COM/ServerContracts/Primitives.cs b/tests/src/Interop/COM/ServerContracts/Primitives.cs new file mode 100644 index 000000000000..cc6a30344b41 --- /dev/null +++ b/tests/src/Interop/COM/ServerContracts/Primitives.cs @@ -0,0 +1,189 @@ +// 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. + +#pragma warning disable 618 // Must test deprecated features + +namespace Server.Contract +{ + using System; + using System.Runtime.InteropServices; + using System.Text; + + [ComVisible(true)] + [Guid("05655A94-A915-4926-815D-A9EA648BAAD9")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface INumericTesting + { + byte Add_Byte(byte a, byte b); + short Add_Short(short a, short b); + ushort Add_UShort(ushort a, ushort b); + int Add_Int(int a, int b); + uint Add_UInt(uint a, uint b); + long Add_Long(long a, long b); + ulong Add_ULong(ulong a, ulong b); + float Add_Float(float a, float b); + double Add_Double(double a, double b); + + void Add_Byte_Ref(byte a, byte b, ref byte c); + void Add_Short_Ref(short a, short b, ref short c); + void Add_UShort_Ref(ushort a, ushort b, ref ushort c); + void Add_Int_Ref(int a, int b, ref int c); + void Add_UInt_Ref(uint a, uint b, ref uint c); + void Add_Long_Ref(long a, long b, ref long c); + void Add_ULong_Ref(ulong a, ulong b, ref ulong c); + void Add_Float_Ref(float a, float b, ref float c); + void Add_Double_Ref(double a, double b, ref double c); + + void Add_Byte_Out(byte a, byte b, out byte c); + void Add_Short_Out(short a, short b, out short c); + void Add_UShort_Out(ushort a, ushort b, out ushort c); + void Add_Int_Out(int a, int b, out int c); + void Add_UInt_Out(uint a, uint b, out uint c); + void Add_Long_Out(long a, long b, out long c); + void Add_ULong_Out(ulong a, ulong b, out ulong c); + void Add_Float_Out(float a, float b, out float c); + void Add_Double_Out(double a, double b, out double c); + } + + [ComVisible(true)] + [Guid("7731CB31-E063-4CC8-BCD2-D151D6BC8F43")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IArrayTesting + { + double Mean_Byte_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] byte[] d); + double Mean_Short_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] short[] d); + double Mean_UShort_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] ushort[] d); + double Mean_Int_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] int[] d); + double Mean_UInt_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] uint[] d); + double Mean_Long_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] long[] d); + double Mean_ULong_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] ulong[] d); + double Mean_Float_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] float[] d); + double Mean_Double_LP_PreLen(int len, [MarshalAs(UnmanagedType.LPArray)] double[] d); + + double Mean_Byte_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] byte[] d, int len); + double Mean_Short_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] short[] d, int len); + double Mean_UShort_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] ushort[] d, int len); + double Mean_Int_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] int[] d, int len); + double Mean_UInt_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] uint[] d, int len); + double Mean_Long_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] long[] d, int len); + double Mean_ULong_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] ulong[] d, int len); + double Mean_Float_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] float[] d, int len); + double Mean_Double_LP_PostLen([MarshalAs(UnmanagedType.LPArray)] double[] d, int len); + + double Mean_Byte_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] byte[] d, out int len); + double Mean_Short_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] short[] d, out int len); + double Mean_UShort_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] ushort[] d, out int len); + double Mean_Int_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] int[] d, out int len); + double Mean_UInt_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] uint[] d, out int len); + double Mean_Long_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] long[] d, out int len); + double Mean_ULong_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] ulong[] d, out int len); + double Mean_Float_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] float[] d, out int len); + double Mean_Double_SafeArray_OutLen([MarshalAs(UnmanagedType.SafeArray)] double[] d, out int len); + } + + [ComVisible(true)] + [Guid("7044C5C0-C6C6-4713-9294-B4A4E86D58CC")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IStringTesting + { + [return: MarshalAs(UnmanagedType.LPStr)] + string Add_LPStr( + [MarshalAs(UnmanagedType.LPStr)] string a, + [MarshalAs(UnmanagedType.LPStr)] string b); + + [return: MarshalAs(UnmanagedType.LPWStr)] + string Add_LPWStr( + [MarshalAs(UnmanagedType.LPWStr)] string a, + [MarshalAs(UnmanagedType.LPWStr)] string b); + + [return: MarshalAs(UnmanagedType.BStr)] + string Add_BStr( + [MarshalAs(UnmanagedType.BStr)] string a, + [MarshalAs(UnmanagedType.BStr)] string b); + + // LPStr + + [return: MarshalAs(UnmanagedType.LPStr)] + string Reverse_LPStr([MarshalAs(UnmanagedType.LPStr)] string a); + + [return: MarshalAs(UnmanagedType.LPStr)] + string Reverse_LPStr_Ref([MarshalAs(UnmanagedType.LPStr)] ref string a); + + [return: MarshalAs(UnmanagedType.LPStr)] + string Reverse_LPStr_InRef([In][MarshalAs(UnmanagedType.LPStr)] ref string a); + + void Reverse_LPStr_Out([MarshalAs(UnmanagedType.LPStr)] string a, [MarshalAs(UnmanagedType.LPStr)] out string b); + + void Reverse_LPStr_OutAttr([MarshalAs(UnmanagedType.LPStr)] string a, [Out][MarshalAs(UnmanagedType.LPStr)] string b); + + [return: MarshalAs(UnmanagedType.LPStr)] + StringBuilder Reverse_SB_LPStr([MarshalAs(UnmanagedType.LPStr)] StringBuilder a); + + [return: MarshalAs(UnmanagedType.LPStr)] + StringBuilder Reverse_SB_LPStr_Ref([MarshalAs(UnmanagedType.LPStr)] ref StringBuilder a); + + [return: MarshalAs(UnmanagedType.LPStr)] + StringBuilder Reverse_SB_LPStr_InRef([In][MarshalAs(UnmanagedType.LPStr)] ref StringBuilder a); + + void Reverse_SB_LPStr_Out([MarshalAs(UnmanagedType.LPStr)] StringBuilder a, [MarshalAs(UnmanagedType.LPStr)] out StringBuilder b); + + void Reverse_SB_LPStr_OutAttr([MarshalAs(UnmanagedType.LPStr)] StringBuilder a, [Out][MarshalAs(UnmanagedType.LPStr)] StringBuilder b); + + // LPWStr + + [return: MarshalAs(UnmanagedType.LPWStr)] + string Reverse_LPWStr([MarshalAs(UnmanagedType.LPWStr)] string a); + + [return: MarshalAs(UnmanagedType.LPWStr)] + string Reverse_LPWStr_Ref([MarshalAs(UnmanagedType.LPWStr)] ref string a); + + [return: MarshalAs(UnmanagedType.LPWStr)] + string Reverse_LPWStr_InRef([In][MarshalAs(UnmanagedType.LPWStr)] ref string a); + + void Reverse_LPWStr_Out([MarshalAs(UnmanagedType.LPWStr)] string a, [MarshalAs(UnmanagedType.LPWStr)] out string b); + + void Reverse_LPWStr_OutAttr([MarshalAs(UnmanagedType.LPWStr)] string a, [Out][MarshalAs(UnmanagedType.LPWStr)] string b); + + [return: MarshalAs(UnmanagedType.LPWStr)] + StringBuilder Reverse_SB_LPWStr([MarshalAs(UnmanagedType.LPWStr)] StringBuilder a); + + [return: MarshalAs(UnmanagedType.LPWStr)] + StringBuilder Reverse_SB_LPWStr_Ref([MarshalAs(UnmanagedType.LPWStr)] ref StringBuilder a); + + [return: MarshalAs(UnmanagedType.LPWStr)] + StringBuilder Reverse_SB_LPWStr_InRef([In][MarshalAs(UnmanagedType.LPWStr)] ref StringBuilder a); + + void Reverse_SB_LPWStr_Out([MarshalAs(UnmanagedType.LPWStr)] StringBuilder a, [MarshalAs(UnmanagedType.LPWStr)] out StringBuilder b); + + void Reverse_SB_LPWStr_OutAttr([MarshalAs(UnmanagedType.LPWStr)] StringBuilder a, [Out][MarshalAs(UnmanagedType.LPWStr)] StringBuilder b); + + // BSTR + + [return: MarshalAs(UnmanagedType.BStr)] + string Reverse_BStr([MarshalAs(UnmanagedType.BStr)] string a); + + [return: MarshalAs(UnmanagedType.BStr)] + string Reverse_BStr_Ref([MarshalAs(UnmanagedType.BStr)] ref string a); + + [return: MarshalAs(UnmanagedType.BStr)] + string Reverse_BStr_InRef([In][MarshalAs(UnmanagedType.BStr)] ref string a); + + void Reverse_BStr_Out([MarshalAs(UnmanagedType.BStr)] string a, [MarshalAs(UnmanagedType.BStr)] out string b); + + void Reverse_BStr_OutAttr([MarshalAs(UnmanagedType.BStr)] string a, [Out][MarshalAs(UnmanagedType.BStr)] string b); + } + + [ComVisible(true)] + [Guid("592386A5-6837-444D-9DE3-250815D18556")] + [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IErrorMarshalTesting + { + void Throw_HResult(int hresultToReturn); + + [PreserveSig] + int Return_As_HResult(int hresultToReturn); + } +} + +#pragma warning restore 618 // Must test deprecated features diff --git a/tests/src/Interop/COM/ServerContracts/PrimitivesNativeServer.cs b/tests/src/Interop/COM/ServerContracts/PrimitivesNativeServer.cs new file mode 100644 index 000000000000..4e028804dd3c --- /dev/null +++ b/tests/src/Interop/COM/ServerContracts/PrimitivesNativeServer.cs @@ -0,0 +1,89 @@ +// 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. + +#pragma warning disable IDE1006 // Naming Styles + +namespace Server.Contract.Servers +{ + using System; + using System.Runtime.InteropServices; + + /// + /// Managed definition of CoClass + /// + [ComImport] + [CoClass(typeof(NumericTestingClass))] + [Guid("05655A94-A915-4926-815D-A9EA648BAAD9")] + internal interface NumericTesting : Server.Contract.INumericTesting + { + } + + /// + /// Managed activation for CoClass + /// + [ComImport] + [Guid("53169A33-E85D-4E3C-B668-24E438D0929B")] + internal class NumericTestingClass + { + } + + /// + /// Managed definition of CoClass + /// + [ComImport] + [CoClass(typeof(ArrayTestingClass))] + [Guid("7731CB31-E063-4CC8-BCD2-D151D6BC8F43")] + internal interface ArrayTesting : Server.Contract.IArrayTesting + { + } + + /// + /// Managed activation for CoClass + /// + [ComImport] + [Guid("B99ABE6A-DFF6-440F-BFB6-55179B8FE18E")] + internal class ArrayTestingClass + { + } + + /// + /// Managed definition of CoClass + /// + [ComImport] + [CoClass(typeof(StringTestingClass))] + [Guid("7044C5C0-C6C6-4713-9294-B4A4E86D58CC")] + internal interface StringTesting : Server.Contract.IStringTesting + { + } + + /// + /// Managed activation for CoClass + /// + [ComImport] + [Guid("C73C83E8-51A2-47F8-9B5C-4284458E47A6")] + internal class StringTestingClass + { + } + + /// + /// Managed definition of CoClass + /// + [ComImport] + [CoClass(typeof(ErrorMarshalTestingClass))] + [Guid("592386A5-6837-444D-9DE3-250815D18556")] + internal interface ErrorMarshalTesting : Server.Contract.IErrorMarshalTesting + { + } + + /// + /// Managed activation for CoClass + /// + [ComImport] + [Guid("71CF5C45-106C-4B32-B418-43A463C6041F")] + internal class ErrorMarshalTestingClass + { + } +} + +#pragma warning restore IDE1006 // Naming Styles diff --git a/tests/src/Interop/COM/ServerContracts/Server.Contracts.tlh b/tests/src/Interop/COM/ServerContracts/Server.Contracts.tlh new file mode 100644 index 000000000000..55597a9ef7a0 --- /dev/null +++ b/tests/src/Interop/COM/ServerContracts/Server.Contracts.tlh @@ -0,0 +1,656 @@ +// Created by Microsoft (R) C/C++ Compiler + +#pragma once +#pragma pack(push, 8) + +#include + +// +// Forward references and typedefs +// + +struct __declspec(uuid("3b973377-8c69-4208-96c1-475da757861c")) +/* LIBID */ __Server_Contract; +struct __declspec(uuid("05655a94-a915-4926-815d-a9ea648baad9")) +/* interface */ INumericTesting; +struct __declspec(uuid("7731cb31-e063-4cc8-bcd2-d151d6bc8f43")) +/* interface */ IArrayTesting; +struct __declspec(uuid("7044c5c0-c6c6-4713-9294-b4a4e86d58cc")) +/* interface */ IStringTesting; +struct __declspec(uuid("592386a5-6837-444d-9de3-250815d18556")) +/* interface */ IErrorMarshalTesting; + +// +// Smart pointer typedef declarations +// + +_COM_SMARTPTR_TYPEDEF(INumericTesting, __uuidof(INumericTesting)); +_COM_SMARTPTR_TYPEDEF(IArrayTesting, __uuidof(IArrayTesting)); +_COM_SMARTPTR_TYPEDEF(IStringTesting, __uuidof(IStringTesting)); +_COM_SMARTPTR_TYPEDEF(IErrorMarshalTesting, __uuidof(IErrorMarshalTesting)); + +// +// Type library items +// + +struct __declspec(uuid("05655a94-a915-4926-815d-a9ea648baad9")) +INumericTesting : IUnknown +{ + // + // Wrapper methods for error-handling + // + + unsigned char Add_Byte ( + unsigned char a, + unsigned char b ); + short Add_Short ( + short a, + short b ); + unsigned short Add_UShort ( + unsigned short a, + unsigned short b ); + long Add_Int ( + long a, + long b ); + unsigned long Add_UInt ( + unsigned long a, + unsigned long b ); + __int64 Add_Long ( + __int64 a, + __int64 b ); + unsigned __int64 Add_ULong ( + unsigned __int64 a, + unsigned __int64 b ); + float Add_Float ( + float a, + float b ); + double Add_Double ( + double a, + double b ); + HRESULT Add_Byte_Ref ( + unsigned char a, + unsigned char b, + unsigned char * c ); + HRESULT Add_Short_Ref ( + short a, + short b, + short * c ); + HRESULT Add_UShort_Ref ( + unsigned short a, + unsigned short b, + unsigned short * c ); + HRESULT Add_Int_Ref ( + long a, + long b, + long * c ); + HRESULT Add_UInt_Ref ( + unsigned long a, + unsigned long b, + unsigned long * c ); + HRESULT Add_Long_Ref ( + __int64 a, + __int64 b, + __int64 * c ); + HRESULT Add_ULong_Ref ( + unsigned __int64 a, + unsigned __int64 b, + unsigned __int64 * c ); + HRESULT Add_Float_Ref ( + float a, + float b, + float * c ); + HRESULT Add_Double_Ref ( + double a, + double b, + double * c ); + HRESULT Add_Byte_Out ( + unsigned char a, + unsigned char b, + unsigned char * c ); + HRESULT Add_Short_Out ( + short a, + short b, + short * c ); + HRESULT Add_UShort_Out ( + unsigned short a, + unsigned short b, + unsigned short * c ); + HRESULT Add_Int_Out ( + long a, + long b, + long * c ); + HRESULT Add_UInt_Out ( + unsigned long a, + unsigned long b, + unsigned long * c ); + HRESULT Add_Long_Out ( + __int64 a, + __int64 b, + __int64 * c ); + HRESULT Add_ULong_Out ( + unsigned __int64 a, + unsigned __int64 b, + unsigned __int64 * c ); + HRESULT Add_Float_Out ( + float a, + float b, + float * c ); + HRESULT Add_Double_Out ( + double a, + double b, + double * c ); + + // + // Raw methods provided by interface + // + + virtual HRESULT __stdcall raw_Add_Byte ( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[out,retval]*/ unsigned char * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Short ( + /*[in]*/ short a, + /*[in]*/ short b, + /*[out,retval]*/ short * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_UShort ( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[out,retval]*/ unsigned short * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Int ( + /*[in]*/ long a, + /*[in]*/ long b, + /*[out,retval]*/ long * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_UInt ( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[out,retval]*/ unsigned long * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Long ( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[out,retval]*/ __int64 * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_ULong ( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[out,retval]*/ unsigned __int64 * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Float ( + /*[in]*/ float a, + /*[in]*/ float b, + /*[out,retval]*/ float * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Double ( + /*[in]*/ double a, + /*[in]*/ double b, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_Byte_Ref ( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[in,out]*/ unsigned char * c ) = 0; + virtual HRESULT __stdcall raw_Add_Short_Ref ( + /*[in]*/ short a, + /*[in]*/ short b, + /*[in,out]*/ short * c ) = 0; + virtual HRESULT __stdcall raw_Add_UShort_Ref ( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[in,out]*/ unsigned short * c ) = 0; + virtual HRESULT __stdcall raw_Add_Int_Ref ( + /*[in]*/ long a, + /*[in]*/ long b, + /*[in,out]*/ long * c ) = 0; + virtual HRESULT __stdcall raw_Add_UInt_Ref ( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[in,out]*/ unsigned long * c ) = 0; + virtual HRESULT __stdcall raw_Add_Long_Ref ( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[in,out]*/ __int64 * c ) = 0; + virtual HRESULT __stdcall raw_Add_ULong_Ref ( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[in,out]*/ unsigned __int64 * c ) = 0; + virtual HRESULT __stdcall raw_Add_Float_Ref ( + /*[in]*/ float a, + /*[in]*/ float b, + /*[in,out]*/ float * c ) = 0; + virtual HRESULT __stdcall raw_Add_Double_Ref ( + /*[in]*/ double a, + /*[in]*/ double b, + /*[in,out]*/ double * c ) = 0; + virtual HRESULT __stdcall raw_Add_Byte_Out ( + /*[in]*/ unsigned char a, + /*[in]*/ unsigned char b, + /*[out]*/ unsigned char * c ) = 0; + virtual HRESULT __stdcall raw_Add_Short_Out ( + /*[in]*/ short a, + /*[in]*/ short b, + /*[out]*/ short * c ) = 0; + virtual HRESULT __stdcall raw_Add_UShort_Out ( + /*[in]*/ unsigned short a, + /*[in]*/ unsigned short b, + /*[out]*/ unsigned short * c ) = 0; + virtual HRESULT __stdcall raw_Add_Int_Out ( + /*[in]*/ long a, + /*[in]*/ long b, + /*[out]*/ long * c ) = 0; + virtual HRESULT __stdcall raw_Add_UInt_Out ( + /*[in]*/ unsigned long a, + /*[in]*/ unsigned long b, + /*[out]*/ unsigned long * c ) = 0; + virtual HRESULT __stdcall raw_Add_Long_Out ( + /*[in]*/ __int64 a, + /*[in]*/ __int64 b, + /*[out]*/ __int64 * c ) = 0; + virtual HRESULT __stdcall raw_Add_ULong_Out ( + /*[in]*/ unsigned __int64 a, + /*[in]*/ unsigned __int64 b, + /*[out]*/ unsigned __int64 * c ) = 0; + virtual HRESULT __stdcall raw_Add_Float_Out ( + /*[in]*/ float a, + /*[in]*/ float b, + /*[out]*/ float * c ) = 0; + virtual HRESULT __stdcall raw_Add_Double_Out ( + /*[in]*/ double a, + /*[in]*/ double b, + /*[out]*/ double * c ) = 0; +}; + +struct __declspec(uuid("7731cb31-e063-4cc8-bcd2-d151d6bc8f43")) +IArrayTesting : IUnknown +{ + // + // Wrapper methods for error-handling + // + + double Mean_Byte_LP_PreLen ( + long len, + unsigned char * d ); + double Mean_Short_LP_PreLen ( + long len, + short * d ); + double Mean_UShort_LP_PreLen ( + long len, + unsigned short * d ); + double Mean_Int_LP_PreLen ( + long len, + long * d ); + double Mean_UInt_LP_PreLen ( + long len, + unsigned long * d ); + double Mean_Long_LP_PreLen ( + long len, + __int64 * d ); + double Mean_ULong_LP_PreLen ( + long len, + unsigned __int64 * d ); + double Mean_Float_LP_PreLen ( + long len, + float * d ); + double Mean_Double_LP_PreLen ( + long len, + double * d ); + double Mean_Byte_LP_PostLen ( + unsigned char * d, + long len ); + double Mean_Short_LP_PostLen ( + short * d, + long len ); + double Mean_UShort_LP_PostLen ( + unsigned short * d, + long len ); + double Mean_Int_LP_PostLen ( + long * d, + long len ); + double Mean_UInt_LP_PostLen ( + unsigned long * d, + long len ); + double Mean_Long_LP_PostLen ( + __int64 * d, + long len ); + double Mean_ULong_LP_PostLen ( + unsigned __int64 * d, + long len ); + double Mean_Float_LP_PostLen ( + float * d, + long len ); + double Mean_Double_LP_PostLen ( + double * d, + long len ); + double Mean_Byte_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_Short_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_UShort_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_Int_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_UInt_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_Long_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_ULong_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_Float_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + double Mean_Double_SafeArray_OutLen ( + SAFEARRAY * d, + long * len ); + + // + // Raw methods provided by interface + // + + virtual HRESULT __stdcall raw_Mean_Byte_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ unsigned char * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Short_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ short * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UShort_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ unsigned short * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Int_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ long * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UInt_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ unsigned long * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Long_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ __int64 * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_ULong_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ unsigned __int64 * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Float_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ float * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Double_LP_PreLen ( + /*[in]*/ long len, + /*[in]*/ double * d, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Byte_LP_PostLen ( + /*[in]*/ unsigned char * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Short_LP_PostLen ( + /*[in]*/ short * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UShort_LP_PostLen ( + /*[in]*/ unsigned short * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Int_LP_PostLen ( + /*[in]*/ long * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UInt_LP_PostLen ( + /*[in]*/ unsigned long * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Long_LP_PostLen ( + /*[in]*/ __int64 * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_ULong_LP_PostLen ( + /*[in]*/ unsigned __int64 * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Float_LP_PostLen ( + /*[in]*/ float * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Double_LP_PostLen ( + /*[in]*/ double * d, + /*[in]*/ long len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Byte_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Short_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UShort_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Int_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_UInt_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Long_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_ULong_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Float_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Mean_Double_SafeArray_OutLen ( + /*[in]*/ SAFEARRAY * d, + /*[out]*/ long * len, + /*[out,retval]*/ double * pRetVal ) = 0; +}; + +struct __declspec(uuid("7044c5c0-c6c6-4713-9294-b4a4e86d58cc")) +IStringTesting : IUnknown +{ + // + // Wrapper methods for error-handling + // + + LPSTR Add_LPStr ( + LPSTR a, + LPSTR b ); + LPWSTR Add_LPWStr ( + LPWSTR a, + LPWSTR b ); + _bstr_t Add_BStr ( + _bstr_t a, + _bstr_t b ); + LPSTR Reverse_LPStr ( + LPSTR a ); + LPSTR Reverse_LPStr_Ref ( + LPSTR * a ); + LPSTR Reverse_LPStr_InRef ( + LPSTR * a ); + HRESULT Reverse_LPStr_Out ( + LPSTR a, + LPSTR * b ); + HRESULT Reverse_LPStr_OutAttr ( + LPSTR a, + LPSTR b ); + LPSTR Reverse_SB_LPStr ( + LPSTR a ); + LPSTR Reverse_SB_LPStr_Ref ( + LPSTR * a ); + LPSTR Reverse_SB_LPStr_InRef ( + LPSTR * a ); + HRESULT Reverse_SB_LPStr_Out ( + LPSTR a, + LPSTR * b ); + HRESULT Reverse_SB_LPStr_OutAttr ( + LPSTR a, + LPSTR b ); + LPWSTR Reverse_LPWStr ( + LPWSTR a ); + LPWSTR Reverse_LPWStr_Ref ( + LPWSTR * a ); + LPWSTR Reverse_LPWStr_InRef ( + LPWSTR * a ); + HRESULT Reverse_LPWStr_Out ( + LPWSTR a, + LPWSTR * b ); + HRESULT Reverse_LPWStr_OutAttr ( + LPWSTR a, + LPWSTR b ); + LPWSTR Reverse_SB_LPWStr ( + LPWSTR a ); + LPWSTR Reverse_SB_LPWStr_Ref ( + LPWSTR * a ); + LPWSTR Reverse_SB_LPWStr_InRef ( + LPWSTR * a ); + HRESULT Reverse_SB_LPWStr_Out ( + LPWSTR a, + LPWSTR * b ); + HRESULT Reverse_SB_LPWStr_OutAttr ( + LPWSTR a, + LPWSTR b ); + _bstr_t Reverse_BStr ( + _bstr_t a ); + _bstr_t Reverse_BStr_Ref ( + BSTR * a ); + _bstr_t Reverse_BStr_InRef ( + BSTR * a ); + HRESULT Reverse_BStr_Out ( + _bstr_t a, + BSTR * b ); + HRESULT Reverse_BStr_OutAttr ( + _bstr_t a, + _bstr_t b ); + + // + // Raw methods provided by interface + // + + virtual HRESULT __stdcall raw_Add_LPStr ( + /*[in]*/ LPSTR a, + /*[in]*/ LPSTR b, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_LPWStr ( + /*[in]*/ LPWSTR a, + /*[in]*/ LPWSTR b, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Add_BStr ( + /*[in]*/ BSTR a, + /*[in]*/ BSTR b, + /*[out,retval]*/ BSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPStr ( + /*[in]*/ LPSTR a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPStr_Ref ( + /*[in,out]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPStr_InRef ( + /*[in]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPStr_Out ( + /*[in]*/ LPSTR a, + /*[out]*/ LPSTR * b ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPStr_OutAttr ( + /*[in]*/ LPSTR a, + /*[out]*/ LPSTR b ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPStr ( + /*[in,out]*/ LPSTR a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPStr_Ref ( + /*[in,out]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPStr_InRef ( + /*[in]*/ LPSTR * a, + /*[out,retval]*/ LPSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPStr_Out ( + /*[in,out]*/ LPSTR a, + /*[out]*/ LPSTR * b ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPStr_OutAttr ( + /*[in,out]*/ LPSTR a, + /*[out]*/ LPSTR b ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPWStr ( + /*[in]*/ LPWSTR a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPWStr_Ref ( + /*[in,out]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPWStr_InRef ( + /*[in]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPWStr_Out ( + /*[in]*/ LPWSTR a, + /*[out]*/ LPWSTR * b ) = 0; + virtual HRESULT __stdcall raw_Reverse_LPWStr_OutAttr ( + /*[in]*/ LPWSTR a, + /*[out]*/ LPWSTR b ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPWStr ( + /*[in,out]*/ LPWSTR a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPWStr_Ref ( + /*[in,out]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPWStr_InRef ( + /*[in]*/ LPWSTR * a, + /*[out,retval]*/ LPWSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPWStr_Out ( + /*[in,out]*/ LPWSTR a, + /*[out]*/ LPWSTR * b ) = 0; + virtual HRESULT __stdcall raw_Reverse_SB_LPWStr_OutAttr ( + /*[in,out]*/ LPWSTR a, + /*[out]*/ LPWSTR b ) = 0; + virtual HRESULT __stdcall raw_Reverse_BStr ( + /*[in]*/ BSTR a, + /*[out,retval]*/ BSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_BStr_Ref ( + /*[in,out]*/ BSTR * a, + /*[out,retval]*/ BSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_BStr_InRef ( + /*[in]*/ BSTR * a, + /*[out,retval]*/ BSTR * pRetVal ) = 0; + virtual HRESULT __stdcall raw_Reverse_BStr_Out ( + /*[in]*/ BSTR a, + /*[out]*/ BSTR * b ) = 0; + virtual HRESULT __stdcall raw_Reverse_BStr_OutAttr ( + /*[in]*/ BSTR a, + /*[out]*/ BSTR b ) = 0; +}; + +struct __declspec(uuid("592386a5-6837-444d-9de3-250815d18556")) +IErrorMarshalTesting : IUnknown +{ + // + // Wrapper methods for error-handling + // + + HRESULT Throw_HResult ( + long hresultToReturn ); + + // + // Raw methods provided by interface + // + + virtual HRESULT __stdcall raw_Throw_HResult ( + /*[in]*/ long hresultToReturn ) = 0; + virtual long __stdcall Return_As_HResult ( + /*[in]*/ long hresultToReturn ) = 0; +}; + +// +// Wrapper method implementations +// + +#include "Server.Contracts.tli" + +#pragma pack(pop) diff --git a/tests/src/Interop/COM/ServerContracts/Server.Contracts.tli b/tests/src/Interop/COM/ServerContracts/Server.Contracts.tli new file mode 100644 index 000000000000..a419c654e6e8 --- /dev/null +++ b/tests/src/Interop/COM/ServerContracts/Server.Contracts.tli @@ -0,0 +1,571 @@ +// Created by Microsoft (R) C/C++ Compiler + +#pragma once + +// +// interface INumericTesting wrapper method implementations +// + +inline unsigned char INumericTesting::Add_Byte ( unsigned char a, unsigned char b ) { + unsigned char _result = 0; + HRESULT _hr = raw_Add_Byte(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline short INumericTesting::Add_Short ( short a, short b ) { + short _result = 0; + HRESULT _hr = raw_Add_Short(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline unsigned short INumericTesting::Add_UShort ( unsigned short a, unsigned short b ) { + unsigned short _result = 0; + HRESULT _hr = raw_Add_UShort(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline long INumericTesting::Add_Int ( long a, long b ) { + long _result = 0; + HRESULT _hr = raw_Add_Int(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline unsigned long INumericTesting::Add_UInt ( unsigned long a, unsigned long b ) { + unsigned long _result = 0; + HRESULT _hr = raw_Add_UInt(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline __int64 INumericTesting::Add_Long ( __int64 a, __int64 b ) { + __int64 _result = 0; + HRESULT _hr = raw_Add_Long(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline unsigned __int64 INumericTesting::Add_ULong ( unsigned __int64 a, unsigned __int64 b ) { + unsigned __int64 _result = 0; + HRESULT _hr = raw_Add_ULong(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline float INumericTesting::Add_Float ( float a, float b ) { + float _result = 0; + HRESULT _hr = raw_Add_Float(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double INumericTesting::Add_Double ( double a, double b ) { + double _result = 0; + HRESULT _hr = raw_Add_Double(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline HRESULT INumericTesting::Add_Byte_Ref ( unsigned char a, unsigned char b, unsigned char * c ) { + HRESULT _hr = raw_Add_Byte_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Short_Ref ( short a, short b, short * c ) { + HRESULT _hr = raw_Add_Short_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_UShort_Ref ( unsigned short a, unsigned short b, unsigned short * c ) { + HRESULT _hr = raw_Add_UShort_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Int_Ref ( long a, long b, long * c ) { + HRESULT _hr = raw_Add_Int_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_UInt_Ref ( unsigned long a, unsigned long b, unsigned long * c ) { + HRESULT _hr = raw_Add_UInt_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Long_Ref ( __int64 a, __int64 b, __int64 * c ) { + HRESULT _hr = raw_Add_Long_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_ULong_Ref ( unsigned __int64 a, unsigned __int64 b, unsigned __int64 * c ) { + HRESULT _hr = raw_Add_ULong_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Float_Ref ( float a, float b, float * c ) { + HRESULT _hr = raw_Add_Float_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Double_Ref ( double a, double b, double * c ) { + HRESULT _hr = raw_Add_Double_Ref(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Byte_Out ( unsigned char a, unsigned char b, unsigned char * c ) { + HRESULT _hr = raw_Add_Byte_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Short_Out ( short a, short b, short * c ) { + HRESULT _hr = raw_Add_Short_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_UShort_Out ( unsigned short a, unsigned short b, unsigned short * c ) { + HRESULT _hr = raw_Add_UShort_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Int_Out ( long a, long b, long * c ) { + HRESULT _hr = raw_Add_Int_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_UInt_Out ( unsigned long a, unsigned long b, unsigned long * c ) { + HRESULT _hr = raw_Add_UInt_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Long_Out ( __int64 a, __int64 b, __int64 * c ) { + HRESULT _hr = raw_Add_Long_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_ULong_Out ( unsigned __int64 a, unsigned __int64 b, unsigned __int64 * c ) { + HRESULT _hr = raw_Add_ULong_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Float_Out ( float a, float b, float * c ) { + HRESULT _hr = raw_Add_Float_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT INumericTesting::Add_Double_Out ( double a, double b, double * c ) { + HRESULT _hr = raw_Add_Double_Out(a, b, c); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +// +// interface IArrayTesting wrapper method implementations +// + +inline double IArrayTesting::Mean_Byte_LP_PreLen ( long len, unsigned char * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Byte_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Short_LP_PreLen ( long len, short * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Short_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UShort_LP_PreLen ( long len, unsigned short * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_UShort_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Int_LP_PreLen ( long len, long * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Int_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UInt_LP_PreLen ( long len, unsigned long * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_UInt_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Long_LP_PreLen ( long len, __int64 * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Long_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_ULong_LP_PreLen ( long len, unsigned __int64 * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_ULong_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Float_LP_PreLen ( long len, float * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Float_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Double_LP_PreLen ( long len, double * d ) { + double _result = 0; + HRESULT _hr = raw_Mean_Double_LP_PreLen(len, d, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Byte_LP_PostLen ( unsigned char * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Byte_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Short_LP_PostLen ( short * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Short_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UShort_LP_PostLen ( unsigned short * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_UShort_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Int_LP_PostLen ( long * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Int_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UInt_LP_PostLen ( unsigned long * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_UInt_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Long_LP_PostLen ( __int64 * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Long_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_ULong_LP_PostLen ( unsigned __int64 * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_ULong_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Float_LP_PostLen ( float * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Float_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Double_LP_PostLen ( double * d, long len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Double_LP_PostLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Byte_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Byte_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Short_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Short_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UShort_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_UShort_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Int_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Int_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_UInt_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_UInt_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Long_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Long_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_ULong_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_ULong_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Float_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Float_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline double IArrayTesting::Mean_Double_SafeArray_OutLen ( SAFEARRAY * d, long * len ) { + double _result = 0; + HRESULT _hr = raw_Mean_Double_SafeArray_OutLen(d, len, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +// +// interface IStringTesting wrapper method implementations +// + +inline LPSTR IStringTesting::Add_LPStr ( LPSTR a, LPSTR b ) { + LPSTR _result = 0; + HRESULT _hr = raw_Add_LPStr(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPWSTR IStringTesting::Add_LPWStr ( LPWSTR a, LPWSTR b ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Add_LPWStr(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline _bstr_t IStringTesting::Add_BStr ( _bstr_t a, _bstr_t b ) { + BSTR _result = 0; + HRESULT _hr = raw_Add_BStr(a, b, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _bstr_t(_result, false); +} + +inline LPSTR IStringTesting::Reverse_LPStr ( LPSTR a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_LPStr(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPSTR IStringTesting::Reverse_LPStr_Ref ( LPSTR * a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_LPStr_Ref(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPSTR IStringTesting::Reverse_LPStr_InRef ( LPSTR * a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_LPStr_InRef(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline HRESULT IStringTesting::Reverse_LPStr_Out ( LPSTR a, LPSTR * b ) { + HRESULT _hr = raw_Reverse_LPStr_Out(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT IStringTesting::Reverse_LPStr_OutAttr ( LPSTR a, LPSTR b ) { + HRESULT _hr = raw_Reverse_LPStr_OutAttr(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline LPSTR IStringTesting::Reverse_SB_LPStr ( LPSTR a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPStr(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPSTR IStringTesting::Reverse_SB_LPStr_Ref ( LPSTR * a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPStr_Ref(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPSTR IStringTesting::Reverse_SB_LPStr_InRef ( LPSTR * a ) { + LPSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPStr_InRef(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline HRESULT IStringTesting::Reverse_SB_LPStr_Out ( LPSTR a, LPSTR * b ) { + HRESULT _hr = raw_Reverse_SB_LPStr_Out(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT IStringTesting::Reverse_SB_LPStr_OutAttr ( LPSTR a, LPSTR b ) { + HRESULT _hr = raw_Reverse_SB_LPStr_OutAttr(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline LPWSTR IStringTesting::Reverse_LPWStr ( LPWSTR a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_LPWStr(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPWSTR IStringTesting::Reverse_LPWStr_Ref ( LPWSTR * a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_LPWStr_Ref(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPWSTR IStringTesting::Reverse_LPWStr_InRef ( LPWSTR * a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_LPWStr_InRef(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline HRESULT IStringTesting::Reverse_LPWStr_Out ( LPWSTR a, LPWSTR * b ) { + HRESULT _hr = raw_Reverse_LPWStr_Out(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT IStringTesting::Reverse_LPWStr_OutAttr ( LPWSTR a, LPWSTR b ) { + HRESULT _hr = raw_Reverse_LPWStr_OutAttr(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline LPWSTR IStringTesting::Reverse_SB_LPWStr ( LPWSTR a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPWStr(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPWSTR IStringTesting::Reverse_SB_LPWStr_Ref ( LPWSTR * a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPWStr_Ref(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline LPWSTR IStringTesting::Reverse_SB_LPWStr_InRef ( LPWSTR * a ) { + LPWSTR _result = 0; + HRESULT _hr = raw_Reverse_SB_LPWStr_InRef(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _result; +} + +inline HRESULT IStringTesting::Reverse_SB_LPWStr_Out ( LPWSTR a, LPWSTR * b ) { + HRESULT _hr = raw_Reverse_SB_LPWStr_Out(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT IStringTesting::Reverse_SB_LPWStr_OutAttr ( LPWSTR a, LPWSTR b ) { + HRESULT _hr = raw_Reverse_SB_LPWStr_OutAttr(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline _bstr_t IStringTesting::Reverse_BStr ( _bstr_t a ) { + BSTR _result = 0; + HRESULT _hr = raw_Reverse_BStr(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _bstr_t(_result, false); +} + +inline _bstr_t IStringTesting::Reverse_BStr_Ref ( BSTR * a ) { + BSTR _result = 0; + HRESULT _hr = raw_Reverse_BStr_Ref(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _bstr_t(_result, false); +} + +inline _bstr_t IStringTesting::Reverse_BStr_InRef ( BSTR * a ) { + BSTR _result = 0; + HRESULT _hr = raw_Reverse_BStr_InRef(a, &_result); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _bstr_t(_result, false); +} + +inline HRESULT IStringTesting::Reverse_BStr_Out ( _bstr_t a, BSTR * b ) { + HRESULT _hr = raw_Reverse_BStr_Out(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +inline HRESULT IStringTesting::Reverse_BStr_OutAttr ( _bstr_t a, _bstr_t b ) { + HRESULT _hr = raw_Reverse_BStr_OutAttr(a, b); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} + +// +// interface IErrorMarshalTesting wrapper method implementations +// + +inline HRESULT IErrorMarshalTesting::Throw_HResult ( long hresultToReturn ) { + HRESULT _hr = raw_Throw_HResult(hresultToReturn); + if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); + return _hr; +} diff --git a/tests/src/Interop/COM/ServerContracts/readme.md b/tests/src/Interop/COM/ServerContracts/readme.md new file mode 100644 index 000000000000..347c7fc3f28e --- /dev/null +++ b/tests/src/Interop/COM/ServerContracts/readme.md @@ -0,0 +1,9 @@ +## Server Contracts + +This directory contains the API contracts for the testing of .NET COM interop. The contract is defined in C# to the degree that the [TlbExp.exe](https://docs.microsoft.com/en-us/dotnet/framework/tools/tlbexp-exe-type-library-exporter) tool can be used to generate a TLB that can then be used by the Microsoft VC++ compiler to generate the `tlh` and `tli` files. This is a manual process at the moment, but as more support is added to CoreCLR, this may change. + +The process to create a TLB and update the native contracts are as follows: + +1) Take the `Primitives.cs` file and create a DLL using a SDK project. +1) Use the .NET Framework [TlbExp.exe](https://docs.microsoft.com/en-us/dotnet/framework/tools/tlbexp-exe-type-library-exporter) to create a `tlb` based on the DLL previously compiled. +1) Using the Microsoft VC++ compiler consume the `tlb` using the [`#import`](https://msdn.microsoft.com/en-us/library/8etzzkb6.aspx) directive (See commented out line in `Servers.h`). The compiler will generate two files (`tlh` and `tli`). The files in this directory can then be updated. \ No newline at end of file diff --git a/tests/src/Interop/ClassicCOM/CMakeLists.txt b/tests/src/Interop/ClassicCOM/CMakeLists.txt deleted file mode 100644 index d3416dd584aa..000000000000 --- a/tests/src/Interop/ClassicCOM/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required (VERSION 2.6) -project (ClassicCOMNative) -include_directories(${INC_PLATFORM_DIR}) -set(SOURCES ClassicCOMNative.cpp) - -# add the executable -add_library (ClassicCOMNative SHARED ${SOURCES}) -target_link_libraries(ClassicCOMNative ${LINK_LIBRARIES_ADDITIONAL}) - -# add the install targets -install (TARGETS ClassicCOMNative DESTINATION bin) - - diff --git a/tests/src/Interop/ClassicCOM/COMLib.cs b/tests/src/Interop/ClassicCOM/COMLib.cs deleted file mode 100644 index fba866c567c0..000000000000 --- a/tests/src/Interop/ClassicCOM/COMLib.cs +++ /dev/null @@ -1,34 +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. - -using System; -using System.Text; -using System.Security; -using System.Runtime.InteropServices; - -public class COMLib -{ - [Guid("00020404-0000-0000-C000-000000000046")] - [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - [ComImport] - public interface IEnumVARIANT - { - [PreserveSig] - int Next(int celt, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0), Out] object[] rgVar, IntPtr pceltFetched); - - [PreserveSig] - int Skip(int celt); - - [PreserveSig] - int Reset(); - - IEnumVARIANT Clone(); - } - - [ComImport] - [Guid("78A51822-51F4-11D0-8F20-00805F2CD064")] - public class ProcessDebugManager - { - } -} diff --git a/tests/src/Interop/ClassicCOM/ClassicCOMNative.cpp b/tests/src/Interop/ClassicCOM/ClassicCOMNative.cpp deleted file mode 100644 index 962313c22901..000000000000 --- a/tests/src/Interop/ClassicCOM/ClassicCOMNative.cpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. -// - -#include -#include -#include - -extern "C" DLL_EXPORT void PassObjectToNative(void * ptr) -{ - // TODO: Add check -} - -extern "C" DLL_EXPORT void PassObjectArrayToNative(void ** pptr) -{ - // TODO: Add check -} - -extern "C" DLL_EXPORT void GetObjectFromNative(void ** pptr) -{ - *pptr = NULL; - // TODO: Add check -} - -extern "C" DLL_EXPORT void GetObjectFromNativeAsRef(void ** pptr) -{ - // TODO: Add check -} \ No newline at end of file diff --git a/tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.cs b/tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.cs deleted file mode 100644 index 530f02c266b1..000000000000 --- a/tests/src/Interop/ClassicCOM/ClassicCOMUnitTest.cs +++ /dev/null @@ -1,255 +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. -// - -// -// Adding tests for Classic COM code coverage -// - -using System; -using System.Text; -using System.Security; -using System.Reflection; -using System.Runtime.InteropServices; -using TestLibrary; - -public class ClassicCOMUnitTest -{ - /// - /// Try to reflect load ComImport Types by enumerate - /// - /// - static bool RelectionLoad() - { - try - { - Console.WriteLine("Scenario: RelectionLoad"); - var asm = Assembly.LoadFrom("COMLib.dll"); - foreach (Type t in asm.GetTypes()) - { - Console.WriteLine(t.Name); - } - - return true; - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception: " + e); - return false; - } - } - - /// - /// Try to test Type.IsCOMObject - /// - /// - static bool TypeIsComObject() - { - try - { - Console.WriteLine("Scenario: TypeIsComObject"); - Type classType = typeof(COMLib2.ContextMenu); - if (!classType.IsCOMObject) - { - Console.WriteLine("ComImport Class's IsCOMObject should return true"); - return false; - } - - Type interfaceType = typeof(COMLib2.IEnumVARIANT); - if (interfaceType.IsCOMObject) - { - Console.WriteLine("ComImport interface's IsCOMObject should return false"); - return false; - } - - return true; - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception: " + e); - return false; - } - } - - /// - /// Try to create COM instance - /// - /// - static bool AcivateCOMType() - { - try - { - Console.WriteLine("Scenario: AcivateCOMType"); - COMLib2.ContextMenu contextMenu = (COMLib2.ContextMenu)Activator.CreateInstance(typeof(COMLib2.ContextMenu)); - - // Linux should throw PlatformNotSupportedException - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return false; - } - - if (contextMenu == null) - { - Console.WriteLine("AcivateCOMType failed"); - return false; - } - - return true; - } - catch (System.Reflection.TargetInvocationException e) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && e.InnerException is PlatformNotSupportedException) - { - return true; - } - - Console.WriteLine("Caught unexpected PlatformNotSupportedException: " + e); - return false; - } - catch(System.Runtime.InteropServices.COMException e) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return true; - } - - Console.WriteLine("Caught unexpected COMException: " + e); - return false; - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception: " + e); - return false; - } - } - - [DllImport("ClassicCOMNative.dll")] - extern static void PassObjectToNative([In, MarshalAs( UnmanagedType.Interface)] object o); - - [DllImport("ClassicCOMNative.dll")] - extern static void PassObjectArrayToNative([In,Out] object[] o); - - [DllImport("ClassicCOMNative.dll")] - extern static void GetObjectFromNative(out object o); - - [DllImport("ClassicCOMNative.dll")] - extern static void GetObjectFromNativeAsRef(ref object o); - - /// - /// Try to Marshal COM Type across managed-native boundary - /// - /// - static bool MarshalCOMType() - { - Console.WriteLine("Scenario: MarshalCOMType"); - try - { - object o = new object(); - PassObjectToNative(o); - } - catch (System.Runtime.InteropServices.MarshalDirectiveException e) - { - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - return true; - } - Console.WriteLine("Caught unexpected MarshalDirectiveException: " + e); - return false; - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception in PassObjectToNative: " + e); - return false; - } - - try - { - object [] oa = new object[2]; - PassObjectArrayToNative(oa); - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception in GetObjectFromNative: " + e); - return false; - } - - - try - { - object o; - GetObjectFromNative(out o); - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception in GetObjectFromNative: " + e); - return false; - } - - try - { - object o = new object(); - GetObjectFromNativeAsRef(ref o); - } - catch (Exception e) - { - Console.WriteLine("Caught unexpected exception in GetObjectFromNativeAsRef: " + e); - return false; - } - - return true; - } - - /// - /// Try to call Marshal API for COM Types - /// - /// - static bool MarshalAPI() - { - Console.WriteLine("Scenario: MarshalAPI"); - // MarshalAPI - if (Marshal.AreComObjectsAvailableForCleanup()) - { - Console.WriteLine("AreComObjectsAvailableForCleanup should return false"); - return false; - } - return true; - } - - [System.Security.SecuritySafeCritical] - static int Main() - { - int failures = 0; - if (!RelectionLoad()) - { - Console.WriteLine("RelectionLoad Failed"); - failures++; - } - - if (!TypeIsComObject()) - { - Console.WriteLine("TypeIsComObject Failed"); - failures++; - } - - if (!AcivateCOMType()) - { - Console.WriteLine("AcivateCOMType Failed"); - failures++; - } - - if (!MarshalCOMType()) - { - Console.WriteLine("MarshalCOMType Failed"); - failures++; - } - - if (!MarshalAPI()) - { - Console.WriteLine("MarshalAPI Failed"); - failures++; - } - - return failures > 0 ? 101 : 100; - } -} diff --git a/tests/src/Interop/MarshalAPI/OffsetOf/OffsetOf.cs b/tests/src/Interop/MarshalAPI/OffsetOf/OffsetOf.cs index 6b284012c583..b56155aea6ed 100644 --- a/tests/src/Interop/MarshalAPI/OffsetOf/OffsetOf.cs +++ b/tests/src/Interop/MarshalAPI/OffsetOf/OffsetOf.cs @@ -95,7 +95,7 @@ internal struct ExplicitLayoutTest // 7 bytes of padding } -internal struct FieldAlignementTest +internal struct FieldAlignmentTest { public byte m_byte1; // 1 byte // 1 byte of padding @@ -127,7 +127,7 @@ internal struct FieldAlignementTest // 7 bytes of padding } -struct FieldAlignementTest_Decimal +struct FieldAlignmentTest_Decimal { public byte b; // 1 byte // 7 bytes of padding @@ -137,13 +137,13 @@ struct FieldAlignementTest_Decimal // This is because unlike fields of other types well known to mcg (like long, char etc.) // which need to be aligned according to their byte size, decimal is really a struct // with 8 byte alignment requirement. - public FieldAlignementTest p; // 80 bytes (72 bytes on x86/Unix) + public FieldAlignmentTest p; // 80 bytes (72 bytes on x86/Unix) public short s; // 2 bytes // 6 bytes of padding } -struct FieldAlignementTest_Guid +struct FieldAlignmentTest_Guid { public byte b; // 1 byte // 3 bytes of padding @@ -155,7 +155,7 @@ struct FieldAlignementTest_Guid // 2 bytes of padding } -struct FieldAlignementTest_Variant +struct FieldAlignmentTest_Variant { public byte b; // 1 byte // 7 bytes of padding @@ -171,7 +171,7 @@ struct FieldAlignementTest_Variant public class OffsetTest { - + public static void NullParameter() { Assert.Throws(() => Marshal.OffsetOf(null, null)); @@ -179,25 +179,25 @@ public static void NullParameter() Assert.Throws(() => Marshal.OffsetOf(null, "abcd")); } - + public static void NonExistField() { Assert.Throws(() => Marshal.OffsetOf(typeof(NonExistField), "NonExistField")); } - + public static void NoLayoutClass() { Assert.Throws(() => Marshal.OffsetOf(typeof(NoLayoutPoint), "x")); } - + public static void StructField() { Assert.AreEqual(new IntPtr(4), Marshal.OffsetOf(typeof(someStruct), "var")); } - + public static void ClassExplicitField() { Assert.AreEqual(new IntPtr(0), Marshal.OffsetOf(typeof(MySystemTime), "wYear")); @@ -205,24 +205,24 @@ public static void ClassExplicitField() Assert.AreEqual(new IntPtr(14), Marshal.OffsetOf(typeof(MySystemTime), "wMilliseconds")); } - + public static void ClassSequentialField() { Assert.AreEqual(new IntPtr(0), Marshal.OffsetOf(typeof(MyPoint), "x")); Assert.AreEqual(new IntPtr(4), Marshal.OffsetOf(typeof(MyPoint), "y")); } - + public static void ProjectedType() { -#if BUG_1212387 +#if BUG_1212387 Assert.AreEqual(new IntPtr(0), Marshal.OffsetOf(typeof(Windows.Foundation.Point), "_x")); Assert.AreEqual(new IntPtr(1), Marshal.OffsetOf(typeof(Windows.UI.Color), "_R")); -#endif +#endif } - + public static void TestExplicitLayout() { var t = typeof(ExplicitLayoutTest); @@ -247,10 +247,10 @@ public static void TestExplicitLayout() Assert.AreEqual(new IntPtr(48), Marshal.OffsetOf(t, "m_char1")); } - + public static void TestFieldAlignment() { - var t = typeof(FieldAlignementTest); + var t = typeof(FieldAlignmentTest); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86)) { Assert.AreEqual(80, Marshal.SizeOf(t)); @@ -293,10 +293,10 @@ public static void TestFieldAlignment() } } - + public static void TestFieldAlignment_Decimal() { - var t = typeof(FieldAlignementTest_Decimal); + var t = typeof(FieldAlignmentTest_Decimal); if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || (RuntimeInformation.ProcessArchitecture != Architecture.X86)) { @@ -320,10 +320,10 @@ public static void TestFieldAlignment_Decimal() } } - + public static void TestFieldAlignment_Guid() { - var t = typeof(FieldAlignementTest_Guid); + var t = typeof(FieldAlignmentTest_Guid); Assert.AreEqual(24, Marshal.SizeOf(t)); Assert.AreEqual(new IntPtr(0), Marshal.OffsetOf(t, "b")); @@ -331,10 +331,10 @@ public static void TestFieldAlignment_Guid() Assert.AreEqual(new IntPtr(20), Marshal.OffsetOf(t, "s")); } - + public static void TestFieldAlignment_Variant() { - var t = typeof(FieldAlignementTest_Variant); + var t = typeof(FieldAlignmentTest_Variant); Assert.AreEqual(new IntPtr(0), Marshal.OffsetOf(t, "b")); Assert.AreEqual(new IntPtr(8), Marshal.OffsetOf(t, "v")); @@ -357,7 +357,7 @@ public static void TestFieldAlignment_Variant() public static int Main(String[] args) { - //https://github.com/dotnet/coreclr/issues/2075 + //https://github.com/dotnet/coreclr/issues/2075 //TestFieldAlignment_Variant(); TestFieldAlignment_Guid(); TestFieldAlignment_Decimal(); diff --git a/tests/src/Interop/MarshalAPI/ReadWrite/ReadWriteObject.cs b/tests/src/Interop/MarshalAPI/ReadWrite/ReadWriteObject.cs index a11c10b01bcf..951954f2e2f4 100644 --- a/tests/src/Interop/MarshalAPI/ReadWrite/ReadWriteObject.cs +++ b/tests/src/Interop/MarshalAPI/ReadWrite/ReadWriteObject.cs @@ -37,15 +37,15 @@ static int Main(string[] args) static void TestNegativeCases() { - Assert.Throws(() => { Marshal.WriteByte(null, 0, 0); }); - Assert.Throws(() => { Marshal.WriteInt16(null, 0, 0); }); - Assert.Throws(() => { Marshal.WriteInt32(null, 0, 0); }); - Assert.Throws(() => { Marshal.WriteInt64(null, 0, 0); }); - Assert.Throws(() => { Marshal.WriteIntPtr(null, 0, IntPtr.Zero); }); - Assert.Throws(() => { Marshal.ReadByte(null, 0); }); - Assert.Throws(() => { Marshal.ReadInt16(null, 0); }); - Assert.Throws(() => { Marshal.ReadInt32(null, 0); }); - Assert.Throws(() => { Marshal.ReadIntPtr(null, 0); }); + Assert.Throws(() => { Marshal.WriteByte(null, 0, 0); }); + Assert.Throws(() => { Marshal.WriteInt16(null, 0, 0); }); + Assert.Throws(() => { Marshal.WriteInt32(null, 0, 0); }); + Assert.Throws(() => { Marshal.WriteInt64(null, 0, 0); }); + Assert.Throws(() => { Marshal.WriteIntPtr(null, 0, IntPtr.Zero); }); + Assert.Throws(() => { Marshal.ReadByte(null, 0); }); + Assert.Throws(() => { Marshal.ReadInt16(null, 0); }); + Assert.Throws(() => { Marshal.ReadInt32(null, 0); }); + Assert.Throws(() => { Marshal.ReadIntPtr(null, 0); }); } static void TestBlittableStruct() diff --git a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp index ea82352e1523..b9fa38128cb2 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableDll.cpp +++ b/tests/src/Interop/NativeCallable/NativeCallableDll.cpp @@ -4,9 +4,9 @@ #include -typedef int (NATIVEAPI *CALLBACKADDPROC)(int n); +typedef int (NATIVEAPI *CALLBACKPROC)(int n); -extern "C" DLL_EXPORT int NATIVEAPI CallManagedAdd(CALLBACKADDPROC pCallbackAddProc, int n) +extern "C" DLL_EXPORT int NATIVEAPI CallManagedProc(CALLBACKPROC pCallbackProc, int n) { - return pCallbackAddProc(n); + return pCallbackProc(n); } diff --git a/tests/src/Interop/NativeCallable/NativeCallableTest.cs b/tests/src/Interop/NativeCallable/NativeCallableTest.cs index c0b057b7ef7d..5e18a3991ece 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableTest.cs +++ b/tests/src/Interop/NativeCallable/NativeCallableTest.cs @@ -9,6 +9,7 @@ using System.Reflection.Emit; using System.Runtime.InteropServices; using System.Threading; +using CoreFXTestLibrary; using Console = Internal.Console; @@ -17,148 +18,240 @@ public class Program public static class NativeMethods { [DllImport("NativeCallableDll")] - public static extern int CallManagedAdd(IntPtr callbackProc, int n); + public static extern int CallManagedProc(IntPtr callbackProc, int n); } - private delegate int IntNativeMethodInvoker(); + private delegate int IntNativeMethodInvoker(); private delegate void NativeMethodInvoker(); - public static int Main() + public static int Main(string[] args) { - int ret; - //NegativeTest_NonBlittable(); - ret = TestNativeCallableValid(); - if (ret != 100) - return ret; - //NegativeTest_ViaDelegate(); - //NegativeTest_ViaLdftn(); + try + { + TestNativeCallableValid(); + NegativeTest_ViaDelegate(); + NegativeTest_NonBlittable(); + NegativeTest_GenericArguments(); + + if (args.Length != 0 && args[0].Equals("calli")) + { + NegativeTest_ViaCalli(); + } + } + catch (Exception e) + { + Console.WriteLine($"Test Failure: {e}"); + return 101; + } + return 100; } - public static int TestNativeCallableValid() + [NativeCallable] + public static int ManagedDoubleCallback(int n) + { + return DoubleImpl(n); + } + + private static int DoubleImpl(int n) { + return 2 * n; + } + + public static void TestNativeCallableValid() + { + Console.WriteLine($"{nameof(NativeCallableAttribute)} function"); + /* void TestNativeCallable() { - .locals init ([0] native int ptr) - IL_0000: nop - IL_0002: ldftn int32 CallbackMethod(int32) - - IL_0012: stloc.0 - IL_0013: ldloc.0 - IL_0014: ldc.i4 100 - IL_0019: call bool NativeMethods::CallNativeAdd(native int, int) - IL_001e: pop - IL_001f: ret + .locals init ([0] native int ptr) + IL_0000: nop + IL_0001: ldftn int32 ManagedDoubleCallback(int32) + IL_0007: stloc.0 + + IL_0008: ldloc.0 + IL_0009: ldc.i4 local + IL_000e: call bool NativeMethods::CallManagedProc(native int, int) + + IL_0013: ret } - */ + */ DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallable", typeof(int), null, typeof(Program).Module); ILGenerator il = testNativeCallable.GetILGenerator(); il.DeclareLocal(typeof(IntPtr)); il.Emit(OpCodes.Nop); // Get native function pointer of the callback - il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod("ManagedAddCallback")); + il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod(nameof(ManagedDoubleCallback))); il.Emit(OpCodes.Stloc_0); il.Emit(OpCodes.Ldloc_0); - // return 111+100 - il.Emit(OpCodes.Ldc_I4, 111); - il.Emit(OpCodes.Call, typeof(NativeMethods).GetMethod("CallManagedAdd")); + int n = 12345; + il.Emit(OpCodes.Ldc_I4, n); + il.Emit(OpCodes.Call, typeof(NativeMethods).GetMethod("CallManagedProc")); il.Emit(OpCodes.Ret); - IntNativeMethodInvoker testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker)); - if (testNativeMethod() != 211) - return 0; - return 100; + var testNativeMethod = (IntNativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(IntNativeMethodInvoker)); + + int expected = DoubleImpl(n); + Assert.AreEqual(expected, testNativeMethod()); } public static void NegativeTest_ViaDelegate() { - // Try invoking method directly + Console.WriteLine($"{nameof(NativeCallableAttribute)} function as delegate"); + + // Try invoking method directly try { - Func invoker = ManagedAddCallback; - invoker(0); + CallAsDelegate(); + Assert.Fail($"Invalid to call {nameof(ManagedDoubleCallback)} as delegate"); } - catch (Exception) + catch (NotSupportedException) { + } + // Local function to delay exception thrown during JIT + void CallAsDelegate() + { + Func invoker = ManagedDoubleCallback; + invoker(0); } } + [NativeCallable] + public static int CallbackMethodNonBlittable(bool x1) + { + Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot have non-blittable arguments"); + return -1; + } + public static void NegativeTest_NonBlittable() { - // Try invoking method directly + Console.WriteLine($"{nameof(NativeCallableAttribute)} function with non-blittable arguments"); + + /* + void TestNativeCallableNonBlittable() + { + .locals init ([0] native int ptr) + IL_0000: nop + IL_0001: ldftn int32 CallbackMethodNonBlittable(bool) + IL_0007: stloc.0 + IL_0008: ret + } + */ + DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableNonBlittable", null, null, typeof(Program).Module); + ILGenerator il = testNativeCallable.GetILGenerator(); + il.DeclareLocal(typeof(IntPtr)); + il.Emit(OpCodes.Nop); + + // Get native function pointer of the callback + il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod(nameof(CallbackMethodNonBlittable))); + il.Emit(OpCodes.Stloc_0); + + il.Emit(OpCodes.Ret); + var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker)); + + // Try invoking method try { - Func invoker = CallbackMethodNonBlitabble; - invoker(true); + testNativeMethod(); + Assert.Fail($"Function {nameof(CallbackMethodNonBlittable)} has non-blittable types"); } - catch (Exception) + catch (NotSupportedException) { - Console.WriteLine(":bla"); } } + [NativeCallable] + public static int CallbackMethodGeneric(T arg) + { + Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot have generic arguments"); + return -1; + } - public static void NegativeTest_ViaLdftn() + public static void NegativeTest_GenericArguments() { /* - .locals init (native int V_0) - IL_0000: nop - IL_0001: ldftn void ConsoleApplication1.Program::callback(int32) - IL_0007: stloc.0 - IL_0008: ldc.i4.s 12 - IL_000a: ldloc.0 - IL_000b: calli void(int32) - IL_0010: nop - IL_0011: ret - */ - DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableLdftn", null, null, typeof(Program).Module); + void TestNativeCallableGenericArguments() + { + .locals init ([0] native int ptr) + IL_0000: nop + IL_0001: ldftn int32 CallbackMethodGeneric(T) + IL_0007: stloc.0 + IL_0008: ret + } + */ + DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableGenericArguments", null, null, typeof(Program).Module); ILGenerator il = testNativeCallable.GetILGenerator(); il.DeclareLocal(typeof(IntPtr)); il.Emit(OpCodes.Nop); - il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod("LdftnCallback")); - il.Emit(OpCodes.Stloc_0); - il.Emit(OpCodes.Ldc_I4,12); - il.Emit(OpCodes.Ldloc_0); - SignatureHelper sig = SignatureHelper.GetMethodSigHelper(typeof(Program).Module, null, new Type[] { typeof(int) }); - sig.AddArgument(typeof(int)); + // Get native function pointer of the callback + il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod(nameof(CallbackMethodGeneric))); + il.Emit(OpCodes.Stloc_0); - // il.EmitCalli is not available and the below is not correct - il.Emit(OpCodes.Calli,sig); - il.Emit(OpCodes.Nop); il.Emit(OpCodes.Ret); + var testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker)); - NativeMethodInvoker testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker)); - testNativeMethod(); - + // Try invoking method + try + { + testNativeMethod(); + Assert.Fail($"Function {nameof(CallbackMethodGeneric)} has generic types"); + } + catch (InvalidProgramException) + { + } } - #region callbacks [NativeCallable] - public static void LdftnCallback(int val) + public static void CallbackViaCalli(int val) { + Assert.Fail($"Functions with attribute {nameof(NativeCallableAttribute)} cannot be called via calli"); } - [NativeCallable] - public static int ManagedAddCallback(int n) + public static void NegativeTest_ViaCalli() { - return n + 100; - } + Console.WriteLine($"{nameof(NativeCallableAttribute)} function via calli instruction. The CLR _will_ crash."); - [NativeCallable] - public static int CallbackMethodGeneric(IntPtr hWnd, IntPtr lParam) - { - return 1; - } + /* + void TestNativeCallableViaCalli() + { + .locals init (native int V_0) + IL_0000: nop + IL_0001: ldftn void CallbackViaCalli(int32) + IL_0007: stloc.0 - [NativeCallable] - public static int CallbackMethodNonBlitabble(bool x1) - { - return 1; - } - #endregion //callbacks + IL_0008: ldc.i4 1234 + IL_000d: ldloc.0 + IL_000e: calli void(int32) + IL_0013: nop + IL_0014: ret + } + */ + DynamicMethod testNativeCallable = new DynamicMethod("TestNativeCallableViaCalli", null, null, typeof(Program).Module); + ILGenerator il = testNativeCallable.GetILGenerator(); + il.DeclareLocal(typeof(IntPtr)); + il.Emit(OpCodes.Nop); + + // Get native function pointer of the callback + il.Emit(OpCodes.Ldftn, typeof(Program).GetMethod(nameof(CallbackViaCalli))); + il.Emit(OpCodes.Stloc_0); + + il.Emit(OpCodes.Ldc_I4, 1234); + il.Emit(OpCodes.Ldloc_0); + il.EmitCalli(OpCodes.Calli, CallingConventions.Standard, null, new Type[] { typeof(int) }, null); + + il.Emit(OpCodes.Nop); + il.Emit(OpCodes.Ret); + + NativeMethodInvoker testNativeMethod = (NativeMethodInvoker)testNativeCallable.CreateDelegate(typeof(NativeMethodInvoker)); + + // It is not possible to catch the resulting ExecutionEngineException exception. + // To observe the crashing behavior set a breakpoint in the ReversePInvokeBadTransition() function + // located in src/vm/dllimportcallback.cpp. + testNativeMethod(); + } } diff --git a/tests/src/Interop/NativeCallable/NativeCallableTest.csproj b/tests/src/Interop/NativeCallable/NativeCallableTest.csproj index efb6d08143a8..af3e9af7d066 100644 --- a/tests/src/Interop/NativeCallable/NativeCallableTest.csproj +++ b/tests/src/Interop/NativeCallable/NativeCallableTest.csproj @@ -27,6 +27,7 @@ + diff --git a/tests/src/JIT/Directed/StructABI/StructABI.c b/tests/src/JIT/Directed/StructABI/StructABI.c index 7e9ae93f89e5..09cd14de9706 100644 --- a/tests/src/JIT/Directed/StructABI/StructABI.c +++ b/tests/src/JIT/Directed/StructABI/StructABI.c @@ -85,6 +85,14 @@ struct PointerFloatAndByte uint8_t Byte; }; +struct ShortIntFloatIntPtr +{ + __int16 Short; + __int32 Int; + float Float; + __int32* Pointer; +}; + struct TwoLongs { uint64_t Long1; @@ -263,6 +271,11 @@ DLLEXPORT struct PointerFloatAndByte EchoPointerFloatAndByte(struct PointerFloat return value; } +DLLEXPORT struct ShortIntFloatIntPtr EchoShortIntFloatIntPtr(struct ShortIntFloatIntPtr value) +{ + return value; +} + DLLEXPORT struct TwoLongs EchoTwoLongs(struct TwoLongs value) { return value; diff --git a/tests/src/JIT/Directed/StructABI/StructABI.cs b/tests/src/JIT/Directed/StructABI/StructABI.cs index 8445e42bc2b6..d577c58ffeef 100644 --- a/tests/src/JIT/Directed/StructABI/StructABI.cs +++ b/tests/src/JIT/Directed/StructABI/StructABI.cs @@ -4,6 +4,7 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; struct SingleByte { @@ -16,7 +17,7 @@ public static SingleByte Get() public bool Equals(SingleByte other) { - return Byte == other.Byte; + return Byte == 42 && Byte == other.Byte; } } @@ -31,7 +32,7 @@ public static SingleLong Get() public bool Equals(SingleLong other) { - return Long == other.Long; + return Long == other.Long && Long == 0xfeedfaceabadf00d; } } @@ -61,7 +62,7 @@ public static SingleDouble Get() public bool Equals(SingleDouble other) { - return Double == other.Double; + return Double == other.Double && Double == 3.14159d; } } @@ -77,7 +78,8 @@ public static ByteAndFloat Get() public bool Equals(ByteAndFloat other) { - return Byte == other.Byte && Float == other.Float; + return Byte == other.Byte && Float == other.Float && + Byte == 42 && Float == 3.14159f; } } @@ -93,7 +95,8 @@ public static FloatAndByte Get() public bool Equals(FloatAndByte other) { - return Byte == other.Byte && Float == other.Float; + return Byte == other.Byte && Float == other.Float && + Byte == 42 && Float == 3.14159f; } } @@ -109,7 +112,8 @@ public static LongAndFloat Get() public bool Equals(LongAndFloat other) { - return Long == other.Long && Float == other.Float; + return Long == other.Long && Float == other.Float && + Long == 0xfeedfaceabadf00d && Float == 3.14159f; } } @@ -195,6 +199,7 @@ public bool Equals(ByteFloatAndPointer other) { return Pointer == other.Pointer && Float == other.Float && Byte == other.Byte; } + } unsafe struct PointerFloatAndByte @@ -215,6 +220,25 @@ public bool Equals(PointerFloatAndByte other) } } +struct ShortIntFloatIntPtr +{ + public short Short; + public int Int; + public float Float; + public IntPtr Pointer; + + public static ShortIntFloatIntPtr Get() + { + IntPtr unused = new IntPtr(42); + return new ShortIntFloatIntPtr { Short = 10, Int = 11, Float = 3.14f, Pointer = unused }; + } + + public bool Equals(ShortIntFloatIntPtr other) + { + return Short == other.Short && Int == other.Int && Float == other.Float && Pointer == other.Pointer; + } +} + struct TwoLongs { public ulong Long1; @@ -507,7 +531,7 @@ public static Nested1 Get() public bool Equals(Nested1 other) { - return Field1.Equals(other.Field1) && Field2.Equals(other.Field2); + return Field1.Equals(other.Field1) && Field2.Long == other.Field2.Long && Field2.Float == other.Field2.Float; } } @@ -527,7 +551,7 @@ public static Nested2 Get() public bool Equals(Nested2 other) { - return Field1.Equals(other.Field1) && Field2.Equals(other.Field2); + return Field1.Equals(other.Field1) && Field2.Byte == other.Field2.Byte && Field2.Float == other.Field2.Float; } } @@ -646,471 +670,1538 @@ public bool Equals(Nested9 other) public static partial class StructABI { - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern SingleByte EchoSingleByte(SingleByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern SingleLong EchoSingleLong(SingleLong value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern SingleFloat EchoSingleFloat(SingleFloat value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern SingleDouble EchoSingleDouble(SingleDouble value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern ByteAndFloat EchoByteAndFloat(ByteAndFloat value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern LongAndFloat EchoLongAndFloat(LongAndFloat value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern ByteAndDouble EchoByteAndDouble(ByteAndDouble value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern DoubleAndByte EchoDoubleAndByte(DoubleAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern PointerAndByte EchoPointerAndByte(PointerAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern ByteAndPointer EchoByteAndPointer(ByteAndPointer value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern ByteFloatAndPointer EchoByteFloatAndPointer(ByteFloatAndPointer value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern PointerFloatAndByte EchoPointerFloatAndByte(PointerFloatAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] + static extern ShortIntFloatIntPtr EchoShortIntFloatIntPtr(ShortIntFloatIntPtr value); + + [DllImport("StructABILib")] static extern TwoLongs EchoTwoLongs(TwoLongs value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoFloats EchoTwoFloats(TwoFloats value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoDoubles EchoTwoDoubles(TwoDoubles value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern FourLongs EchoFourLongs(FourLongs value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern FourDoubles EchoFourDoubles(FourDoubles value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray1 EchoInlineArray1(InlineArray1 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray2 EchoInlineArray2(InlineArray2 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray3 EchoInlineArray3(InlineArray3 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray4 EchoInlineArray4(InlineArray4 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray5 EchoInlineArray5(InlineArray5 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern InlineArray6 EchoInlineArray6(InlineArray6 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested1 EchoNested1(Nested1 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested2 EchoNested2(Nested2 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested3 EchoNested3(Nested3 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested4 EchoNested4(Nested4 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested5 EchoNested5(Nested5 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested6 EchoNested6(Nested6 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested7 EchoNested7(Nested7 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested8 EchoNested8(Nested8 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern Nested9 EchoNested9(Nested9 value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoLongs NotEnoughRegistersSysV1(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, TwoLongs value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoLongs NotEnoughRegistersSysV2(ulong a, ulong b, ulong c, ulong d, ulong e, TwoLongs value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern DoubleAndByte NotEnoughRegistersSysV3(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, DoubleAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoDoubles NotEnoughRegistersSysV4(double a, double b, double c, double d, double e, double f, double g, double h, TwoDoubles value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoDoubles NotEnoughRegistersSysV5(double a, double b, double c, double d, double e, double f, double g, TwoDoubles value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern DoubleAndByte NotEnoughRegistersSysV6(double a, double b, double c, double d, double e, double f, double g, double h, DoubleAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoDoubles EnoughRegistersSysV1(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, TwoDoubles value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern DoubleAndByte EnoughRegistersSysV2(ulong a, ulong b, ulong c, ulong d, ulong e, DoubleAndByte value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern TwoLongs EnoughRegistersSysV3(double a, double b, double c, double d, double e, double f, double g, double h, TwoLongs value); - [DllImport(StructABILib)] + [DllImport("StructABILib")] static extern DoubleAndByte EnoughRegistersSysV4(double a, double b, double c, double d, double e, double f, double g, DoubleAndByte value); - static int Main() + //////////////////////////////////////////////////////////////////////////// + // Managed echo tests. + //////////////////////////////////////////////////////////////////////////// + + [MethodImpl(MethodImplOptions.NoInlining)] + static SingleByte EchoSingleByteManaged(SingleByte value) { - var ok = true; + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static SingleLong EchoSingleLongManaged(SingleLong value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static SingleFloat EchoSingleFloatManaged(SingleFloat value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static SingleDouble EchoSingleDoubleManaged(SingleDouble value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static ByteAndFloat EchoByteAndFloatManaged(ByteAndFloat value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static LongAndFloat EchoLongAndFloatManaged(LongAndFloat value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static ByteAndDouble EchoByteAndDoubleManaged(ByteAndDouble value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static DoubleAndByte EchoDoubleAndByteManaged(DoubleAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static PointerAndByte EchoPointerAndByteManaged(PointerAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static ByteAndPointer EchoByteAndPointerManaged(ByteAndPointer value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static ByteFloatAndPointer EchoByteFloatAndPointerManaged(ByteFloatAndPointer value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static PointerFloatAndByte EchoPointerFloatAndByteManaged(PointerFloatAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static ShortIntFloatIntPtr EchoShortIntFloatIntPtrManaged(ShortIntFloatIntPtr value) + { + + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoLongs EchoTwoLongsManaged(TwoLongs value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoFloats EchoTwoFloatsManaged(TwoFloats value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoDoubles EchoTwoDoublesManaged(TwoDoubles value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static FourLongs EchoFourLongsManaged(FourLongs value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static FourDoubles EchoFourDoublesManaged(FourDoubles value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray1 EchoInlineArray1Managed(InlineArray1 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray2 EchoInlineArray2Managed(InlineArray2 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray3 EchoInlineArray3Managed(InlineArray3 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray4 EchoInlineArray4Managed(InlineArray4 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray5 EchoInlineArray5Managed(InlineArray5 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static InlineArray6 EchoInlineArray6Managed(InlineArray6 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested1 EchoNested1Managed(Nested1 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested2 EchoNested2Managed(Nested2 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested3 EchoNested3Managed(Nested3 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested4 EchoNested4Managed(Nested4 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested5 EchoNested5Managed(Nested5 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested6 EchoNested6Managed(Nested6 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested7 EchoNested7Managed(Nested7 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested8 EchoNested8Managed(Nested8 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Nested9 EchoNested9Managed(Nested9 value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoLongs NotEnoughRegistersSysV1Managed(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, TwoLongs value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoLongs NotEnoughRegistersSysV2Managed(ulong a, ulong b, ulong c, ulong d, ulong e, TwoLongs value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static DoubleAndByte NotEnoughRegistersSysV3Managed(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, DoubleAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoDoubles NotEnoughRegistersSysV4Managed(double a, double b, double c, double d, double e, double f, double g, double h, TwoDoubles value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoDoubles NotEnoughRegistersSysV5Managed(double a, double b, double c, double d, double e, double f, double g, TwoDoubles value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static DoubleAndByte NotEnoughRegistersSysV6Managed(double a, double b, double c, double d, double e, double f, double g, double h, DoubleAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoDoubles EnoughRegistersSysV1Managed(ulong a, ulong b, ulong c, ulong d, ulong e, ulong f, TwoDoubles value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static DoubleAndByte EnoughRegistersSysV2Managed(ulong a, ulong b, ulong c, ulong d, ulong e, DoubleAndByte value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static TwoLongs EnoughRegistersSysV3Managed(double a, double b, double c, double d, double e, double f, double g, double h, TwoLongs value) + { + return value; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static DoubleAndByte EnoughRegistersSysV4Managed(double a, double b, double c, double d, double e, double f, double g, DoubleAndByte value) + { + return value; + } + + //////////////////////////////////////////////////////////////////////////// + // Wrapper methods + // + // This will allow us to call both the PInvoke native function and + // managed method. + //////////////////////////////////////////////////////////////////////////// + + static bool EchoSingleByteWrapper() + { + bool ok = true; SingleByte expectedSingleByte = SingleByte.Get(); - SingleByte actualSingleByte = EchoSingleByte(expectedSingleByte); - if (!expectedSingleByte.Equals(actualSingleByte)) + SingleByte nativeSingleByte = EchoSingleByte(expectedSingleByte); + SingleByte managedSingleByte = EchoSingleByteManaged(expectedSingleByte); + + if (!expectedSingleByte.Equals(nativeSingleByte)) { - Console.WriteLine("EchoSingleByte failed"); + Console.WriteLine("Native call for EchoSingleByte failed"); ok = false; } - SingleLong expectedSingleLong = SingleLong.Get(); - SingleLong actualSingleLong = EchoSingleLong(expectedSingleLong); - if (!expectedSingleLong.Equals(actualSingleLong)) + if (!expectedSingleByte.Equals(managedSingleByte)) { - Console.WriteLine("EchoSingleLong failed"); + Console.WriteLine("Managed call for EchoSingleByte failed"); ok = false; } - SingleFloat expectedSingleFloat = SingleFloat.Get(); - SingleFloat actualSingleFloat = EchoSingleFloat(expectedSingleFloat); - if (!expectedSingleFloat.Equals(actualSingleFloat)) + SingleByte expectedSingleByte2 = new SingleByte(); + expectedSingleByte2.Byte = 42; + + nativeSingleByte = EchoSingleByte(expectedSingleByte2); + managedSingleByte = EchoSingleByteManaged(expectedSingleByte2); + + if (!expectedSingleByte2.Equals(nativeSingleByte)) { - Console.WriteLine("EchoSingleFloat failed"); + Console.WriteLine("Native call for EchoSingleByte failed"); ok = false; } - SingleDouble expectedSingleDouble = SingleDouble.Get(); - SingleDouble actualSingleDouble = EchoSingleDouble(expectedSingleDouble); - if (!expectedSingleDouble.Equals(actualSingleDouble)) + if (!expectedSingleByte2.Equals(managedSingleByte)) { - Console.WriteLine("EchoSingleDouble failed"); + Console.WriteLine("Managed call for EchoSingleByte failed"); ok = false; } - ByteAndFloat expectedByteAndFloat = ByteAndFloat.Get(); - ByteAndFloat actualByteAndFloat = EchoByteAndFloat(expectedByteAndFloat); - if (!expectedByteAndFloat.Equals(actualByteAndFloat)) + return ok; + } + + static bool EchoSingleLongWrapper() + { + bool ok = true; + SingleLong expectedSingleLong = SingleLong.Get(); + SingleLong nativeSingleLong = EchoSingleLong(expectedSingleLong); + SingleLong managedSingleLong = EchoSingleLongManaged(expectedSingleLong); + + if (!expectedSingleLong.Equals(nativeSingleLong)) { - Console.WriteLine("EchoByteAndFloat failed"); + Console.WriteLine("Native call for EchoSingleLong failed"); ok = false; } - LongAndFloat expectedLongAndFloat = LongAndFloat.Get(); - LongAndFloat actualLongAndFloat = EchoLongAndFloat(expectedLongAndFloat); - if (!expectedLongAndFloat.Equals(actualLongAndFloat)) + if (!expectedSingleLong.Equals(managedSingleLong)) { - Console.WriteLine("EchoLongAndFloat failed"); + Console.WriteLine("Managed call for EchoSingleLong failed"); ok = false; } - ByteAndDouble expectedByteAndDouble = ByteAndDouble.Get(); - ByteAndDouble actualByteAndDouble = EchoByteAndDouble(expectedByteAndDouble); - if (!expectedByteAndDouble.Equals(actualByteAndDouble)) + SingleLong expectedSingleLong2 = new SingleLong(); + expectedSingleLong2.Long = 0xfeedfaceabadf00d; + + nativeSingleLong = EchoSingleLong(expectedSingleLong2); + managedSingleLong = EchoSingleLongManaged(expectedSingleLong2); + + if (!expectedSingleLong2.Equals(nativeSingleLong)) { - Console.WriteLine("EchoByteAndDouble failed"); + Console.WriteLine("Native call for EchoSingleByte failed"); ok = false; } - DoubleAndByte expectedDoubleAndByte = DoubleAndByte.Get(); - DoubleAndByte actualDoubleAndByte = EchoDoubleAndByte(expectedDoubleAndByte); - if (!expectedDoubleAndByte.Equals(actualDoubleAndByte)) + if (!expectedSingleLong2.Equals(managedSingleLong)) { - Console.WriteLine("EchoDoubleAndByte failed"); + Console.WriteLine("Managed call for EchoSingleByte failed"); ok = false; } - PointerAndByte expectedPointerAndByte = PointerAndByte.Get(); - PointerAndByte actualPointerAndByte = EchoPointerAndByte(expectedPointerAndByte); - if (!expectedPointerAndByte.Equals(actualPointerAndByte)) + return ok; + } + + static bool EchoSingleFloatWrapper() + { + bool ok = true; + SingleFloat expectedSingleFloat = SingleFloat.Get(); + SingleFloat nativeSingleFloat = EchoSingleFloat(expectedSingleFloat); + SingleFloat managedSingleFloat = EchoSingleFloatManaged(expectedSingleFloat); + + if (!expectedSingleFloat.Equals(nativeSingleFloat)) { - Console.WriteLine("EchoPointerAndByte failed"); + Console.WriteLine("Native call for EchoSingleFloat failed"); ok = false; } - ByteAndPointer expectedByteAndPointer = ByteAndPointer.Get(); - ByteAndPointer actualByteAndPointer = EchoByteAndPointer(expectedByteAndPointer); - if (!expectedByteAndPointer.Equals(actualByteAndPointer)) + if (!expectedSingleFloat.Equals(managedSingleFloat)) { - Console.WriteLine("EchoByteAndPointer failed"); + Console.WriteLine("Managed call for EchoSingleFloat failed"); ok = false; } - ByteFloatAndPointer expectedByteFloatAndPointer = ByteFloatAndPointer.Get(); - ByteFloatAndPointer actualByteFloatAndPointer = EchoByteFloatAndPointer(expectedByteFloatAndPointer); - if (!expectedByteFloatAndPointer.Equals(actualByteFloatAndPointer)) + SingleFloat expectedSingleFloat2 = new SingleFloat(); + expectedSingleFloat2.Float = 3.14159f; + + nativeSingleFloat = EchoSingleFloat(expectedSingleFloat2); + managedSingleFloat = EchoSingleFloatManaged(expectedSingleFloat2); + + if (!expectedSingleFloat2.Equals(nativeSingleFloat)) { - Console.WriteLine("EchoByteFloatAndPointer failed"); + Console.WriteLine("Native call for EchoSingleFloat failed"); ok = false; } - PointerFloatAndByte expectedPointerFloatAndByte = PointerFloatAndByte.Get(); - PointerFloatAndByte actualPointerFloatAndByte = EchoPointerFloatAndByte(expectedPointerFloatAndByte); - if (!expectedPointerFloatAndByte.Equals(actualPointerFloatAndByte)) + if (!expectedSingleFloat2.Equals(managedSingleFloat)) { - Console.WriteLine("EchoPointerFloatAndByte failed"); + Console.WriteLine("Managed call for EchoSingleFloat failed"); ok = false; } - TwoLongs expectedTwoLongs = TwoLongs.Get(); - TwoLongs actualTwoLongs = EchoTwoLongs(expectedTwoLongs); - if (!expectedTwoLongs.Equals(actualTwoLongs)) + return ok; + } + + static bool EchoSingleDoubleWrapper() + { + bool ok = true; + SingleDouble expectedSingleDouble = SingleDouble.Get(); + SingleDouble nativeSingleDouble = EchoSingleDouble(expectedSingleDouble); + SingleDouble managedSingleDouble = EchoSingleDoubleManaged(expectedSingleDouble); + + if (!expectedSingleDouble.Equals(nativeSingleDouble)) { - Console.WriteLine("EchoTwoLongs failed"); + Console.WriteLine("Native call for EchoSingleDouble failed"); ok = false; } - TwoFloats expectedTwoFloats = TwoFloats.Get(); - TwoFloats actualTwoFloats = EchoTwoFloats(expectedTwoFloats); - if (!expectedTwoFloats.Equals(actualTwoFloats)) + if (!expectedSingleDouble.Equals(managedSingleDouble)) { - Console.WriteLine("EchoTwoFloats failed"); + Console.WriteLine("Managed call for EchoSingleDouble failed"); ok = false; } - TwoDoubles expectedTwoDoubles = TwoDoubles.Get(); - TwoDoubles actualTwoDoubles = EchoTwoDoubles(expectedTwoDoubles); - if (!expectedTwoDoubles.Equals(actualTwoDoubles)) + SingleDouble expectedSingleDouble2 = new SingleDouble(); + expectedSingleDouble2.Double = 3.14159d; + + nativeSingleDouble = EchoSingleDouble(expectedSingleDouble2); + managedSingleDouble = EchoSingleDoubleManaged(expectedSingleDouble2); + + if (!expectedSingleDouble2.Equals(nativeSingleDouble)) { - Console.WriteLine("EchoTwoDoubles failed"); + Console.WriteLine("Native call for EchoSingleDouble failed"); ok = false; } - FourLongs expectedFourLongs = FourLongs.Get(); - FourLongs actualFourLongs = EchoFourLongs(expectedFourLongs); - if (!expectedFourLongs.Equals(actualFourLongs)) + if (!expectedSingleDouble2.Equals(managedSingleDouble)) { - Console.WriteLine("EchoFourLongs failed"); + Console.WriteLine("Managed call for EchoSingleDouble failed"); ok = false; } - FourDoubles expectedFourDoubles = FourDoubles.Get(); - FourDoubles actualFourDoubles = EchoFourDoubles(expectedFourDoubles); - if (!expectedFourDoubles.Equals(actualFourDoubles)) + return ok; + } + + static bool EchoByteAndFloatWrapper() + { + bool ok = true; + ByteAndFloat expectedByteAndFloat = ByteAndFloat.Get(); + ByteAndFloat nativeByteAndFloat = EchoByteAndFloat(expectedByteAndFloat); + ByteAndFloat managedByteAndFloat = EchoByteAndFloatManaged(expectedByteAndFloat); + + if (!expectedByteAndFloat.Equals(nativeByteAndFloat)) { - Console.WriteLine("EchoFourDoubles failed"); + Console.WriteLine("Native call for EchoByteAndFloat failed"); ok = false; } - InlineArray1 expectedInlineArray1 = InlineArray1.Get(); - InlineArray1 actualInlineArray1 = EchoInlineArray1(expectedInlineArray1); - if (!expectedInlineArray1.Equals(actualInlineArray1)) + if (!expectedByteAndFloat.Equals(managedByteAndFloat)) { - Console.WriteLine("EchoInlineArray1 failed"); + Console.WriteLine("Managed call for EchoByteAndFloat failed"); ok = false; } - InlineArray2 expectedInlineArray2 = InlineArray2.Get(); - InlineArray2 actualInlineArray2 = EchoInlineArray2(expectedInlineArray2); - if (!expectedInlineArray2.Equals(actualInlineArray2)) + ByteAndFloat expectedByteAndFloat2 = new ByteAndFloat(); + expectedByteAndFloat2.Byte = 42; + expectedByteAndFloat2.Float = 3.14159f; + + nativeByteAndFloat = EchoByteAndFloat(expectedByteAndFloat2); + managedByteAndFloat = EchoByteAndFloatManaged(expectedByteAndFloat2); + + if (!expectedByteAndFloat2.Equals(nativeByteAndFloat)) { - Console.WriteLine("EchoInlineArray2 failed"); + Console.WriteLine("Native call for EchoByteAndFloat failed"); ok = false; } - InlineArray3 expectedInlineArray3 = InlineArray3.Get(); - InlineArray3 actualInlineArray3 = EchoInlineArray3(expectedInlineArray3); - if (!expectedInlineArray3.Equals(actualInlineArray3)) + if (!expectedByteAndFloat2.Equals(managedByteAndFloat)) { - Console.WriteLine("EchoInlineArray3 failed"); + Console.WriteLine("Managed call for EchoByteAndFloat failed"); ok = false; } - InlineArray4 expectedInlineArray4 = InlineArray4.Get(); - InlineArray4 actualInlineArray4 = EchoInlineArray4(expectedInlineArray4); - if (!expectedInlineArray4.Equals(actualInlineArray4)) + return ok; + } + + static bool EchoLongAndFloatWrapper() + { + bool ok = true; + LongAndFloat expectedLongAndFloat = LongAndFloat.Get(); + LongAndFloat nativeLongAndFloat = EchoLongAndFloat(expectedLongAndFloat); + LongAndFloat managedLongAndFloat = EchoLongAndFloatManaged(expectedLongAndFloat); + + if (!expectedLongAndFloat.Equals(nativeLongAndFloat)) { - Console.WriteLine("EchoInlineArray4 failed"); + Console.WriteLine("Native call for EchoLongAndFloat failed"); ok = false; } - InlineArray5 expectedInlineArray5 = InlineArray5.Get(); - InlineArray5 actualInlineArray5 = EchoInlineArray5(expectedInlineArray5); - if (!expectedInlineArray5.Equals(actualInlineArray5)) + if (!expectedLongAndFloat.Equals(managedLongAndFloat)) { - Console.WriteLine("EchoInlineArray5 failed"); + Console.WriteLine("Managed call for EchoLongAndFloat failed"); ok = false; } - InlineArray6 expectedInlineArray6 = InlineArray6.Get(); - InlineArray6 actualInlineArray6 = EchoInlineArray6(expectedInlineArray6); - if (!expectedInlineArray6.Equals(actualInlineArray6)) + LongAndFloat expectedLongAndFloat2 = new LongAndFloat(); + expectedLongAndFloat2.Long = 0xfeedfaceabadf00d; + expectedLongAndFloat2.Float = 3.14159f; + + nativeLongAndFloat = EchoLongAndFloat(expectedLongAndFloat2); + managedLongAndFloat = EchoLongAndFloatManaged(expectedLongAndFloat2); + + if (!expectedLongAndFloat2.Equals(nativeLongAndFloat)) { - Console.WriteLine("EchoInlineArray6 failed"); + Console.WriteLine("Native call for EchoLongAndFloat failed"); ok = false; } - Nested1 expectedNested1 = Nested1.Get(); - Nested1 actualNested1 = EchoNested1(expectedNested1); - if (!expectedNested1.Equals(actualNested1)) + if (!expectedLongAndFloat2.Equals(managedLongAndFloat)) { - Console.WriteLine("EchoNested1 failed"); + Console.WriteLine("Managed call for EchoLongAndFloat failed"); ok = false; } - Nested2 expectedNested2 = Nested2.Get(); - Nested2 actualNested2 = EchoNested2(expectedNested2); - if (!expectedNested2.Equals(actualNested2)) + return ok; + } + + static bool EchoByteAndDoubleWrapper() + { + bool ok = true; + ByteAndDouble expectedByteAndDouble = ByteAndDouble.Get(); + ByteAndDouble nativeByteAndDouble = EchoByteAndDouble(expectedByteAndDouble); + ByteAndDouble managedByteAndDouble = EchoByteAndDoubleManaged(expectedByteAndDouble); + + if (!expectedByteAndDouble.Equals(nativeByteAndDouble)) { - Console.WriteLine("EchoNested2 failed"); + Console.WriteLine("Native call for EchoByteAndDouble failed"); ok = false; } - Nested3 expectedNested3 = Nested3.Get(); - Nested3 actualNested3 = EchoNested3(expectedNested3); - if (!expectedNested3.Equals(actualNested3)) + if (!expectedByteAndDouble.Equals(managedByteAndDouble)) { - Console.WriteLine("EchoNested3 failed"); + Console.WriteLine("Managed call for EchoByteAndDouble failed"); ok = false; } - Nested4 expectedNested4 = Nested4.Get(); - Nested4 actualNested4 = EchoNested4(expectedNested4); - if (!expectedNested4.Equals(actualNested4)) + ByteAndDouble expectedByteAndDouble2 = new ByteAndDouble(); + expectedByteAndDouble2.Byte = 42; + expectedByteAndDouble2.Double = 3.14159d; + + nativeByteAndDouble = EchoByteAndDouble(expectedByteAndDouble2); + managedByteAndDouble = EchoByteAndDoubleManaged(expectedByteAndDouble2); + + if (!expectedByteAndDouble2.Equals(nativeByteAndDouble)) { - Console.WriteLine("EchoNested4 failed"); + Console.WriteLine("Native call for EchoByteAndDouble failed"); ok = false; } - Nested5 expectedNested5 = Nested5.Get(); - Nested5 actualNested5 = EchoNested5(expectedNested5); - if (!expectedNested5.Equals(actualNested5)) + if (!expectedByteAndDouble2.Equals(managedByteAndDouble)) { - Console.WriteLine("EchoNested5 failed"); + Console.WriteLine("Managed call for EchoByteAndDouble failed"); ok = false; } - Nested6 expectedNested6 = Nested6.Get(); - Nested6 actualNested6 = EchoNested6(expectedNested6); - if (!expectedNested6.Equals(actualNested6)) + return ok; + } + + static bool EchoDoubleAndByteWrapper() + { + bool ok = true; + DoubleAndByte expectedDoubleAndByte = DoubleAndByte.Get(); + DoubleAndByte nativeDoubleAndByte = EchoDoubleAndByte(expectedDoubleAndByte); + DoubleAndByte managedDoubleAndByte = EchoDoubleAndByteManaged(expectedDoubleAndByte); + + if (!expectedDoubleAndByte.Equals(nativeDoubleAndByte)) { - Console.WriteLine("EchoNested6 failed"); + Console.WriteLine("Native call for EchoDoubleAndByte failed"); ok = false; } - Nested7 expectedNested7 = Nested7.Get(); - Nested7 actualNested7 = EchoNested7(expectedNested7); - if (!expectedNested7.Equals(actualNested7)) + if (!expectedDoubleAndByte.Equals(managedDoubleAndByte)) { - Console.WriteLine("EchoNested7 failed"); + Console.WriteLine("Managed call for EchoDoubleAndByte failed"); ok = false; } - Nested8 expectedNested8 = Nested8.Get(); - Nested8 actualNested8 = EchoNested8(expectedNested8); - if (!expectedNested8.Equals(actualNested8)) + return ok; + } + + static bool EchoPointerAndByteWrapper() + { + bool ok = true; + PointerAndByte expectedPointerAndByte = PointerAndByte.Get(); + PointerAndByte nativePointerAndByte = EchoPointerAndByte(expectedPointerAndByte); + PointerAndByte managedPointerAndByte = EchoPointerAndByteManaged(expectedPointerAndByte); + + if (!expectedPointerAndByte.Equals(nativePointerAndByte)) { - Console.WriteLine("EchoNested8 failed"); + Console.WriteLine("Native call for EchoPointerAndByte failed"); ok = false; } - Nested9 expectedNested9 = Nested9.Get(); - Nested9 actualNested9 = EchoNested9(expectedNested9); - if (!expectedNested9.Equals(actualNested9)) + if (!expectedPointerAndByte.Equals(managedPointerAndByte)) { - Console.WriteLine("EchoNested9 failed"); + Console.WriteLine("Managed call for EchoPointerAndByte failed"); ok = false; } - TwoLongs expectedNotEnoughRegistersSysV1 = TwoLongs.Get(); - TwoLongs actualNotEnoughRegistersSysV1 = NotEnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV1); - if (!expectedNotEnoughRegistersSysV1.Equals(actualNotEnoughRegistersSysV1)) + return ok; + } + + static bool EchoByteAndPointerWrapper() + { + bool ok = true; + ByteAndPointer expectedByteAndPointer = ByteAndPointer.Get(); + ByteAndPointer nativeByteAndPointer = EchoByteAndPointer(expectedByteAndPointer); + ByteAndPointer managedByteAndPointer = EchoByteAndPointerManaged(expectedByteAndPointer); + + if (!expectedByteAndPointer.Equals(nativeByteAndPointer)) { - Console.WriteLine("NotEnoughRegistersSysV1 failed"); + Console.WriteLine("Native call for EchoByteAndPointer failed"); ok = false; } - TwoLongs expectedNotEnoughRegistersSysV2 = TwoLongs.Get(); - TwoLongs actualNotEnoughRegistersSysV2 = NotEnoughRegistersSysV2(1, 2, 3, 4, 5, expectedNotEnoughRegistersSysV2); - if (!expectedNotEnoughRegistersSysV2.Equals(actualNotEnoughRegistersSysV2)) + if (!expectedByteAndPointer.Equals(managedByteAndPointer)) { - Console.WriteLine("NotEnoughRegistersSysV2 failed"); + Console.WriteLine("Managed call for EchoByteAndPointer failed"); ok = false; } - DoubleAndByte expectedNotEnoughRegistersSysV3 = DoubleAndByte.Get(); - DoubleAndByte actualNotEnoughRegistersSysV3 = NotEnoughRegistersSysV3(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV3); - if (!expectedNotEnoughRegistersSysV3.Equals(actualNotEnoughRegistersSysV3)) + return ok; + } + + static bool EchoByteFloatAndPointerWrapper() + { + bool ok = true; + ByteFloatAndPointer expectedByteFloatAndPointer = ByteFloatAndPointer.Get(); + ByteFloatAndPointer nativeByteFloatAndPointer = EchoByteFloatAndPointer(expectedByteFloatAndPointer); + ByteFloatAndPointer managedByteFloatAndPointer = EchoByteFloatAndPointerManaged(expectedByteFloatAndPointer); + + if (!expectedByteFloatAndPointer.Equals(nativeByteFloatAndPointer)) { - Console.WriteLine("NotEnoughRegistersSysV3 failed"); + Console.WriteLine("Native call for EchoByteFloatAndPointer failed"); ok = false; } - TwoDoubles expectedNotEnoughRegistersSysV4 = TwoDoubles.Get(); - TwoDoubles actualNotEnoughRegistersSysV4 = NotEnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV4); - if (!expectedNotEnoughRegistersSysV4.Equals(actualNotEnoughRegistersSysV4)) + if (!expectedByteFloatAndPointer.Equals(managedByteFloatAndPointer)) { - Console.WriteLine("NotEnoughRegistersSysV4 failed"); + Console.WriteLine("Managed call for EchoByteFloatAndPointer failed"); ok = false; } - TwoDoubles expectedNotEnoughRegistersSysV5 = TwoDoubles.Get(); - TwoDoubles actualNotEnoughRegistersSysV5 = NotEnoughRegistersSysV5(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedNotEnoughRegistersSysV5); - if (!expectedNotEnoughRegistersSysV5.Equals(actualNotEnoughRegistersSysV5)) + return ok; + } + + static bool EchoPointerFloatAndByteWrapper() + { + bool ok = true; + PointerFloatAndByte expectedPointerFloatAndByte = PointerFloatAndByte.Get(); + PointerFloatAndByte nativePointerFloatAndByte = EchoPointerFloatAndByte(expectedPointerFloatAndByte); + PointerFloatAndByte managedPointerFloatAndByte = EchoPointerFloatAndByteManaged(expectedPointerFloatAndByte); + + if (!expectedPointerFloatAndByte.Equals(nativePointerFloatAndByte)) { - Console.WriteLine("NotEnoughRegistersSysV5 failed"); + Console.WriteLine("Native call for EchoPointerFloatAndByte failed"); ok = false; } - DoubleAndByte expectedNotEnoughRegistersSysV6 = DoubleAndByte.Get(); - DoubleAndByte actualNotEnoughRegistersSysV6 = NotEnoughRegistersSysV6(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV6); - if (!expectedNotEnoughRegistersSysV6.Equals(actualNotEnoughRegistersSysV6)) + if (!expectedPointerFloatAndByte.Equals(managedPointerFloatAndByte)) { - Console.WriteLine("NotEnoughRegistersSysV6 failed"); + Console.WriteLine("Managed call for EchoPointerFloatAndByte failed"); ok = false; } - TwoDoubles expectedEnoughRegistersSysV1 = TwoDoubles.Get(); - TwoDoubles actualEnoughRegistersSysV1 = EnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedEnoughRegistersSysV1); - if (!expectedEnoughRegistersSysV1.Equals(actualEnoughRegistersSysV1)) + return ok; + } + + static bool EchoShortIntFloatIntPtrWrapper() + { + bool ok = true; + ShortIntFloatIntPtr expectedShortIntFloatIntPtr = ShortIntFloatIntPtr.Get(); + ShortIntFloatIntPtr nativeShortIntFloatIntPtr = EchoShortIntFloatIntPtr(expectedShortIntFloatIntPtr); + ShortIntFloatIntPtr managedShortIntFloatIntPtr = EchoShortIntFloatIntPtrManaged(expectedShortIntFloatIntPtr); + + if (!expectedShortIntFloatIntPtr.Equals(nativeShortIntFloatIntPtr)) { - Console.WriteLine("EnoughRegistersSysV1 failed"); + Console.WriteLine("Native call for EchoShortIntFloatIntPtr failed"); ok = false; } - DoubleAndByte expectedEnoughRegistersSysV2 = DoubleAndByte.Get(); - DoubleAndByte actualEnoughRegistersSysV2 = EnoughRegistersSysV2(1, 2, 3, 4, 5, expectedEnoughRegistersSysV2); - if (!expectedEnoughRegistersSysV2.Equals(actualEnoughRegistersSysV2)) + if (!expectedShortIntFloatIntPtr.Equals(managedShortIntFloatIntPtr)) { - Console.WriteLine("EnoughRegistersSysV2 failed"); + Console.WriteLine("Managed call for EchoShortIntFloatIntPtr failed"); ok = false; } - TwoLongs expectedEnoughRegistersSysV3 = TwoLongs.Get(); - TwoLongs actualEnoughRegistersSysV3 = EnoughRegistersSysV3(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedEnoughRegistersSysV3); - if (!expectedEnoughRegistersSysV3.Equals(actualEnoughRegistersSysV3)) + return ok; + } + + static bool EchoTwoLongsWrapper() + { + bool ok = true; + TwoLongs expectedTwoLongs = TwoLongs.Get(); + TwoLongs nativeTwoLongs = EchoTwoLongs(expectedTwoLongs); + TwoLongs managedTwoLongs = EchoTwoLongsManaged(expectedTwoLongs); + + if (!expectedTwoLongs.Equals(nativeTwoLongs)) { - Console.WriteLine("EnoughRegistersSysV3 failed"); + Console.WriteLine("Native call for EchoTwoLongs failed"); ok = false; } - DoubleAndByte expectedEnoughRegistersSysV4 = DoubleAndByte.Get(); - DoubleAndByte actualEnoughRegistersSysV4 = EnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedEnoughRegistersSysV4); - if (!expectedEnoughRegistersSysV4.Equals(actualEnoughRegistersSysV4)) + if (!expectedTwoLongs.Equals(managedTwoLongs)) + { + Console.WriteLine("Managed call for EchoTwoLongs failed"); + ok = false; + } + + return ok; + } + + static bool EchoTwoFloatsWrapper() + { + bool ok = true; + TwoFloats expectedTwoFloats = TwoFloats.Get(); + TwoFloats nativeTwoFloats = EchoTwoFloats(expectedTwoFloats); + TwoFloats managedTwoFloats = EchoTwoFloatsManaged(expectedTwoFloats); + + if (!expectedTwoFloats.Equals(nativeTwoFloats)) { - Console.WriteLine("EnoughRegistersSysV4 failed"); + Console.WriteLine("Native call for EchoTwoFloats failed"); ok = false; } + if (!expectedTwoFloats.Equals(managedTwoFloats)) + { + Console.WriteLine("Managed call for EchoTwoFloats failed"); + ok = false; + } + + return ok; + } + + static bool EchoTwoDoublesWrapper() + { + bool ok = true; + TwoDoubles expectedTwoDoubles = TwoDoubles.Get(); + TwoDoubles nativeTwoDoubles = EchoTwoDoubles(expectedTwoDoubles); + TwoDoubles managedTwoDoubles = EchoTwoDoublesManaged(expectedTwoDoubles); + + if (!expectedTwoDoubles.Equals(nativeTwoDoubles)) + { + Console.WriteLine("Native call for EchoTwoDoubles failed"); + ok = false; + } + + if (!expectedTwoDoubles.Equals(managedTwoDoubles)) + { + Console.WriteLine("Managed call for EchoTwoDoubles failed"); + ok = false; + } + + return ok; + } + + static bool EchoFourLongsWrapper() + { + bool ok = true; + FourLongs expectedFourLongs = FourLongs.Get(); + FourLongs nativeFourLongs = EchoFourLongs(expectedFourLongs); + FourLongs managedFourLongs = EchoFourLongsManaged(expectedFourLongs); + + if (!expectedFourLongs.Equals(nativeFourLongs)) + { + Console.WriteLine("Native call for EchoFourLongs failed"); + ok = false; + } + + if (!expectedFourLongs.Equals(managedFourLongs)) + { + Console.WriteLine("Managed call for EchoFourLongs failed"); + ok = false; + } + + return ok; + } + + static bool EchoFourDoublesWrapper() + { + bool ok = true; + FourDoubles expectedFourDoubles = FourDoubles.Get(); + FourDoubles nativeFourDoubles = EchoFourDoubles(expectedFourDoubles); + FourDoubles managedFourDoubles = EchoFourDoublesManaged(expectedFourDoubles); + + if (!expectedFourDoubles.Equals(nativeFourDoubles)) + { + Console.WriteLine("Native call for EchoFourDoubles failed"); + ok = false; + } + + if (!expectedFourDoubles.Equals(managedFourDoubles)) + { + Console.WriteLine("Managed call for EchoFourDoubles failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray1Wrapper() + { + bool ok = true; + InlineArray1 expectedInlineArray1 = InlineArray1.Get(); + InlineArray1 nativeInlineArray1 = EchoInlineArray1(expectedInlineArray1); + InlineArray1 managedInlineArray1 = EchoInlineArray1Managed(expectedInlineArray1); + + if (!expectedInlineArray1.Equals(nativeInlineArray1)) + { + Console.WriteLine("Native call for EchoInlineArray1 failed"); + ok = false; + } + + if (!expectedInlineArray1.Equals(managedInlineArray1)) + { + Console.WriteLine("Managed call for EchoInlineArray1 failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray2Wrapper() + { + bool ok = true; + InlineArray2 expectedInlineArray2 = InlineArray2.Get(); + InlineArray2 nativeInlineArray2 = EchoInlineArray2(expectedInlineArray2); + InlineArray2 managedInlineArray2 = EchoInlineArray2Managed(expectedInlineArray2); + + if (!expectedInlineArray2.Equals(nativeInlineArray2)) + { + Console.WriteLine("Native call for EchoInlineArray2 failed"); + ok = false; + } + + if (!expectedInlineArray2.Equals(managedInlineArray2)) + { + Console.WriteLine("Managed call for EchoInlineArray2 failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray3Wrapper() + { + bool ok = true; + InlineArray3 expectedInlineArray3 = InlineArray3.Get(); + InlineArray3 nativeInlineArray3 = EchoInlineArray3(expectedInlineArray3); + InlineArray3 managedInlineArray3 = EchoInlineArray3Managed(expectedInlineArray3); + + if (!expectedInlineArray3.Equals(nativeInlineArray3)) + { + Console.WriteLine("Native call for EchoInlineArray3 failed"); + ok = false; + } + + if (!expectedInlineArray3.Equals(managedInlineArray3)) + { + Console.WriteLine("Managed call for EchoInlineArray3 failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray4Wrapper() + { + bool ok = true; + InlineArray4 expectedInlineArray4 = InlineArray4.Get(); + InlineArray4 nativeInlineArray4 = EchoInlineArray4(expectedInlineArray4); + InlineArray4 managedInlineArray4 = EchoInlineArray4Managed(expectedInlineArray4); + + if (!expectedInlineArray4.Equals(nativeInlineArray4)) + { + Console.WriteLine("Native call for EchoInlineArray4 failed"); + ok = false; + } + + if (!expectedInlineArray4.Equals(managedInlineArray4)) + { + Console.WriteLine("Managed call for EchoInlineArray4 failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray5Wrapper() + { + bool ok = true; + InlineArray5 expectedInlineArray5 = InlineArray5.Get(); + InlineArray5 nativeInlineArray5 = EchoInlineArray5(expectedInlineArray5); + InlineArray5 managedInlineArray5 = EchoInlineArray5Managed(expectedInlineArray5); + + if (!expectedInlineArray5.Equals(nativeInlineArray5)) + { + Console.WriteLine("Native call for EchoInlineArray5 failed"); + ok = false; + } + + if (!expectedInlineArray5.Equals(managedInlineArray5)) + { + Console.WriteLine("Managed call for EchoInlineArray5 failed"); + ok = false; + } + + return ok; + } + + static bool EchoInlineArray6Wrapper() + { + bool ok = true; + InlineArray6 expectedInlineArray6 = InlineArray6.Get(); + InlineArray6 nativeInlineArray6 = EchoInlineArray6(expectedInlineArray6); + InlineArray6 managedInlineArray6 = EchoInlineArray6Managed(expectedInlineArray6); + + if (!expectedInlineArray6.Equals(nativeInlineArray6)) + { + Console.WriteLine("Native call for EchoInlineArray6 failed"); + ok = false; + } + + if (!expectedInlineArray6.Equals(managedInlineArray6)) + { + Console.WriteLine("Managed call for EchoInlineArray6 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested1Wrapper() + { + bool ok = true; + Nested1 expectedNested1 = Nested1.Get(); + Nested1 nativeNested1 = EchoNested1(expectedNested1); + Nested1 managedNested1 = EchoNested1Managed(expectedNested1); + + if (!expectedNested1.Equals(nativeNested1)) + { + Console.WriteLine("Native call for EchoNested1 failed"); + ok = false; + } + + if (!expectedNested1.Equals(managedNested1)) + { + Console.WriteLine("Managed call for EchoNested1 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested2Wrapper() + { + bool ok = true; + Nested2 expectedNested2 = Nested2.Get(); + Nested2 nativeNested2 = EchoNested2(expectedNested2); + Nested2 managedNested2 = EchoNested2Managed(expectedNested2); + + if (!expectedNested2.Equals(nativeNested2)) + { + Console.WriteLine("Native call for EchoNested2 failed"); + ok = false; + } + + if (!expectedNested2.Equals(managedNested2)) + { + Console.WriteLine("Managed call for EchoNested2 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested3Wrapper() + { + bool ok = true; + Nested3 expectedNested3 = Nested3.Get(); + Nested3 nativeNested3 = EchoNested3(expectedNested3); + Nested3 managedNested3 = EchoNested3Managed(expectedNested3); + + if (!expectedNested3.Equals(nativeNested3)) + { + Console.WriteLine("Native call for EchoNested3 failed"); + ok = false; + } + + if (!expectedNested3.Equals(managedNested3)) + { + Console.WriteLine("Managed call for EchoNested3 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested4Wrapper() + { + bool ok = true; + Nested4 expectedNested4 = Nested4.Get(); + Nested4 nativeNested4 = EchoNested4(expectedNested4); + Nested4 managedNested4 = EchoNested4Managed(expectedNested4); + + if (!expectedNested4.Equals(nativeNested4)) + { + Console.WriteLine("Native call for EchoNested4 failed"); + ok = false; + } + + if (!expectedNested4.Equals(managedNested4)) + { + Console.WriteLine("Managed call for EchoNested4 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested5Wrapper() + { + bool ok = true; + Nested5 expectedNested5 = Nested5.Get(); + Nested5 nativeNested5 = EchoNested5(expectedNested5); + Nested5 managedNested5 = EchoNested5Managed(expectedNested5); + + if (!expectedNested5.Equals(nativeNested5)) + { + Console.WriteLine("Native call for EchoNested5 failed"); + ok = false; + } + + if (!expectedNested5.Equals(managedNested5)) + { + Console.WriteLine("Managed call for EchoNested5 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested6Wrapper() + { + bool ok = true; + Nested6 expectedNested6 = Nested6.Get(); + Nested6 nativeNested6 = EchoNested6(expectedNested6); + Nested6 managedNested6 = EchoNested6Managed(expectedNested6); + + if (!expectedNested6.Equals(nativeNested6)) + { + Console.WriteLine("Native call for EchoNested6 failed"); + ok = false; + } + + if (!expectedNested6.Equals(managedNested6)) + { + Console.WriteLine("Managed call for EchoNested6 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested7Wrapper() + { + bool ok = true; + Nested7 expectedNested7 = Nested7.Get(); + Nested7 nativeNested7 = EchoNested7(expectedNested7); + Nested7 managedNested7 = EchoNested7Managed(expectedNested7); + + if (!expectedNested7.Equals(nativeNested7)) + { + Console.WriteLine("Native call for EchoNested7 failed"); + ok = false; + } + + if (!expectedNested7.Equals(managedNested7)) + { + Console.WriteLine("Managed call for EchoNested7 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested8Wrapper() + { + bool ok = true; + Nested8 expectedNested8 = Nested8.Get(); + Nested8 nativeNested8 = EchoNested8(expectedNested8); + Nested8 managedNested8 = EchoNested8Managed(expectedNested8); + + if (!expectedNested8.Equals(nativeNested8)) + { + Console.WriteLine("Native call for EchoNested8 failed"); + ok = false; + } + + if (!expectedNested8.Equals(managedNested8)) + { + Console.WriteLine("Managed call for EchoNested8 failed"); + ok = false; + } + + return ok; + } + + static bool EchoNested9Wrapper() + { + bool ok = true; + Nested9 expectedNested9 = Nested9.Get(); + Nested9 nativeNested9 = EchoNested9(expectedNested9); + Nested9 managedNested9 = EchoNested9Managed(expectedNested9); + + if (!expectedNested9.Equals(nativeNested9)) + { + Console.WriteLine("Native call for EchoNested9 failed"); + ok = false; + } + + if (!expectedNested9.Equals(managedNested9)) + { + Console.WriteLine("Managed call for EchoNested9 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV1Wrapper() + { + bool ok = true; + + TwoLongs expectedNotEnoughRegistersSysV1 = TwoLongs.Get(); + TwoLongs nativeNotEnoughRegistersSysV1 = NotEnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV1); + TwoLongs managedNotEnoughRegistersSysV1 = NotEnoughRegistersSysV1Managed(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV1); + + if (!expectedNotEnoughRegistersSysV1.Equals(nativeNotEnoughRegistersSysV1)) + { + Console.WriteLine("Native NotEnoughRegistersSysV1 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV1.Equals(managedNotEnoughRegistersSysV1)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV1 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV2Wrapper() + { + bool ok = true; + + TwoLongs expectedNotEnoughRegistersSysV2 = TwoLongs.Get(); + TwoLongs nativeNotEnoughRegistersSysV2 = NotEnoughRegistersSysV2(1, 2, 3, 4, 5, expectedNotEnoughRegistersSysV2); + TwoLongs managedNotEnoughRegistersSysV2 = NotEnoughRegistersSysV2Managed(1, 2, 3, 4, 5, expectedNotEnoughRegistersSysV2); + + if (!expectedNotEnoughRegistersSysV2.Equals(nativeNotEnoughRegistersSysV2)) + { + Console.WriteLine("Native NotEnoughRegistersSysV2 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV2.Equals(managedNotEnoughRegistersSysV2)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV2 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV3Wrapper() + { + bool ok = true; + + DoubleAndByte expectedNotEnoughRegistersSysV3 = DoubleAndByte.Get(); + DoubleAndByte nativeNotEnoughRegistersSysV3 = NotEnoughRegistersSysV3(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV3); + DoubleAndByte managedNotEnoughRegistersSysV3 = NotEnoughRegistersSysV3Managed(1, 2, 3, 4, 5, 6, expectedNotEnoughRegistersSysV3); + + if (!expectedNotEnoughRegistersSysV3.Equals(nativeNotEnoughRegistersSysV3)) + { + Console.WriteLine("Native NotEnoughRegistersSysV3 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV3.Equals(managedNotEnoughRegistersSysV3)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV3 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV4Wrapper() + { + bool ok = true; + + TwoDoubles expectedNotEnoughRegistersSysV4 = TwoDoubles.Get(); + TwoDoubles nativeNotEnoughRegistersSysV4 = NotEnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV4); + TwoDoubles managedNotEnoughRegistersSysV4 = NotEnoughRegistersSysV4Managed(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV4); + + if (!expectedNotEnoughRegistersSysV4.Equals(nativeNotEnoughRegistersSysV4)) + { + Console.WriteLine("Native NotEnoughRegistersSysV4 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV4.Equals(managedNotEnoughRegistersSysV4)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV4 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV5Wrapper() + { + bool ok = true; + + TwoDoubles expectedNotEnoughRegistersSysV5 = TwoDoubles.Get(); + TwoDoubles nativeNotEnoughRegistersSysV5 = NotEnoughRegistersSysV5(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedNotEnoughRegistersSysV5); + TwoDoubles managedNotEnoughRegistersSysV5 = NotEnoughRegistersSysV5Managed(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedNotEnoughRegistersSysV5); + + if (!expectedNotEnoughRegistersSysV5.Equals(nativeNotEnoughRegistersSysV5)) + { + Console.WriteLine("Native NotEnoughRegistersSysV5 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV5.Equals(managedNotEnoughRegistersSysV5)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV5 failed"); + ok = false; + } + + return ok; + } + + static bool NotEnoughRegistersSysV6Wrapper() + { + bool ok = true; + + DoubleAndByte expectedNotEnoughRegistersSysV6 = DoubleAndByte.Get(); + DoubleAndByte nativeNotEnoughRegistersSysV6 = NotEnoughRegistersSysV6(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV6); + DoubleAndByte managedNotEnoughRegistersSysV6 = NotEnoughRegistersSysV6Managed(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedNotEnoughRegistersSysV6); + + if (!expectedNotEnoughRegistersSysV6.Equals(nativeNotEnoughRegistersSysV6)) + { + Console.WriteLine("Native NotEnoughRegistersSysV6 failed"); + ok = false; + } + + if (!expectedNotEnoughRegistersSysV6.Equals(managedNotEnoughRegistersSysV6)) + { + Console.WriteLine("Managed NotEnoughRegistersSysV6 failed"); + ok = false; + } + + return ok; + } + + static bool EnoughRegistersSysV1Wrapper() + { + bool ok = true; + + TwoDoubles expectedEnoughRegistersSysV1 = TwoDoubles.Get(); + TwoDoubles nativeEnoughRegistersSysV1 = EnoughRegistersSysV1(1, 2, 3, 4, 5, 6, expectedEnoughRegistersSysV1); + TwoDoubles managedEnoughRegistersSysV1 = EnoughRegistersSysV1Managed(1, 2, 3, 4, 5, 6, expectedEnoughRegistersSysV1); + + if (!expectedEnoughRegistersSysV1.Equals(nativeEnoughRegistersSysV1)) + { + Console.WriteLine("Native EnoughRegistersSysV1 failed"); + ok = false; + } + + if (!expectedEnoughRegistersSysV1.Equals(managedEnoughRegistersSysV1)) + { + Console.WriteLine("Managed EnoughRegistersSysV1 failed"); + ok = false; + } + + return ok; + } + + static bool EnoughRegistersSysV2Wrapper() + { + bool ok = true; + + DoubleAndByte expectedEnoughRegistersSysV2 = DoubleAndByte.Get(); + DoubleAndByte nativeEnoughRegistersSysV2 = EnoughRegistersSysV2(1, 2, 3, 4, 5, expectedEnoughRegistersSysV2); + DoubleAndByte managedEnoughRegistersSysV2 = EnoughRegistersSysV2Managed(1, 2, 3, 4, 5, expectedEnoughRegistersSysV2); + + if (!expectedEnoughRegistersSysV2.Equals(nativeEnoughRegistersSysV2)) + { + Console.WriteLine("Native EnoughRegistersSysV2 failed"); + ok = false; + } + + if (!expectedEnoughRegistersSysV2.Equals(managedEnoughRegistersSysV2)) + { + Console.WriteLine("Managed EnoughRegistersSysV2 failed"); + ok = false; + } + + return ok; + } + + static bool EnoughRegistersSysV3Wrapper() + { + bool ok = true; + + TwoLongs expectedEnoughRegistersSysV3 = TwoLongs.Get(); + TwoLongs nativeEnoughRegistersSysV3 = EnoughRegistersSysV3(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedEnoughRegistersSysV3); + TwoLongs managedEnoughRegistersSysV3 = EnoughRegistersSysV3Managed(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, 8.0d, expectedEnoughRegistersSysV3); + + if (!expectedEnoughRegistersSysV3.Equals(nativeEnoughRegistersSysV3)) + { + Console.WriteLine("Native EnoughRegistersSysV3 failed"); + ok = false; + } + + if (!expectedEnoughRegistersSysV3.Equals(managedEnoughRegistersSysV3)) + { + Console.WriteLine("Managed EnoughRegistersSysV3 failed"); + ok = false; + } + + return ok; + } + + static bool EnoughRegistersSysV4Wrapper() + { + bool ok = true; + + DoubleAndByte expectedEnoughRegistersSysV4 = DoubleAndByte.Get(); + DoubleAndByte nativeEnoughRegistersSysV4 = EnoughRegistersSysV4(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedEnoughRegistersSysV4); + DoubleAndByte managedEnoughRegistersSysV4 = EnoughRegistersSysV4Managed(1.0d, 2.0d, 3.0d, 4.0d, 5.0d, 6.0d, 7.0d, expectedEnoughRegistersSysV4); + + if (!expectedEnoughRegistersSysV4.Equals(nativeEnoughRegistersSysV4)) + { + Console.WriteLine("Native EnoughRegistersSysV4 failed"); + ok = false; + } + + if (!expectedEnoughRegistersSysV4.Equals(managedEnoughRegistersSysV4)) + { + Console.WriteLine("Managed EnoughRegistersSysV4 failed"); + ok = false; + } + + return ok; + } + + static int Main() + { + var ok = true; + + if (!EchoSingleByteWrapper()) ok = false; + if (!EchoSingleLongWrapper()) ok = false; + if (!EchoSingleFloatWrapper()) ok = false; + if (!EchoSingleDoubleWrapper()) ok = false; + if (!EchoByteAndFloatWrapper()) ok = false; + if (!EchoLongAndFloatWrapper()) ok = false; + if (!EchoByteAndDoubleWrapper()) ok = false; + if (!EchoDoubleAndByteWrapper()) ok = false; + if (!EchoPointerAndByteWrapper()) ok = false; + if (!EchoByteAndPointerWrapper()) ok = false; + if (!EchoByteFloatAndPointerWrapper()) ok = false; + if (!EchoPointerFloatAndByteWrapper()) ok = false; + if (!EchoShortIntFloatIntPtrWrapper()) ok = false; + if (!EchoTwoLongsWrapper()) ok = false; + if (!EchoTwoFloatsWrapper()) ok = false; + if (!EchoTwoDoublesWrapper()) ok = false; + if (!EchoFourLongsWrapper()) ok = false; + if (!EchoFourDoublesWrapper()) ok = false; + if (!EchoInlineArray1Wrapper()) ok = false; + if (!EchoInlineArray2Wrapper()) ok = false; + if (!EchoInlineArray3Wrapper()) ok = false; + if (!EchoInlineArray4Wrapper()) ok = false; + if (!EchoInlineArray5Wrapper()) ok = false; + if (!EchoInlineArray6Wrapper()) ok = false; + if (!EchoNested1Wrapper()) ok = false; + if (!EchoNested2Wrapper()) ok = false; + if (!EchoNested3Wrapper()) ok = false; + if (!EchoNested4Wrapper()) ok = false; + if (!EchoNested5Wrapper()) ok = false; + if (!EchoNested6Wrapper()) ok = false; + if (!EchoNested7Wrapper()) ok = false; + if (!EchoNested8Wrapper()) ok = false; + if (!EchoNested9Wrapper()) ok = false; + if (!NotEnoughRegistersSysV1Wrapper()) ok = false; + if (!NotEnoughRegistersSysV2Wrapper()) ok = false; + if (!NotEnoughRegistersSysV3Wrapper()) ok = false; + if (!NotEnoughRegistersSysV4Wrapper()) ok = false; + if (!NotEnoughRegistersSysV5Wrapper()) ok = false; + if (!NotEnoughRegistersSysV6Wrapper()) ok = false; + if (!EnoughRegistersSysV1Wrapper()) ok = false; + if (!EnoughRegistersSysV2Wrapper()) ok = false; + if (!EnoughRegistersSysV3Wrapper()) ok = false; + if (!EnoughRegistersSysV4Wrapper()) ok = false; + return ok ? 100 : -1; } } diff --git a/tests/src/JIT/Directed/StructABI/StructABI.csproj b/tests/src/JIT/Directed/StructABI/StructABI.csproj index a951e17ce615..c1065f86411c 100644 --- a/tests/src/JIT/Directed/StructABI/StructABI.csproj +++ b/tests/src/JIT/Directed/StructABI/StructABI.csproj @@ -11,7 +11,6 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} true ..\..\ - 1 diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs index ab282494fd43..2a879ee84955 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs @@ -64,11 +64,17 @@ private static void AddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddDouble() public sealed unsafe class SimpleBinaryOpTest__AddDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddDouble testClass) + { + var result = Avx.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddDouble(); var result = Avx.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs index ebb2751a0217..5f38b49a3dab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs @@ -64,11 +64,17 @@ private static void AddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSingle() public sealed unsafe class SimpleBinaryOpTest__AddSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSingle testClass) + { + var result = Avx.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSingle(); var result = Avx.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs index e1ae4afdb0db..e48df8819629 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs @@ -64,11 +64,17 @@ private static void AddSubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSubtractDouble() public sealed unsafe class SimpleBinaryOpTest__AddSubtractDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSubtractDouble testClass) + { + var result = Avx.AddSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddSubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddSubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSubtractDouble(); var result = Avx.AddSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.AddSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.AddSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs index 15822235ab38..40fcb164e297 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs @@ -64,11 +64,17 @@ private static void AddSubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSubtractSingle() public sealed unsafe class SimpleBinaryOpTest__AddSubtractSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSubtractSingle testClass) + { + var result = Avx.AddSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddSubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddSubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSubtractSingle(); var result = Avx.AddSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.AddSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.AddSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs index b71ad1ae2fad..2a8565c71976 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs @@ -64,11 +64,17 @@ private static void AndDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndDouble() public sealed unsafe class SimpleBinaryOpTest__AndDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndDouble testClass) + { + var result = Avx.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndDouble(); var result = Avx.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs index b6e5e62a7f48..a0f41926343a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs @@ -64,11 +64,17 @@ private static void AndSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndSingle() public sealed unsafe class SimpleBinaryOpTest__AndSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndSingle testClass) + { + var result = Avx.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndSingle(); var result = Avx.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs index aa62937bcdf8..46c3c6a2c50d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs @@ -64,11 +64,17 @@ private static void AndNotDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotDouble() public sealed unsafe class SimpleBinaryOpTest__AndNotDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotDouble testClass) + { + var result = Avx.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndNotDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndNotDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotDouble(); var result = Avx.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs index 41aa383a45f4..30d312508bba 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs @@ -64,11 +64,17 @@ private static void AndNotSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotSingle() public sealed unsafe class SimpleBinaryOpTest__AndNotSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotSingle testClass) + { + var result = Avx.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndNotSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndNotSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotSingle(); var result = Avx.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj index 7f89b8944017..d2e65588b901 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj @@ -45,12 +45,8 @@ - - - - @@ -61,8 +57,6 @@ - - @@ -196,6 +190,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj index 66eb86a7e156..b91bc6d91d8d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj @@ -45,12 +45,8 @@ - - - - @@ -61,8 +57,6 @@ - - @@ -196,6 +190,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs index 7a576dfe2a67..3574911f29fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs @@ -64,11 +64,17 @@ private static void BlendVariableDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableDouble() public sealed unsafe class SimpleTernaryOpTest__BlendVariableDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableDouble testClass) + { + var result = Avx.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,9 +146,9 @@ static SimpleTernaryOpTest__BlendVariableDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); @@ -124,15 +160,15 @@ public SimpleTernaryOpTest__BlendVariableDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableDouble(); var result = Avx.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs index 6af68ac357ad..91888eec19e5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs @@ -64,11 +64,17 @@ private static void BlendVariableSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableSingle() public sealed unsafe class SimpleTernaryOpTest__BlendVariableSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableSingle testClass) + { + var result = Avx.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,9 +146,9 @@ static SimpleTernaryOpTest__BlendVariableSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); @@ -124,15 +160,15 @@ public SimpleTernaryOpTest__BlendVariableSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableSingle(); var result = Avx.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs index f34542f43758..3c4655f524b9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs @@ -64,11 +64,17 @@ private static void CeilingDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void CeilingDouble() public sealed unsafe class SimpleUnaryOpTest__CeilingDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__CeilingDouble testClass) + { + var result = Avx.Ceiling(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__CeilingDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__CeilingDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__CeilingDouble(); var result = Avx.Ceiling(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Ceiling(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Ceiling(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs index d6a27d52c620..c78face4c888 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs @@ -64,11 +64,17 @@ private static void CeilingSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void CeilingSingle() public sealed unsafe class SimpleUnaryOpTest__CeilingSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__CeilingSingle testClass) + { + var result = Avx.Ceiling(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__CeilingSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__CeilingSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__CeilingSingle(); var result = Avx.Ceiling(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Ceiling(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Ceiling(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs index 52588d9e2c19..960456019766 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs @@ -64,11 +64,17 @@ private static void DivideDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideDouble() public sealed unsafe class SimpleBinaryOpTest__DivideDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideDouble testClass) + { + var result = Avx.Divide(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideDouble(); var result = Avx.Divide(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Divide(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Divide(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs index aa28dc18a48c..4adf0118ee95 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs @@ -64,11 +64,17 @@ private static void DivideSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideSingle() public sealed unsafe class SimpleBinaryOpTest__DivideSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideSingle testClass) + { + var result = Avx.Divide(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideSingle(); var result = Avx.Divide(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Divide(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Divide(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs index ae42b1a0afcb..0b5901483ec9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs @@ -64,11 +64,17 @@ private static void DuplicateEvenIndexedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void DuplicateEvenIndexedDouble() public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__DuplicateEvenIndexedDouble testClass) + { + var result = Avx.DuplicateEvenIndexed(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__DuplicateEvenIndexedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__DuplicateEvenIndexedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__DuplicateEvenIndexedDouble(); var result = Avx.DuplicateEvenIndexed(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.DuplicateEvenIndexed(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.DuplicateEvenIndexed(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs index 45728ded0358..e1363a5722f7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs @@ -64,11 +64,17 @@ private static void DuplicateEvenIndexedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void DuplicateEvenIndexedSingle() public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__DuplicateEvenIndexedSingle testClass) + { + var result = Avx.DuplicateEvenIndexed(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__DuplicateEvenIndexedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__DuplicateEvenIndexedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__DuplicateEvenIndexedSingle(); var result = Avx.DuplicateEvenIndexed(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.DuplicateEvenIndexed(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.DuplicateEvenIndexed(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs index 94180518c9b4..600fcc2c07f3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs @@ -64,11 +64,17 @@ private static void DuplicateOddIndexedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void DuplicateOddIndexedSingle() public sealed unsafe class SimpleUnaryOpTest__DuplicateOddIndexedSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__DuplicateOddIndexedSingle testClass) + { + var result = Avx.DuplicateOddIndexed(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__DuplicateOddIndexedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__DuplicateOddIndexedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__DuplicateOddIndexedSingle(); var result = Avx.DuplicateOddIndexed(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.DuplicateOddIndexed(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.DuplicateOddIndexed(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Byte.cs index a84bd435ca06..02a254da5981 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Byte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Byte() { - var test = new SimpleUnaryOpTest__ExtendToVector256Byte(); + var test = new GenericUnaryOpTest__ExtendToVector256Byte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Byte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Byte() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Byte + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Byte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Byte testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Byte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Byte() + static GenericUnaryOpTest__ExtendToVector256Byte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256Byte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Byte() + public GenericUnaryOpTest__ExtendToVector256Byte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Byte(); + var test = new GenericUnaryOpTest__ExtendToVector256Byte(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Double.cs index 75f635d53f8b..0c21147f6d1d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Double.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Double() { - var test = new SimpleUnaryOpTest__ExtendToVector256Double(); + var test = new GenericUnaryOpTest__ExtendToVector256Double(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Double() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Double() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Double + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Double { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Double testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Double private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Double() + static GenericUnaryOpTest__ExtendToVector256Double() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Double() + public GenericUnaryOpTest__ExtendToVector256Double() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Double(); + var test = new GenericUnaryOpTest__ExtendToVector256Double(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int16.cs index 99d8a7580458..74d514bed8d4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Int16() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int16(); + var test = new GenericUnaryOpTest__ExtendToVector256Int16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Int16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Int16() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int16 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Int16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Int16 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Int16() + static GenericUnaryOpTest__ExtendToVector256Int16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256Int16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Int16() + public GenericUnaryOpTest__ExtendToVector256Int16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int16(); + var test = new GenericUnaryOpTest__ExtendToVector256Int16(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int32.cs index 97da6a6fb096..09e87ca43b55 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Int32() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int32(); + var test = new GenericUnaryOpTest__ExtendToVector256Int32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Int32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Int32() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int32 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Int32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Int32 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Int32() + static GenericUnaryOpTest__ExtendToVector256Int32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256Int32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Int32() + public GenericUnaryOpTest__ExtendToVector256Int32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int32(); + var test = new GenericUnaryOpTest__ExtendToVector256Int32(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int64.cs index dd181a0db935..6389c973a31b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Int64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Int64() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int64(); + var test = new GenericUnaryOpTest__ExtendToVector256Int64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Int64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Int64() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int64 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Int64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Int64 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Int64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Int64() + static GenericUnaryOpTest__ExtendToVector256Int64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256Int64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Int64() + public GenericUnaryOpTest__ExtendToVector256Int64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Int64(); + var test = new GenericUnaryOpTest__ExtendToVector256Int64(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.SByte.cs index a8a83d7b288b..9722dbdb3fde 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.SByte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256SByte() { - var test = new SimpleUnaryOpTest__ExtendToVector256SByte(); + var test = new GenericUnaryOpTest__ExtendToVector256SByte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256SByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256SByte() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256SByte + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256SByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256SByte testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256SByte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256SByte() + static GenericUnaryOpTest__ExtendToVector256SByte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256SByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256SByte() + public GenericUnaryOpTest__ExtendToVector256SByte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256SByte(); + var test = new GenericUnaryOpTest__ExtendToVector256SByte(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Single.cs index 44be3a25a3c2..104b96f83b05 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.Single.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256Single() { - var test = new SimpleUnaryOpTest__ExtendToVector256Single(); + var test = new GenericUnaryOpTest__ExtendToVector256Single(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256Single() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256Single() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Single + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256Single { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256Single testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256Single private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256Single() + static GenericUnaryOpTest__ExtendToVector256Single() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256Single() + public GenericUnaryOpTest__ExtendToVector256Single() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256Single(); + var test = new GenericUnaryOpTest__ExtendToVector256Single(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt16.cs index f2f1d3747dab..65e9386a47f3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256UInt16() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt16(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256UInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256UInt16() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt16 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256UInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256UInt16 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256UInt16() + static GenericUnaryOpTest__ExtendToVector256UInt16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256UInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256UInt16() + public GenericUnaryOpTest__ExtendToVector256UInt16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt16(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt16(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt32.cs index 6a9d7908a9ad..b30299a925fb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256UInt32() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt32(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256UInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256UInt32() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt32 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256UInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256UInt32 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256UInt32() + static GenericUnaryOpTest__ExtendToVector256UInt32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256UInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256UInt32() + public GenericUnaryOpTest__ExtendToVector256UInt32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt32(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt32(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt64.cs index 3e504b119eae..fdeefd7ee390 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtendToVector256.UInt64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtendToVector256UInt64() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt64(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtendToVector256UInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtendToVector256UInt64() } } - public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt64 + public sealed unsafe class GenericUnaryOpTest__ExtendToVector256UInt64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__ExtendToVector256UInt64 testClass) + { + var result = Avx.ExtendToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtendToVector256UInt64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtendToVector256UInt64() + static GenericUnaryOpTest__ExtendToVector256UInt64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtendToVector256UInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtendToVector256UInt64() + public GenericUnaryOpTest__ExtendToVector256UInt64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtendToVector256UInt64(); + var test = new GenericUnaryOpTest__ExtendToVector256UInt64(); var result = Avx.ExtendToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.ExtendToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.ExtendToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.1.cs index 2c59dfdf730a..1afb0403f65d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractByte1() { - var test = new SimpleUnaryOpTest__ExtractByte1(); - - try - { + var test = new ExtractScalarTest__ExtractByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractByte1 + public sealed unsafe class ExtractScalarTest__ExtractByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractByte1 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractByte1() + static ExtractScalarTest__ExtractByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractByte1() + public ExtractScalarTest__ExtractByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractByte1(); + var test = new ExtractScalarTest__ExtractByte1(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.20.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.20.cs index 068e812b00ec..247845d34222 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.20.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.20.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractByte20() { - var test = new SimpleUnaryOpTest__ExtractByte20(); - - try - { + var test = new ExtractScalarTest__ExtractByte20(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractByte20() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractByte20() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractByte20 + public sealed unsafe class ExtractScalarTest__ExtractByte20 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractByte20 testClass) + { + var result = Avx.Extract(_fld, 20); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractByte20 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractByte20() + static ExtractScalarTest__ExtractByte20() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractByte20() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractByte20() + public ExtractScalarTest__ExtractByte20() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractByte20() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractByte20(); + var test = new ExtractScalarTest__ExtractByte20(); var result = Avx.Extract(test._fld, 20); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 20); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 20); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.52.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.52.cs index 4f39a52795a0..d67f0b1b141c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.52.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Byte.52.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractByte52() { - var test = new SimpleUnaryOpTest__ExtractByte52(); - - try - { + var test = new ExtractScalarTest__ExtractByte52(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractByte52() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractByte52() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractByte52 + public sealed unsafe class ExtractScalarTest__ExtractByte52 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractByte52 testClass) + { + var result = Avx.Extract(_fld, 52); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractByte52 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractByte52() + static ExtractScalarTest__ExtractByte52() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractByte52() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractByte52() + public ExtractScalarTest__ExtractByte52() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractByte52() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractByte52(); + var test = new ExtractScalarTest__ExtractByte52(); var result = Avx.Extract(test._fld, 52); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 52); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 52); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs deleted file mode 100644 index 157ae1696f33..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.1.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractInt161() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt161 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - var result = Avx.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs deleted file mode 100644 index ba511b820092..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.11.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractInt1611() - { - var test = new SimpleUnaryOpTest__ExtractInt1611(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt1611 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt1611() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt1611() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)11 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 11 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt1611(); - var result = Avx.Extract(test._fld, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 11); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[11])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs deleted file mode 100644 index 83d73dacf628..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int16.27.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractInt1627() - { - var test = new SimpleUnaryOpTest__ExtractInt1627(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt1627 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt1627() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt1627() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)), - (byte)27 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 27 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt1627(); - var result = Avx.Extract(test._fld, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 27); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[11])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.1.cs index 133d65a06e37..61a19f77d79b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt321() { - var test = new SimpleUnaryOpTest__ExtractInt321(); - - try - { + var test = new ExtractScalarTest__ExtractInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt321 + public sealed unsafe class ExtractScalarTest__ExtractInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt321 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt321() + static ExtractScalarTest__ExtractInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt321() + public ExtractScalarTest__ExtractInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt321(); + var test = new ExtractScalarTest__ExtractInt321(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.22.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.22.cs index bd79d925cf05..499ca1c12e79 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.22.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.22.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt3222() { - var test = new SimpleUnaryOpTest__ExtractInt3222(); - - try - { + var test = new ExtractScalarTest__ExtractInt3222(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt3222() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt3222() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt3222 + public sealed unsafe class ExtractScalarTest__ExtractInt3222 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt3222 testClass) + { + var result = Avx.Extract(_fld, 22); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt3222 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt3222() + static ExtractScalarTest__ExtractInt3222() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt3222() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt3222() + public ExtractScalarTest__ExtractInt3222() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt3222() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt3222(); + var test = new ExtractScalarTest__ExtractInt3222(); var result = Avx.Extract(test._fld, 22); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 22); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 22); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.6.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.6.cs index 0e42ec785d47..bcfdbbb218c4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.6.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int32.6.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt326() { - var test = new SimpleUnaryOpTest__ExtractInt326(); - - try - { + var test = new ExtractScalarTest__ExtractInt326(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt326() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt326() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt326 + public sealed unsafe class ExtractScalarTest__ExtractInt326 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt326 testClass) + { + var result = Avx.Extract(_fld, 6); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt326 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt326() + static ExtractScalarTest__ExtractInt326() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt326() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt326() + public ExtractScalarTest__ExtractInt326() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt326() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt326(); + var test = new ExtractScalarTest__ExtractInt326(); var result = Avx.Extract(test._fld, 6); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 6); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 6); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.1.cs index 2213721e5225..969241461d7d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt641() { - var test = new SimpleUnaryOpTest__ExtractInt641(); - - try - { + var test = new ExtractScalarTest__ExtractInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt641 + public sealed unsafe class ExtractScalarTest__ExtractInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt641 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt641() + static ExtractScalarTest__ExtractInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt641() + public ExtractScalarTest__ExtractInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt641(); + var test = new ExtractScalarTest__ExtractInt641(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.19.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.19.cs index 24e72078037f..50484863e68d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.19.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.19.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt6419() { - var test = new SimpleUnaryOpTest__ExtractInt6419(); - - try - { + var test = new ExtractScalarTest__ExtractInt6419(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt6419() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt6419() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt6419 + public sealed unsafe class ExtractScalarTest__ExtractInt6419 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt6419 testClass) + { + var result = Avx.Extract(_fld, 19); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt6419 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt6419() + static ExtractScalarTest__ExtractInt6419() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt6419() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt6419() + public ExtractScalarTest__ExtractInt6419() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt6419() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt6419(); + var test = new ExtractScalarTest__ExtractInt6419(); var result = Avx.Extract(test._fld, 19); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 19); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 19); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.3.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.3.cs index fb89cd06a804..e7d8270388b0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.3.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.Int64.3.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt643() { - var test = new SimpleUnaryOpTest__ExtractInt643(); - - try - { + var test = new ExtractScalarTest__ExtractInt643(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt643() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt643() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt643 + public sealed unsafe class ExtractScalarTest__ExtractInt643 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt643 testClass) + { + var result = Avx.Extract(_fld, 3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt643 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt643() + static ExtractScalarTest__ExtractInt643() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt643() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt643() + public ExtractScalarTest__ExtractInt643() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt643() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt643(); + var test = new ExtractScalarTest__ExtractInt643(); var result = Avx.Extract(test._fld, 3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 3); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs deleted file mode 100644 index 387e00b548ea..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.1.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractSByte1() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte1 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - var result = Avx.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs deleted file mode 100644 index 4fb463acd804..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.20.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractSByte20() - { - var test = new SimpleUnaryOpTest__ExtractSByte20(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte20 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte20() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte20() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)20 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 20 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte20(); - var result = Avx.Extract(test._fld, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 20); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[20])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs deleted file mode 100644 index 391703f2d9aa..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.SByte.52.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractSByte52() - { - var test = new SimpleUnaryOpTest__ExtractSByte52(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Avx.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte52 - { - private static readonly int LargestVectorSize = 32; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector256 _clsVar; - - private Vector256 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte52() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte52() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Avx.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Avx.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Avx.Extract( - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Avx.Extract( - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Avx).GetMethod(nameof(Avx.Extract), new Type[] { typeof(Vector256), typeof(byte) }) - .Invoke(null, new object[] { - Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)), - (byte)52 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Avx.Extract( - _clsVar, - 52 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); - var result = Avx.Extract(firstOp, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte52(); - var result = Avx.Extract(test._fld, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Avx.Extract(_fld, 52); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector256 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[20])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Extract)}(Vector256<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.1.cs index 717749c9bafb..f1d71842cc2c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt161() { - var test = new SimpleUnaryOpTest__ExtractUInt161(); - - try - { + var test = new ExtractScalarTest__ExtractUInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt161 + public sealed unsafe class ExtractScalarTest__ExtractUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt161 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt161() + static ExtractScalarTest__ExtractUInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt161() + public ExtractScalarTest__ExtractUInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt161(); + var test = new ExtractScalarTest__ExtractUInt161(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.11.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.11.cs index b68ab35dedf1..ab7500766376 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.11.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.11.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt1611() { - var test = new SimpleUnaryOpTest__ExtractUInt1611(); - - try - { + var test = new ExtractScalarTest__ExtractUInt1611(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt1611() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt1611() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt1611 + public sealed unsafe class ExtractScalarTest__ExtractUInt1611 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt1611 testClass) + { + var result = Avx.Extract(_fld, 11); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt1611 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt1611() + static ExtractScalarTest__ExtractUInt1611() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt1611() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt1611() + public ExtractScalarTest__ExtractUInt1611() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt1611() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt1611(); + var test = new ExtractScalarTest__ExtractUInt1611(); var result = Avx.Extract(test._fld, 11); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 11); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 11); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.27.cs index 9ece246b5488..1e88bbdfd807 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.27.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt16.27.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt1627() { - var test = new SimpleUnaryOpTest__ExtractUInt1627(); - - try - { + var test = new ExtractScalarTest__ExtractUInt1627(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt1627() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt1627() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt1627 + public sealed unsafe class ExtractScalarTest__ExtractUInt1627 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt1627 testClass) + { + var result = Avx.Extract(_fld, 27); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt1627 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt1627() + static ExtractScalarTest__ExtractUInt1627() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt1627() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt1627() + public ExtractScalarTest__ExtractUInt1627() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt1627() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt1627(); + var test = new ExtractScalarTest__ExtractUInt1627(); var result = Avx.Extract(test._fld, 27); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 27); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.1.cs index 846efb1b2cfd..c96bcefa1f42 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt321() { - var test = new SimpleUnaryOpTest__ExtractUInt321(); - - try - { + var test = new ExtractScalarTest__ExtractUInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt321 + public sealed unsafe class ExtractScalarTest__ExtractUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt321 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt321() + static ExtractScalarTest__ExtractUInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt321() + public ExtractScalarTest__ExtractUInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt321(); + var test = new ExtractScalarTest__ExtractUInt321(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.22.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.22.cs index 7251ef78035c..0ac84ea9b85d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.22.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.22.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt3222() { - var test = new SimpleUnaryOpTest__ExtractUInt3222(); - - try - { + var test = new ExtractScalarTest__ExtractUInt3222(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt3222() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt3222() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt3222 + public sealed unsafe class ExtractScalarTest__ExtractUInt3222 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt3222 testClass) + { + var result = Avx.Extract(_fld, 22); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt3222 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt3222() + static ExtractScalarTest__ExtractUInt3222() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt3222() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt3222() + public ExtractScalarTest__ExtractUInt3222() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt3222() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt3222(); + var test = new ExtractScalarTest__ExtractUInt3222(); var result = Avx.Extract(test._fld, 22); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 22); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 22); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.6.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.6.cs index 6546a7e0979c..d5f7ebd95ed2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.6.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt32.6.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt326() { - var test = new SimpleUnaryOpTest__ExtractUInt326(); - - try - { + var test = new ExtractScalarTest__ExtractUInt326(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt326() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt326() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt326 + public sealed unsafe class ExtractScalarTest__ExtractUInt326 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt326 testClass) + { + var result = Avx.Extract(_fld, 6); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt326 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt326() + static ExtractScalarTest__ExtractUInt326() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt326() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt326() + public ExtractScalarTest__ExtractUInt326() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt326() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt326(); + var test = new ExtractScalarTest__ExtractUInt326(); var result = Avx.Extract(test._fld, 6); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 6); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 6); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.1.cs index 9f6315a58ea7..02a92b954ccf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt641() { - var test = new SimpleUnaryOpTest__ExtractUInt641(); - - try - { + var test = new ExtractScalarTest__ExtractUInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt641 + public sealed unsafe class ExtractScalarTest__ExtractUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt641 testClass) + { + var result = Avx.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt641() + static ExtractScalarTest__ExtractUInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt641() + public ExtractScalarTest__ExtractUInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt641(); + var test = new ExtractScalarTest__ExtractUInt641(); var result = Avx.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.19.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.19.cs index d3d90d8bd66f..52ce9a273de8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.19.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.19.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt6419() { - var test = new SimpleUnaryOpTest__ExtractUInt6419(); - - try - { + var test = new ExtractScalarTest__ExtractUInt6419(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt6419() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt6419() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt6419 + public sealed unsafe class ExtractScalarTest__ExtractUInt6419 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt6419 testClass) + { + var result = Avx.Extract(_fld, 19); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt6419 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt6419() + static ExtractScalarTest__ExtractUInt6419() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt6419() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt6419() + public ExtractScalarTest__ExtractUInt6419() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt6419() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt6419(); + var test = new ExtractScalarTest__ExtractUInt6419(); var result = Avx.Extract(test._fld, 19); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 19); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 19); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.3.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.3.cs index 8b3f3cfba6a2..52f92c4a6a5d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.3.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Extract.UInt64.3.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt643() { - var test = new SimpleUnaryOpTest__ExtractUInt643(); - - try - { + var test = new ExtractScalarTest__ExtractUInt643(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt643() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt643() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt643 + public sealed unsafe class ExtractScalarTest__ExtractUInt643 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt643 testClass) + { + var result = Avx.Extract(_fld, 3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt643 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt643() + static ExtractScalarTest__ExtractUInt643() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt643() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt643() + public ExtractScalarTest__ExtractUInt643() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt643() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt643(); + var test = new ExtractScalarTest__ExtractUInt643(); var result = Avx.Extract(test._fld, 3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Extract(_fld, 3); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Extract(test._fld, 3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs index 844edcc9d2ba..ccb6fedadcf7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Byte.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Byte1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1Store(); + var test = new ExtractStoreTest__ExtractVector128Byte1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Byte1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Byte1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Byte1 testClass) + { + Avx.ExtractVector128((Byte*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Byte1Store() + static ExtractStoreTest__ExtractVector128Byte1() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Byte1Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Byte1Store() + public ExtractStoreTest__ExtractVector128Byte1() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1Store(); + var test = new ExtractStoreTest__ExtractVector128Byte1(); Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs index d55515d2a7f5..f049585ffcea 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Double.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Double1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Double1Store(); + var test = new ExtractStoreTest__ExtractVector128Double1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Double1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Double1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Double1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Double1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Double1 testClass) + { + Avx.ExtractVector128((Double*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -99,24 +127,24 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Double1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Double1Store() + static ExtractStoreTest__ExtractVector128Double1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Double1Store() + public ExtractStoreTest__ExtractVector128Double1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Double1Store(); + var test = new ExtractStoreTest__ExtractVector128Double1(); Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Double*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs index 8b073bd2701d..8333f88f37cc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int16.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int161Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161Store(); + var test = new ExtractStoreTest__ExtractVector128Int161(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int161Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int161Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int161 testClass) + { + Avx.ExtractVector128((Int16*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int161Store() + static ExtractStoreTest__ExtractVector128Int161() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int161Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int161Store() + public ExtractStoreTest__ExtractVector128Int161() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161Store(); + var test = new ExtractStoreTest__ExtractVector128Int161(); Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs index 7b55d154d6bf..3a168adad405 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int32.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int321Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321Store(); + var test = new ExtractStoreTest__ExtractVector128Int321(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int321Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int321Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int321 testClass) + { + Avx.ExtractVector128((Int32*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int321Store() + static ExtractStoreTest__ExtractVector128Int321() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int321Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int321Store() + public ExtractStoreTest__ExtractVector128Int321() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321Store(); + var test = new ExtractStoreTest__ExtractVector128Int321(); Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs index c683405c3b78..265775bec818 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Int64.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int641Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641Store(); + var test = new ExtractStoreTest__ExtractVector128Int641(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int641Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int641Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int641 testClass) + { + Avx.ExtractVector128((Int64*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int641Store() + static ExtractStoreTest__ExtractVector128Int641() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int641Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int641Store() + public ExtractStoreTest__ExtractVector128Int641() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641Store(); + var test = new ExtractStoreTest__ExtractVector128Int641(); Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs index 25d4cfc6232c..a0675a69305b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.SByte.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128SByte1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1Store(); + var test = new ExtractStoreTest__ExtractVector128SByte1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128SByte1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128SByte1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128SByte1 testClass) + { + Avx.ExtractVector128((SByte*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128SByte1Store() + static ExtractStoreTest__ExtractVector128SByte1() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128SByte1Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128SByte1Store() + public ExtractStoreTest__ExtractVector128SByte1() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1Store(); + var test = new ExtractStoreTest__ExtractVector128SByte1(); Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs index 03c29d2a0e83..742dac0b8ba0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.Single.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Single1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Single1Store(); + var test = new ExtractStoreTest__ExtractVector128Single1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Single1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Single1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Single1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Single1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Single1 testClass) + { + Avx.ExtractVector128((Single*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -99,24 +127,24 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Single1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Single1Store() + static ExtractStoreTest__ExtractVector128Single1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Single1Store() + public ExtractStoreTest__ExtractVector128Single1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Single1Store(); + var test = new ExtractStoreTest__ExtractVector128Single1(); Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((Single*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs index 2deda23f9a64..3fe565dd5ad3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt16.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt161Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161Store(); + var test = new ExtractStoreTest__ExtractVector128UInt161(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt161Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt161Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt161 testClass) + { + Avx.ExtractVector128((UInt16*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt161Store() + static ExtractStoreTest__ExtractVector128UInt161() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt161Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt161Store() + public ExtractStoreTest__ExtractVector128UInt161() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161Store(); + var test = new ExtractStoreTest__ExtractVector128UInt161(); Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs index 53769a5194c0..4e0f64f09399 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt32.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt321Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321Store(); + var test = new ExtractStoreTest__ExtractVector128UInt321(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt321Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt321Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt321 testClass) + { + Avx.ExtractVector128((UInt32*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt321Store() + static ExtractStoreTest__ExtractVector128UInt321() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt321Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt321Store() + public ExtractStoreTest__ExtractVector128UInt321() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321Store(); + var test = new ExtractStoreTest__ExtractVector128UInt321(); Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs index 949d618a03d8..67e47638a6b9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/ExtractVector128.UInt64.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt641Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641Store(); + var test = new ExtractStoreTest__ExtractVector128UInt641(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt641Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt641Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt641 testClass) + { + Avx.ExtractVector128((UInt64*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt641Store() + static ExtractStoreTest__ExtractVector128UInt641() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt641Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt641Store() + public ExtractStoreTest__ExtractVector128UInt641() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)); Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641Store(); + var test = new ExtractStoreTest__ExtractVector128UInt641(); Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs index d616cf19d40f..37975374fe25 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs @@ -64,11 +64,17 @@ private static void FloorDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void FloorDouble() public sealed unsafe class SimpleUnaryOpTest__FloorDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__FloorDouble testClass) + { + var result = Avx.Floor(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__FloorDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__FloorDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__FloorDouble(); var result = Avx.Floor(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Floor(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Floor(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs index f85a61495158..ab0b10b3292b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs @@ -64,11 +64,17 @@ private static void FloorSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void FloorSingle() public sealed unsafe class SimpleUnaryOpTest__FloorSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__FloorSingle testClass) + { + var result = Avx.Floor(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__FloorSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__FloorSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__FloorSingle(); var result = Avx.Floor(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Floor(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Floor(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Byte.cs index b8bb560f1435..d8b50873f679 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Byte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfByte() { - var test = new SimpleUnaryOpTest__GetLowerHalfByte(); + var test = new GenericUnaryOpTest__GetLowerHalfByte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfByte() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfByte + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfByte { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfByte testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfByte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfByte() + static GenericUnaryOpTest__GetLowerHalfByte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfByte() + public GenericUnaryOpTest__GetLowerHalfByte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfByte(); + var test = new GenericUnaryOpTest__GetLowerHalfByte(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Double.cs index 604d537e867f..55a8728096cb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Double.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfDouble() { - var test = new SimpleUnaryOpTest__GetLowerHalfDouble(); + var test = new GenericUnaryOpTest__GetLowerHalfDouble(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfDouble() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfDouble + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfDouble testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfDouble private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfDouble() + static GenericUnaryOpTest__GetLowerHalfDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfDouble() + public GenericUnaryOpTest__GetLowerHalfDouble() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfDouble(); + var test = new GenericUnaryOpTest__GetLowerHalfDouble(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int16.cs index 30d48a1176eb..1c6ddcd83b6b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfInt16() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt16(); + var test = new GenericUnaryOpTest__GetLowerHalfInt16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfInt16() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt16 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfInt16 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfInt16 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfInt16() + static GenericUnaryOpTest__GetLowerHalfInt16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfInt16() + public GenericUnaryOpTest__GetLowerHalfInt16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt16(); + var test = new GenericUnaryOpTest__GetLowerHalfInt16(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int32.cs index ade78b59073e..82bb872293fc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfInt32() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt32(); + var test = new GenericUnaryOpTest__GetLowerHalfInt32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfInt32() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt32 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfInt32 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfInt32 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfInt32() + static GenericUnaryOpTest__GetLowerHalfInt32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfInt32() + public GenericUnaryOpTest__GetLowerHalfInt32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt32(); + var test = new GenericUnaryOpTest__GetLowerHalfInt32(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int64.cs index 9c17b248decd..cd5a6f5843fa 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Int64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfInt64() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt64(); + var test = new GenericUnaryOpTest__GetLowerHalfInt64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfInt64() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt64 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfInt64 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfInt64 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfInt64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfInt64() + static GenericUnaryOpTest__GetLowerHalfInt64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfInt64() + public GenericUnaryOpTest__GetLowerHalfInt64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfInt64(); + var test = new GenericUnaryOpTest__GetLowerHalfInt64(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.SByte.cs index 51e1f79165ec..ca2d196865e9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.SByte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfSByte() { - var test = new SimpleUnaryOpTest__GetLowerHalfSByte(); + var test = new GenericUnaryOpTest__GetLowerHalfSByte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfSByte() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfSByte + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfSByte { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfSByte testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfSByte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfSByte() + static GenericUnaryOpTest__GetLowerHalfSByte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfSByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfSByte() + public GenericUnaryOpTest__GetLowerHalfSByte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfSByte(); + var test = new GenericUnaryOpTest__GetLowerHalfSByte(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Single.cs index cb29e95568bc..dfbb503ae9c5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.Single.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfSingle() { - var test = new SimpleUnaryOpTest__GetLowerHalfSingle(); + var test = new GenericUnaryOpTest__GetLowerHalfSingle(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfSingle() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfSingle + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfSingle testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfSingle private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfSingle() + static GenericUnaryOpTest__GetLowerHalfSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfSingle() + public GenericUnaryOpTest__GetLowerHalfSingle() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfSingle(); + var test = new GenericUnaryOpTest__GetLowerHalfSingle(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt16.cs index 1ce642c1c815..4de1b65bd8d8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfUInt16() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt16(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfUInt16() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt16 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfUInt16 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfUInt16 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfUInt16() + static GenericUnaryOpTest__GetLowerHalfUInt16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfUInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfUInt16() + public GenericUnaryOpTest__GetLowerHalfUInt16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt16(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt16(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt32.cs index 2ef048d1902f..289cc6e580eb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfUInt32() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt32(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfUInt32() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt32 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfUInt32 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfUInt32 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfUInt32() + static GenericUnaryOpTest__GetLowerHalfUInt32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfUInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfUInt32() + public GenericUnaryOpTest__GetLowerHalfUInt32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt32(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt32(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt64.cs index 06727e54df4e..e177a26cc3d1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/GetLowerHalf.UInt64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void GetLowerHalfUInt64() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt64(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void GetLowerHalfUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void GetLowerHalfUInt64() } } - public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt64 + public sealed unsafe class GenericUnaryOpTest__GetLowerHalfUInt64 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__GetLowerHalfUInt64 testClass) + { + var result = Avx.GetLowerHalf(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__GetLowerHalfUInt64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__GetLowerHalfUInt64() + static GenericUnaryOpTest__GetLowerHalfUInt64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__GetLowerHalfUInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__GetLowerHalfUInt64() + public GenericUnaryOpTest__GetLowerHalfUInt64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__GetLowerHalfUInt64(); + var test = new GenericUnaryOpTest__GetLowerHalfUInt64(); var result = Avx.GetLowerHalf(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.GetLowerHalf(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.GetLowerHalf(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.1.cs index d596cfc7f11e..4279421be9a3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertByte1() { - var test = new SimpleUnaryOpTest__InsertByte1(); - - try - { + var test = new InsertScalarTest__InsertByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertByte1() } } - public sealed unsafe class SimpleUnaryOpTest__InsertByte1 + public sealed unsafe class InsertScalarTest__InsertByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertByte1 testClass) + { + var result = Avx.Insert(_fld, (byte)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertByte1() + static InsertScalarTest__InsertByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertByte1() + public InsertScalarTest__InsertByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertByte1(); + var test = new InsertScalarTest__InsertByte1(); var result = Avx.Insert(test._fld, (byte)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (byte)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (byte)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.20.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.20.cs index 73ccb9dfd8d2..9782ff6d2b47 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.20.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.20.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertByte20() { - var test = new SimpleUnaryOpTest__InsertByte20(); - - try - { + var test = new InsertScalarTest__InsertByte20(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertByte20() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertByte20() } } - public sealed unsafe class SimpleUnaryOpTest__InsertByte20 + public sealed unsafe class InsertScalarTest__InsertByte20 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertByte20 testClass) + { + var result = Avx.Insert(_fld, (byte)2, 20); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertByte20 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertByte20() + static InsertScalarTest__InsertByte20() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertByte20() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertByte20() + public InsertScalarTest__InsertByte20() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertByte20() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertByte20(); + var test = new InsertScalarTest__InsertByte20(); var result = Avx.Insert(test._fld, (byte)2, 20); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (byte)2, 20); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (byte)2, 20); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.52.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.52.cs index 218f984165cf..39e1837e990d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.52.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Byte.52.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertByte52() { - var test = new SimpleUnaryOpTest__InsertByte52(); - - try - { + var test = new InsertScalarTest__InsertByte52(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertByte52() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertByte52() } } - public sealed unsafe class SimpleUnaryOpTest__InsertByte52 + public sealed unsafe class InsertScalarTest__InsertByte52 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertByte52 testClass) + { + var result = Avx.Insert(_fld, (byte)2, 52); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertByte52 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertByte52() + static InsertScalarTest__InsertByte52() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertByte52() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertByte52() + public InsertScalarTest__InsertByte52() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertByte52() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertByte52(); + var test = new InsertScalarTest__InsertByte52(); var result = Avx.Insert(test._fld, (byte)2, 52); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (byte)2, 52); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (byte)2, 52); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.1.cs index 1899ec728c87..715c9c49d999 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt161() { - var test = new SimpleUnaryOpTest__InsertInt161(); - - try - { + var test = new InsertScalarTest__InsertInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt161() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt161 + public sealed unsafe class InsertScalarTest__InsertInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt161 testClass) + { + var result = Avx.Insert(_fld, (short)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt161() + static InsertScalarTest__InsertInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt161() + public InsertScalarTest__InsertInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt161(); + var test = new InsertScalarTest__InsertInt161(); var result = Avx.Insert(test._fld, (short)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (short)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (short)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.11.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.11.cs index 7e3049b42893..fecb2605a8d5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.11.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.11.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt1611() { - var test = new SimpleUnaryOpTest__InsertInt1611(); - - try - { + var test = new InsertScalarTest__InsertInt1611(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt1611() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt1611() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt1611 + public sealed unsafe class InsertScalarTest__InsertInt1611 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt1611 testClass) + { + var result = Avx.Insert(_fld, (short)2, 11); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt1611 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt1611() + static InsertScalarTest__InsertInt1611() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt1611() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt1611() + public InsertScalarTest__InsertInt1611() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt1611() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt1611(); + var test = new InsertScalarTest__InsertInt1611(); var result = Avx.Insert(test._fld, (short)2, 11); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (short)2, 11); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (short)2, 11); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.27.cs index 373db0f0238b..5c8ba0a34b99 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.27.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int16.27.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt1627() { - var test = new SimpleUnaryOpTest__InsertInt1627(); - - try - { + var test = new InsertScalarTest__InsertInt1627(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt1627() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt1627() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt1627 + public sealed unsafe class InsertScalarTest__InsertInt1627 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt1627 testClass) + { + var result = Avx.Insert(_fld, (short)2, 27); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt1627 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt1627() + static InsertScalarTest__InsertInt1627() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt1627() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt1627() + public InsertScalarTest__InsertInt1627() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt1627() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt1627(); + var test = new InsertScalarTest__InsertInt1627(); var result = Avx.Insert(test._fld, (short)2, 27); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (short)2, 27); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (short)2, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.1.cs index 0e2d1eb8bb44..3ba748680ce7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt321() { - var test = new SimpleUnaryOpTest__InsertInt321(); - - try - { + var test = new InsertScalarTest__InsertInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt321() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt321 + public sealed unsafe class InsertScalarTest__InsertInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt321 testClass) + { + var result = Avx.Insert(_fld, (int)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt321() + static InsertScalarTest__InsertInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt321() + public InsertScalarTest__InsertInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt321(); + var test = new InsertScalarTest__InsertInt321(); var result = Avx.Insert(test._fld, (int)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (int)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (int)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.22.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.22.cs index 9740754b8007..9c3f35be248d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.22.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.22.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt3222() { - var test = new SimpleUnaryOpTest__InsertInt3222(); - - try - { + var test = new InsertScalarTest__InsertInt3222(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt3222() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt3222() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt3222 + public sealed unsafe class InsertScalarTest__InsertInt3222 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt3222 testClass) + { + var result = Avx.Insert(_fld, (int)2, 22); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt3222 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt3222() + static InsertScalarTest__InsertInt3222() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt3222() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt3222() + public InsertScalarTest__InsertInt3222() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt3222() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt3222(); + var test = new InsertScalarTest__InsertInt3222(); var result = Avx.Insert(test._fld, (int)2, 22); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (int)2, 22); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (int)2, 22); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.6.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.6.cs index 2b1da8784020..fd5afdf87b6f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.6.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int32.6.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt326() { - var test = new SimpleUnaryOpTest__InsertInt326(); - - try - { + var test = new InsertScalarTest__InsertInt326(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt326() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt326() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt326 + public sealed unsafe class InsertScalarTest__InsertInt326 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt326 testClass) + { + var result = Avx.Insert(_fld, (int)2, 6); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt326 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt326() + static InsertScalarTest__InsertInt326() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt326() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt326() + public InsertScalarTest__InsertInt326() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt326() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt326(); + var test = new InsertScalarTest__InsertInt326(); var result = Avx.Insert(test._fld, (int)2, 6); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (int)2, 6); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (int)2, 6); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.1.cs index f17ff1ff20c2..c4774e5e3da9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt641() { - var test = new SimpleUnaryOpTest__InsertInt641(); - - try - { + var test = new InsertScalarTest__InsertInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt641() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt641 + public sealed unsafe class InsertScalarTest__InsertInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt641 testClass) + { + var result = Avx.Insert(_fld, (long)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt641() + static InsertScalarTest__InsertInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt641() + public InsertScalarTest__InsertInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt641(); + var test = new InsertScalarTest__InsertInt641(); var result = Avx.Insert(test._fld, (long)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (long)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (long)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.19.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.19.cs index 012f96493d1c..1babe82c7e6e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.19.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.19.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt6419() { - var test = new SimpleUnaryOpTest__InsertInt6419(); - - try - { + var test = new InsertScalarTest__InsertInt6419(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt6419() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt6419() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt6419 + public sealed unsafe class InsertScalarTest__InsertInt6419 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt6419 testClass) + { + var result = Avx.Insert(_fld, (long)2, 19); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt6419 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt6419() + static InsertScalarTest__InsertInt6419() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt6419() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt6419() + public InsertScalarTest__InsertInt6419() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt6419() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt6419(); + var test = new InsertScalarTest__InsertInt6419(); var result = Avx.Insert(test._fld, (long)2, 19); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (long)2, 19); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (long)2, 19); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.3.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.3.cs index 24471323d265..e28dc8b5ffee 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.3.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.Int64.3.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt643() { - var test = new SimpleUnaryOpTest__InsertInt643(); - - try - { + var test = new InsertScalarTest__InsertInt643(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt643() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt643() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt643 + public sealed unsafe class InsertScalarTest__InsertInt643 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt643 testClass) + { + var result = Avx.Insert(_fld, (long)2, 3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt643 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt643() + static InsertScalarTest__InsertInt643() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt643() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt643() + public InsertScalarTest__InsertInt643() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt643() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt643(); + var test = new InsertScalarTest__InsertInt643(); var result = Avx.Insert(test._fld, (long)2, 3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (long)2, 3); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (long)2, 3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.1.cs index ca6d9f5e3904..3a4a1d237831 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertSByte1() { - var test = new SimpleUnaryOpTest__InsertSByte1(); - - try - { + var test = new InsertScalarTest__InsertSByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSByte1 + public sealed unsafe class InsertScalarTest__InsertSByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertSByte1 testClass) + { + var result = Avx.Insert(_fld, (sbyte)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSByte1() + static InsertScalarTest__InsertSByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSByte1() + public InsertScalarTest__InsertSByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertSByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertSByte1(); + var test = new InsertScalarTest__InsertSByte1(); var result = Avx.Insert(test._fld, (sbyte)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (sbyte)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (sbyte)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.20.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.20.cs index 917aba5300bb..97549a1e2654 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.20.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.20.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertSByte20() { - var test = new SimpleUnaryOpTest__InsertSByte20(); - - try - { + var test = new InsertScalarTest__InsertSByte20(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertSByte20() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertSByte20() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSByte20 + public sealed unsafe class InsertScalarTest__InsertSByte20 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertSByte20 testClass) + { + var result = Avx.Insert(_fld, (sbyte)2, 20); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertSByte20 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSByte20() + static InsertScalarTest__InsertSByte20() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertSByte20() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSByte20() + public InsertScalarTest__InsertSByte20() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertSByte20() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertSByte20(); + var test = new InsertScalarTest__InsertSByte20(); var result = Avx.Insert(test._fld, (sbyte)2, 20); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (sbyte)2, 20); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (sbyte)2, 20); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.52.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.52.cs index cbbaa73d1c20..3c5d502680f5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.52.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.SByte.52.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertSByte52() { - var test = new SimpleUnaryOpTest__InsertSByte52(); - - try - { + var test = new InsertScalarTest__InsertSByte52(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertSByte52() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertSByte52() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSByte52 + public sealed unsafe class InsertScalarTest__InsertSByte52 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertSByte52 testClass) + { + var result = Avx.Insert(_fld, (sbyte)2, 52); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertSByte52 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSByte52() + static InsertScalarTest__InsertSByte52() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertSByte52() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSByte52() + public InsertScalarTest__InsertSByte52() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertSByte52() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertSByte52(); + var test = new InsertScalarTest__InsertSByte52(); var result = Avx.Insert(test._fld, (sbyte)2, 52); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (sbyte)2, 52); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (sbyte)2, 52); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.1.cs index b17dbdcc34ef..beea0ba05b08 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt161() { - var test = new SimpleUnaryOpTest__InsertUInt161(); - - try - { + var test = new InsertScalarTest__InsertUInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt161 + public sealed unsafe class InsertScalarTest__InsertUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt161 testClass) + { + var result = Avx.Insert(_fld, (ushort)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt161() + static InsertScalarTest__InsertUInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt161() + public InsertScalarTest__InsertUInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt161(); + var test = new InsertScalarTest__InsertUInt161(); var result = Avx.Insert(test._fld, (ushort)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ushort)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ushort)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.11.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.11.cs index 43f4a5a2e9bc..6cb5e5a5e3d2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.11.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.11.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt1611() { - var test = new SimpleUnaryOpTest__InsertUInt1611(); - - try - { + var test = new InsertScalarTest__InsertUInt1611(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt1611() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt1611() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt1611 + public sealed unsafe class InsertScalarTest__InsertUInt1611 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt1611 testClass) + { + var result = Avx.Insert(_fld, (ushort)2, 11); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt1611 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt1611() + static InsertScalarTest__InsertUInt1611() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt1611() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt1611() + public InsertScalarTest__InsertUInt1611() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt1611() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt1611(); + var test = new InsertScalarTest__InsertUInt1611(); var result = Avx.Insert(test._fld, (ushort)2, 11); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ushort)2, 11); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ushort)2, 11); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.27.cs index cff1f45bc4b9..767e920c45a0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.27.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt16.27.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt1627() { - var test = new SimpleUnaryOpTest__InsertUInt1627(); - - try - { + var test = new InsertScalarTest__InsertUInt1627(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt1627() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt1627() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt1627 + public sealed unsafe class InsertScalarTest__InsertUInt1627 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt1627 testClass) + { + var result = Avx.Insert(_fld, (ushort)2, 27); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt1627 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt1627() + static InsertScalarTest__InsertUInt1627() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt1627() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt1627() + public InsertScalarTest__InsertUInt1627() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt1627() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt1627(); + var test = new InsertScalarTest__InsertUInt1627(); var result = Avx.Insert(test._fld, (ushort)2, 27); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ushort)2, 27); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ushort)2, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.1.cs index 608bedef57bf..4c20835d0a13 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt321() { - var test = new SimpleUnaryOpTest__InsertUInt321(); - - try - { + var test = new InsertScalarTest__InsertUInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt321 + public sealed unsafe class InsertScalarTest__InsertUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt321 testClass) + { + var result = Avx.Insert(_fld, (uint)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt321() + static InsertScalarTest__InsertUInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt321() + public InsertScalarTest__InsertUInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt321(); + var test = new InsertScalarTest__InsertUInt321(); var result = Avx.Insert(test._fld, (uint)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (uint)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (uint)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.22.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.22.cs index e3609e8962fa..4766efac8b6c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.22.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.22.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt3222() { - var test = new SimpleUnaryOpTest__InsertUInt3222(); - - try - { + var test = new InsertScalarTest__InsertUInt3222(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt3222() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt3222() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt3222 + public sealed unsafe class InsertScalarTest__InsertUInt3222 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt3222 testClass) + { + var result = Avx.Insert(_fld, (uint)2, 22); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt3222 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt3222() + static InsertScalarTest__InsertUInt3222() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt3222() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt3222() + public InsertScalarTest__InsertUInt3222() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt3222() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt3222(); + var test = new InsertScalarTest__InsertUInt3222(); var result = Avx.Insert(test._fld, (uint)2, 22); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (uint)2, 22); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (uint)2, 22); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.6.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.6.cs index ffd003572abb..993cfa6274b2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.6.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt32.6.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt326() { - var test = new SimpleUnaryOpTest__InsertUInt326(); - - try - { + var test = new InsertScalarTest__InsertUInt326(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt326() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt326() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt326 + public sealed unsafe class InsertScalarTest__InsertUInt326 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt326 testClass) + { + var result = Avx.Insert(_fld, (uint)2, 6); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt326 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt326() + static InsertScalarTest__InsertUInt326() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt326() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt326() + public InsertScalarTest__InsertUInt326() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt326() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt326(); + var test = new InsertScalarTest__InsertUInt326(); var result = Avx.Insert(test._fld, (uint)2, 6); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (uint)2, 6); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (uint)2, 6); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.1.cs index 8ec1dd80f445..bf6cd63d9033 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt641() { - var test = new SimpleUnaryOpTest__InsertUInt641(); - - try - { + var test = new InsertScalarTest__InsertUInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt641 + public sealed unsafe class InsertScalarTest__InsertUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt641 testClass) + { + var result = Avx.Insert(_fld, (ulong)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt641() + static InsertScalarTest__InsertUInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt641() + public InsertScalarTest__InsertUInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt641(); + var test = new InsertScalarTest__InsertUInt641(); var result = Avx.Insert(test._fld, (ulong)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ulong)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ulong)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.19.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.19.cs index f60e347cadbe..bd8f843929be 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.19.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.19.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt6419() { - var test = new SimpleUnaryOpTest__InsertUInt6419(); - - try - { + var test = new InsertScalarTest__InsertUInt6419(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt6419() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt6419() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt6419 + public sealed unsafe class InsertScalarTest__InsertUInt6419 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt6419 testClass) + { + var result = Avx.Insert(_fld, (ulong)2, 19); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt6419 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt6419() + static InsertScalarTest__InsertUInt6419() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt6419() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt6419() + public InsertScalarTest__InsertUInt6419() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt6419() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt6419(); + var test = new InsertScalarTest__InsertUInt6419(); var result = Avx.Insert(test._fld, (ulong)2, 19); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ulong)2, 19); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ulong)2, 19); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.3.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.3.cs index fd815ca985f8..df7bd7a6b577 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.3.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Insert.UInt64.3.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt643() { - var test = new SimpleUnaryOpTest__InsertUInt643(); - - try - { + var test = new InsertScalarTest__InsertUInt643(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt643() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt643() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt643 + public sealed unsafe class InsertScalarTest__InsertUInt643 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt643 testClass) + { + var result = Avx.Insert(_fld, (ulong)2, 3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt643 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt643() + static InsertScalarTest__InsertUInt643() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt643() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt643() + public InsertScalarTest__InsertUInt643() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt643() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Avx.IsSupported; + public bool IsSupported => Avx.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt643(); + var test = new InsertScalarTest__InsertUInt643(); var result = Avx.Insert(test._fld, (ulong)2, 3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Insert(_fld, (ulong)2, 3); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Insert(test._fld, (ulong)2, 3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs index 58d3894af52a..849e6b51b55c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Byte.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Byte1Load() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1Load(); + var test = new InsertLoadTest__InsertVector128Byte1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Byte1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Byte1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1Load + public sealed unsafe class InsertLoadTest__InsertVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Byte1 testClass) + { + var result = Avx.InsertVector128(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Byte1Load() + static InsertLoadTest__InsertVector128Byte1() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Byte1Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Byte1Load() + public InsertLoadTest__InsertVector128Byte1() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1Load(); + var test = new InsertLoadTest__InsertVector128Byte1(); var result = Avx.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Byte*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs index 74ca07cd1e3f..34cfd138f4e4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Double.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Double1Load() { - var test = new SimpleBinaryOpTest__InsertVector128Double1Load(); + var test = new InsertLoadTest__InsertVector128Double1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Double1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Double1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Double1Load + public sealed unsafe class InsertLoadTest__InsertVector128Double1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Double1 testClass) + { + var result = Avx.InsertVector128(_fld1, (Double*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Double*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -104,29 +137,29 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Double1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Double1Load() + static InsertLoadTest__InsertVector128Double1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Double1Load() + public InsertLoadTest__InsertVector128Double1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Double1Load(); + var test = new InsertLoadTest__InsertVector128Double1(); var result = Avx.InsertVector128(test._fld1, (Double*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Double*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Double*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Double*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs index 03247d9ff848..8006b77edaf4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int16.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int161Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int161Load(); + var test = new InsertLoadTest__InsertVector128Int161(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int161Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int161Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161Load + public sealed unsafe class InsertLoadTest__InsertVector128Int161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0,short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int161 testClass) + { + var result = Avx.InsertVector128(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int161Load() + static InsertLoadTest__InsertVector128Int161() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int161Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int161Load() + public InsertLoadTest__InsertVector128Int161() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int161Load(); + var test = new InsertLoadTest__InsertVector128Int161(); var result = Avx.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Int16*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs index 23fa97846605..b6eef6b29f2f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int32.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int321Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int321Load(); + var test = new InsertLoadTest__InsertVector128Int321(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int321Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int321Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321Load + public sealed unsafe class InsertLoadTest__InsertVector128Int321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int321 testClass) + { + var result = Avx.InsertVector128(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int321Load() + static InsertLoadTest__InsertVector128Int321() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int321Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int321Load() + public InsertLoadTest__InsertVector128Int321() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int321Load(); + var test = new InsertLoadTest__InsertVector128Int321(); var result = Avx.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Int32*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs index 3fbc0874225a..81a4f6e3fe40 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Int64.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int641Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int641Load(); + var test = new InsertLoadTest__InsertVector128Int641(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int641Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int641Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641Load + public sealed unsafe class InsertLoadTest__InsertVector128Int641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int641 testClass) + { + var result = Avx.InsertVector128(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int641Load() + static InsertLoadTest__InsertVector128Int641() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int641Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int641Load() + public InsertLoadTest__InsertVector128Int641() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int641Load(); + var test = new InsertLoadTest__InsertVector128Int641(); var result = Avx.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Int64*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs index 881f52996580..0949c32ce49d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.SByte.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128SByte1Load() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1Load(); + var test = new InsertLoadTest__InsertVector128SByte1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128SByte1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128SByte1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1Load + public sealed unsafe class InsertLoadTest__InsertVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0,sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128SByte1 testClass) + { + var result = Avx.InsertVector128(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128SByte1Load() + static InsertLoadTest__InsertVector128SByte1() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128SByte1Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128SByte1Load() + public InsertLoadTest__InsertVector128SByte1() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1Load(); + var test = new InsertLoadTest__InsertVector128SByte1(); var result = Avx.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (SByte*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs index 715484eb319b..9dc951410c73 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.Single.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Single1Load() { - var test = new SimpleBinaryOpTest__InsertVector128Single1Load(); + var test = new InsertLoadTest__InsertVector128Single1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Single1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Single1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Single1Load + public sealed unsafe class InsertLoadTest__InsertVector128Single1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Single1 testClass) + { + var result = Avx.InsertVector128(_fld1, (Single*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Single*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -104,29 +137,29 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Single1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Single1Load() + static InsertLoadTest__InsertVector128Single1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Single1Load() + public InsertLoadTest__InsertVector128Single1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Single1Load(); + var test = new InsertLoadTest__InsertVector128Single1(); var result = Avx.InsertVector128(test._fld1, (Single*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (Single*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (Single*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Single*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs index 745aa55c534e..816f3dd59510 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt16.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt161Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161Load(); + var test = new InsertLoadTest__InsertVector128UInt161(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt161Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt161Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt161 testClass) + { + var result = Avx.InsertVector128(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt161Load() + static InsertLoadTest__InsertVector128UInt161() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt161Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt161Load() + public InsertLoadTest__InsertVector128UInt161() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161Load(); + var test = new InsertLoadTest__InsertVector128UInt161(); var result = Avx.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs index ecc6655e57a1..827d8f387889 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt32.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt321Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321Load(); + var test = new InsertLoadTest__InsertVector128UInt321(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt321Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt321Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt321 testClass) + { + var result = Avx.InsertVector128(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt321Load() + static InsertLoadTest__InsertVector128UInt321() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt321Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt321Load() + public InsertLoadTest__InsertVector128UInt321() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321Load(); + var test = new InsertLoadTest__InsertVector128UInt321(); var result = Avx.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs index 8ed7dfdaaadb..0757b7e81e46 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/InsertVector128.UInt64.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt641Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641Load(); + var test = new InsertLoadTest__InsertVector128UInt641(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt641Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt641Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt641 testClass) + { + var result = Avx.InsertVector128(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt641Load() + static InsertLoadTest__InsertVector128UInt641() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt641Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt641Load() + public InsertLoadTest__InsertVector128UInt641() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641Load(); + var test = new InsertLoadTest__InsertVector128UInt641(); var result = Avx.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.InsertVector128(_fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad.cs index 2a493e095ee4..cb1ca4188fe3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad.cs @@ -24,7 +24,7 @@ static unsafe int Main(string[] args) { using (TestTable floatTable = new TestTable(new float[8] { 1, -5, 100, 0, 1, 2, 3, 4 }, new uint[8] { uint.MaxValue, uint.MaxValue, 0, 0, uint.MaxValue, uint.MaxValue, 0, 0 }, new float[8])) { - Vector256 vf = Avx.MaskLoad((float*)(floatTable.inArrayPtr), Avx.LoadVector256((uint*)(floatTable.maskArrayPtr))); + Vector256 vf = Avx.MaskLoad((float*)(floatTable.inArrayPtr), Avx.LoadVector256((float*)(floatTable.maskArrayPtr))); Unsafe.Write(floatTable.outArrayPtr, vf); if (!floatTable.CheckResult((x, m, y) => m == uint.MaxValue ? BitConverter.SingleToInt32Bits(x) == BitConverter.SingleToInt32Bits(y) : BitConverter.SingleToInt32Bits(y) == 0)) @@ -41,7 +41,7 @@ static unsafe int Main(string[] args) using (TestTable doubleTable = new TestTable(new double[4] { 1, -5, 100, 0}, new ulong[4] { 0, ulong.MaxValue, ulong.MaxValue, 0}, new double[4])) { - Vector256 vf = Avx.MaskLoad((double*)(doubleTable.inArrayPtr), Avx.LoadVector256((ulong*)(doubleTable.maskArrayPtr))); + Vector256 vf = Avx.MaskLoad((double*)(doubleTable.inArrayPtr), Avx.LoadVector256((double*)(doubleTable.maskArrayPtr))); Unsafe.Write(doubleTable.outArrayPtr, vf); if (!doubleTable.CheckResult((x, m, y) => m == ulong.MaxValue ? BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y) : BitConverter.DoubleToInt64Bits(y) == 0)) @@ -58,7 +58,7 @@ static unsafe int Main(string[] args) using (TestTable floatTable = new TestTable(new float[4] { 1, -5, 100, 0 }, new uint[4] { uint.MaxValue, 0, 0, uint.MaxValue }, new float[4])) { - Vector128 vf = Avx.MaskLoad((float*)(floatTable.inArrayPtr), Sse2.LoadVector128((uint*)(floatTable.maskArrayPtr))); + Vector128 vf = Avx.MaskLoad((float*)(floatTable.inArrayPtr), Sse.LoadVector128((float*)(floatTable.maskArrayPtr))); Unsafe.Write(floatTable.outArrayPtr, vf); if (!floatTable.CheckResult((x, m, y) => m == uint.MaxValue ? BitConverter.SingleToInt32Bits(x) == BitConverter.SingleToInt32Bits(y) : BitConverter.SingleToInt32Bits(y) == 0)) @@ -75,7 +75,7 @@ static unsafe int Main(string[] args) using (TestTable doubleTable = new TestTable(new double[2] { 1, -5}, new ulong[2] { 0, ulong.MaxValue}, new double[2])) { - Vector128 vf = Avx.MaskLoad((double*)(doubleTable.inArrayPtr), Sse2.LoadVector128((ulong*)(doubleTable.maskArrayPtr))); + Vector128 vf = Avx.MaskLoad((double*)(doubleTable.inArrayPtr), Sse2.LoadVector128((double*)(doubleTable.maskArrayPtr))); Unsafe.Write(doubleTable.outArrayPtr, vf); if (!doubleTable.CheckResult((x, m, y) => m == ulong.MaxValue ? BitConverter.DoubleToInt64Bits(x) == BitConverter.DoubleToInt64Bits(y) : BitConverter.DoubleToInt64Bits(y) == 0)) diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj index a35fbf8f8af8..1150e2ce7999 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_r.csproj @@ -1,34 +1,34 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - None - - - - - - - - - - + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj index d0a0a9c518c5..ec56cdee40d6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/MaskLoad_ro.csproj @@ -1,34 +1,34 @@ - - - - - Debug - AnyCPU - 2.0 - {95DFC527-4DC1-495E-97D7-E94EE1F7140D} - Exe - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - ..\..\ - true - - - - - - - False - - - - None - True - - - - - - - - - + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs index c8b281551950..420b434837d3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs @@ -64,11 +64,17 @@ private static void MaxDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxDouble() public sealed unsafe class SimpleBinaryOpTest__MaxDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxDouble testClass) + { + var result = Avx.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxDouble(); var result = Avx.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs index 3939057befef..9148e0d8a52b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs @@ -64,11 +64,17 @@ private static void MaxSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxSingle() public sealed unsafe class SimpleBinaryOpTest__MaxSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxSingle testClass) + { + var result = Avx.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxSingle(); var result = Avx.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs index d9c08b037365..7669a18ead8b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs @@ -64,11 +64,17 @@ private static void MinDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinDouble() public sealed unsafe class SimpleBinaryOpTest__MinDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinDouble testClass) + { + var result = Avx.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinDouble(); var result = Avx.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs index 4c80d5f146f9..b094b9b09c4f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs @@ -64,11 +64,17 @@ private static void MinSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinSingle() public sealed unsafe class SimpleBinaryOpTest__MinSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinSingle testClass) + { + var result = Avx.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinSingle(); var result = Avx.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs index 278e320b55e0..36561a5e70c8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyDouble() public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyDouble testClass) + { + var result = Avx.Multiply(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplyDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplyDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyDouble(); var result = Avx.Multiply(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Multiply(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Multiply(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs index c6f0b5338cd0..6a6ce7ad8123 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplySingle() public sealed unsafe class SimpleBinaryOpTest__MultiplySingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplySingle testClass) + { + var result = Avx.Multiply(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplySingle(); var result = Avx.Multiply(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Multiply(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Multiply(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs index c28d3c9ac6b8..658fc5ee6060 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs @@ -64,11 +64,17 @@ private static void OrDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrDouble() public sealed unsafe class SimpleBinaryOpTest__OrDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrDouble testClass) + { + var result = Avx.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__OrDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__OrDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrDouble(); var result = Avx.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs index 3336030aa1bd..a27b12498bc8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs @@ -64,11 +64,17 @@ private static void OrSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrSingle() public sealed unsafe class SimpleBinaryOpTest__OrSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrSingle testClass) + { + var result = Avx.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__OrSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__OrSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrSingle(); var result = Avx.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.1.cs index a7d3bf9e1eef..eb1996040e72 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void PermuteDouble1() { - var test = new SimpleUnaryOpTest__PermuteDouble1(); + var test = new ImmUnaryOpTest__PermuteDouble1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void PermuteDouble1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void PermuteDouble1() } } - public sealed unsafe class SimpleUnaryOpTest__PermuteDouble1 + public sealed unsafe class ImmUnaryOpTest__PermuteDouble1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__PermuteDouble1 testClass) + { + var result = Avx.Permute(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__PermuteDouble1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__PermuteDouble1() + static ImmUnaryOpTest__PermuteDouble1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__PermuteDouble1() + public ImmUnaryOpTest__PermuteDouble1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__PermuteDouble1(); + var test = new ImmUnaryOpTest__PermuteDouble1(); var result = Avx.Permute(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Permute(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Permute(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.2.cs index 4ccecc5ddc5e..6cc9e4b7796f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Double.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void PermuteDouble2() { - var test = new SimpleUnaryOpTest__PermuteDouble2(); + var test = new ImmUnaryOpTest__PermuteDouble2(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void PermuteDouble2() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void PermuteDouble2() } } - public sealed unsafe class SimpleUnaryOpTest__PermuteDouble2 + public sealed unsafe class ImmUnaryOpTest__PermuteDouble2 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__PermuteDouble2 testClass) + { + var result = Avx.Permute(_fld, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__PermuteDouble2 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__PermuteDouble2() + static ImmUnaryOpTest__PermuteDouble2() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__PermuteDouble2() + public ImmUnaryOpTest__PermuteDouble2() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__PermuteDouble2(); + var test = new ImmUnaryOpTest__PermuteDouble2(); var result = Avx.Permute(test._fld, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Permute(_fld, 2); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Permute(test._fld, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.1.cs index 30b5838d981b..7a202f17944b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void PermuteSingle1() { - var test = new SimpleUnaryOpTest__PermuteSingle1(); + var test = new ImmUnaryOpTest__PermuteSingle1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void PermuteSingle1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void PermuteSingle1() } } - public sealed unsafe class SimpleUnaryOpTest__PermuteSingle1 + public sealed unsafe class ImmUnaryOpTest__PermuteSingle1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__PermuteSingle1 testClass) + { + var result = Avx.Permute(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__PermuteSingle1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__PermuteSingle1() + static ImmUnaryOpTest__PermuteSingle1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__PermuteSingle1() + public ImmUnaryOpTest__PermuteSingle1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__PermuteSingle1(); + var test = new ImmUnaryOpTest__PermuteSingle1(); var result = Avx.Permute(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Permute(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Permute(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.2.cs index d50cddc384fe..3ae3aa80bc6b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Permute.Single.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void PermuteSingle2() { - var test = new SimpleUnaryOpTest__PermuteSingle2(); + var test = new ImmUnaryOpTest__PermuteSingle2(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void PermuteSingle2() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void PermuteSingle2() } } - public sealed unsafe class SimpleUnaryOpTest__PermuteSingle2 + public sealed unsafe class ImmUnaryOpTest__PermuteSingle2 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__PermuteSingle2 testClass) + { + var result = Avx.Permute(_fld, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__PermuteSingle2 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__PermuteSingle2() + static ImmUnaryOpTest__PermuteSingle2() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__PermuteSingle2() + public ImmUnaryOpTest__PermuteSingle2() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__PermuteSingle2(); + var test = new ImmUnaryOpTest__PermuteSingle2(); var result = Avx.Permute(test._fld, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Permute(_fld, 2); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Permute(test._fld, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Double.cs index f9171d8e02f3..dff318c76ac3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Double.cs @@ -64,11 +64,17 @@ private static void PermuteVarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void PermuteVarDouble() public sealed unsafe class SimpleBinaryOpTest__PermuteVarDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int64BitsToDouble(1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__PermuteVarDouble testClass) + { + var result = Avx.PermuteVar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,7 +139,7 @@ static SimpleBinaryOpTest__PermuteVarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int64BitsToDouble(1); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); @@ -118,12 +151,12 @@ public SimpleBinaryOpTest__PermuteVarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int64BitsToDouble(1); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int64BitsToDouble(1); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__PermuteVarDouble(); var result = Avx.PermuteVar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.PermuteVar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.PermuteVar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Single.cs index 24e5bb021d6a..f2a33e66218b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/PermuteVar.Single.cs @@ -64,11 +64,17 @@ private static void PermuteVarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void PermuteVarSingle() public sealed unsafe class SimpleBinaryOpTest__PermuteVarSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int32BitsToSingle(1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__PermuteVarSingle testClass) + { + var result = Avx.PermuteVar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,7 +139,7 @@ static SimpleBinaryOpTest__PermuteVarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int32BitsToSingle(1); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); @@ -118,12 +151,12 @@ public SimpleBinaryOpTest__PermuteVarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int32BitsToSingle(1); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = BitConverter.Int32BitsToSingle(1); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__PermuteVarSingle(); var result = Avx.PermuteVar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.PermuteVar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.PermuteVar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs index 9c52458bfab2..0b40b214f166 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs @@ -30,16 +30,10 @@ static Program() ["DuplicateEvenIndexed.Single"] = DuplicateEvenIndexedSingle, ["DuplicateOddIndexed.Single"] = DuplicateOddIndexedSingle, ["Extract.Byte.1"] = ExtractByte1, - ["Extract.SByte.1"] = ExtractSByte1, ["Extract.Byte.20"] = ExtractByte20, - ["Extract.SByte.20"] = ExtractSByte20, ["Extract.Byte.52"] = ExtractByte52, - ["Extract.SByte.52"] = ExtractSByte52, - ["Extract.Int16.1"] = ExtractInt161, ["Extract.UInt16.1"] = ExtractUInt161, - ["Extract.Int16.11"] = ExtractInt1611, ["Extract.UInt16.11"] = ExtractUInt1611, - ["Extract.Int16.27"] = ExtractInt1627, ["Extract.UInt16.27"] = ExtractUInt1627, ["Extract.Int32.1"] = ExtractInt321, ["Extract.UInt32.1"] = ExtractUInt321, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs index 89728933eae5..c4f465bd1464 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundCurrentDirectionDouble() public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundCurrentDirectionDouble testClass) + { + var result = Avx.RoundCurrentDirection(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundCurrentDirectionDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundCurrentDirectionDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundCurrentDirectionDouble(); var result = Avx.RoundCurrentDirection(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundCurrentDirection(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundCurrentDirection(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs index 1ff78899b6d4..388bbce4aff6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundCurrentDirectionSingle() public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundCurrentDirectionSingle testClass) + { + var result = Avx.RoundCurrentDirection(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundCurrentDirectionSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundCurrentDirectionSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundCurrentDirectionSingle(); var result = Avx.RoundCurrentDirection(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundCurrentDirection(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundCurrentDirection(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs index 70aa33104413..6d252f0f3280 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNearestIntegerDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNearestIntegerDouble testClass) + { + var result = Avx.RoundToNearestInteger(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNearestIntegerDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNearestIntegerDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNearestIntegerDouble(); var result = Avx.RoundToNearestInteger(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToNearestInteger(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToNearestInteger(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs index 4ca041cbf331..4231c53aa092 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNearestIntegerSingle() public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNearestIntegerSingle testClass) + { + var result = Avx.RoundToNearestInteger(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNearestIntegerSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNearestIntegerSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNearestIntegerSingle(); var result = Avx.RoundToNearestInteger(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToNearestInteger(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToNearestInteger(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs index 90ce9cbb7fff..79625b3f3928 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinityDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNegativeInfinityDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinityDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNegativeInfinityDouble testClass) + { + var result = Avx.RoundToNegativeInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNegativeInfinityDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNegativeInfinityDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNegativeInfinityDouble(); var result = Avx.RoundToNegativeInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToNegativeInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToNegativeInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs index 8ac2fade6844..f94b92ef4b3e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinitySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNegativeInfinitySingle() public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinitySingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNegativeInfinitySingle testClass) + { + var result = Avx.RoundToNegativeInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNegativeInfinitySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNegativeInfinitySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNegativeInfinitySingle(); var result = Avx.RoundToNegativeInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToNegativeInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToNegativeInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs index f37472f523d8..06f995afc65f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinityDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToPositiveInfinityDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinityDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToPositiveInfinityDouble testClass) + { + var result = Avx.RoundToPositiveInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToPositiveInfinityDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToPositiveInfinityDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToPositiveInfinityDouble(); var result = Avx.RoundToPositiveInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToPositiveInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToPositiveInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs index fb216f4f235e..4895085cf665 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinitySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToPositiveInfinitySingle() public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinitySingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToPositiveInfinitySingle testClass) + { + var result = Avx.RoundToPositiveInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToPositiveInfinitySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToPositiveInfinitySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToPositiveInfinitySingle(); var result = Avx.RoundToPositiveInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToPositiveInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToPositiveInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs index 3c20297c4ebb..593f8d6d762c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs @@ -64,11 +64,17 @@ private static void RoundToZeroDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToZeroDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToZeroDouble { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToZeroDouble testClass) + { + var result = Avx.RoundToZero(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToZeroDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToZeroDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToZeroDouble(); var result = Avx.RoundToZero(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToZero(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToZero(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs index d8ecdb21386c..df42a606839d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs @@ -64,11 +64,17 @@ private static void RoundToZeroSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToZeroSingle() public sealed unsafe class SimpleUnaryOpTest__RoundToZeroSingle { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToZeroSingle testClass) + { + var result = Avx.RoundToZero(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToZeroSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToZeroSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToZeroSingle(); var result = Avx.RoundToZero(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.RoundToZero(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.RoundToZero(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Double.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Double.1.cs index 97ea26a72ad0..92f89711265c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Double.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Double.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShuffleDouble1() { - var test = new SimpleBinaryOpTest__ShuffleDouble1(); + var test = new ImmBinaryOpTest__ShuffleDouble1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShuffleDouble1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void ShuffleDouble1() } } - public sealed unsafe class SimpleBinaryOpTest__ShuffleDouble1 + public sealed unsafe class ImmBinaryOpTest__ShuffleDouble1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__ShuffleDouble1 testClass) + { + var result = Avx.Shuffle(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,29 +135,29 @@ public sealed unsafe class SimpleBinaryOpTest__ShuffleDouble1 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__ShuffleDouble1() + static ImmBinaryOpTest__ShuffleDouble1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__ShuffleDouble1() + public ImmBinaryOpTest__ShuffleDouble1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__ShuffleDouble1(); + var test = new ImmBinaryOpTest__ShuffleDouble1(); var result = Avx.Shuffle(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Shuffle(_fld1, _fld2, 1); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Shuffle(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Single.1.cs index 3192185336b2..253d36290de5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Single.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Shuffle.Single.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShuffleSingle1() { - var test = new SimpleBinaryOpTest__ShuffleSingle1(); + var test = new ImmBinaryOpTest__ShuffleSingle1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShuffleSingle1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void ShuffleSingle1() } } - public sealed unsafe class SimpleBinaryOpTest__ShuffleSingle1 + public sealed unsafe class ImmBinaryOpTest__ShuffleSingle1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__ShuffleSingle1 testClass) + { + var result = Avx.Shuffle(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,29 +135,29 @@ public sealed unsafe class SimpleBinaryOpTest__ShuffleSingle1 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__ShuffleSingle1() + static ImmBinaryOpTest__ShuffleSingle1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__ShuffleSingle1() + public ImmBinaryOpTest__ShuffleSingle1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__ShuffleSingle1(); + var test = new ImmBinaryOpTest__ShuffleSingle1(); var result = Avx.Shuffle(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Shuffle(_fld1, _fld2, 1); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Shuffle(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast.cs new file mode 100644 index 000000000000..df076a82de33 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast.cs @@ -0,0 +1,127 @@ +// 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.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace IntelHardwareIntrinsicTest +{ + // that it is intentionally designed to be a struct type that meets + // the generic constraint but is not supported by any intrinsics + struct Num + { + public int a; + } + + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + int testResult = Pass; + + if (Avx.IsSupported) + { + using (TestTable floatTable = new TestTable(new float[8] { 1, float.NaN, float.PositiveInfinity, float.NegativeInfinity, float.NegativeInfinity, float.PositiveInfinity, float.NaN, 1 }, new int[8])) + { + var vf1 = Unsafe.Read>(floatTable.inArrayPtr); + var vf2 = Avx.StaticCast(vf1); + Unsafe.Write(floatTable.outArrayPtr, vf2); + + if (!floatTable.CheckResult((x, y) => BitConverter.SingleToInt32Bits(x) == y)) + { + Console.WriteLine("Avx StaticCast failed on float:"); + foreach (var item in floatTable.outArray) + { + Console.Write(item + ", "); + } + Console.WriteLine(); + testResult = Fail; + } + + // the successful path is the one that catches the exception, so that does nothing, + // it is the fall-through path that's the error path + try + { + var v = Avx.StaticCast(vf1); + Unsafe.Write(floatTable.outArrayPtr, v); + Console.WriteLine("Avx StaticCast failed on target type test:"); + testResult = Fail; + } + catch (System.NotSupportedException) + { + } + + // the successful path is the one that catches the exception, so that does nothing, + // it is the fall-through path that's the error path + try + { + var v = TestSrcType(); + Unsafe.Write(floatTable.outArrayPtr, v); + Console.WriteLine("Avx StaticCast failed on source type test:"); + testResult = Fail; + } + catch (System.NotSupportedException) + { + } + } + } + + return testResult; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Vector256 TestSrcType() + { + Vector256 v1 = new Vector256(); + Vector256 v2 = new Vector256(); + return Avx2.Add(Avx.StaticCast(v1), Avx.StaticCast(v2)); + } + + public unsafe struct TestTable : IDisposable where T : struct where U : struct + { + public T[] inArray; + public U[] outArray; + + public void* inArrayPtr => inHandle.AddrOfPinnedObject().ToPointer(); + public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer(); + + GCHandle inHandle; + GCHandle outHandle; + + public TestTable(T[] a, U[] b) + { + this.inArray = a; + this.outArray = b; + + inHandle = GCHandle.Alloc(inArray, GCHandleType.Pinned); + outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned); + } + + public bool CheckResult(Func check) + { + for (int i = 0; i < inArray.Length; i++) + { + if (!check(inArray[i], outArray[i])) + { + return false; + } + } + return true; + } + + public void Dispose() + { + inHandle.Free(); + outHandle.Free(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_r.csproj new file mode 100644 index 000000000000..55e5f3cf14e7 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_ro.csproj new file mode 100644 index 000000000000..913ca450e25a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/StaticCast_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs index 51f355ab2be1..74d9e20a3453 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs @@ -64,11 +64,17 @@ private static void SubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractDouble() public sealed unsafe class SimpleBinaryOpTest__SubtractDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractDouble testClass) + { + var result = Avx.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractDouble(); var result = Avx.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs index 9ad31d60ef0b..7b368bec0c69 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs @@ -64,11 +64,17 @@ private static void SubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSingle() public sealed unsafe class SimpleBinaryOpTest__SubtractSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSingle testClass) + { + var result = Avx.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSingle(); var result = Avx.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs index b98a09bdd448..630e545ed1cc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs @@ -64,11 +64,17 @@ private static void TestCByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCByte() public sealed unsafe class BooleanBinaryOpTest__TestCByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCByte testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCByte(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs index b9d579135ab4..63284f0d28ab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs @@ -64,11 +64,17 @@ private static void TestCInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt16() public sealed unsafe class BooleanBinaryOpTest__TestCInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt16 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt16(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs index 0808a5ba6b99..76ab9687ed65 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs @@ -64,11 +64,17 @@ private static void TestCInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt32() public sealed unsafe class BooleanBinaryOpTest__TestCInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt32 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt32(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs index 6d59986f4695..04b170bad85c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs @@ -64,11 +64,17 @@ private static void TestCInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt64() public sealed unsafe class BooleanBinaryOpTest__TestCInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt64 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt64(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs index 230bb03864eb..df2a9f995db1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs @@ -64,11 +64,17 @@ private static void TestCSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCSByte() public sealed unsafe class BooleanBinaryOpTest__TestCSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCSByte testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCSByte(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs index f203b62218cb..c00d3694a7e0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs @@ -64,11 +64,17 @@ private static void TestCUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt16() public sealed unsafe class BooleanBinaryOpTest__TestCUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt16 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt16(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs index 430b97b82aae..c0b4f076a86b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs @@ -64,11 +64,17 @@ private static void TestCUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt32() public sealed unsafe class BooleanBinaryOpTest__TestCUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt32 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt32(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs index 573fd505cb38..8992258a40bf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs @@ -64,11 +64,17 @@ private static void TestCUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt64() public sealed unsafe class BooleanBinaryOpTest__TestCUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt64 testClass) + { + var result = Avx.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt64(); var result = Avx.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs index 5c40fd04aa99..003ce55fa62f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCByte testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCByte(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs index e4be74f53994..471222c583a5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt16 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt16(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs index 494b36b7e5cf..dee10d6a55a2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt32 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt32(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs index 047a1d23d963..4d33bc980363 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt64 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt64(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs index 5f4b056ba22c..e359d12329c7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCSByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCSByte testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCSByte(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs index 8325d5e7bf9d..b8c165939768 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs index 74ffd2d301d4..b56dfabb4364 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs index 3e09f105e6c4..c4e60bdf8349 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64 testClass) + { + var result = Avx.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64(); var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs index 2a7afbea9603..952aa7abc8fb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs @@ -64,11 +64,17 @@ private static void TestZByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZByte() public sealed unsafe class BooleanBinaryOpTest__TestZByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZByte testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZByte(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs index 04ae3058b4bc..45ad68aa7840 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs @@ -64,11 +64,17 @@ private static void TestZInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt16() public sealed unsafe class BooleanBinaryOpTest__TestZInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt16 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt16(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs index 8cd3156a16bb..7d786e879d0c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs @@ -64,11 +64,17 @@ private static void TestZInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt32() public sealed unsafe class BooleanBinaryOpTest__TestZInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt32 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt32(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs index 2b2be9432f7f..3451a1405ec6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs @@ -64,11 +64,17 @@ private static void TestZInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt64() public sealed unsafe class BooleanBinaryOpTest__TestZInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt64 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt64(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs index a7b11ef09ca7..69dfb44620c8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs @@ -64,11 +64,17 @@ private static void TestZSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZSByte() public sealed unsafe class BooleanBinaryOpTest__TestZSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZSByte testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZSByte(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs index 660c3733d223..296ffb6e9d87 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs @@ -64,11 +64,17 @@ private static void TestZUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt16() public sealed unsafe class BooleanBinaryOpTest__TestZUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt16 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt16(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs index 10fd92a941e5..cea14a9ba49c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs @@ -64,11 +64,17 @@ private static void TestZUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt32() public sealed unsafe class BooleanBinaryOpTest__TestZUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt32 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt32(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs index e5d330de03cf..30f727790257 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs @@ -64,11 +64,17 @@ private static void TestZUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt64() public sealed unsafe class BooleanBinaryOpTest__TestZUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt64 testClass) + { + var result = Avx.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256), typeof(Vector256) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt64(); var result = Avx.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs index 053026e49028..9a8738aca9d0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs @@ -64,11 +64,17 @@ private static void XorDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorDouble() public sealed unsafe class SimpleBinaryOpTest__XorDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorDouble testClass) + { + var result = Avx.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__XorDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__XorDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorDouble(); var result = Avx.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs index 9e91f6f6f9fd..8ce416e03641 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs @@ -64,11 +64,17 @@ private static void XorSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorSingle() public sealed unsafe class SimpleBinaryOpTest__XorSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorSingle testClass) + { + var result = Avx.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__XorSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__XorSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorSingle(); var result = Avx.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs index bba9fe7e8d3c..5bb3f3c1ce9d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs @@ -64,11 +64,17 @@ private static void AddByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddByte() public sealed unsafe class SimpleBinaryOpTest__AddByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddByte testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddByte(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs index d1df1b650fde..8c381ed0653b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs @@ -64,11 +64,17 @@ private static void AddInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt16() public sealed unsafe class SimpleBinaryOpTest__AddInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt16 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt16(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs index e758f3be0972..f77d1adbed3e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs @@ -64,11 +64,17 @@ private static void AddInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt32() public sealed unsafe class SimpleBinaryOpTest__AddInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt32 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt32(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs index bfe96038eca5..250e60407e8e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs @@ -64,11 +64,17 @@ private static void AddInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt64() public sealed unsafe class SimpleBinaryOpTest__AddInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt64 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt64(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs index ad8dc3f87813..bde1c469fcb7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs @@ -64,11 +64,17 @@ private static void AddSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSByte() public sealed unsafe class SimpleBinaryOpTest__AddSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSByte testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSByte(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs index 750621a15c22..22f09d035578 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs @@ -64,11 +64,17 @@ private static void AddUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt16() public sealed unsafe class SimpleBinaryOpTest__AddUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt16 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt16(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs index 0a1001ef11a3..b71a8e2f2fe8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs @@ -64,11 +64,17 @@ private static void AddUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt32() public sealed unsafe class SimpleBinaryOpTest__AddUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt32 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt32(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs index a47f3d102239..b6cc1ec767d0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs @@ -64,11 +64,17 @@ private static void AddUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt64() public sealed unsafe class SimpleBinaryOpTest__AddUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt64 testClass) + { + var result = Avx2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt64(); var result = Avx2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.228.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.228.cs new file mode 100644 index 000000000000..83ec968458bb --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.228.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AlignRightSByte228() + { + var test = new ImmBinaryOpTest__AlignRightSByte228(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__AlignRightSByte228 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__AlignRightSByte228 testClass) + { + var result = Avx2.AlignRight(_fld1, _fld2, 228); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); + + private static SByte[] _data1 = new SByte[Op1ElementCount]; + private static SByte[] _data2 = new SByte[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__AlignRightSByte228() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__AlignRightSByte228() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.AlignRight( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 228 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.AlignRight( + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + 228 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.AlignRight( + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + 228 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)228 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)228 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)228 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.AlignRight( + _clsVar1, + _clsVar2, + 228 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.AlignRight(left, right, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__AlignRightSByte228(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.AlignRight(_fld1, _fld2, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 228); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") + { + if (result[0] != 0) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != 0) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AlignRight)}(Vector256.228, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.250.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.250.cs new file mode 100644 index 000000000000..1ea68999ebad --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.250.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AlignRightSByte250() + { + var test = new ImmBinaryOpTest__AlignRightSByte250(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__AlignRightSByte250 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__AlignRightSByte250 testClass) + { + var result = Avx2.AlignRight(_fld1, _fld2, 250); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); + + private static SByte[] _data1 = new SByte[Op1ElementCount]; + private static SByte[] _data2 = new SByte[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__AlignRightSByte250() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__AlignRightSByte250() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.AlignRight( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 250 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.AlignRight( + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + 250 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.AlignRight( + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + 250 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)250 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)250 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)250 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.AlignRight( + _clsVar1, + _clsVar2, + 250 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.AlignRight(left, right, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__AlignRightSByte250(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.AlignRight(_fld1, _fld2, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 250); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") + { + if (result[0] != 0) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != 0) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AlignRight)}(Vector256.250, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.27.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.27.cs new file mode 100644 index 000000000000..ca0302f2acee --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.27.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AlignRightSByte27() + { + var test = new ImmBinaryOpTest__AlignRightSByte27(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__AlignRightSByte27 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__AlignRightSByte27 testClass) + { + var result = Avx2.AlignRight(_fld1, _fld2, 27); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); + + private static SByte[] _data1 = new SByte[Op1ElementCount]; + private static SByte[] _data2 = new SByte[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__AlignRightSByte27() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__AlignRightSByte27() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.AlignRight( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 27 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.AlignRight( + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + 27 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.AlignRight( + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + 27 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)27 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)27 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)27 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.AlignRight( + _clsVar1, + _clsVar2, + 27 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.AlignRight(left, right, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__AlignRightSByte27(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.AlignRight(_fld1, _fld2, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 27); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") + { + if (result[0] != left[11]) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if ((result[i] != ((i < 16) ? ((i < 5) ? left[i + 11] : 0) : ((i < 21) ? left[i + 11] : 0)))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AlignRight)}(Vector256.27, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.5.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.5.cs new file mode 100644 index 000000000000..78660ad44df5 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AlignRight.SByte.5.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AlignRightSByte5() + { + var test = new ImmBinaryOpTest__AlignRightSByte5(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__AlignRightSByte5 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__AlignRightSByte5 testClass) + { + var result = Avx2.AlignRight(_fld1, _fld2, 5); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(SByte); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); + + private static SByte[] _data1 = new SByte[Op1ElementCount]; + private static SByte[] _data2 = new SByte[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__AlignRightSByte5() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__AlignRightSByte5() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new SByte[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.AlignRight( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 5 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.AlignRight( + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + 5 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.AlignRight( + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + 5 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)5 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)5 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.AlignRight), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)), + (byte)5 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.AlignRight( + _clsVar1, + _clsVar2, + 5 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.AlignRight(left, right, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr)); + var result = Avx2.AlignRight(left, right, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__AlignRightSByte5(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.AlignRight(_fld1, _fld2, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AlignRight(test._fld1, test._fld2, 5); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + SByte[] inArray1 = new SByte[Op1ElementCount]; + SByte[] inArray2 = new SByte[Op2ElementCount]; + SByte[] outArray = new SByte[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(SByte[] left, SByte[] right, SByte[] result, [CallerMemberName] string method = "") + { + if (result[0] != right[5]) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if ((result[i] != ((i < 16) ? ((i < 11) ? right[i + 5] : left[i - 11]) : ((i < 27) ? right[i + 5] : left[i - 11])))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AlignRight)}(Vector256.5, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs index 582513def6bb..e6efd0ef229b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs @@ -64,11 +64,17 @@ private static void AndByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndByte() public sealed unsafe class SimpleBinaryOpTest__AndByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndByte testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndByte(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs index 86f080807601..fe21d1fd395c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs @@ -64,11 +64,17 @@ private static void AndInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt16() public sealed unsafe class SimpleBinaryOpTest__AndInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt16 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt16(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs index 40a021c0d664..0d111aec0d99 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs @@ -64,11 +64,17 @@ private static void AndInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt32() public sealed unsafe class SimpleBinaryOpTest__AndInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt32 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt32(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs index e0acc87cd58d..2d3418cd6d17 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs @@ -64,11 +64,17 @@ private static void AndInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt64() public sealed unsafe class SimpleBinaryOpTest__AndInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt64 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt64(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs index 4c40e4e313c3..1e5a52b2271c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs @@ -64,11 +64,17 @@ private static void AndSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndSByte() public sealed unsafe class SimpleBinaryOpTest__AndSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndSByte testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndSByte(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs index 7943d3fcbd7d..66a2b368dcda 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs @@ -64,11 +64,17 @@ private static void AndUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt16() public sealed unsafe class SimpleBinaryOpTest__AndUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt16 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt16(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs index 26c74e3ea6c5..b94534c05ee8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs @@ -64,11 +64,17 @@ private static void AndUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt32() public sealed unsafe class SimpleBinaryOpTest__AndUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt32 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt32(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs index ddbeef057b9d..4df88d1fc3cb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs @@ -64,11 +64,17 @@ private static void AndUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt64() public sealed unsafe class SimpleBinaryOpTest__AndUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt64 testClass) + { + var result = Avx2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt64(); var result = Avx2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs index af8dc71ff526..906540040721 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs @@ -64,11 +64,17 @@ private static void AndNotByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotByte() public sealed unsafe class SimpleBinaryOpTest__AndNotByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotByte testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotByte(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs index db5f3232fe5f..1896f6fcd009 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs @@ -64,11 +64,17 @@ private static void AndNotInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt16() public sealed unsafe class SimpleBinaryOpTest__AndNotInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt16 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt16(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs index 6f85e8193236..88b6a778555c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs @@ -64,11 +64,17 @@ private static void AndNotInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt32() public sealed unsafe class SimpleBinaryOpTest__AndNotInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt32 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt32(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs index 2af6e9a92f13..2e7d48855085 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs @@ -64,11 +64,17 @@ private static void AndNotInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt64() public sealed unsafe class SimpleBinaryOpTest__AndNotInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt64 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt64(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs index 6af9e2eb792d..94c5280e1498 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs @@ -64,11 +64,17 @@ private static void AndNotSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotSByte() public sealed unsafe class SimpleBinaryOpTest__AndNotSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotSByte testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotSByte(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs index a4fbb70cc59d..d85d71ec0715 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs @@ -64,11 +64,17 @@ private static void AndNotUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt16() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt16 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt16(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs index 3a5304a8fc5d..fe1d0436b677 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs @@ -64,11 +64,17 @@ private static void AndNotUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt32() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt32 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt32(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs index b940c7f4c80a..fbf6beb31167 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs @@ -64,11 +64,17 @@ private static void AndNotUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt64() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt64 testClass) + { + var result = Avx2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt64(); var result = Avx2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs index d5d9e8226b4d..8bb2af3d0fa0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs @@ -64,11 +64,17 @@ private static void AverageByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AverageByte() public sealed unsafe class SimpleBinaryOpTest__AverageByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AverageByte testClass) + { + var result = Avx2.Average(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AverageByte(); var result = Avx2.Average(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Average(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Average(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs index 00907cd611e8..cc9f78d2b299 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs @@ -64,11 +64,17 @@ private static void AverageUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AverageUInt16() public sealed unsafe class SimpleBinaryOpTest__AverageUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AverageUInt16 testClass) + { + var result = Avx2.Average(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AverageUInt16(); var result = Avx2.Average(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Average(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Average(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj index bc465abb8381..a74819f3a218 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_r.csproj @@ -35,6 +35,10 @@ + + + + @@ -53,6 +57,22 @@ + + + + + + + + + + + + + + + + @@ -87,6 +107,9 @@ + + + @@ -205,10 +228,14 @@ - + + + + + - \ No newline at end of file + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj index 55ddee102a22..3c58841243ba 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Avx2_ro.csproj @@ -35,6 +35,10 @@ + + + + @@ -53,6 +57,22 @@ + + + + + + + + + + + + + + + + @@ -87,6 +107,9 @@ + + + @@ -205,9 +228,13 @@ - - + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.1.cs new file mode 100644 index 000000000000..f71f9ac0aaa0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt161() + { + var test = new ImmBinaryOpTest__BlendInt161(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt161 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt161 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); + + private static Int16[] _data1 = new Int16[Op1ElementCount]; + private static Int16[] _data2 = new Int16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt161() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt161() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt161(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((1 & (1 << i)) == 0) ? left[i] : right[i]) : (((1 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.1, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.2.cs new file mode 100644 index 000000000000..8fe1bed32d60 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt162() + { + var test = new ImmBinaryOpTest__BlendInt162(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt162 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt162 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); + + private static Int16[] _data1 = new Int16[Op1ElementCount]; + private static Int16[] _data2 = new Int16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt162() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt162() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt162(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((2 & (1 << i)) == 0) ? left[i] : right[i]) : (((2 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.2, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.4.cs new file mode 100644 index 000000000000..dacb01a7661e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt164() + { + var test = new ImmBinaryOpTest__BlendInt164(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt164 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt164 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); + + private static Int16[] _data1 = new Int16[Op1ElementCount]; + private static Int16[] _data2 = new Int16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt164() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt164() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt164(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((4 & (1 << i)) == 0) ? left[i] : right[i]) : (((4 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.4, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.85.cs new file mode 100644 index 000000000000..9ef5911037b1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int16.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt1685() + { + var test = new ImmBinaryOpTest__BlendInt1685(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt1685 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt1685 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); + + private static Int16[] _data1 = new Int16[Op1ElementCount]; + private static Int16[] _data2 = new Int16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt1685() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt1685() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt1685(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int16[] inArray1 = new Int16[Op1ElementCount]; + Int16[] inArray2 = new Int16[Op2ElementCount]; + Int16[] outArray = new Int16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int16[] left, Int16[] right, Int16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((85 & (1 << i)) == 0) ? left[i] : right[i]) : (((85 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.85, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.1.cs new file mode 100644 index 000000000000..d3384ed0e087 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt321() + { + var test = new ImmBinaryOpTest__BlendInt321(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt321 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt321 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt321() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt321() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt321(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.1, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.2.cs new file mode 100644 index 000000000000..c08dd6c30339 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt322() + { + var test = new ImmBinaryOpTest__BlendInt322(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt322 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt322 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt322() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt322() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt322(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.2, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.4.cs new file mode 100644 index 000000000000..00089cbc38b3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt324() + { + var test = new ImmBinaryOpTest__BlendInt324(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt324 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt324 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt324() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt324() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt324(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.4, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.85.cs new file mode 100644 index 000000000000..23fc11e330a0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.Int32.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt3285() + { + var test = new ImmBinaryOpTest__BlendInt3285(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt3285 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt3285 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt3285() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt3285() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt3285(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.85, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.1.cs new file mode 100644 index 000000000000..e07661c97053 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt161() + { + var test = new ImmBinaryOpTest__BlendUInt161(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt161 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt161 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + + private static UInt16[] _data1 = new UInt16[Op1ElementCount]; + private static UInt16[] _data2 = new UInt16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt161() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt161() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt161(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((1 & (1 << i)) == 0) ? left[i] : right[i]) : (((1 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.1, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.2.cs new file mode 100644 index 000000000000..aab3deb9bc5d --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt162() + { + var test = new ImmBinaryOpTest__BlendUInt162(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt162 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt162 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + + private static UInt16[] _data1 = new UInt16[Op1ElementCount]; + private static UInt16[] _data2 = new UInt16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt162() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt162() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt162(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((2 & (1 << i)) == 0) ? left[i] : right[i]) : (((2 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.2, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.4.cs new file mode 100644 index 000000000000..6b020b8085d3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt164() + { + var test = new ImmBinaryOpTest__BlendUInt164(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt164 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt164 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + + private static UInt16[] _data1 = new UInt16[Op1ElementCount]; + private static UInt16[] _data2 = new UInt16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt164() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt164() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt164(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((4 & (1 << i)) == 0) ? left[i] : right[i]) : (((4 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.4, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.85.cs new file mode 100644 index 000000000000..06426f7a2198 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt16.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt1685() + { + var test = new ImmBinaryOpTest__BlendUInt1685(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt1685 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt1685 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); + + private static UInt16[] _data1 = new UInt16[Op1ElementCount]; + private static UInt16[] _data2 = new UInt16[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt1685() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt1685() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt16[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt1685(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt16[] inArray1 = new UInt16[Op1ElementCount]; + UInt16[] inArray2 = new UInt16[Op2ElementCount]; + UInt16[] outArray = new UInt16[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt16[] left, UInt16[] right, UInt16[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((i < 8) ? (((85 & (1 << i)) == 0) ? left[i] : right[i]) : (((85 & (1 << (i - 8))) == 0) ? left[i] : right[i]))) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.85, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.1.cs new file mode 100644 index 000000000000..5f61a4a8f8b2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt321() + { + var test = new ImmBinaryOpTest__BlendUInt321(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt321 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt321 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt321() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt321() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt321(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.1, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.2.cs new file mode 100644 index 000000000000..b4e38e0d1beb --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt322() + { + var test = new ImmBinaryOpTest__BlendUInt322(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt322 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt322 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt322() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt322() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt322(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.2, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.4.cs new file mode 100644 index 000000000000..5f1ca1332e57 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt324() + { + var test = new ImmBinaryOpTest__BlendUInt324(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt324 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt324 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt324() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt324() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt324(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.4, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.85.cs new file mode 100644 index 000000000000..3cb59f1f81bf --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Blend.UInt32.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt3285() + { + var test = new ImmBinaryOpTest__BlendUInt3285(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt3285 + { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt3285 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector256 _clsVar1; + private static Vector256 _clsVar2; + + private Vector256 _fld1; + private Vector256 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt3285() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt3285() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector256), typeof(Vector256), typeof(byte) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)), + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector256)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)); + var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt3285(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 left, Vector256 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector256.85, Vector256): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs index ca4738e493e7..46aa4afd797a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs @@ -64,11 +64,17 @@ private static void BlendVariableByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableByte() public sealed unsafe class SimpleTernaryOpTest__BlendVariableByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableByte testClass) + { + var result = Avx2.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableByte(); var result = Avx2.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs index f15a531a4017..95ec7320d25b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs @@ -64,11 +64,17 @@ private static void BlendVariableSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableSByte() public sealed unsafe class SimpleTernaryOpTest__BlendVariableSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableSByte testClass) + { + var result = Avx2.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableSByte(); var result = Avx2.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Byte.cs index e02e1f3c5308..09a6d630474d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Byte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Byte() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Byte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Byte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Byte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Byte() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Byte + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Byte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Byte testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Byte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Byte() + static GenericUnaryOpTest__BroadcastScalarToVector128Byte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128Byte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Byte() + public GenericUnaryOpTest__BroadcastScalarToVector128Byte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Byte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Byte(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Double.cs index e2165e0877aa..edf4aa7e2a50 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Double.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Double() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Double(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Double(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Double() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Double() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Double + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Double { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Double testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Double private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Double() + static GenericUnaryOpTest__BroadcastScalarToVector128Double() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Double() + public GenericUnaryOpTest__BroadcastScalarToVector128Double() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Double(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Double(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int16.cs index cca08b34d7b1..0b4027fc1088 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Int16() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Int16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Int16() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int16 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Int16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Int16 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Int16() + static GenericUnaryOpTest__BroadcastScalarToVector128Int16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128Int16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Int16() + public GenericUnaryOpTest__BroadcastScalarToVector128Int16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int16(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int32.cs index 0c2791583939..e5528d9612e9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Int32() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Int32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Int32() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int32 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Int32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Int32 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Int32() + static GenericUnaryOpTest__BroadcastScalarToVector128Int32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128Int32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Int32() + public GenericUnaryOpTest__BroadcastScalarToVector128Int32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int32(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int64.cs index 98a9fa2672c4..f140f49f60d1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Int64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Int64() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Int64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Int64() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int64 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Int64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Int64 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Int64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Int64() + static GenericUnaryOpTest__BroadcastScalarToVector128Int64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128Int64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Int64() + public GenericUnaryOpTest__BroadcastScalarToVector128Int64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Int64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Int64(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.SByte.cs index 8c8ea54db735..ef53cd834929 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.SByte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128SByte() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128SByte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128SByte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128SByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128SByte() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128SByte + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128SByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128SByte testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128SByte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128SByte() + static GenericUnaryOpTest__BroadcastScalarToVector128SByte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128SByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128SByte() + public GenericUnaryOpTest__BroadcastScalarToVector128SByte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128SByte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128SByte(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Single.cs index 0e7535fcf8ad..f15422125741 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.Single.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128Single() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Single(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Single(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128Single() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128Single() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Single + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128Single { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128Single testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128Single private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128Single() + static GenericUnaryOpTest__BroadcastScalarToVector128Single() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128Single() + public GenericUnaryOpTest__BroadcastScalarToVector128Single() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128Single(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128Single(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt16.cs index ec5efa944465..74b2d7f53356 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128UInt16() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128UInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128UInt16() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt16 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128UInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128UInt16 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128UInt16() + static GenericUnaryOpTest__BroadcastScalarToVector128UInt16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128UInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128UInt16() + public GenericUnaryOpTest__BroadcastScalarToVector128UInt16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt16(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt32.cs index 6cf303e86d88..885d034c87f7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128UInt32() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128UInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128UInt32() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt32 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128UInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128UInt32 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128UInt32() + static GenericUnaryOpTest__BroadcastScalarToVector128UInt32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128UInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128UInt32() + public GenericUnaryOpTest__BroadcastScalarToVector128UInt32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt32(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt64.cs index 3a2acad9c07f..2c263bb945d7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector128.UInt64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector128UInt64() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector128UInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector128UInt64() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt64 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector128UInt64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector128UInt64 testClass) + { + var result = Avx2.BroadcastScalarToVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector128UInt64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector128UInt64() + static GenericUnaryOpTest__BroadcastScalarToVector128UInt64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector128UInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector128UInt64() + public GenericUnaryOpTest__BroadcastScalarToVector128UInt64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector128UInt64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector128UInt64(); var result = Avx2.BroadcastScalarToVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector128(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Byte.cs index 6710791d14ab..5b30e65ae5b8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Byte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Byte() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Byte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Byte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Byte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Byte() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Byte + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Byte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Byte testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Byte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Byte() + static GenericUnaryOpTest__BroadcastScalarToVector256Byte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256Byte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Byte() + public GenericUnaryOpTest__BroadcastScalarToVector256Byte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Byte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Byte(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Double.cs index df0ddd82bd8f..3656cef2a327 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Double.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Double() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Double(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Double(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Double() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Double() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Double + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Double { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Double testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Double private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Double() + static GenericUnaryOpTest__BroadcastScalarToVector256Double() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Double() + public GenericUnaryOpTest__BroadcastScalarToVector256Double() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Double(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Double(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int16.cs index 2fb31320150c..1f676c9101ae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Int16() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Int16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Int16() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int16 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Int16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Int16 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Int16() + static GenericUnaryOpTest__BroadcastScalarToVector256Int16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256Int16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Int16() + public GenericUnaryOpTest__BroadcastScalarToVector256Int16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int16(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int32.cs index 4d1792a46c41..e4fccefa7441 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Int32() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Int32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Int32() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int32 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Int32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Int32 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Int32() + static GenericUnaryOpTest__BroadcastScalarToVector256Int32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256Int32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Int32() + public GenericUnaryOpTest__BroadcastScalarToVector256Int32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int32(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int64.cs index feef4b96430f..cbdbe7bbb32e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Int64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Int64() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Int64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Int64() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int64 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Int64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Int64 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Int64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Int64() + static GenericUnaryOpTest__BroadcastScalarToVector256Int64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256Int64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Int64() + public GenericUnaryOpTest__BroadcastScalarToVector256Int64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Int64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Int64(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.SByte.cs index 33a9ac1bda02..bd268da8d8f1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.SByte.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256SByte() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256SByte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256SByte(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256SByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256SByte() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256SByte + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256SByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256SByte testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256SByte private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256SByte() + static GenericUnaryOpTest__BroadcastScalarToVector256SByte() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256SByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256SByte() + public GenericUnaryOpTest__BroadcastScalarToVector256SByte() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256SByte(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256SByte(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Single.cs index 4fc18d7bc5fd..9b650fd3c056 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.Single.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256Single() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Single(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Single(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256Single() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256Single() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Single + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256Single { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256Single testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -98,24 +128,24 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256Single private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256Single() + static GenericUnaryOpTest__BroadcastScalarToVector256Single() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256Single() + public GenericUnaryOpTest__BroadcastScalarToVector256Single() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256Single(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256Single(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt16.cs index 64c4e8109dfc..0c707ae5db91 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256UInt16() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt16(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256UInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256UInt16() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt16 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256UInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256UInt16 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt16 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256UInt16() + static GenericUnaryOpTest__BroadcastScalarToVector256UInt16() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256UInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256UInt16() + public GenericUnaryOpTest__BroadcastScalarToVector256UInt16() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt16(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt16(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt32.cs index 0136d9949cc9..0d8983158e5b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256UInt32() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt32(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256UInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256UInt32() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt32 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256UInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256UInt32 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt32 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256UInt32() + static GenericUnaryOpTest__BroadcastScalarToVector256UInt32() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256UInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256UInt32() + public GenericUnaryOpTest__BroadcastScalarToVector256UInt32() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt32(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt32(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt64.cs index 2f9aaf8e571e..025eaaef862b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BroadcastScalarToVector256.UInt64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void BroadcastScalarToVector256UInt64() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt64(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void BroadcastScalarToVector256UInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void BroadcastScalarToVector256UInt64() } } - public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt64 + public sealed unsafe class GenericUnaryOpTest__BroadcastScalarToVector256UInt64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__BroadcastScalarToVector256UInt64 testClass) + { + var result = Avx2.BroadcastScalarToVector256(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__BroadcastScalarToVector256UInt64 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__BroadcastScalarToVector256UInt64() + static GenericUnaryOpTest__BroadcastScalarToVector256UInt64() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__BroadcastScalarToVector256UInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__BroadcastScalarToVector256UInt64() + public GenericUnaryOpTest__BroadcastScalarToVector256UInt64() { Succeeded = true; @@ -226,16 +256,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__BroadcastScalarToVector256UInt64(); + var test = new GenericUnaryOpTest__BroadcastScalarToVector256UInt64(); var result = Avx2.BroadcastScalarToVector256(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.BroadcastScalarToVector256(_fld); @@ -243,6 +273,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.BroadcastScalarToVector256(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs index 7c0154216b1c..afb9c3051003 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs @@ -64,11 +64,17 @@ private static void CompareEqualByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualByte() public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualByte testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualByte(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs index 7e3304fa8e79..a965da973cd1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt16() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt16 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt16(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs index a3c8d5b95bc2..0fc224bf065a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt32() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt32 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt32(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs index 4764dd4f3f75..352fd1dc65b5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt64() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt64 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt64(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs index 2616f1f7c354..aeda65b9e913 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs @@ -64,11 +64,17 @@ private static void CompareEqualSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualSByte() public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualSByte testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualSByte(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs index 34835ba54921..2ba1dd710b6d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt16() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt16 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt16(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs index 6dcaca2435f4..cc5d707e3513 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt32() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt32 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt32(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs index 8df791cb9d04..d3cb844aba85 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt64() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt64 testClass) + { + var result = Avx2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt64(); var result = Avx2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs index 804d24e87b84..0ce6b5c03ecd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt16() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt16 testClass) + { + var result = Avx2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt16(); var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs index e5cb25e464f6..859faa438a18 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt32() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt32 testClass) + { + var result = Avx2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt32(); var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs index 0227f9d6409e..2df6d3f7f98f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt64() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt64 testClass) + { + var result = Avx2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt64(); var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs index b3d8c4dd0f84..91e2a6f0c703 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanSByte() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanSByte testClass) + { + var result = Avx2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanSByte(); var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToDouble.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToDouble.Double.cs new file mode 100644 index 000000000000..4e4a07bc39b0 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToDouble.Double.cs @@ -0,0 +1,316 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ConvertToDoubleDouble() + { + var test = new SimdScalarUnaryOpTest__ConvertToDoubleDouble(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class SimdScalarUnaryOpTest__ConvertToDoubleDouble + { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimdScalarUnaryOpTest__ConvertToDoubleDouble testClass) + { + var result = Avx2.ConvertToDouble(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); + + private static Double[] _data = new Double[Op1ElementCount]; + + private static Vector256 _clsVar; + + private Vector256 _fld; + + private SimdScalarUnaryOpTest__DataTable _dataTable; + + static SimdScalarUnaryOpTest__ConvertToDoubleDouble() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + } + + public SimdScalarUnaryOpTest__ConvertToDoubleDouble() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + _dataTable = new SimdScalarUnaryOpTest__DataTable(_data, LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.ConvertToDouble( + Unsafe.Read>(_dataTable.inArrayPtr) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.ConvertToDouble( + Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.ConvertToDouble( + Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToDouble), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArrayPtr) + }); + + ValidateResult(_dataTable.inArrayPtr, (Double)(result)); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToDouble), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (Double)(result)); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToDouble), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (Double)(result)); + } + + public void RunClsVarScenario() + { + var result = Avx2.ConvertToDouble( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); + var result = Avx2.ConvertToDouble(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_Load() + { + var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToDouble(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_LoadAligned() + { + var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToDouble(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunClassLclFldScenario() + { + var test = new SimdScalarUnaryOpTest__ConvertToDoubleDouble(); + var result = Avx2.ConvertToDouble(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Avx2.ConvertToDouble(_fld); + + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ConvertToDouble(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 firstOp, Double result, [CallerMemberName] string method = "") + { + Double[] inArray = new Double[Op1ElementCount]; + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(void* firstOp, Double result, [CallerMemberName] string method = "") + { + Double[] inArray = new Double[Op1ElementCount]; + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(Double[] firstOp, Double result, [CallerMemberName] string method = "") + { + if (BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result)) + { + Succeeded = false; + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.ConvertToDouble)}(Vector256): {method} failed:"); + Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); + Console.WriteLine($" result: result"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToInt32.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToInt32.Int32.cs new file mode 100644 index 000000000000..a6abf45df42e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToInt32.Int32.cs @@ -0,0 +1,316 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ConvertToInt32Int32() + { + var test = new SimdScalarUnaryOpTest__ConvertToInt32Int32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class SimdScalarUnaryOpTest__ConvertToInt32Int32 + { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimdScalarUnaryOpTest__ConvertToInt32Int32 testClass) + { + var result = Avx2.ConvertToInt32(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data = new Int32[Op1ElementCount]; + + private static Vector256 _clsVar; + + private Vector256 _fld; + + private SimdScalarUnaryOpTest__DataTable _dataTable; + + static SimdScalarUnaryOpTest__ConvertToInt32Int32() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + } + + public SimdScalarUnaryOpTest__ConvertToInt32Int32() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimdScalarUnaryOpTest__DataTable(_data, LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.ConvertToInt32( + Unsafe.Read>(_dataTable.inArrayPtr) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.ConvertToInt32( + Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.ConvertToInt32( + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArrayPtr) + }); + + ValidateResult(_dataTable.inArrayPtr, (Int32)(result)); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (Int32)(result)); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (Int32)(result)); + } + + public void RunClsVarScenario() + { + var result = Avx2.ConvertToInt32( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); + var result = Avx2.ConvertToInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_Load() + { + var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_LoadAligned() + { + var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunClassLclFldScenario() + { + var test = new SimdScalarUnaryOpTest__ConvertToInt32Int32(); + var result = Avx2.ConvertToInt32(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Avx2.ConvertToInt32(_fld); + + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ConvertToInt32(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 firstOp, Int32 result, [CallerMemberName] string method = "") + { + Int32[] inArray = new Int32[Op1ElementCount]; + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(void* firstOp, Int32 result, [CallerMemberName] string method = "") + { + Int32[] inArray = new Int32[Op1ElementCount]; + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(Int32[] firstOp, Int32 result, [CallerMemberName] string method = "") + { + if (result != firstOp[0]) + { + Succeeded = false; + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.ConvertToInt32)}(Vector256): {method} failed:"); + Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); + Console.WriteLine($" result: result"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToUInt32.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToUInt32.UInt32.cs new file mode 100644 index 000000000000..fe71b7a453e3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ConvertToUInt32.UInt32.cs @@ -0,0 +1,316 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ConvertToUInt32UInt32() + { + var test = new SimdScalarUnaryOpTest__ConvertToUInt32UInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Avx.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class SimdScalarUnaryOpTest__ConvertToUInt32UInt32 + { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimdScalarUnaryOpTest__ConvertToUInt32UInt32 testClass) + { + var result = Avx2.ConvertToUInt32(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data = new UInt32[Op1ElementCount]; + + private static Vector256 _clsVar; + + private Vector256 _fld; + + private SimdScalarUnaryOpTest__DataTable _dataTable; + + static SimdScalarUnaryOpTest__ConvertToUInt32UInt32() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + } + + public SimdScalarUnaryOpTest__ConvertToUInt32UInt32() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimdScalarUnaryOpTest__DataTable(_data, LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.ConvertToUInt32( + Unsafe.Read>(_dataTable.inArrayPtr) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.ConvertToUInt32( + Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.ConvertToUInt32( + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToUInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArrayPtr) + }); + + ValidateResult(_dataTable.inArrayPtr, (UInt32)(result)); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToUInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (UInt32)(result)); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.ConvertToUInt32), new Type[] { typeof(Vector256) }) + .Invoke(null, new object[] { + Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, (UInt32)(result)); + } + + public void RunClsVarScenario() + { + var result = Avx2.ConvertToUInt32( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); + var result = Avx2.ConvertToUInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_Load() + { + var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToUInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_LoadAligned() + { + var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); + var result = Avx2.ConvertToUInt32(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunClassLclFldScenario() + { + var test = new SimdScalarUnaryOpTest__ConvertToUInt32UInt32(); + var result = Avx2.ConvertToUInt32(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Avx2.ConvertToUInt32(_fld); + + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ConvertToUInt32(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector256 firstOp, UInt32 result, [CallerMemberName] string method = "") + { + UInt32[] inArray = new UInt32[Op1ElementCount]; + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(void* firstOp, UInt32 result, [CallerMemberName] string method = "") + { + UInt32[] inArray = new UInt32[Op1ElementCount]; + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(UInt32[] firstOp, UInt32 result, [CallerMemberName] string method = "") + { + if (result != firstOp[0]) + { + Succeeded = false; + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.ConvertToUInt32)}(Vector256): {method} failed:"); + Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); + Console.WriteLine($" result: result"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs index 01e37463cb0d..a7afd6dafe3f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Byte1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1Store(); + var test = new ExtractStoreTest__ExtractVector128Byte1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Byte1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Byte1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Byte1 testClass) + { + Avx2.ExtractVector128((Byte*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Byte1Store() + static ExtractStoreTest__ExtractVector128Byte1() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Byte1Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Byte1Store() + public ExtractStoreTest__ExtractVector128Byte1() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Byte*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1Store(); + var test = new ExtractStoreTest__ExtractVector128Byte1(); Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((Byte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.cs index 90ff66ba4ab3..a64c5d050706 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Byte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128Byte1() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1(); + var test = new ExtractVector128Test__ExtractVector128Byte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128Byte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128Byte1() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1 + public sealed unsafe class ExtractVector128Test__ExtractVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128Byte1 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Byte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Byte1() + static ExtractVector128Test__ExtractVector128Byte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128Byte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Byte1() + public ExtractVector128Test__ExtractVector128Byte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Byte1(); + var test = new ExtractVector128Test__ExtractVector128Byte1(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs index 3f1b9644b49c..9d1b4744e274 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int161Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161Store(); + var test = new ExtractStoreTest__ExtractVector128Int161(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int161Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int161Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int161 testClass) + { + Avx2.ExtractVector128((Int16*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int161Store() + static ExtractStoreTest__ExtractVector128Int161() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int161Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int161Store() + public ExtractStoreTest__ExtractVector128Int161() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int16*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161Store(); + var test = new ExtractStoreTest__ExtractVector128Int161(); Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((Int16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.cs index b92fc89c54c9..ca2c3a670128 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128Int161() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161(); + var test = new ExtractVector128Test__ExtractVector128Int161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128Int161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128Int161() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161 + public sealed unsafe class ExtractVector128Test__ExtractVector128Int161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128Int161 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int161() + static ExtractVector128Test__ExtractVector128Int161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128Int161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int161() + public ExtractVector128Test__ExtractVector128Int161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int161(); + var test = new ExtractVector128Test__ExtractVector128Int161(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs index 35446e6e5076..a7e671df151c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int321Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321Store(); + var test = new ExtractStoreTest__ExtractVector128Int321(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int321Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int321Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int321 testClass) + { + Avx2.ExtractVector128((Int32*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int321Store() + static ExtractStoreTest__ExtractVector128Int321() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int321Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int321Store() + public ExtractStoreTest__ExtractVector128Int321() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int32*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321Store(); + var test = new ExtractStoreTest__ExtractVector128Int321(); Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((Int32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.cs index 8d6c800e8a02..37732d5ac93e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128Int321() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321(); + var test = new ExtractVector128Test__ExtractVector128Int321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128Int321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128Int321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321 + public sealed unsafe class ExtractVector128Test__ExtractVector128Int321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128Int321 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int321() + static ExtractVector128Test__ExtractVector128Int321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128Int321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int321() + public ExtractVector128Test__ExtractVector128Int321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int321(); + var test = new ExtractVector128Test__ExtractVector128Int321(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs index 9d7443527059..2e848a3bab6e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128Int641Store() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641Store(); + var test = new ExtractStoreTest__ExtractVector128Int641(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128Int641Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128Int641Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641Store + public sealed unsafe class ExtractStoreTest__ExtractVector128Int641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128Int641 testClass) + { + Avx2.ExtractVector128((Int64*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int641Store() + static ExtractStoreTest__ExtractVector128Int641() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128Int641Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int641Store() + public ExtractStoreTest__ExtractVector128Int641() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((Int64*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641Store(); + var test = new ExtractStoreTest__ExtractVector128Int641(); Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((Int64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.cs index 82eb318b4c43..5a60973c1f4c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128Int641() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641(); + var test = new ExtractVector128Test__ExtractVector128Int641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128Int641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128Int641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641 + public sealed unsafe class ExtractVector128Test__ExtractVector128Int641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128Int641 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128Int641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128Int641() + static ExtractVector128Test__ExtractVector128Int641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128Int641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128Int641() + public ExtractVector128Test__ExtractVector128Int641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128Int641(); + var test = new ExtractVector128Test__ExtractVector128Int641(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs index 7af171776adc..a0d9ca1e0db1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128SByte1Store() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1Store(); + var test = new ExtractStoreTest__ExtractVector128SByte1(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128SByte1Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128SByte1Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1Store + public sealed unsafe class ExtractStoreTest__ExtractVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128SByte1 testClass) + { + Avx2.ExtractVector128((SByte*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128SByte1Store() + static ExtractStoreTest__ExtractVector128SByte1() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128SByte1Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128SByte1Store() + public ExtractStoreTest__ExtractVector128SByte1() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((SByte*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1Store(); + var test = new ExtractStoreTest__ExtractVector128SByte1(); Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((SByte*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.cs index a24c5deab77d..b9f9c827ba1a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.SByte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128SByte1() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1(); + var test = new ExtractVector128Test__ExtractVector128SByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128SByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128SByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1 + public sealed unsafe class ExtractVector128Test__ExtractVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128SByte1 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128SByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128SByte1() + static ExtractVector128Test__ExtractVector128SByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128SByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128SByte1() + public ExtractVector128Test__ExtractVector128SByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128SByte1(); + var test = new ExtractVector128Test__ExtractVector128SByte1(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs index f2da2506253d..6416d25c6d46 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt161Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161Store(); + var test = new ExtractStoreTest__ExtractVector128UInt161(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt161Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt161Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt161 testClass) + { + Avx2.ExtractVector128((UInt16*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt161Store() + static ExtractStoreTest__ExtractVector128UInt161() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt161Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt161Store() + public ExtractStoreTest__ExtractVector128UInt161() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt16*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161Store(); + var test = new ExtractStoreTest__ExtractVector128UInt161(); Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((UInt16*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.cs index 93a99dfec253..324646e82df4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128UInt161() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161(); + var test = new ExtractVector128Test__ExtractVector128UInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128UInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128UInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161 + public sealed unsafe class ExtractVector128Test__ExtractVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128UInt161 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt161() + static ExtractVector128Test__ExtractVector128UInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt161() + public ExtractVector128Test__ExtractVector128UInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt161(); + var test = new ExtractVector128Test__ExtractVector128UInt161(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs index 538328541393..8a22c33eb96f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt321Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321Store(); + var test = new ExtractStoreTest__ExtractVector128UInt321(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt321Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt321Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt321 testClass) + { + Avx2.ExtractVector128((UInt32*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt321Store() + static ExtractStoreTest__ExtractVector128UInt321() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt321Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt321Store() + public ExtractStoreTest__ExtractVector128UInt321() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt32*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321Store(); + var test = new ExtractStoreTest__ExtractVector128UInt321(); Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((UInt32*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.cs index 88b415c50c76..b916464edd09 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128UInt321() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321(); + var test = new ExtractVector128Test__ExtractVector128UInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128UInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128UInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321 + public sealed unsafe class ExtractVector128Test__ExtractVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128UInt321 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt321() + static ExtractVector128Test__ExtractVector128UInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt321() + public ExtractVector128Test__ExtractVector128UInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt321(); + var test = new ExtractVector128Test__ExtractVector128UInt321(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs index 02ce1e7ded60..11b2d9663df7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.Store.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void ExtractVector128UInt641Store() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641Store(); + var test = new ExtractStoreTest__ExtractVector128UInt641(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void ExtractVector128UInt641Store() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void ExtractVector128UInt641Store() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641Store + public sealed unsafe class ExtractStoreTest__ExtractVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__ExtractVector128UInt641 testClass) + { + Avx2.ExtractVector128((UInt64*)testClass._dataTable.outArrayPtr, _fld, 1); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -99,7 +127,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641Store private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt641Store() + static ExtractStoreTest__ExtractVector128UInt641() { var random = new Random(); @@ -107,7 +135,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt641Store() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt641Store() + public ExtractStoreTest__ExtractVector128UInt641() { Succeeded = true; @@ -200,35 +228,55 @@ public void RunClsVarScenario() _clsVar, 1 ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = Avx.LoadVector256((UInt64*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArrayPtr)); Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, firstOp, 1); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641Store(); + var test = new ExtractStoreTest__ExtractVector128UInt641(); Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, _fld, 1); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + Avx2.ExtractVector128((UInt64*)_dataTable.outArrayPtr, test._fld, 1); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.cs index 227c62b0569e..350887fbe7fa 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ExtractVector128.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ExtractVector128UInt641() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641(); + var test = new ExtractVector128Test__ExtractVector128UInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ExtractVector128UInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ExtractVector128UInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641 + public sealed unsafe class ExtractVector128Test__ExtractVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__ExtractVector128UInt641 testClass) + { + var result = Avx2.ExtractVector128(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractVector128UInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractVector128UInt641() + static ExtractVector128Test__ExtractVector128UInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ExtractVector128UInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractVector128UInt641() + public ExtractVector128Test__ExtractVector128UInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractVector128UInt641(); + var test = new ExtractVector128Test__ExtractVector128UInt641(); var result = Avx2.ExtractVector128(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ExtractVector128(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ExtractVector128(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs index 4585907c87aa..d8f946d945cb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Byte1Load() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1Load(); + var test = new InsertLoadTest__InsertVector128Byte1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Byte1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Byte1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1Load + public sealed unsafe class InsertLoadTest__InsertVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Byte1 testClass) + { + var result = Avx2.InsertVector128(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Byte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Byte1Load() + static InsertLoadTest__InsertVector128Byte1() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Byte1Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Byte1Load() + public InsertLoadTest__InsertVector128Byte1() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1Load(); + var test = new InsertLoadTest__InsertVector128Byte1(); var result = Avx2.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (Byte*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (Byte*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Byte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.cs index 71ff744478c8..5a7351c6f0a6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Byte.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128Byte1() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1(); + var test = new InsertVector128Test__InsertVector128Byte1(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128Byte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128Byte1() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1 + public sealed unsafe class InsertVector128Test__InsertVector128Byte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128Byte1 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Byte1 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Byte1() + static InsertVector128Test__InsertVector128Byte1() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Byte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Byte1() + public InsertVector128Test__InsertVector128Byte1() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Byte1(); + var test = new InsertVector128Test__InsertVector128Byte1(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs index 073b5a199696..655ba083e4a0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int161Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int161Load(); + var test = new InsertLoadTest__InsertVector128Int161(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int161Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int161Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161Load + public sealed unsafe class InsertLoadTest__InsertVector128Int161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0,short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int161 testClass) + { + var result = Avx2.InsertVector128(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int161Load() + static InsertLoadTest__InsertVector128Int161() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int161Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int161Load() + public InsertLoadTest__InsertVector128Int161() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int161Load(); + var test = new InsertLoadTest__InsertVector128Int161(); var result = Avx2.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (Int16*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (Int16*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.cs index 226d8471dab4..0b13a754b138 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int16.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int161() { - var test = new SimpleBinaryOpTest__InsertVector128Int161(); + var test = new InsertVector128Test__InsertVector128Int161(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128Int161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128Int161() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161 + public sealed unsafe class InsertVector128Test__InsertVector128Int161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128Int161 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int161 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int161() + static InsertVector128Test__InsertVector128Int161() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int161() + public InsertVector128Test__InsertVector128Int161() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int161(); + var test = new InsertVector128Test__InsertVector128Int161(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs index 7401013cf6dc..904e8b2d7ea8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int321Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int321Load(); + var test = new InsertLoadTest__InsertVector128Int321(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int321Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int321Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321Load + public sealed unsafe class InsertLoadTest__InsertVector128Int321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int321 testClass) + { + var result = Avx2.InsertVector128(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int321Load() + static InsertLoadTest__InsertVector128Int321() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int321Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int321Load() + public InsertLoadTest__InsertVector128Int321() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int321Load(); + var test = new InsertLoadTest__InsertVector128Int321(); var result = Avx2.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (Int32*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (Int32*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.cs index ddf47a583861..5a519fd1e235 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int32.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int321() { - var test = new SimpleBinaryOpTest__InsertVector128Int321(); + var test = new InsertVector128Test__InsertVector128Int321(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128Int321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128Int321() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321 + public sealed unsafe class InsertVector128Test__InsertVector128Int321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128Int321 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int321 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int321() + static InsertVector128Test__InsertVector128Int321() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int321() + public InsertVector128Test__InsertVector128Int321() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int321(); + var test = new InsertVector128Test__InsertVector128Int321(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs index 40deb8cd891f..1e0cf798b0d8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int641Load() { - var test = new SimpleBinaryOpTest__InsertVector128Int641Load(); + var test = new InsertLoadTest__InsertVector128Int641(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128Int641Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128Int641Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641Load + public sealed unsafe class InsertLoadTest__InsertVector128Int641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128Int641 testClass) + { + var result = Avx2.InsertVector128(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (Int64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int641Load() + static InsertLoadTest__InsertVector128Int641() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int641Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int641Load() + public InsertLoadTest__InsertVector128Int641() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int641Load(); + var test = new InsertLoadTest__InsertVector128Int641(); var result = Avx2.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (Int64*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (Int64*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (Int64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.cs index e8cdf0f40a87..368a8c89c5cb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.Int64.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128Int641() { - var test = new SimpleBinaryOpTest__InsertVector128Int641(); + var test = new InsertVector128Test__InsertVector128Int641(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128Int641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128Int641() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641 + public sealed unsafe class InsertVector128Test__InsertVector128Int641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128Int641 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128Int641 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128Int641() + static InsertVector128Test__InsertVector128Int641() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128Int641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128Int641() + public InsertVector128Test__InsertVector128Int641() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128Int641(); + var test = new InsertVector128Test__InsertVector128Int641(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs index 9ccc2c547f3e..e90a626b9705 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128SByte1Load() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1Load(); + var test = new InsertLoadTest__InsertVector128SByte1(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128SByte1Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128SByte1Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1Load + public sealed unsafe class InsertLoadTest__InsertVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0,sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128SByte1 testClass) + { + var result = Avx2.InsertVector128(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (SByte*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128SByte1Load() + static InsertLoadTest__InsertVector128SByte1() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128SByte1Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128SByte1Load() + public InsertLoadTest__InsertVector128SByte1() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1Load(); + var test = new InsertLoadTest__InsertVector128SByte1(); var result = Avx2.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (SByte*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (SByte*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (SByte*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.cs index 94c92ee0d658..4a39530ee664 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.SByte.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128SByte1() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1(); + var test = new InsertVector128Test__InsertVector128SByte1(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128SByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128SByte1() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1 + public sealed unsafe class InsertVector128Test__InsertVector128SByte1 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128SByte1 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128SByte1 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128SByte1() + static InsertVector128Test__InsertVector128SByte1() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128SByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128SByte1() + public InsertVector128Test__InsertVector128SByte1() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128SByte1(); + var test = new InsertVector128Test__InsertVector128SByte1(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs index 0f561f65b619..83f1216c837d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt161Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161Load(); + var test = new InsertLoadTest__InsertVector128UInt161(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt161Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt161Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt161 testClass) + { + var result = Avx2.InsertVector128(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt16*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt161Load() + static InsertLoadTest__InsertVector128UInt161() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt161Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt161Load() + public InsertLoadTest__InsertVector128UInt161() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161Load(); + var test = new InsertLoadTest__InsertVector128UInt161(); var result = Avx2.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt16*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.cs index 57f1d2da5494..6d474445248f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt16.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt161() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161(); + var test = new InsertVector128Test__InsertVector128UInt161(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128UInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128UInt161() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161 + public sealed unsafe class InsertVector128Test__InsertVector128UInt161 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128UInt161 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt161 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt161() + static InsertVector128Test__InsertVector128UInt161() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt161() + public InsertVector128Test__InsertVector128UInt161() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt161(); + var test = new InsertVector128Test__InsertVector128UInt161(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs index 138463655227..5f91467c8919 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt321Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321Load(); + var test = new InsertLoadTest__InsertVector128UInt321(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt321Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt321Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt321 testClass) + { + var result = Avx2.InsertVector128(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt32*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt321Load() + static InsertLoadTest__InsertVector128UInt321() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt321Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt321Load() + public InsertLoadTest__InsertVector128UInt321() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321Load(); + var test = new InsertLoadTest__InsertVector128UInt321(); var result = Avx2.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt32*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.cs index 244d788ca891..a6ae9d1f902d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt32.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt321() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321(); + var test = new InsertVector128Test__InsertVector128UInt321(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128UInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128UInt321() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321 + public sealed unsafe class InsertVector128Test__InsertVector128UInt321 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128UInt321 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt321 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt321() + static InsertVector128Test__InsertVector128UInt321() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt321() + public InsertVector128Test__InsertVector128UInt321() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt321(); + var test = new InsertVector128Test__InsertVector128UInt321(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs index 5cb7d0c2e3b2..9cd284b49232 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.Load.cs @@ -23,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt641Load() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641Load(); + var test = new InsertLoadTest__InsertVector128UInt641(); if (test.IsSupported) { @@ -66,11 +66,17 @@ private static void InsertVector128UInt641Load() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ private static void InsertVector128UInt641Load() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641Load + public sealed unsafe class InsertLoadTest__InsertVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0,int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__InsertVector128UInt641 testClass) + { + var result = Avx2.InsertVector128(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, (UInt64*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -104,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641Load private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt641Load() + static InsertLoadTest__InsertVector128UInt641() { var random = new Random(); @@ -114,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt641Load() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt641Load() + public InsertLoadTest__InsertVector128UInt641() { Succeeded = true; @@ -251,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641Load(); + var test = new InsertLoadTest__InsertVector128UInt641(); var result = Avx2.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); @@ -268,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, (UInt64*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.cs index 76ac558da50b..6d8ddbd99832 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/InsertVector128.UInt64.1.cs @@ -14,6 +14,7 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ public static partial class Program { private static void InsertVector128UInt641() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641(); + var test = new InsertVector128Test__InsertVector128UInt641(); if (test.IsSupported) { @@ -65,11 +66,17 @@ private static void InsertVector128UInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ private static void InsertVector128UInt641() } } - public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641 + public sealed unsafe class InsertVector128Test__InsertVector128UInt641 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertVector128UInt641 testClass) + { + var result = Avx2.InsertVector128(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -103,7 +137,7 @@ public sealed unsafe class SimpleBinaryOpTest__InsertVector128UInt641 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__InsertVector128UInt641() + static InsertVector128Test__InsertVector128UInt641() { var random = new Random(); @@ -113,7 +147,7 @@ static SimpleBinaryOpTest__InsertVector128UInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__InsertVector128UInt641() + public InsertVector128Test__InsertVector128UInt641() { Succeeded = true; @@ -250,16 +284,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__InsertVector128UInt641(); + var test = new InsertVector128Test__InsertVector128UInt641(); var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.InsertVector128(_fld1, _fld2, 1); @@ -267,6 +301,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.InsertVector128(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Byte.cs index 00af5a5699bf..4deb7338377f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Byte.cs @@ -64,11 +64,17 @@ private static void MaxByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxByte() public sealed unsafe class SimpleBinaryOpTest__MaxByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(byte.MinValue, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(byte.MinValue, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxByte testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxByte(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int16.cs index bd8f391a29bb..032f73185b32 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int16.cs @@ -64,11 +64,17 @@ private static void MaxInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxInt16() public sealed unsafe class SimpleBinaryOpTest__MaxInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxInt16 testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxInt16(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int32.cs index e9c45952b016..d57682b4636a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.Int32.cs @@ -64,11 +64,17 @@ private static void MaxInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxInt32() public sealed unsafe class SimpleBinaryOpTest__MaxInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxInt32 testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxInt32(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.SByte.cs index cf8f8095af0e..a8bf9c3240bb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.SByte.cs @@ -64,11 +64,17 @@ private static void MaxSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxSByte() public sealed unsafe class SimpleBinaryOpTest__MaxSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxSByte testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxSByte(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt16.cs index 147cddaf5bc8..f9ad906ba547 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt16.cs @@ -64,11 +64,17 @@ private static void MaxUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxUInt16() public sealed unsafe class SimpleBinaryOpTest__MaxUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxUInt16 testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxUInt16(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt32.cs index 98982ff2f6d6..be90bd329062 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Max.UInt32.cs @@ -64,11 +64,17 @@ private static void MaxUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxUInt32() public sealed unsafe class SimpleBinaryOpTest__MaxUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxUInt32 testClass) + { + var result = Avx2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxUInt32(); var result = Avx2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Byte.cs index 1144fe86e999..37620e66b39a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Byte.cs @@ -64,11 +64,17 @@ private static void MinByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinByte() public sealed unsafe class SimpleBinaryOpTest__MinByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(byte.MinValue, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(byte.MinValue, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinByte testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinByte(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int16.cs index 5cd0fd570775..11cb6056f80c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int16.cs @@ -64,11 +64,17 @@ private static void MinInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinInt16() public sealed unsafe class SimpleBinaryOpTest__MinInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinInt16 testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinInt16(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int32.cs index 280dbfaa7094..4770ea82f4be 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.Int32.cs @@ -64,11 +64,17 @@ private static void MinInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinInt32() public sealed unsafe class SimpleBinaryOpTest__MinInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinInt32 testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinInt32(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.SByte.cs index c2cd75a4a217..eb114cca59ee 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.SByte.cs @@ -64,11 +64,17 @@ private static void MinSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinSByte() public sealed unsafe class SimpleBinaryOpTest__MinSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinSByte testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinSByte(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt16.cs index 9b07ddfd833a..0d70c1a52384 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt16.cs @@ -64,11 +64,17 @@ private static void MinUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinUInt16() public sealed unsafe class SimpleBinaryOpTest__MinUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinUInt16 testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinUInt16(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt32.cs index 8272e8582a2b..fd0c2a7c034a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Min.UInt32.cs @@ -64,11 +64,17 @@ private static void MinUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinUInt32() public sealed unsafe class SimpleBinaryOpTest__MinUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinUInt32 testClass) + { + var result = Avx2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinUInt32(); var result = Avx2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs index 6db5c686324f..db367289ee96 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs @@ -64,11 +64,17 @@ private static void OrByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrByte() public sealed unsafe class SimpleBinaryOpTest__OrByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrByte testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrByte(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs index 63c83e45a76a..e58a5b19498d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs @@ -64,11 +64,17 @@ private static void OrInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt16() public sealed unsafe class SimpleBinaryOpTest__OrInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt16 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt16(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs index 8ee4521b2543..ee8098e70c4d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs @@ -64,11 +64,17 @@ private static void OrInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt32() public sealed unsafe class SimpleBinaryOpTest__OrInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt32 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt32(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs index 1e13397d303b..c701d819bf1a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs @@ -64,11 +64,17 @@ private static void OrInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt64() public sealed unsafe class SimpleBinaryOpTest__OrInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt64 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt64(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs index cfead69ed589..4900f005e3a6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs @@ -64,11 +64,17 @@ private static void OrSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrSByte() public sealed unsafe class SimpleBinaryOpTest__OrSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrSByte testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrSByte(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs index 98459c4d6c0b..818df49fa28f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs @@ -64,11 +64,17 @@ private static void OrUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt16() public sealed unsafe class SimpleBinaryOpTest__OrUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt16 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt16(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs index 8bb9bbbc068c..c1c7a85958b4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs @@ -64,11 +64,17 @@ private static void OrUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt32() public sealed unsafe class SimpleBinaryOpTest__OrUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt32 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt32(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs index ffd4564e3bd7..9b405fc3c2a1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs @@ -64,11 +64,17 @@ private static void OrUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt64() public sealed unsafe class SimpleBinaryOpTest__OrUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt64 testClass) + { + var result = Avx2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt64(); var result = Avx2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int32.2.cs index 1f650764e94c..53e4f1e5491e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int32.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int32.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void Permute2x128Int322() { - var test = new SimpleBinaryOpTest__Permute2x128Int322(); + var test = new ImmBinaryOpTest__Permute2x128Int322(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void Permute2x128Int322() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void Permute2x128Int322() } } - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int322 + public sealed unsafe class ImmBinaryOpTest__Permute2x128Int322 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__Permute2x128Int322 testClass) + { + var result = Avx2.Permute2x128(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -102,7 +135,7 @@ public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int322 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__Permute2x128Int322() + static ImmBinaryOpTest__Permute2x128Int322() { var random = new Random(); @@ -112,7 +145,7 @@ static SimpleBinaryOpTest__Permute2x128Int322() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__Permute2x128Int322() + public ImmBinaryOpTest__Permute2x128Int322() { Succeeded = true; @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__Permute2x128Int322(); + var test = new ImmBinaryOpTest__Permute2x128Int322(); var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Permute2x128(_fld1, _fld2, 2); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int64.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int64.2.cs index 066222767560..b045fc6b464a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int64.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.Int64.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void Permute2x128Int642() { - var test = new SimpleBinaryOpTest__Permute2x128Int642(); + var test = new ImmBinaryOpTest__Permute2x128Int642(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void Permute2x128Int642() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void Permute2x128Int642() } } - public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int642 + public sealed unsafe class ImmBinaryOpTest__Permute2x128Int642 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__Permute2x128Int642 testClass) + { + var result = Avx2.Permute2x128(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -102,7 +135,7 @@ public sealed unsafe class SimpleBinaryOpTest__Permute2x128Int642 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__Permute2x128Int642() + static ImmBinaryOpTest__Permute2x128Int642() { var random = new Random(); @@ -112,7 +145,7 @@ static SimpleBinaryOpTest__Permute2x128Int642() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__Permute2x128Int642() + public ImmBinaryOpTest__Permute2x128Int642() { Succeeded = true; @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__Permute2x128Int642(); + var test = new ImmBinaryOpTest__Permute2x128Int642(); var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Permute2x128(_fld1, _fld2, 2); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt32.2.cs index ca46e060b033..75b420e19467 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt32.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt32.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void Permute2x128UInt322() { - var test = new SimpleBinaryOpTest__Permute2x128UInt322(); + var test = new ImmBinaryOpTest__Permute2x128UInt322(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void Permute2x128UInt322() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void Permute2x128UInt322() } } - public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt322 + public sealed unsafe class ImmBinaryOpTest__Permute2x128UInt322 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__Permute2x128UInt322 testClass) + { + var result = Avx2.Permute2x128(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -102,7 +135,7 @@ public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt322 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__Permute2x128UInt322() + static ImmBinaryOpTest__Permute2x128UInt322() { var random = new Random(); @@ -112,7 +145,7 @@ static SimpleBinaryOpTest__Permute2x128UInt322() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__Permute2x128UInt322() + public ImmBinaryOpTest__Permute2x128UInt322() { Succeeded = true; @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__Permute2x128UInt322(); + var test = new ImmBinaryOpTest__Permute2x128UInt322(); var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Permute2x128(_fld1, _fld2, 2); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt64.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt64.2.cs index 15a271b26607..23b52fdddad4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt64.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Permute2x128.UInt64.2.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void Permute2x128UInt642() { - var test = new SimpleBinaryOpTest__Permute2x128UInt642(); + var test = new ImmBinaryOpTest__Permute2x128UInt642(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void Permute2x128UInt642() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ private static void Permute2x128UInt642() } } - public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt642 + public sealed unsafe class ImmBinaryOpTest__Permute2x128UInt642 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__Permute2x128UInt642 testClass) + { + var result = Avx2.Permute2x128(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -102,7 +135,7 @@ public sealed unsafe class SimpleBinaryOpTest__Permute2x128UInt642 private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleBinaryOpTest__Permute2x128UInt642() + static ImmBinaryOpTest__Permute2x128UInt642() { var random = new Random(); @@ -112,7 +145,7 @@ static SimpleBinaryOpTest__Permute2x128UInt642() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleBinaryOpTest__Permute2x128UInt642() + public ImmBinaryOpTest__Permute2x128UInt642() { Succeeded = true; @@ -249,16 +282,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__Permute2x128UInt642(); + var test = new ImmBinaryOpTest__Permute2x128UInt642(); var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Permute2x128(_fld1, _fld2, 2); @@ -266,6 +299,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Permute2x128(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs index 5b38d5eb0864..3dd3790cf30a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs @@ -20,6 +20,10 @@ static Program() ["Add.UInt16"] = AddUInt16, ["Add.UInt32"] = AddUInt32, ["Add.UInt64"] = AddUInt64, + ["AlignRight.SByte.5"] = AlignRightSByte5, + ["AlignRight.SByte.27"] = AlignRightSByte27, + ["AlignRight.SByte.228"] = AlignRightSByte228, + ["AlignRight.SByte.250"] = AlignRightSByte250, ["And.Byte"] = AndByte, ["And.Int16"] = AndInt16, ["And.Int32"] = AndInt32, @@ -38,6 +42,22 @@ static Program() ["AndNot.UInt64"] = AndNotUInt64, ["Average.Byte"] = AverageByte, ["Average.UInt16"] = AverageUInt16, + ["Blend.Int16.1"] = BlendInt161, + ["Blend.Int16.2"] = BlendInt162, + ["Blend.Int16.4"] = BlendInt164, + ["Blend.Int16.85"] = BlendInt1685, + ["Blend.UInt16.1"] = BlendUInt161, + ["Blend.UInt16.2"] = BlendUInt162, + ["Blend.UInt16.4"] = BlendUInt164, + ["Blend.UInt16.85"] = BlendUInt1685, + ["Blend.Int32.1"] = BlendInt321, + ["Blend.Int32.2"] = BlendInt322, + ["Blend.Int32.4"] = BlendInt324, + ["Blend.Int32.85"] = BlendInt3285, + ["Blend.UInt32.1"] = BlendUInt321, + ["Blend.UInt32.2"] = BlendUInt322, + ["Blend.UInt32.4"] = BlendUInt324, + ["Blend.UInt32.85"] = BlendUInt3285, ["BlendVariable.Byte"] = BlendVariableByte, ["BlendVariable.SByte"] = BlendVariableSByte, ["BroadcastScalarToVector128.Byte"] = BroadcastScalarToVector128Byte, @@ -72,6 +92,9 @@ static Program() ["CompareGreaterThan.Int32"] = CompareGreaterThanInt32, ["CompareGreaterThan.Int64"] = CompareGreaterThanInt64, ["CompareGreaterThan.SByte"] = CompareGreaterThanSByte, + ["ConvertToDouble.Double"] = ConvertToDoubleDouble, + ["ConvertToInt32.Int32"] = ConvertToInt32Int32, + ["ConvertToUInt32.UInt32"] = ConvertToUInt32UInt32, ["ExtractVector128.Byte.1"] = ExtractVector128Byte1, ["ExtractVector128.SByte.1"] = ExtractVector128SByte1, ["ExtractVector128.Int16.1"] = ExtractVector128Int161, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.1.cs index 4cc6a6935055..db35fbb0d59f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt161 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt161() + static ImmUnaryOpTest__ShiftLeftLogicalInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt161() + public ImmUnaryOpTest__ShiftLeftLogicalInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt161(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.16.cs index a38f968bf138..58a1ddba9b04 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt1616() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt1616 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt1616 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt1616() + static ImmUnaryOpTest__ShiftLeftLogicalInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt1616() + public ImmUnaryOpTest__ShiftLeftLogicalInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt1616(); var result = Avx2.ShiftLeftLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.1.cs index a7cd9f9b2c48..52c615099c07 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt321 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt321() + static ImmUnaryOpTest__ShiftLeftLogicalInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt321() + public ImmUnaryOpTest__ShiftLeftLogicalInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt321(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.32.cs index f4fd0c2844e5..8a82a1ed5c79 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt3232() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt3232 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt3232 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt3232() + static ImmUnaryOpTest__ShiftLeftLogicalInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt3232() + public ImmUnaryOpTest__ShiftLeftLogicalInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt3232(); var result = Avx2.ShiftLeftLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.1.cs index 346d1b0e9eff..91a5472570a4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt641 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt641() + static ImmUnaryOpTest__ShiftLeftLogicalInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt641() + public ImmUnaryOpTest__ShiftLeftLogicalInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt641(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.64.cs index 3c9520d17b31..012bfd4552c8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.Int64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt6464() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt6464 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt6464 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt6464() + static ImmUnaryOpTest__ShiftLeftLogicalInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt6464() + public ImmUnaryOpTest__ShiftLeftLogicalInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt6464(); var result = Avx2.ShiftLeftLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.1.cs index 82ff5e985d36..e205a106a0f0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt161 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt161() + static ImmUnaryOpTest__ShiftLeftLogicalUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt161() + public ImmUnaryOpTest__ShiftLeftLogicalUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt161(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.16.cs index 9704991ef219..1ee092bbf8f3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt1616() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt1616 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt1616 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() + static ImmUnaryOpTest__ShiftLeftLogicalUInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() + public ImmUnaryOpTest__ShiftLeftLogicalUInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt1616(); var result = Avx2.ShiftLeftLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.1.cs index e7a4c80edbe7..bc359cf0afbc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt321 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt321() + static ImmUnaryOpTest__ShiftLeftLogicalUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt321() + public ImmUnaryOpTest__ShiftLeftLogicalUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt321(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.32.cs index 69a727d6e87b..3300fb65c03e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt3232() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt3232 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt3232 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() + static ImmUnaryOpTest__ShiftLeftLogicalUInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() + public ImmUnaryOpTest__ShiftLeftLogicalUInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt3232(); var result = Avx2.ShiftLeftLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.1.cs index 145d23313d60..e54fae7dffd7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt641 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt641() + static ImmUnaryOpTest__ShiftLeftLogicalUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt641() + public ImmUnaryOpTest__ShiftLeftLogicalUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt641(); var result = Avx2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.64.cs index f71e4ce517ea..42bd270599f7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical.UInt64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt6464() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt6464 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt6464 testClass) + { + var result = Avx2.ShiftLeftLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() + static ImmUnaryOpTest__ShiftLeftLogicalUInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() + public ImmUnaryOpTest__ShiftLeftLogicalUInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt6464(); var result = Avx2.ShiftLeftLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Byte.1.cs index 6a84ddf7be28..f4cfb416ded8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Byte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneByte1() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int16.1.cs index c79430a237ef..bcdf259438e3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int32.1.cs index c21577797416..332a06800598 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int64.1.cs index 2ff1810c715d..fd9b4ca22510 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.SByte.1.cs index 1f7cca825aac..73065285aa57 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.SByte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneSByte1() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt16.1.cs index b2a019de4407..ffc700111f65 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt32.1.cs index 2ab40fd6991f..955cad2c372e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt64.1.cs index 7f75ba48d4cb..47557048d919 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftLeftLogical128BitLane.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 testClass) + { + var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.1.cs index 92717b230c50..e68514c2fecb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt161() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt161(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt161 testClass) + { + var result = Avx2.ShiftRightArithmetic(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt161() + static ImmUnaryOpTest__ShiftRightArithmeticInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt161() + public ImmUnaryOpTest__ShiftRightArithmeticInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt161(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt161(); var result = Avx2.ShiftRightArithmetic(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightArithmetic(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightArithmetic(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.16.cs index 36d5864e1daa..a7b32f8a3f8d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt1616(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt1616 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt1616 testClass) + { + var result = Avx2.ShiftRightArithmetic(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt1616() + static ImmUnaryOpTest__ShiftRightArithmeticInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt1616() + public ImmUnaryOpTest__ShiftRightArithmeticInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt1616(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt1616(); var result = Avx2.ShiftRightArithmetic(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightArithmetic(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightArithmetic(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.1.cs index 266b014377eb..1f12a87c3491 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt321() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt321(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt321 testClass) + { + var result = Avx2.ShiftRightArithmetic(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt321() + static ImmUnaryOpTest__ShiftRightArithmeticInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt321() + public ImmUnaryOpTest__ShiftRightArithmeticInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt321(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt321(); var result = Avx2.ShiftRightArithmetic(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightArithmetic(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightArithmetic(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.32.cs index 0869e6316dbe..95f2cfcb1460 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightArithmetic.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt3232(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt3232 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt3232 testClass) + { + var result = Avx2.ShiftRightArithmetic(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt3232() + static ImmUnaryOpTest__ShiftRightArithmeticInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt3232() + public ImmUnaryOpTest__ShiftRightArithmeticInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt3232(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt3232(); var result = Avx2.ShiftRightArithmetic(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightArithmetic(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightArithmetic(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.1.cs index c16999ca66c0..103eab60414c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt161 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt161() + static ImmUnaryOpTest__ShiftRightLogicalInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt161() + public ImmUnaryOpTest__ShiftRightLogicalInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt161(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.16.cs index d6edfd687dc1..094a730e9ccf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt1616 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt1616 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt1616() + static ImmUnaryOpTest__ShiftRightLogicalInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt1616() + public ImmUnaryOpTest__ShiftRightLogicalInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt1616(); var result = Avx2.ShiftRightLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.1.cs index f5d0f5d1bd32..af532cbcb4ea 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt321 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt321() + static ImmUnaryOpTest__ShiftRightLogicalInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt321() + public ImmUnaryOpTest__ShiftRightLogicalInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt321(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.32.cs index 82a1c7ac6c4f..eb230872d2c4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt3232 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt3232 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt3232() + static ImmUnaryOpTest__ShiftRightLogicalInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt3232() + public ImmUnaryOpTest__ShiftRightLogicalInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt3232(); var result = Avx2.ShiftRightLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.1.cs index d0a2651ca053..e95aab1d06d7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt641 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt641() + static ImmUnaryOpTest__ShiftRightLogicalInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt641() + public ImmUnaryOpTest__ShiftRightLogicalInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt641(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.64.cs index aa0b01e5d559..5c04086f80b8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.Int64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt6464() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt6464 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt6464 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt6464() + static ImmUnaryOpTest__ShiftRightLogicalInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt6464() + public ImmUnaryOpTest__ShiftRightLogicalInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt6464(); var result = Avx2.ShiftRightLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.1.cs index 6b2b2a804b4b..5b28ae3bb6a7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt161 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt161() + static ImmUnaryOpTest__ShiftRightLogicalUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt161() + public ImmUnaryOpTest__ShiftRightLogicalUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt161(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.16.cs index 0a15497903aa..4d4c965c200b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt1616 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt1616 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt1616() + static ImmUnaryOpTest__ShiftRightLogicalUInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt1616() + public ImmUnaryOpTest__ShiftRightLogicalUInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt1616(); var result = Avx2.ShiftRightLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.1.cs index dc966abcf147..2a479c31ba4c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt321 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt321() + static ImmUnaryOpTest__ShiftRightLogicalUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt321() + public ImmUnaryOpTest__ShiftRightLogicalUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt321(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.32.cs index cc21fd1b12cc..44903ed8f49d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt3232 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt3232 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt3232() + static ImmUnaryOpTest__ShiftRightLogicalUInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt3232() + public ImmUnaryOpTest__ShiftRightLogicalUInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt3232(); var result = Avx2.ShiftRightLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.1.cs index edcb324936a9..e8be2c9f4045 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt641 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt641() + static ImmUnaryOpTest__ShiftRightLogicalUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt641() + public ImmUnaryOpTest__ShiftRightLogicalUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt641(); var result = Avx2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.64.cs index 737f16c0dbd3..cd1ceb4a0db9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical.UInt64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt6464() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt6464 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt6464 testClass) + { + var result = Avx2.ShiftRightLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt6464() + static ImmUnaryOpTest__ShiftRightLogicalUInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt6464() + public ImmUnaryOpTest__ShiftRightLogicalUInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt6464(); var result = Avx2.ShiftRightLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Byte.1.cs index 93078a8392eb..3592d4d53f80 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Byte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneByte1() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int16.1.cs index ee65a4ae23bb..70e148a08582 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int32.1.cs index 422f23570ac9..161ec9674102 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int64.1.cs index 128661215551..7de670c7599c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.SByte.1.cs index d9221f3fb2f3..90036bff9daf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.SByte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneSByte1() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt16.1.cs index 8b1f3fa7c1a7..c936a2def8f0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt32.1.cs index 074706267ef0..4fe70b99aee1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt64.1.cs index ba0f42a631ee..0bcabd209126 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/ShiftRightLogical128BitLane.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641 { + private struct TestStruct + { + public Vector256 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641 testClass) + { + var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs index 73723503f928..3f08373745cc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs @@ -64,11 +64,17 @@ private static void SubtractByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractByte() public sealed unsafe class SimpleBinaryOpTest__SubtractByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractByte testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractByte(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs index 4729c2e9cff6..461957ea99e4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs @@ -64,11 +64,17 @@ private static void SubtractInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt16 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt16(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs index d9274da2fe82..3596ec25240f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs @@ -64,11 +64,17 @@ private static void SubtractInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt32() public sealed unsafe class SimpleBinaryOpTest__SubtractInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt32 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt32(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs index 2066b4116cfc..225668f66352 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs @@ -64,11 +64,17 @@ private static void SubtractInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt64() public sealed unsafe class SimpleBinaryOpTest__SubtractInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt64 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt64(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs index cf5c34531cbe..4ee5b3873c12 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs @@ -64,11 +64,17 @@ private static void SubtractSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSByte() public sealed unsafe class SimpleBinaryOpTest__SubtractSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSByte testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSByte(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs index eb9d675a98ce..596840194e04 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs @@ -64,11 +64,17 @@ private static void SubtractUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt16 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt16(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs index 6b0d32edf8eb..bd57ecb0b34c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs @@ -64,11 +64,17 @@ private static void SubtractUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt32() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt32 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt32(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs index 34953a389ad0..f2dc9a01dbb5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs @@ -64,11 +64,17 @@ private static void SubtractUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt64() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt64 testClass) + { + var result = Avx2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt64(); var result = Avx2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs index aa3bc6ba6e58..c279b1d43ea2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs @@ -64,11 +64,17 @@ private static void XorByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorByte() public sealed unsafe class SimpleBinaryOpTest__XorByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorByte testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorByte(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs index a7866e8ec0a2..f7e1d9a53592 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs @@ -64,11 +64,17 @@ private static void XorInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt16() public sealed unsafe class SimpleBinaryOpTest__XorInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt16 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt16(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs index 809b1f7ed2ef..1f7310e1c84f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs @@ -64,11 +64,17 @@ private static void XorInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt32() public sealed unsafe class SimpleBinaryOpTest__XorInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt32 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt32(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs index 0276a29e0758..2c021383699b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs @@ -64,11 +64,17 @@ private static void XorInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt64() public sealed unsafe class SimpleBinaryOpTest__XorInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt64 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt64(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs index 49f5784cf1c8..263dc54a1e58 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs @@ -64,11 +64,17 @@ private static void XorSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorSByte() public sealed unsafe class SimpleBinaryOpTest__XorSByte { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorSByte testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorSByte(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs index c175a5dd65fd..002a38b72ab7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs @@ -64,11 +64,17 @@ private static void XorUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt16() public sealed unsafe class SimpleBinaryOpTest__XorUInt16 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt16 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt16(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs index 924d6705e7bb..865aff5e750a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs @@ -64,11 +64,17 @@ private static void XorUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt32() public sealed unsafe class SimpleBinaryOpTest__XorUInt32 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt32 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt32(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs index d178951b04ee..0ed91f44fc1d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs @@ -64,11 +64,17 @@ private static void XorUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt64() public sealed unsafe class SimpleBinaryOpTest__XorUInt64 { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt64 testClass) + { + var result = Avx2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt64(); var result = Avx2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Avx2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_r.csproj new file mode 100644 index 000000000000..4d7b189ef1d4 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_r.csproj @@ -0,0 +1,47 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_ro.csproj new file mode 100644 index 000000000000..122e1463612e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Avx2_ro.csproj @@ -0,0 +1,47 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.1.cs new file mode 100644 index 000000000000..3bc58f7cf566 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt321() + { + var test = new ImmBinaryOpTest__BlendInt321(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt321 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt321 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt321() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt321() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt321(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.1, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.2.cs new file mode 100644 index 000000000000..858d58275dd4 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt322() + { + var test = new ImmBinaryOpTest__BlendInt322(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt322 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt322 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt322() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt322() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt322(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.2, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.4.cs new file mode 100644 index 000000000000..6978b908bdc9 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt324() + { + var test = new ImmBinaryOpTest__BlendInt324(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt324 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt324 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt324() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt324() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt324(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.4, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.85.cs new file mode 100644 index 000000000000..7e3fde74bde4 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.Int32.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendInt3285() + { + var test = new ImmBinaryOpTest__BlendInt3285(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendInt3285 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendInt3285 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Int32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); + + private static Int32[] _data1 = new Int32[Op1ElementCount]; + private static Int32[] _data2 = new Int32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendInt3285() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendInt3285() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Int32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendInt3285(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Int32[] inArray1 = new Int32[Op1ElementCount]; + Int32[] inArray2 = new Int32[Op2ElementCount]; + Int32[] outArray = new Int32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Int32[] left, Int32[] right, Int32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.85, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.1.cs new file mode 100644 index 000000000000..e6b4c34260d2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.1.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt321() + { + var test = new ImmBinaryOpTest__BlendUInt321(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt321 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt321 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt321() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt321() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)1 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 1 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt321(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.1, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.2.cs new file mode 100644 index 000000000000..f1ea0277a2f6 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.2.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt322() + { + var test = new ImmBinaryOpTest__BlendUInt322(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt322 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt322 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt322() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt322() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)2 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt322(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.2, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.4.cs new file mode 100644 index 000000000000..af9c53ef53e9 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.4.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt324() + { + var test = new ImmBinaryOpTest__BlendUInt324(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt324 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt324 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt324() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt324() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)4 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 4 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt324(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.4, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.85.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.85.cs new file mode 100644 index 000000000000..5d8588b59507 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Blend.UInt32.85.cs @@ -0,0 +1,385 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void BlendUInt3285() + { + var test = new ImmBinaryOpTest__BlendUInt3285(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ImmBinaryOpTest__BlendUInt3285 + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__BlendUInt3285 testClass) + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 32; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); + + private static UInt32[] _data1 = new UInt32[Op1ElementCount]; + private static UInt32[] _data2 = new UInt32[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static ImmBinaryOpTest__BlendUInt3285() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public ImmBinaryOpTest__BlendUInt3285() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new UInt32[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Avx2.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Avx2.Blend( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Avx2.Blend( + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Avx2.Blend( + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Avx2).GetMethod(nameof(Avx2.Blend), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)), + (byte)85 + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Avx2.Blend( + _clsVar1, + _clsVar2, + 85 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr)); + var result = Avx2.Blend(left, right, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ImmBinaryOpTest__BlendUInt3285(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Avx2.Blend(_fld1, _fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Avx2.Blend(test._fld1, test._fld2, 85); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + UInt32[] inArray1 = new UInt32[Op1ElementCount]; + UInt32[] inArray2 = new UInt32[Op2ElementCount]; + UInt32[] outArray = new UInt32[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(UInt32[] left, UInt32[] right, UInt32[] result, [CallerMemberName] string method = "") + { + if (result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Blend)}(Vector128.85, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Program.Avx2_Vector128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Program.Avx2_Vector128.cs new file mode 100644 index 000000000000..3253b8b27193 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2_Vector128/Program.Avx2_Vector128.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; +using System.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + static Program() + { + TestList = new Dictionary() { + ["Blend.Int32.1"] = BlendInt321, + ["Blend.Int32.2"] = BlendInt322, + ["Blend.Int32.4"] = BlendInt324, + ["Blend.Int32.85"] = BlendInt3285, + ["Blend.UInt32.1"] = BlendUInt321, + ["Blend.UInt32.2"] = BlendUInt322, + ["Blend.UInt32.4"] = BlendUInt324, + ["Blend.UInt32.85"] = BlendUInt3285, + }; + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt32.cs new file mode 100644 index 000000000000..a8f5f8545252 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt32.cs @@ -0,0 +1,221 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AndNotUInt32() + { + var test = new ScalarBinaryOpTest__AndNotUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__AndNotUInt32 + { + private struct TestStruct + { + public UInt32 _fld1; + public UInt32 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (uint)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (uint)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__AndNotUInt32 testClass) + { + var result = Bmi1.AndNot(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt32 _data1; + private static UInt32 _data2; + + private static UInt32 _clsVar1; + private static UInt32 _clsVar2; + + private UInt32 _fld1; + private UInt32 _fld2; + + static ScalarBinaryOpTest__AndNotUInt32() + { + var random = new Random(); + _clsVar1 = (uint)(random.Next(0, int.MaxValue)); + _clsVar2 = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__AndNotUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (uint)(random.Next(0, int.MaxValue)); + _fld2 = (uint)(random.Next(0, int.MaxValue)); + + _data1 = (uint)(random.Next(0, int.MaxValue)); + _data2 = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.AndNot( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.AndNot), new Type[] { typeof(UInt32), typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.AndNot( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi1.AndNot(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__AndNotUInt32(); + var result = Bmi1.AndNot(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.AndNot(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.AndNot(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 left, UInt32 right, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = ((~left & right) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.AndNot)}(UInt32, UInt32): AndNot failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt64.cs new file mode 100644 index 000000000000..1758aac9bc4c --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/AndNot.UInt64.cs @@ -0,0 +1,221 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void AndNotUInt64() + { + var test = new ScalarBinaryOpTest__AndNotUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__AndNotUInt64 + { + private struct TestStruct + { + public UInt64 _fld1; + public UInt64 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (ulong)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (ulong)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__AndNotUInt64 testClass) + { + var result = Bmi1.AndNot(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt64 _data1; + private static UInt64 _data2; + + private static UInt64 _clsVar1; + private static UInt64 _clsVar2; + + private UInt64 _fld1; + private UInt64 _fld2; + + static ScalarBinaryOpTest__AndNotUInt64() + { + var random = new Random(); + _clsVar1 = (ulong)(random.Next(0, int.MaxValue)); + _clsVar2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__AndNotUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (ulong)(random.Next(0, int.MaxValue)); + _fld2 = (ulong)(random.Next(0, int.MaxValue)); + + _data1 = (ulong)(random.Next(0, int.MaxValue)); + _data2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.AndNot( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.AndNot), new Type[] { typeof(UInt64), typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.AndNot( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi1.AndNot(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__AndNotUInt64(); + var result = Bmi1.AndNot(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.AndNot(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.AndNot(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = ((~left & right) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.AndNot)}(UInt64, UInt64): AndNot failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_r.csproj new file mode 100644 index 000000000000..39dfd673f8c7 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_r.csproj @@ -0,0 +1,45 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_ro.csproj new file mode 100644 index 000000000000..5ef9723d4bd5 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Bmi1_ro.csproj @@ -0,0 +1,45 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt32.cs new file mode 100644 index 000000000000..998301c65c34 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt32.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ExtractLowestSetBitUInt32() + { + var test = new ScalarUnaryOpTest__ExtractLowestSetBitUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__ExtractLowestSetBitUInt32 + { + private struct TestStruct + { + public UInt32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (uint)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__ExtractLowestSetBitUInt32 testClass) + { + var result = Bmi1.ExtractLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt32 _data; + + private static UInt32 _clsVar; + + private UInt32 _fld; + + static ScalarUnaryOpTest__ExtractLowestSetBitUInt32() + { + var random = new Random(); + _clsVar = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__ExtractLowestSetBitUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld = (uint)(random.Next(0, int.MaxValue)); + _data = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.ExtractLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.ExtractLowestSetBit), new Type[] { typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.ExtractLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.ExtractLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__ExtractLowestSetBitUInt32(); + var result = Bmi1.ExtractLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.ExtractLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.ExtractLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 data, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = ((unchecked((uint)(-(int)data)) & data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.ExtractLowestSetBit)}(UInt32): ExtractLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt64.cs new file mode 100644 index 000000000000..791ec9b9b9bc --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ExtractLowestSetBit.UInt64.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ExtractLowestSetBitUInt64() + { + var test = new ScalarUnaryOpTest__ExtractLowestSetBitUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__ExtractLowestSetBitUInt64 + { + private struct TestStruct + { + public UInt64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ulong)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__ExtractLowestSetBitUInt64 testClass) + { + var result = Bmi1.ExtractLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt64 _data; + + private static UInt64 _clsVar; + + private UInt64 _fld; + + static ScalarUnaryOpTest__ExtractLowestSetBitUInt64() + { + var random = new Random(); + _clsVar = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__ExtractLowestSetBitUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld = (ulong)(random.Next(0, int.MaxValue)); + _data = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.ExtractLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.ExtractLowestSetBit), new Type[] { typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.ExtractLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.ExtractLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__ExtractLowestSetBitUInt64(); + var result = Bmi1.ExtractLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.ExtractLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.ExtractLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = ((unchecked((ulong)(-(long)data)) & data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.ExtractLowestSetBit)}(UInt64): ExtractLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt32.cs new file mode 100644 index 000000000000..9a11c71316cc --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt32.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void GetMaskUpToLowestSetBitUInt32() + { + var test = new ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32 + { + private struct TestStruct + { + public UInt32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (uint)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32 testClass) + { + var result = Bmi1.GetMaskUpToLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt32 _data; + + private static UInt32 _clsVar; + + private UInt32 _fld; + + static ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32() + { + var random = new Random(); + _clsVar = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld = (uint)(random.Next(0, int.MaxValue)); + _data = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.GetMaskUpToLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.GetMaskUpToLowestSetBit), new Type[] { typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.GetMaskUpToLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.GetMaskUpToLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt32(); + var result = Bmi1.GetMaskUpToLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.GetMaskUpToLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.GetMaskUpToLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 data, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = (((data - 1) ^ data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.GetMaskUpToLowestSetBit)}(UInt32): GetMaskUpToLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt64.cs new file mode 100644 index 000000000000..6eef299ad15e --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/GetMaskUpToLowestSetBit.UInt64.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void GetMaskUpToLowestSetBitUInt64() + { + var test = new ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64 + { + private struct TestStruct + { + public UInt64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ulong)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64 testClass) + { + var result = Bmi1.GetMaskUpToLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt64 _data; + + private static UInt64 _clsVar; + + private UInt64 _fld; + + static ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64() + { + var random = new Random(); + _clsVar = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld = (ulong)(random.Next(0, int.MaxValue)); + _data = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.GetMaskUpToLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.GetMaskUpToLowestSetBit), new Type[] { typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.GetMaskUpToLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.GetMaskUpToLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__GetMaskUpToLowestSetBitUInt64(); + var result = Bmi1.GetMaskUpToLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.GetMaskUpToLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.GetMaskUpToLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = (((data - 1) ^ data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.GetMaskUpToLowestSetBit)}(UInt64): GetMaskUpToLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Program.Bmi1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Program.Bmi1.cs new file mode 100644 index 000000000000..5760453e745d --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/Program.Bmi1.cs @@ -0,0 +1,28 @@ +// 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.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + static Program() + { + TestList = new Dictionary() { + ["AndNot.UInt32"] = AndNotUInt32, + ["AndNot.UInt64"] = AndNotUInt64, + ["ExtractLowestSetBit.UInt32"] = ExtractLowestSetBitUInt32, + ["ExtractLowestSetBit.UInt64"] = ExtractLowestSetBitUInt64, + ["GetMaskUpToLowestSetBit.UInt32"] = GetMaskUpToLowestSetBitUInt32, + ["GetMaskUpToLowestSetBit.UInt64"] = GetMaskUpToLowestSetBitUInt64, + ["ResetLowestSetBit.UInt32"] = ResetLowestSetBitUInt32, + ["ResetLowestSetBit.UInt64"] = ResetLowestSetBitUInt64, + ["TrailingZeroCount.UInt32"] = TrailingZeroCountUInt32, + ["TrailingZeroCount.UInt64"] = TrailingZeroCountUInt64, + }; + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt32.cs new file mode 100644 index 000000000000..ff12e0399e1a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt32.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ResetLowestSetBitUInt32() + { + var test = new ScalarUnaryOpTest__ResetLowestSetBitUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__ResetLowestSetBitUInt32 + { + private struct TestStruct + { + public UInt32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (uint)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__ResetLowestSetBitUInt32 testClass) + { + var result = Bmi1.ResetLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt32 _data; + + private static UInt32 _clsVar; + + private UInt32 _fld; + + static ScalarUnaryOpTest__ResetLowestSetBitUInt32() + { + var random = new Random(); + _clsVar = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__ResetLowestSetBitUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld = (uint)(random.Next(0, int.MaxValue)); + _data = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.ResetLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.ResetLowestSetBit), new Type[] { typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.ResetLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.ResetLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__ResetLowestSetBitUInt32(); + var result = Bmi1.ResetLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.ResetLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.ResetLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 data, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = (((data - 1) & data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.ResetLowestSetBit)}(UInt32): ResetLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt64.cs new file mode 100644 index 000000000000..bc505e095e92 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/ResetLowestSetBit.UInt64.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ResetLowestSetBitUInt64() + { + var test = new ScalarUnaryOpTest__ResetLowestSetBitUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__ResetLowestSetBitUInt64 + { + private struct TestStruct + { + public UInt64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ulong)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__ResetLowestSetBitUInt64 testClass) + { + var result = Bmi1.ResetLowestSetBit(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt64 _data; + + private static UInt64 _clsVar; + + private UInt64 _fld; + + static ScalarUnaryOpTest__ResetLowestSetBitUInt64() + { + var random = new Random(); + _clsVar = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__ResetLowestSetBitUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld = (ulong)(random.Next(0, int.MaxValue)); + _data = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.ResetLowestSetBit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.ResetLowestSetBit), new Type[] { typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.ResetLowestSetBit( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.ResetLowestSetBit(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__ResetLowestSetBitUInt64(); + var result = Bmi1.ResetLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.ResetLowestSetBit(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.ResetLowestSetBit(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + isUnexpectedResult = (((data - 1) & data) != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.ResetLowestSetBit)}(UInt64): ResetLowestSetBit failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt32.cs new file mode 100644 index 000000000000..5349394db541 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt32.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void TrailingZeroCountUInt32() + { + var test = new ScalarUnaryOpTest__TrailingZeroCountUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__TrailingZeroCountUInt32 + { + private struct TestStruct + { + public UInt32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (uint)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__TrailingZeroCountUInt32 testClass) + { + var result = Bmi1.TrailingZeroCount(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt32 _data; + + private static UInt32 _clsVar; + + private UInt32 _fld; + + static ScalarUnaryOpTest__TrailingZeroCountUInt32() + { + var random = new Random(); + _clsVar = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__TrailingZeroCountUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld = (uint)(random.Next(0, int.MaxValue)); + _data = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.TrailingZeroCount( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.TrailingZeroCount), new Type[] { typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.TrailingZeroCount( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.TrailingZeroCount(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__TrailingZeroCountUInt32(); + var result = Bmi1.TrailingZeroCount(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.TrailingZeroCount(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.TrailingZeroCount(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 data, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + uint expectedResult = 0; for (int index = 0; ((data >> index) & 1) == 0; index++) { expectedResult++; } isUnexpectedResult = (expectedResult != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.TrailingZeroCount)}(UInt32): TrailingZeroCount failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt64.cs new file mode 100644 index 000000000000..8e8cda2a66c3 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi1/TrailingZeroCount.UInt64.cs @@ -0,0 +1,206 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void TrailingZeroCountUInt64() + { + var test = new ScalarUnaryOpTest__TrailingZeroCountUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarUnaryOpTest__TrailingZeroCountUInt64 + { + private struct TestStruct + { + public UInt64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ulong)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarUnaryOpTest__TrailingZeroCountUInt64 testClass) + { + var result = Bmi1.TrailingZeroCount(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static UInt64 _data; + + private static UInt64 _clsVar; + + private UInt64 _fld; + + static ScalarUnaryOpTest__TrailingZeroCountUInt64() + { + var random = new Random(); + _clsVar = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarUnaryOpTest__TrailingZeroCountUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld = (ulong)(random.Next(0, int.MaxValue)); + _data = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi1.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi1.TrailingZeroCount( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + ); + + ValidateResult(_data, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi1).GetMethod(nameof(Bmi1.TrailingZeroCount), new Type[] { typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); + + ValidateResult(_data, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi1.TrailingZeroCount( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Bmi1.TrailingZeroCount(data); + + ValidateResult(data, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarUnaryOpTest__TrailingZeroCountUInt64(); + var result = Bmi1.TrailingZeroCount(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = Bmi1.TrailingZeroCount(_fld); + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi1.TrailingZeroCount(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 data, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + ulong expectedResult = 0; for (int index = 0; ((data >> index) & 1) == 0; index++) { expectedResult++; } isUnexpectedResult = (expectedResult != result); + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi1)}.{nameof(Bmi1.TrailingZeroCount)}(UInt64): TrailingZeroCount failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_r.csproj new file mode 100644 index 000000000000..007f09731d76 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_r.csproj @@ -0,0 +1,39 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_ro.csproj new file mode 100644 index 000000000000..d0ad1a184589 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Bmi2_ro.csproj @@ -0,0 +1,39 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt32.cs new file mode 100644 index 000000000000..9a56e891ecfc --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt32.cs @@ -0,0 +1,243 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ParallelBitDepositUInt32() + { + var test = new ScalarBinaryOpTest__ParallelBitDepositUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__ParallelBitDepositUInt32 + { + private struct TestStruct + { + public UInt32 _fld1; + public UInt32 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (uint)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (uint)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__ParallelBitDepositUInt32 testClass) + { + var result = Bmi2.ParallelBitDeposit(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt32 _data1; + private static UInt32 _data2; + + private static UInt32 _clsVar1; + private static UInt32 _clsVar2; + + private UInt32 _fld1; + private UInt32 _fld2; + + static ScalarBinaryOpTest__ParallelBitDepositUInt32() + { + var random = new Random(); + _clsVar1 = (uint)(random.Next(0, int.MaxValue)); + _clsVar2 = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__ParallelBitDepositUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (uint)(random.Next(0, int.MaxValue)); + _fld2 = (uint)(random.Next(0, int.MaxValue)); + + _data1 = (uint)(random.Next(0, int.MaxValue)); + _data2 = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi2.ParallelBitDeposit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi2).GetMethod(nameof(Bmi2.ParallelBitDeposit), new Type[] { typeof(UInt32), typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi2.ParallelBitDeposit( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi2.ParallelBitDeposit(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__ParallelBitDepositUInt32(); + var result = Bmi2.ParallelBitDeposit(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi2.ParallelBitDeposit(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi2.ParallelBitDeposit(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 left, UInt32 right, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + +// The validation logic defined here for Bmi2.ParallelBitDeposit and Bmi2.ParallelBitExtract is +// based on the 'Operation' pseudo-code defined for the pdep and pext instruction in the 'Intel® +// 64 and IA-32 Architectures Software Developer’s Manual; Volume 2 (2A, 2B, 2C & 2D): Instruction +// Set Reference, A-Z' + +uint temp = left; +uint mask = right; +uint dest = 0; +byte m = 0, k = 0; + +while (m < 32) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> k) & 1) << m); // Extract bit at index k of temp and insert to index m of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); + + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi2)}.{nameof(Bmi2.ParallelBitDeposit)}(UInt32, UInt32): ParallelBitDeposit failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt64.cs new file mode 100644 index 000000000000..e95212bb26ce --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitDeposit.UInt64.cs @@ -0,0 +1,243 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ParallelBitDepositUInt64() + { + var test = new ScalarBinaryOpTest__ParallelBitDepositUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__ParallelBitDepositUInt64 + { + private struct TestStruct + { + public UInt64 _fld1; + public UInt64 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (ulong)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (ulong)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__ParallelBitDepositUInt64 testClass) + { + var result = Bmi2.ParallelBitDeposit(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt64 _data1; + private static UInt64 _data2; + + private static UInt64 _clsVar1; + private static UInt64 _clsVar2; + + private UInt64 _fld1; + private UInt64 _fld2; + + static ScalarBinaryOpTest__ParallelBitDepositUInt64() + { + var random = new Random(); + _clsVar1 = (ulong)(random.Next(0, int.MaxValue)); + _clsVar2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__ParallelBitDepositUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (ulong)(random.Next(0, int.MaxValue)); + _fld2 = (ulong)(random.Next(0, int.MaxValue)); + + _data1 = (ulong)(random.Next(0, int.MaxValue)); + _data2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi2.ParallelBitDeposit( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi2).GetMethod(nameof(Bmi2.ParallelBitDeposit), new Type[] { typeof(UInt64), typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi2.ParallelBitDeposit( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi2.ParallelBitDeposit(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__ParallelBitDepositUInt64(); + var result = Bmi2.ParallelBitDeposit(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi2.ParallelBitDeposit(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi2.ParallelBitDeposit(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + +// The validation logic defined here for Bmi2.ParallelBitDeposit and Bmi2.ParallelBitExtract is +// based on the 'Operation' pseudo-code defined for the pdep and pext instruction in the 'Intel® +// 64 and IA-32 Architectures Software Developer’s Manual; Volume 2 (2A, 2B, 2C & 2D): Instruction +// Set Reference, A-Z' + +ulong temp = left; +ulong mask = right; +ulong dest = 0; +byte m = 0, k = 0; + +while (m < 64) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> k) & 1) << m); // Extract bit at index k of temp and insert to index m of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); + + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi2)}.{nameof(Bmi2.ParallelBitDeposit)}(UInt64, UInt64): ParallelBitDeposit failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt32.cs new file mode 100644 index 000000000000..5d3e651af817 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt32.cs @@ -0,0 +1,243 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ParallelBitExtractUInt32() + { + var test = new ScalarBinaryOpTest__ParallelBitExtractUInt32(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__ParallelBitExtractUInt32 + { + private struct TestStruct + { + public UInt32 _fld1; + public UInt32 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (uint)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (uint)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__ParallelBitExtractUInt32 testClass) + { + var result = Bmi2.ParallelBitExtract(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt32 _data1; + private static UInt32 _data2; + + private static UInt32 _clsVar1; + private static UInt32 _clsVar2; + + private UInt32 _fld1; + private UInt32 _fld2; + + static ScalarBinaryOpTest__ParallelBitExtractUInt32() + { + var random = new Random(); + _clsVar1 = (uint)(random.Next(0, int.MaxValue)); + _clsVar2 = (uint)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__ParallelBitExtractUInt32() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (uint)(random.Next(0, int.MaxValue)); + _fld2 = (uint)(random.Next(0, int.MaxValue)); + + _data1 = (uint)(random.Next(0, int.MaxValue)); + _data2 = (uint)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi2.ParallelBitExtract( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi2).GetMethod(nameof(Bmi2.ParallelBitExtract), new Type[] { typeof(UInt32), typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt32)result); + } + + public void RunClsVarScenario() + { + var result = Bmi2.ParallelBitExtract( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi2.ParallelBitExtract(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__ParallelBitExtractUInt32(); + var result = Bmi2.ParallelBitExtract(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi2.ParallelBitExtract(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi2.ParallelBitExtract(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt32 left, UInt32 right, UInt32 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + +// The validation logic defined here for Bmi2.ParallelBitDeposit and Bmi2.ParallelBitExtract is +// based on the 'Operation' pseudo-code defined for the pdep and pext instruction in the 'Intel® +// 64 and IA-32 Architectures Software Developer’s Manual; Volume 2 (2A, 2B, 2C & 2D): Instruction +// Set Reference, A-Z' + +uint temp = left; +uint mask = right; +uint dest = 0; +byte m = 0, k = 0; + +while (m < 32) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> m) & 1) << k); // Extract bit at index m of temp and insert to index k of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); + + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi2)}.{nameof(Bmi2.ParallelBitExtract)}(UInt32, UInt32): ParallelBitExtract failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt64.cs new file mode 100644 index 000000000000..bdb246d0cb4c --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/ParallelBitExtract.UInt64.cs @@ -0,0 +1,243 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ParallelBitExtractUInt64() + { + var test = new ScalarBinaryOpTest__ParallelBitExtractUInt64(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__ParallelBitExtractUInt64 + { + private struct TestStruct + { + public UInt64 _fld1; + public UInt64 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = (ulong)(random.Next(0, int.MaxValue)); + testStruct._fld2 = (ulong)(random.Next(0, int.MaxValue)); + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__ParallelBitExtractUInt64 testClass) + { + var result = Bmi2.ParallelBitExtract(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static UInt64 _data1; + private static UInt64 _data2; + + private static UInt64 _clsVar1; + private static UInt64 _clsVar2; + + private UInt64 _fld1; + private UInt64 _fld2; + + static ScalarBinaryOpTest__ParallelBitExtractUInt64() + { + var random = new Random(); + _clsVar1 = (ulong)(random.Next(0, int.MaxValue)); + _clsVar2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public ScalarBinaryOpTest__ParallelBitExtractUInt64() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = (ulong)(random.Next(0, int.MaxValue)); + _fld2 = (ulong)(random.Next(0, int.MaxValue)); + + _data1 = (ulong)(random.Next(0, int.MaxValue)); + _data2 = (ulong)(random.Next(0, int.MaxValue)); + } + + public bool IsSupported => Bmi2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Bmi2.ParallelBitExtract( + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Bmi2).GetMethod(nameof(Bmi2.ParallelBitExtract), new Type[] { typeof(UInt64), typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)), + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)) + }); + + ValidateResult(_data1, _data2, (UInt64)result); + } + + public void RunClsVarScenario() + { + var result = Bmi2.ParallelBitExtract( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data1)); + var data2 = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data2)); + var result = Bmi2.ParallelBitExtract(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__ParallelBitExtractUInt64(); + var result = Bmi2.ParallelBitExtract(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = Bmi2.ParallelBitExtract(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Bmi2.ParallelBitExtract(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(UInt64 left, UInt64 right, UInt64 result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + +// The validation logic defined here for Bmi2.ParallelBitDeposit and Bmi2.ParallelBitExtract is +// based on the 'Operation' pseudo-code defined for the pdep and pext instruction in the 'Intel® +// 64 and IA-32 Architectures Software Developer’s Manual; Volume 2 (2A, 2B, 2C & 2D): Instruction +// Set Reference, A-Z' + +ulong temp = left; +ulong mask = right; +ulong dest = 0; +byte m = 0, k = 0; + +while (m < 64) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> m) & 1) << k); // Extract bit at index m of temp and insert to index k of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); + + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof(Bmi2)}.{nameof(Bmi2.ParallelBitExtract)}(UInt64, UInt64): ParallelBitExtract failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Program.Bmi2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Program.Bmi2.cs new file mode 100644 index 000000000000..1f65f58aa063 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Bmi2/Program.Bmi2.cs @@ -0,0 +1,22 @@ +// 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.Collections.Generic; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + static Program() + { + TestList = new Dictionary() { + ["ParallelBitDeposit.UInt32"] = ParallelBitDepositUInt32, + ["ParallelBitDeposit.UInt64"] = ParallelBitDepositUInt64, + ["ParallelBitExtract.UInt32"] = ParallelBitExtractUInt32, + ["ParallelBitExtract.UInt64"] = ParallelBitExtractUInt64, + }; + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_r.csproj index 145f6a26f545..434e8c3adeea 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_r.csproj @@ -52,6 +52,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_ro.csproj index f3b9a0d9ceb2..3db0f3c5fc76 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/Fma_ro.csproj @@ -52,6 +52,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Double.cs index bb0fd1e06fe4..3de1793b53c8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddDouble testClass) + { + var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddDouble(); var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Single.cs index b968359c5bd0..982f0a8e6f6a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAdd.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddSingle testClass) + { + var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddSingle(); var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Double.cs index 9bdded606a15..1c75202e474d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedDouble testClass) + { + var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedDouble(); var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Single.cs index fea3ec766603..9a9f1ca45e99 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegated.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedSingle testClass) + { + var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedSingle(); var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Double.cs index 72cb3af14a7c..00dc858b3eda 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedScalarDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedScalarDouble testClass) + { + var result = Fma.MultiplyAddNegatedScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedScalarDouble(); var result = Fma.MultiplyAddNegatedScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegatedScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegatedScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Single.cs index 78e5cdaff97e..788647f239a4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddNegatedScalar.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedScalarSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedScalarSingle testClass) + { + var result = Fma.MultiplyAddNegatedScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedScalarSingle(); var result = Fma.MultiplyAddNegatedScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegatedScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegatedScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Double.cs index 666bb1c3b301..bc6dc563fe80 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddScalarDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddScalarDouble testClass) + { + var result = Fma.MultiplyAddScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddScalarDouble(); var result = Fma.MultiplyAddScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Single.cs index ca4914fbb6d9..f2ec6783823b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddScalar.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddScalarSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddScalarSingle testClass) + { + var result = Fma.MultiplyAddScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddScalarSingle(); var result = Fma.MultiplyAddScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Double.cs index 51c5f67e0a45..eafb99b6f01f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSubtractDouble() public sealed unsafe class AlternatingTernaryOpTest__MultiplyAddSubtractDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplyAddSubtractDouble testClass) + { + var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplyAddSubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplyAddSubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplyAddSubtractDouble(); var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Single.cs index 7e847db004ce..d2f4585070db 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplyAddSubtract.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSubtractSingle() public sealed unsafe class AlternatingTernaryOpTest__MultiplyAddSubtractSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplyAddSubtractSingle testClass) + { + var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplyAddSubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplyAddSubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplyAddSubtractSingle(); var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Double.cs index 95681f373040..25e3195b60e3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractDouble testClass) + { + var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractDouble(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Single.cs index b5878bc0bd16..46fd95a0655f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractSingle testClass) + { + var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractSingle(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Double.cs index a1691448d42d..02d525c1ad2d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractAddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractAddDouble() public sealed unsafe class AlternatingTernaryOpTest__MultiplySubtractAddDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplySubtractAddDouble testClass) + { + var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplySubtractAddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplySubtractAddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplySubtractAddDouble(); var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Single.cs index 2d4486b0ffb2..8daa36641236 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractAdd.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractAddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractAddSingle() public sealed unsafe class AlternatingTernaryOpTest__MultiplySubtractAddSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplySubtractAddSingle testClass) + { + var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplySubtractAddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplySubtractAddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplySubtractAddSingle(); var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Double.cs index 87a05cccf8ad..00c6a1971e70 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedDouble testClass) + { + var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedDouble(); var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Single.cs index 4a69878c7a3a..e487921421c1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegated.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedSingle testClass) + { + var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedSingle(); var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Double.cs index d24ee618706f..395c42f7c54f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedScalarDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedScalarDouble testClass) + { + var result = Fma.MultiplySubtractNegatedScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedScalarDouble(); var result = Fma.MultiplySubtractNegatedScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegatedScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegatedScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Single.cs index 0383238cdb21..344701da9357 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractNegatedScalar.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedScalarSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedScalarSingle testClass) + { + var result = Fma.MultiplySubtractNegatedScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedScalarSingle(); var result = Fma.MultiplySubtractNegatedScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegatedScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegatedScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Double.cs index d9a9d377f640..1dc837fc20a8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractScalarDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractScalarDouble testClass) + { + var result = Fma.MultiplySubtractScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractScalarDouble(); var result = Fma.MultiplySubtractScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Single.cs index f5ce69a4b22b..7e45066f48f0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtractScalar.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractScalarSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractScalarSingle testClass) + { + var result = Fma.MultiplySubtractScalar(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractScalarSingle(); var result = Fma.MultiplySubtractScalar(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractScalar(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractScalar(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_r.csproj index 9622d1d16290..5b470cdf24f5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_r.csproj @@ -44,6 +44,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_ro.csproj index 32256c742763..fb354fff787e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/Fma_ro.csproj @@ -44,6 +44,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Double.cs index ea72fa1eb101..346a8d1f3401 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddDouble testClass) + { + var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddDouble(); var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Single.cs index b43f125fef75..97082d858142 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAdd.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddSingle testClass) + { + var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddSingle(); var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Double.cs index df2b53d3d1d1..50b0fd844fb6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedDouble testClass) + { + var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedDouble(); var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Single.cs index 4e9056599a04..3d67ba89f9a9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddNegated.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddNegatedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddNegatedSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplyAddNegatedSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplyAddNegatedSingle testClass) + { + var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplyAddNegatedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplyAddNegatedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplyAddNegatedSingle(); var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Double.cs index 4fb1287752bf..e7fd3fa6c4b1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSubtractDouble() public sealed unsafe class AlternatingTernaryOpTest__MultiplyAddSubtractDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplyAddSubtractDouble testClass) + { + var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplyAddSubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplyAddSubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplyAddSubtractDouble(); var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Single.cs index fcfcef76f5ca..968218df73e0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplyAddSubtract.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyAddSubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplyAddSubtractSingle() public sealed unsafe class AlternatingTernaryOpTest__MultiplyAddSubtractSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplyAddSubtractSingle testClass) + { + var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplyAddSubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplyAddSubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplyAddSubtractSingle(); var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplyAddSubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplyAddSubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Double.cs index 58e6e8f40ac5..de53c755ccbf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractDouble testClass) + { + var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractDouble(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Single.cs index f9c0195048fe..67e6af163ade 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtract.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractSingle testClass) + { + var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractSingle(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Double.cs index c20c08499a03..600eab1385da 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractAddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractAddDouble() public sealed unsafe class AlternatingTernaryOpTest__MultiplySubtractAddDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplySubtractAddDouble testClass) + { + var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplySubtractAddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplySubtractAddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplySubtractAddDouble(); var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Single.cs index dddb2ebd5350..6e0009f7e219 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractAdd.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractAddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractAddSingle() public sealed unsafe class AlternatingTernaryOpTest__MultiplySubtractAddSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__MultiplySubtractAddSingle testClass) + { + var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static AlternatingTernaryOpTest__MultiplySubtractAddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public AlternatingTernaryOpTest__MultiplySubtractAddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new AlternatingTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__MultiplySubtractAddSingle(); var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractAdd(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractAdd(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Double.cs index 538ccde61016..e053db21b778 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Double.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedDouble() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedDouble { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedDouble testClass) + { + var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedDouble(); var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Single.cs index d193c3c704f1..8c77564b3951 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector256/MultiplySubtractNegated.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySubtractNegatedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void MultiplySubtractNegatedSingle() public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractNegatedSingle { + private struct TestStruct + { + public Vector256 _fld1; + public Vector256 _fld2; + public Vector256 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractNegatedSingle testClass) + { + var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 32; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,11 +146,11 @@ static SimpleTernaryOpTest__MultiplySubtractNegatedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); } @@ -124,16 +160,16 @@ public SimpleTernaryOpTest__MultiplySubtractNegatedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__MultiplySubtractNegatedSingle(); var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Fma.MultiplySubtractNegated(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Fma.MultiplySubtractNegated(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingBinOpTest.template index 5f152248cead..bee607a52b66 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingBinOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingBinOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class AlternatingBinaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingBinaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -242,7 +275,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingBinaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -251,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); @@ -259,6 +292,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingTernOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingTernOpTest.template index 0fff77538072..16823d957813 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingTernOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/AlternatingTernOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class AlternatingTernaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + public {Op3VectorType}<{Op3BaseType}> _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref testStruct._fld3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingTernaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -261,7 +297,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingTernaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanBinOpTest.template index 94adda7d95f5..2c5989f68750 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanBinOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanBinOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class BooleanBinaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -164,7 +195,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_UnsafeRead() { var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_Load() { var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_LoadAligned() { var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -251,13 +282,26 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template index f5674e8d2afa..228991aebe2a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class BooleanComparisonOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -231,7 +262,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -239,13 +270,26 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanTwoCmpOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanTwoCmpOpTest.template index eb49edb9f953..cc9cdb7286bf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanTwoCmpOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanTwoCmpOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class BooleanTwoComparisonOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -164,7 +195,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_UnsafeRead() { var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_Load() { var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ namespace JIT.HardwareIntrinsics.X86 public void RunReflectionScenario_LoadAligned() {var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>), typeof({Op2VectorType}<{Op2BaseType}>) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -250,13 +281,26 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanUnOpTest.template index 551e51398c93..daef5c7ec436 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanUnOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanUnOpTest.template @@ -22,7 +22,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}() { - var test = new BooleanComparisonOpTest__{Method}{RetBaseType}(); + var test = new BooleanUnaryOpTest__{Method}{RetBaseType}(); if (test.IsSupported) { @@ -65,11 +65,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class BooleanComparisonOpTest__{Method}{RetBaseType} + public sealed unsafe class BooleanUnaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -98,7 +126,7 @@ namespace JIT.HardwareIntrinsics.X86 private BooleanUnaryOpTest__DataTable<{Op1BaseType}> _dataTable; - static BooleanComparisonOpTest__{Method}{RetBaseType}() + static BooleanUnaryOpTest__{Method}{RetBaseType}() { var random = new Random(); @@ -106,7 +134,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public BooleanComparisonOpTest__{Method}{RetBaseType}() + public BooleanUnaryOpTest__{Method}{RetBaseType}() { Succeeded = true; @@ -213,21 +241,34 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__{Method}{RetBaseType}(); + var test = new BooleanUnaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractScalarTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractScalarTest.template index 0ac2b50e1e36..a13b2e66acd1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractScalarTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractScalarTest.template @@ -21,10 +21,8 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); - - try - { + var test = new ExtractScalarTest__{Method}{RetBaseType}{Imm}(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class ExtractScalarTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -105,7 +128,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + static ExtractScalarTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -113,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + public ExtractScalarTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -126,7 +149,7 @@ namespace JIT.HardwareIntrinsics.X86 _dataTable = new SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}>(_data, new {RetBaseType}[RetElementCount], LargestVectorSize); } - public bool IsSupported => {Isa}.IsSupported; + public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ExtractScalarTest__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld, {Imm}); @@ -254,6 +277,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template index 3a1af15f421b..480f3734390a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractStoreTest.template @@ -22,7 +22,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}Store() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}Store(); + var test = new ExtractStoreTest__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -65,11 +65,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}Store + public sealed unsafe class ExtractStoreTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractStoreTest__{Method}{RetBaseType}{Imm} testClass) + { + {Isa}.{Method}(({Op1BaseType}*)testClass._dataTable.outArrayPtr, _fld, {Imm}); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -99,7 +127,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}Store() + static ExtractStoreTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -107,7 +135,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}Store() + public ExtractStoreTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -200,35 +228,55 @@ namespace JIT.HardwareIntrinsics.X86 _clsVar, {Imm} ); + + ValidateResult(_clsVar, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { var firstOp = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr); {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { var firstOp = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); + ValidateResult(firstOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { var firstOp = {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, firstOp, {Imm}); + ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}Store(); + var test = new ExtractStoreTest__{Method}{RetBaseType}{Imm}(); {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, test._fld, {Imm}); + ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, _fld, {Imm}); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + {Isa}.{Method}(({Op1BaseType}*)_dataTable.outArrayPtr, test._fld, {Imm}); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractVector128Test.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractVector128Test.template index 49fb80e55f82..247243a9e4bc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractVector128Test.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ExtractVector128Test.template @@ -21,7 +21,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ExtractVector128Test__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class ExtractVector128Test__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractVector128Test__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -98,7 +128,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + static ExtractVector128Test__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -106,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + public ExtractVector128Test__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -230,16 +260,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ExtractVector128Test__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld, {Imm}); @@ -247,6 +277,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx index e8f44cde1889..f81f234e16f0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx @@ -21,235 +21,233 @@ using System.IO; private static readonly (string templateFileName, Dictionary templateData)[] SseInputs = new [] { - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "AddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] == right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] == right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] > right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] > right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] >= right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualUnorderedScalar",["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] >= right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] < right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] < right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] <= right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] <= right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] != right[0]) != result"}), - ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(left[0] != right[0]) != result"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareOrdered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareUnordered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MaxScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MinScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Multiply", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "SubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "AddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] == right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] == right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] > right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] > right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] >= right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareGreaterThanOrEqualUnorderedScalar",["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] >= right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] < right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] < right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] <= right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareLessThanOrEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] <= right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] != right[0]) != result"}), + ("BooleanCmpOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotEqualUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Boolean", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(left[0] != right[0]) != result"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotGreaterThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareNotLessThanOrEqualScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareOrdered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareOrderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareUnordered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "CompareUnorderedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MaxScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MinScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Multiply", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "SubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse", ["LoadIsa"] = "Sse", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}), }; private static readonly (string templateFileName, Dictionary templateData)[] Sse2Inputs = new [] { - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] + right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))",["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(~BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(~left[i] & right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Average", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Average", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))",["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareOrdered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareUnordered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Math.Max(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Max(left[i], right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Math.Max(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Max(left[i], right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MaxScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MinValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MinValue))", ["ValidateFirstResult"] = "Math.Min(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Min(left[i], right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MinValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MinValue))", ["ValidateFirstResult"] = "Math.Min(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Min(left[i], right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MinScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Multiply", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] | right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] | right[i]) != result[i]"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(Random.Next(byte.MinValue, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(Random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(Random.Next(ushort.MinValue, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(Random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(Random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(Random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(Random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "Random.NextDouble()", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(uint)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(long)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(long)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(ulong)(firstOp[i] << 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0!= result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)8", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 8"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)8", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 8"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 15) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 15) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 31) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 31) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(uint)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(long)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(long)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(ulong)(firstOp[i] >> 1) != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0!= result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)8", ["ValidateFirstResult"] = "result[0] != 8", ["ValidateRemainingResults"] = "(i == 15 ? result[i] != 0 : result[i] != 8)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)8", ["ValidateFirstResult"] = "result[0] != 8", ["ValidateRemainingResults"] = "(i == 15 ? result[i] != 0 : result[i] != 8)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "(i == 7 ? result[i] != 0 : result[i] != 2048)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "(i == 7 ? result[i] != 0 : result[i] != 2048)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)8", ["ValidateFirstResult"] = "result[0] != 134217728", ["ValidateRemainingResults"] = "(i == 3 ? result[i] != 0 : result[i] != 134217728)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)8", ["ValidateFirstResult"] = "result[0] != 134217728", ["ValidateRemainingResults"] = "(i == 3 ? result[i] != 0 : result[i] != 134217728)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)8", ["ValidateFirstResult"] = "result[0] != 576460752303423488L", ["ValidateRemainingResults"] = "(result[i] != 0)"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)8", ["ValidateFirstResult"] = "result[0] != 576460752303423488UL", ["ValidateRemainingResults"] = "(result[i] != 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] - right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))",["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] ^ right[i]) != result[i]"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Add", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] + right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.AddSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.AddSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "And", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(~BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "AndNot", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(~left[i] & right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Average", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Average", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotGreaterThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotGreaterThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotLessThan", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareNotLessThanOrEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareOrdered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "CompareUnordered", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Divide", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "DivideScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Math.Max(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Max(left[i], right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Math.Max(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Max(left[i], right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MaxScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MinValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MinValue))", ["ValidateFirstResult"] = "Math.Min(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Min(left[i], right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MinValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MinValue))", ["ValidateFirstResult"] = "Math.Min(left[0], right[0]) != result[0]", ["ValidateRemainingResults"] = "Math.Min(left[i], right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MinScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Multiply", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] | right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Or", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] | right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] | right[i]) != result[i]"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(byte.MinValue, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ScalarSimdUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SetAllVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "result[0] != firstOp", ["ValidateRemainingResults"] = "result[i] != firstOp"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(uint)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(long)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(long)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(firstOp[0] << 1) != result[0]", ["ValidateRemainingResults"] = "(ulong)(firstOp[i] << 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0!= result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)8", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 8"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)8", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 8"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftLeftLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "result[i] != 2048"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 15) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 15) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightArithmetic", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 31) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 31) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(short)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(short)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(int)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(int)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(uint)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(long)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(long)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(firstOp[0] >> 1) != result[0]", ["ValidateRemainingResults"] = "(ulong)(firstOp[i] >> 1) != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0!= result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "0 != result[0]", ["ValidateRemainingResults"] = "0 != result[i]"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)8", ["ValidateFirstResult"] = "result[0] != 8", ["ValidateRemainingResults"] = "(i == 15 ? result[i] != 0 : result[i] != 8)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)8", ["ValidateFirstResult"] = "result[0] != 8", ["ValidateRemainingResults"] = "(i == 15 ? result[i] != 0 : result[i] != 8)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "(i == 7 ? result[i] != 0 : result[i] != 2048)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)8", ["ValidateFirstResult"] = "result[0] != 2048", ["ValidateRemainingResults"] = "(i == 7 ? result[i] != 0 : result[i] != 2048)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)8", ["ValidateFirstResult"] = "result[0] != 134217728", ["ValidateRemainingResults"] = "(i == 3 ? result[i] != 0 : result[i] != 134217728)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)8", ["ValidateFirstResult"] = "result[0] != 134217728", ["ValidateRemainingResults"] = "(i == 3 ? result[i] != 0 : result[i] != 134217728)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)8", ["ValidateFirstResult"] = "result[0] != 576460752303423488L", ["ValidateRemainingResults"] = "(result[i] != 0)"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "ShiftRightLogical128BitLane", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)8", ["ValidateFirstResult"] = "result[0] != 576460752303423488UL", ["ValidateRemainingResults"] = "(result[i] != 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Subtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] - right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] - right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(ushort.MinValue,ushort.MaxValue))", ["ValidateFirstResult"] = "Sse2Verify.SubtractSaturate(left[0], right[0], result[0])", ["ValidateRemainingResults"] = "Sse2Verify.SubtractSaturate(left[i], right[i], result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "SubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(long)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(long)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(sbyte)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(sbyte)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] ^ right[i]) != result[i]"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse2", ["LoadIsa"] = "Sse2", ["Method"] = "Xor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] ^ right[i]) != result[i]"}), }; private static readonly (string templateFileName, Dictionary templateData)[] Sse3Inputs = new [] { - ("AlternatingBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i] - right[i])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i + 1]) != BitConverter.DoubleToInt64Bits(left[i + 1] + right[i + 1])"}), - ("AlternatingBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse" , ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i] - right[i])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i + 1]) != BitConverter.SingleToInt32Bits(left[i + 1] + right[i + 1])"}), - ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "HorizontalAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i1]) != BitConverter.DoubleToInt64Bits(left[i3] + left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i2]) != BitConverter.DoubleToInt64Bits(right[i3] + right[i3 + 1])"}), - ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse", ["Method"] = "HorizontalAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i1]) != BitConverter.SingleToInt32Bits(left[i3] + left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i2]) != BitConverter.SingleToInt32Bits(right[i3] + right[i3 + 1])"}), - ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "HorizontalSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i1]) != BitConverter.DoubleToInt64Bits(left[i3] - left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i2]) != BitConverter.DoubleToInt64Bits(right[i3] - right[i3 + 1])"}), - ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse", ["Method"] = "HorizontalSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i1]) != BitConverter.SingleToInt32Bits(left[i3] - left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i2]) != BitConverter.SingleToInt32Bits(right[i3] - right[i3 + 1])"}), + ("AlternatingBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i] - right[i])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i + 1]) != BitConverter.DoubleToInt64Bits(left[i + 1] + right[i + 1])"}), + ("AlternatingBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse" , ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i] - right[i])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i + 1]) != BitConverter.SingleToInt32Bits(left[i + 1] + right[i + 1])"}), + ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "HorizontalAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i1]) != BitConverter.DoubleToInt64Bits(left[i3] + left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i2]) != BitConverter.DoubleToInt64Bits(right[i3] + right[i3 + 1])"}), + ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse", ["Method"] = "HorizontalAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i1]) != BitConverter.SingleToInt32Bits(left[i3] + left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i2]) != BitConverter.SingleToInt32Bits(right[i3] + right[i3 + 1])"}), + ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse2", ["Method"] = "HorizontalSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[i1]) != BitConverter.DoubleToInt64Bits(left[i3] - left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i2]) != BitConverter.DoubleToInt64Bits(right[i3] - right[i3 + 1])"}), + ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse3", ["LoadIsa"] = "Sse", ["Method"] = "HorizontalSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[i1]) != BitConverter.SingleToInt32Bits(left[i3] - left[i3 + 1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i2]) != BitConverter.SingleToInt32Bits(right[i3] - right[i3 + 1])"}), }; private static readonly (string templateFileName, Dictionary templateData)[] Ssse3Inputs = new [] @@ -265,6 +263,7 @@ private static readonly (string templateFileName, Dictionary tem ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "HorizontalSubtractSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[i1] != Math.Clamp((left[i3] - left[i3 + 1]), short.MinValue, short.MaxValue)", ["ValidateRemainingResults"] = "result[i2] != Math.Clamp((right[i3] - right[i3 + 1]), short.MinValue, short.MaxValue)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddAdjacent", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Clamp(((right[1] * left[1]) + (right[0] * left[0])), short.MinValue, short.MaxValue)", ["ValidateRemainingResults"] = "result[i] != Math.Clamp(((right[(i * 2) + 1] * left[(i * 2) + 1]) + (right[i * 2] * left[i * 2])), short.MinValue, short.MaxValue)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyHighRoundScale", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (short)((((left[0] * right[0]) >> 14) + 1) >> 1)", ["ValidateRemainingResults"] = "result[i] != (short)((((left[i] * right[i]) >> 14) + 1) >> 1)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((right[0] > 127) ? 0 : left[right[0] & 0x0F])", ["ValidateRemainingResults"] = "result[i] != ((right[i] > 127) ? 0 : left[right[i] & 0x0F])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((right[0] < 0) ? 0 : left[right[0] & 0x0F])", ["ValidateRemainingResults"] = "result[i] != ((right[i] < 0) ? 0 : left[right[i] & 0x0F])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "Sign", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue + 1, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != (right[0] < 0 ? (sbyte)(-left[0]) : (right[0] > 0 ? left[0] : 0))", ["ValidateRemainingResults"] = "result[i] != (right[i] < 0 ? (sbyte)(-left[i]) : (right[i] > 0 ? left[i] : 0))"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Ssse3", ["LoadIsa"] = "Sse2", ["Method"] = "Sign", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue + 1, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (right[0] < 0 ? (short)(-left[0]) : (right[0] > 0 ? left[0] : 0))", ["ValidateRemainingResults"] = "result[i] != (right[i] < 0 ? (short)(-left[i]) : (right[i] > 0 ? left[i] : 0))"}), @@ -274,57 +273,55 @@ private static readonly (string templateFileName, Dictionary tem private static readonly (string templateFileName, Dictionary templateData)[] Sse41Inputs = new [] { ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp3"] = "(byte)(((i % 2) == 0) ? 128 : 1)", ["ValidateFirstResult"] = "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", ["ValidateRemainingResults"] = "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "(double)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp3"] = "(sbyte)(((i % 2) == 0) ? -128 : 1)", ["ValidateFirstResult"] = "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", ["ValidateRemainingResults"] = "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CeilingScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "CeilingScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "(float)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CeilingScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "CeilingScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1]))"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1]))"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Floor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Floor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "0", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Extract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Floor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Floor", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "FloorScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "0", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "4", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "8", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "48", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "128", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(0.0f)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])", ["ValidateRemainingResults"] = "i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "4", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])", ["ValidateRemainingResults"] = "i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "8", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])", ["ValidateRemainingResults"] = "i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "48", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "128", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[2])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != firstOp[i])"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Data"] = "(float)2", ["Imm"] = "192", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "129", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(0.0f)", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("InsertVector128Test.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "Insert", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "192", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[3])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Max", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Max(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Max(left[i], right[i])"}), @@ -335,26 +332,26 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "Min", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != Math.Min(left[0], right[0])", ["ValidateRemainingResults"] = "result[i] != Math.Min(left[i], right[i])"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyLow", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != BitConverter.ToInt32(BitConverter.GetBytes(((long)(left[0])) * right[0]), 0)", ["ValidateRemainingResults"] = "result[i] != BitConverter.ToInt32(BitConverter.GetBytes(((long)(left[i])) * right[i]), 0)"}), ("HorizontalBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "PackUnsignedSaturate", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[i1] != ((left[i3 - inner] > 0xFFFF) ? 0xFFFF : ((left[i3 - inner] < 0) ? 0 : BitConverter.ToUInt16(BitConverter.GetBytes(left[i3 - inner]), 0)))", ["ValidateRemainingResults"] = "result[i2] != ((right[i3 - inner] > 0xFFFF) ? 0xFFFF : ((right[i3 - inner] < 0) ? 0 : BitConverter.ToUInt16(BitConverter.GetBytes(right[i3 - inner]), 0)))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundCurrentDirectionScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundCurrentDirectionScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNearestIntegerScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(right[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNearestIntegerScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(right[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNegativeInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNegativeInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToPositiveInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToPositiveInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToZeroScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((right[0] > 0) ? Math.Floor(right[0]) : Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToZeroScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((right[0] > 0) ? MathF.Floor(right[0]) : MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundCurrentDirectionScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundCurrentDirectionScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNearestIntegerScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(right[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNearestIntegerScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(right[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToNegativeInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToNegativeInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToPositiveInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToPositiveInfinityScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "RoundToZeroScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((right[0] > 0) ? Math.Floor(right[0]) : Math.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse", ["Method"] = "RoundToZeroScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((right[0] > 0) ? MathF.Floor(right[0]) : MathF.Ceiling(right[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])"}), ("BooleanUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "TestAllOnes", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(~value[i] & byte.MaxValue) == 0"}), ("BooleanUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "TestAllOnes", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(~value[i] & -1) == 0"}), ("BooleanUnOpTest.template", new Dictionary { ["Isa"] = "Sse41", ["LoadIsa"] = "Sse2", ["Method"] = "TestAllOnes", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(~value[i] & -1) == 0"}), @@ -412,167 +409,161 @@ private static readonly (string templateFileName, Dictionary tem private static readonly (string templateFileName, Dictionary templateData)[] AvxInputs = new [] { - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AndNot", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AndNot", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Divide", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Divide", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateEvenIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateEvenIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateOddIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), - ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse", ["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[4])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i + 4]))"}), - ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[2])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(firstOp[i + 2]))"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), - ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(0,sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(0,short.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0,ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "(i > 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[i - 4]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i]))"}), - ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[0])", ["ValidateRemainingResults"] = "(i > 1 ? BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(right[i - 2]) : BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Max", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Max", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Min", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Min", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Multiply", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Multiply", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Or", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Or", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Permute", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[4]) != BitConverter.SingleToInt32Bits(firstOp[5])"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Permute", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[2]) != BitConverter.DoubleToInt64Bits(firstOp[2]) || BitConverter.DoubleToInt64Bits(result[2]) != BitConverter.DoubleToInt64Bits(firstOp[2])"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse", ["Method"] = "Permute", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[2])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[1]) != BitConverter.SingleToInt32Bits(firstOp[0]) || BitConverter.SingleToInt32Bits(result[2]) != BitConverter.SingleToInt32Bits(firstOp[0])"}), - ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "Permute", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[1]) != BitConverter.DoubleToInt64Bits(firstOp[1])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "PermuteVar", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "BitConverter.Int32BitsToSingle(1)", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[1]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "i > 3 ? (BitConverter.SingleToInt32Bits(left[5]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(left[1]) != BitConverter.SingleToInt32Bits(result[i]))"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "PermuteVar", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "BitConverter.Int64BitsToDouble(1)", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "i > 1 ? (BitConverter.DoubleToInt64Bits(left[2]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(left[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i]))"}), - ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i]))"}), - ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[7]) != BitConverter.SingleToInt32Bits(right[4])"}), - ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[3]) != BitConverter.DoubleToInt64Bits(right[2])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AndNot", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "AndNot", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "(double)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "(float)(((i % 2) == 0) ? -0.0 : 1.0)", ["ValidateFirstResult"] = "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Ceiling", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Divide", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Divide", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateEvenIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateEvenIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "DuplicateOddIndexed", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[20])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[11])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[6])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[1])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), + ("ExtractScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Extract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(result[0] != firstOp[3])"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse", ["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "ExtendToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (RetElementCount / 2)) ? firstOp[i] : 0)"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[4]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 4])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[2]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 2])"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[4])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i + 4]))"}), + ("ExtractStoreTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[2])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(firstOp[i + 2]))"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "20", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Byte", ["Data"] = "(byte)2", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "SByte", ["Data"] = "(sbyte)2", ["Imm"] = "52", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)0", ["ValidateFirstResult"] = "(i == 20 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "11", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int16", ["Data"] = "(short)2", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt16", ["Data"] = "(ushort)2",["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)0", ["ValidateFirstResult"] = "(i == 11 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "6", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int32", ["Data"] = "(int)2", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt32", ["Data"] = "(uint)2", ["Imm"] = "22", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)0", ["ValidateFirstResult"] = "(i == 6 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 1 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "3", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "Int64", ["Data"] = "(long)2", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), + ("InsertScalarTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Insert", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] ="Vector256", ["Op1BaseType"] = "UInt64", ["Data"] = "(ulong)2", ["Imm"] = "19", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)0", ["ValidateFirstResult"] = "(i == 3 ? result[i] != 2 : result[i] != 0)"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(0,sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 15 ? result[i] != right[i - 16] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(0,short.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0,ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 7 ? result[i] != right[i - 8] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 3 ? result[i] != right[i - 4] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt64", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0,int.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[0]", ["ValidateRemainingResults"] = "(i > 1 ? result[i] != right[i - 2] : result[i] != left[i])"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])", ["ValidateRemainingResults"] = "(i > 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[i - 4]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i]))"}), + ("InsertLoadTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "InsertVector128", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[0])", ["ValidateRemainingResults"] = "(i > 1 ? BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(right[i - 2]) : BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(left[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Floor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "GetLowerHalf", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "result[i] != ((i < (Op1ElementCount / 2)) ? firstOp[i] : 0)"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Max", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Max", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Min", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Min", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Multiply", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Multiply", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Or", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Or", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Permute", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[4]) != BitConverter.SingleToInt32Bits(firstOp[5])"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Permute", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[2]) != BitConverter.DoubleToInt64Bits(firstOp[2]) || BitConverter.DoubleToInt64Bits(result[2]) != BitConverter.DoubleToInt64Bits(firstOp[2])"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse", ["Method"] = "Permute", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(firstOp[2])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[1]) != BitConverter.SingleToInt32Bits(firstOp[0]) || BitConverter.SingleToInt32Bits(result[2]) != BitConverter.SingleToInt32Bits(firstOp[0])"}), + ("ImmUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Sse2",["Method"] = "Permute", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Imm"] = "2", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(firstOp[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[1]) != BitConverter.DoubleToInt64Bits(firstOp[1])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "PermuteVar", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "BitConverter.Int32BitsToSingle(1)", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[1]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "i > 3 ? (BitConverter.SingleToInt32Bits(left[5]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(left[1]) != BitConverter.SingleToInt32Bits(result[i]))"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "PermuteVar", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "BitConverter.Int64BitsToDouble(1)", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "i > 1 ? (BitConverter.DoubleToInt64Bits(left[2]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(left[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundCurrentDirection", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNearestInteger", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToNegativeInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToPositiveInfinity", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i]))"}), + ("SimpleUnOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "RoundToZero", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0]))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[1])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(result[7]) != BitConverter.SingleToInt32Bits(right[4])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Shuffle", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(left[1])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(result[3]) != BitConverter.DoubleToInt64Bits(right[2])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Subtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(~left[i] & right[i]) == 0"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanTwoCmpOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestNotZAndNotC", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "((left[i] & right[i]) == 0)", ["ValidateRemainingResults"] = "((~left[i] & right[i]) == 0)"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("BooleanBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "TestZ", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(left[i] & right[i]) == 0"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}), }; private static readonly (string templateFileName, Dictionary templateData)[] Avx2Inputs = new [] @@ -585,6 +576,10 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "(ushort)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ushort)(left[i] + right[i]) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(uint)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(uint)(left[i] + right[i]) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Add", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] + right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] + right[i]) != result[i]"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "AlignRight", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["Imm"] = "5", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != right[5]", ["ValidateRemainingResults"] = "(result[i] != ((i < 16) ? ((i < 11) ? right[i + 5] : left[i - 11]) : ((i < 27) ? right[i + 5] : left[i - 11])))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "AlignRight", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["Imm"] = "27", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != left[11]", ["ValidateRemainingResults"] = "(result[i] != ((i < 16) ? ((i < 5) ? left[i + 11] : 0) : ((i < 21) ? left[i + 11] : 0)))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "AlignRight", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["Imm"] = "228", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 0"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "AlignRight", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["Imm"] = "250", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != 0", ["ValidateRemainingResults"] = "result[i] != 0"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(byte)(left[i] & right[i]) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(short)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(short)(left[i] & right[i]) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "And", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "(int)(left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(int)(left[i] & right[i]) != result[i]"}), @@ -603,6 +598,22 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "AndNot", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(~left[0] & right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(~left[i] & right[i]) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Average", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Average", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", ["ValidateRemainingResults"] = "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((1 & (1 << i)) == 0) ? left[i] : right[i]) : (((1 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((2 & (1 << i)) == 0) ? left[i] : right[i]) : (((2 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((4 & (1 << i)) == 0) ? left[i] : right[i]) : (((4 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((85 & (1 << i)) == 0) ? left[i] : right[i]) : (((85 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((1 & (1 << i)) == 0) ? left[i] : right[i]) : (((1 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((2 & (1 << i)) == 0) ? left[i] : right[i]) : (((2 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((4 & (1 << i)) == 0) ? left[i] : right[i]) : (((4 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt16", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["NextValueOp2"] = "(ushort)(random.Next(0, ushort.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != ((i < 8) ? (((85 & (1 << i)) == 0) ? left[i] : right[i]) : (((85 & (1 << (i - 8))) == 0) ? left[i] : right[i]))"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Blend", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt32", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])"}), ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp3"] = "(byte)(((i % 2) == 0) ? 128 : 1)", ["ValidateFirstResult"] = "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", ["ValidateRemainingResults"] = "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}), ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "BlendVariable", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp3"] = "(sbyte)(((i % 2) == 0) ? -128 : 1)", ["ValidateFirstResult"] = "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", ["ValidateRemainingResults"] = "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), @@ -613,8 +624,8 @@ private static readonly (string templateFileName, Dictionary tem ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[i]))"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[i]))"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), @@ -623,8 +634,8 @@ private static readonly (string templateFileName, Dictionary tem ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "firstOp[0] != result[0]", ["ValidateRemainingResults"] = "(firstOp[0] != result[i])"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[i]))"}), - ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[i]))"}), + ("GenericUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "BroadcastScalarToVector256", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", ["ValidateRemainingResults"] = "(BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[i]))"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Byte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["NextValueOp2"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int16", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["NextValueOp2"] = "(short)(random.Next(short.MinValue, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareEqual", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}), @@ -637,6 +648,9 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Int64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Int64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(long)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}), ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "CompareGreaterThan", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "SByte", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["NextValueOp2"] = "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", ["ValidateRemainingResults"] = "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}), + ("SimdScalarUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ConvertToDouble", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result)"}), + ("SimdScalarUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ConvertToInt32", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result != firstOp[0]"}), + ("SimdScalarUnOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ConvertToUInt32", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result != firstOp[0]"}), ("ExtractVector128Test.template",new Dictionary{["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Byte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Byte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(byte)(random.Next(0, byte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), ("ExtractVector128Test.template",new Dictionary{["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "SByte", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(sbyte)(random.Next(0, sbyte.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[16]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 16])"}), ("ExtractVector128Test.template",new Dictionary{["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "ExtractVector128", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int16", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Int16", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(short)(random.Next(0, short.MaxValue))", ["ValidateFirstResult"] = "result[0] != firstOp[8]", ["ValidateRemainingResults"] = "(result[i] != firstOp[i + 8])"}), @@ -755,44 +769,161 @@ private static readonly (string templateFileName, Dictionary tem ("SimpleBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Avx", ["Method"] = "Xor", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "UInt64", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "UInt64", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "(ulong)(left[0] ^ right[0]) != result[0]", ["ValidateRemainingResults"] = "(ulong)(left[i] ^ right[i]) != result[i]"}), }; +private static readonly (string templateFileName, Dictionary templateData)[] Avx2_Vector128Inputs = new [] +{ + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Int32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Int32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Int32", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["NextValueOp2"] = "(int)(random.Next(int.MinValue, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "1", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((1 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((1 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "2", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((2 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((2 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "4", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((4 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((4 & (1 << i)) == 0) ? left[i] : right[i])"}), + ("ImmBinOpTest.template", new Dictionary { ["Isa"] = "Avx2", ["LoadIsa"] = "Sse2", ["Method"] = "Blend", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "UInt32", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "UInt32", ["Imm"] = "85", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateFirstResult"] = "result[0] != (((85 & (1 << 0)) == 0) ? left[0] : right[0])", ["ValidateRemainingResults"] = "result[i] != (((85 & (1 << i)) == 0) ? left[i] : right[i])"}), +}; + private static readonly (string templateFileName, Dictionary templateData)[] Fma_Vector128Inputs = new [] { - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractNegatedScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse2", ["Method"] = "MultiplySubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Sse", ["Method"] = "MultiplySubtractScalar", ["RetVectorType"] = "Vector128", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector128", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector128", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector128", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "16", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}), }; private static readonly (string templateFileName, Dictionary templateData)[] Fma_Vector256Inputs = new [] { - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), - ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(double)(random.NextDouble())", ["NextValueOp2"] = "(double)(random.NextDouble())", ["NextValueOp3"] = "(double)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), - ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "(float)(random.NextDouble())", ["NextValueOp2"] = "(float)(random.NextDouble())", ["NextValueOp3"] = "(float)(random.NextDouble())", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) + thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplyAddSubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) + thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtract", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i + 1], 9))"}), + ("AlternatingTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractAdd", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i] * secondOp[i]) + thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round((firstOp[i + 1] * secondOp[i + 1]) - thirdOp[i + 1], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i + 1], 3))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateFirstResult"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))", ["ValidateRemainingResults"] = "BitConverter.DoubleToInt64Bits(Math.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))"}), + ("SimpleTernOpTest.template", new Dictionary { ["Isa"] = "Fma", ["LoadIsa"] = "Avx", ["Method"] = "MultiplySubtractNegated", ["RetVectorType"] = "Vector256", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector256", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector256", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector256", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "32", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateFirstResult"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[0] * secondOp[0]) - thirdOp[0], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[0], 3))", ["ValidateRemainingResults"] = "BitConverter.SingleToInt32Bits(MathF.Round(-(firstOp[i] * secondOp[i]) - thirdOp[i], 3)) != BitConverter.SingleToInt32Bits(MathF.Round(result[i], 3))"}), +}; + +private static readonly (string templateFileName, Dictionary templateData)[] Bmi1Inputs = new [] +{ + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "AndNot", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = ((~left & right) != result);" }), + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "AndNot", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = ((~left & right) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "ExtractLowestSetBit", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = ((unchecked((uint)(-(int)data)) & data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "ExtractLowestSetBit", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = ((unchecked((ulong)(-(long)data)) & data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "GetMaskUpToLowestSetBit", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = (((data - 1) ^ data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "GetMaskUpToLowestSetBit", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = (((data - 1) ^ data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "ResetLowestSetBit", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = (((data - 1) & data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "ResetLowestSetBit", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "isUnexpectedResult = (((data - 1) & data) != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "TrailingZeroCount", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "uint expectedResult = 0; for (int index = 0; ((data >> index) & 1) == 0; index++) { expectedResult++; } isUnexpectedResult = (expectedResult != result);" }), + ("ScalarUnOpTest.template", new Dictionary { ["Isa"] = "Bmi1", ["Method"] = "TrailingZeroCount", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = "ulong expectedResult = 0; for (int index = 0; ((data >> index) & 1) == 0; index++) { expectedResult++; } isUnexpectedResult = (expectedResult != result);" }), +}; + +private const string ValidateBmi2ParallelBitComment = @" +// The validation logic defined here for Bmi2.ParallelBitDeposit and Bmi2.ParallelBitExtract is +// based on the 'Operation' pseudo-code defined for the pdep and pext instruction in the 'Intel® +// 64 and IA-32 Architectures Software Developer’s Manual; Volume 2 (2A, 2B, 2C & 2D): Instruction +// Set Reference, A-Z' +"; + +private const string ValidateBmi2ParallelBitDepositUInt32 = ValidateBmi2ParallelBitComment + @" +uint temp = left; +uint mask = right; +uint dest = 0; +byte m = 0, k = 0; + +while (m < 32) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> k) & 1) << m); // Extract bit at index k of temp and insert to index m of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); +"; + +private const string ValidateBmi2ParallelBitDepositUInt64 = ValidateBmi2ParallelBitComment + @" +ulong temp = left; +ulong mask = right; +ulong dest = 0; +byte m = 0, k = 0; + +while (m < 64) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> k) & 1) << m); // Extract bit at index k of temp and insert to index m of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); +"; + +private const string ValidateBmi2ParallelBitExtractUInt32 = ValidateBmi2ParallelBitComment + @" +uint temp = left; +uint mask = right; +uint dest = 0; +byte m = 0, k = 0; + +while (m < 32) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> m) & 1) << k); // Extract bit at index m of temp and insert to index k of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); +"; + +private const string ValidateBmi2ParallelBitExtractUInt64 = ValidateBmi2ParallelBitComment + @" +ulong temp = left; +ulong mask = right; +ulong dest = 0; +byte m = 0, k = 0; + +while (m < 64) +{ + if (((mask >> m) & 1) == 1) // Extract bit at index m of mask + { + dest |= (((temp >> m) & 1) << k); // Extract bit at index m of temp and insert to index k of dest + k++; + } + m++; +} + +isUnexpectedResult = (dest != result); +"; + +private static readonly (string templateFileName, Dictionary templateData)[] Bmi2Inputs = new [] +{ + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi2", ["Method"] = "ParallelBitDeposit", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = ValidateBmi2ParallelBitDepositUInt32 }), + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi2", ["Method"] = "ParallelBitDeposit", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = ValidateBmi2ParallelBitDepositUInt64 }), + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi2", ["Method"] = "ParallelBitExtract", ["RetBaseType"] = "UInt32", ["Op1BaseType"] = "UInt32", ["Op2BaseType"] = "UInt32", ["NextValueOp1"] = "(uint)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(uint)(random.Next(0, int.MaxValue))", ["ValidateResult"] = ValidateBmi2ParallelBitExtractUInt32 }), + ("ScalarBinOpTest.template", new Dictionary { ["Isa"] = "Bmi2", ["Method"] = "ParallelBitExtract", ["RetBaseType"] = "UInt64", ["Op1BaseType"] = "UInt64", ["Op2BaseType"] = "UInt64", ["NextValueOp1"] = "(ulong)(random.Next(0, int.MaxValue))", ["NextValueOp2"] = "(ulong)(random.Next(0, int.MaxValue))", ["ValidateResult"] = ValidateBmi2ParallelBitExtractUInt64 }), }; private static void ProcessInputs(string groupName, (string templateFileName, Dictionary templateData)[] inputs) @@ -883,5 +1014,8 @@ ProcessInputs("Sse41", Sse41Inputs); ProcessInputs("Sse42", Sse42Inputs); ProcessInputs("Avx", AvxInputs); ProcessInputs("Avx2", Avx2Inputs); +ProcessInputs("Avx2_Vector128", Avx2_Vector128Inputs); ProcessInputs("Fma_Vector128", Fma_Vector128Inputs); ProcessInputs("Fma_Vector256", Fma_Vector256Inputs); +ProcessInputs("Bmi1", Bmi1Inputs); +ProcessInputs("Bmi2", Bmi2Inputs); diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenericUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenericUnOpTest.template index bfd71e722b3e..9ed3500ff460 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenericUnOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenericUnOpTest.template @@ -21,7 +21,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}(); + var test = new GenericUnaryOpTest__{Method}{RetBaseType}(); if (test.IsSupported) { @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType} + public sealed unsafe class GenericUnaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(GenericUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}<{RetBaseType}>(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -98,7 +128,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}() + static GenericUnaryOpTest__{Method}{RetBaseType}() { var random = new Random(); @@ -106,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}() + public GenericUnaryOpTest__{Method}{RetBaseType}() { Succeeded = true; @@ -226,16 +256,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}(); + var test = new GenericUnaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}<{RetBaseType}>(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}<{RetBaseType}>(_fld); @@ -243,6 +273,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/HorizontalBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/HorizontalBinOpTest.template index a78e426316ca..d6e83b7b9397 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/HorizontalBinOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/HorizontalBinOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class HorizontalBinaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -242,7 +275,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -251,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); @@ -259,6 +292,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmBinOpTest.template index c8e2a864b96a..f2acb74926be 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmBinOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmBinOpTest.template @@ -21,7 +21,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ImmBinaryOpTest__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,35 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleBinaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class ImmBinaryOpTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmBinaryOpTest__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -102,7 +135,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleBinaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}, {Op2BaseType}> _dataTable; - static SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}() + static ImmBinaryOpTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -112,7 +145,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _clsVar2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); } - public SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}() + public ImmBinaryOpTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -249,16 +282,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ImmBinaryOpTest__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld1, test._fld2, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2, {Imm}); @@ -266,6 +299,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmUnOpTest.template index 49fb80e55f82..5c593efdf9c3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmUnOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ImmUnOpTest.template @@ -21,7 +21,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ImmUnaryOpTest__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class ImmUnaryOpTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -98,7 +128,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + static ImmUnaryOpTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -106,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + public ImmUnaryOpTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -230,16 +260,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new ImmUnaryOpTest__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld, {Imm}); @@ -247,6 +277,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template index eaf1b64df54b..28d0e8a4a192 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertLoadTest.template @@ -23,7 +23,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}Load() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}Load(); + var test = new InsertLoadTest__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -66,11 +66,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,8 +91,35 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}Load + public sealed unsafe class InsertLoadTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertLoadTest__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld1, ({Op2BaseType}*)testClass._dataTable.inArray2Ptr, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, ({Op2BaseType}*)testClass._dataTable.inArray2Ptr, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -104,7 +137,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleBinaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}, {Op2BaseType}> _dataTable; - static SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}Load() + static InsertLoadTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -114,7 +147,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _clsVar2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); } - public SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}Load() + public InsertLoadTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -251,16 +284,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}Load(); + var test = new InsertLoadTest__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); @@ -268,6 +301,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, ({Op2BaseType}*)(_dataTable.inArray2Ptr), _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertScalarTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertScalarTest.template index cc330e715b11..e61ba655cc44 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertScalarTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertScalarTest.template @@ -21,10 +21,8 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); - - try - { + var test = new InsertScalarTest__{Method}{RetBaseType}{Imm}(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class InsertScalarTest__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld, {Data}, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -105,7 +128,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}> _dataTable; - static SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + static InsertScalarTest__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -113,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); } - public SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}() + public InsertScalarTest__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -126,7 +149,7 @@ namespace JIT.HardwareIntrinsics.X86 _dataTable = new SimpleUnaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}>(_data, new {RetBaseType}[RetElementCount], LargestVectorSize); } - public bool IsSupported => {Isa}.IsSupported; + public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new InsertScalarTest__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld, {Data}, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld, {Data}, {Imm}); @@ -261,6 +284,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld, {Data}, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertVector128Test.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertVector128Test.template index e95bb2b8d77e..ecbdcbb77279 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertVector128Test.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/InsertVector128Test.template @@ -14,6 +14,7 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 @@ -22,7 +23,7 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}{Imm}() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new InsertVector128Test__{Method}{RetBaseType}{Imm}(); if (test.IsSupported) { @@ -65,11 +66,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +91,35 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleBinaryOpTest__{Method}{RetBaseType}{Imm} + public sealed unsafe class InsertVector128Test__{Method}{RetBaseType}{Imm} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__{Method}{RetBaseType}{Imm} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2, {Imm}); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -103,7 +137,7 @@ namespace JIT.HardwareIntrinsics.X86 private SimpleBinaryOpTest__DataTable<{RetBaseType}, {Op1BaseType}, {Op2BaseType}> _dataTable; - static SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}() + static InsertVector128Test__{Method}{RetBaseType}{Imm}() { var random = new Random(); @@ -113,7 +147,7 @@ namespace JIT.HardwareIntrinsics.X86 Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref _clsVar2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); } - public SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}() + public InsertVector128Test__{Method}{RetBaseType}{Imm}() { Succeeded = true; @@ -250,16 +284,16 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleBinaryOpTest__{Method}{RetBaseType}{Imm}(); + var test = new InsertVector128Test__{Method}{RetBaseType}{Imm}(); var result = {Isa}.{Method}(test._fld1, test._fld2, {Imm}); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2, {Imm}); @@ -267,6 +301,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2, {Imm}); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarBinOpTest.template new file mode 100644 index 000000000000..767ecb1a5f1f --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarBinOpTest.template @@ -0,0 +1,221 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void {Method}{RetBaseType}() + { + var test = new ScalarBinaryOpTest__{Method}{RetBaseType}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarBinaryOpTest__{Method}{RetBaseType} + { + private struct TestStruct + { + public {Op1BaseType} _fld1; + public {Op2BaseType} _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld1 = {NextValueOp1}; + testStruct._fld2 = {NextValueOp2}; + + return testStruct; + } + + public void RunStructFldScenario(ScalarBinaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + + private static {Op1BaseType} _data1; + private static {Op2BaseType} _data2; + + private static {Op1BaseType} _clsVar1; + private static {Op2BaseType} _clsVar2; + + private {Op1BaseType} _fld1; + private {Op2BaseType} _fld2; + + static ScalarBinaryOpTest__{Method}{RetBaseType}() + { + var random = new Random(); + _clsVar1 = {NextValueOp1}; + _clsVar2 = {NextValueOp2}; + } + + public ScalarBinaryOpTest__{Method}{RetBaseType}() + { + Succeeded = true; + + var random = new Random(); + + _fld1 = {NextValueOp1}; + _fld2 = {NextValueOp2}; + + _data1 = {NextValueOp1}; + _data2 = {NextValueOp2}; + } + + public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = {Isa}.{Method}( + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data1)), + Unsafe.ReadUnaligned<{Op2BaseType}>(ref Unsafe.As<{Op2BaseType}, byte>(ref _data2)) + ); + + ValidateResult(_data1, _data2, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}), typeof({Op2BaseType}) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data1)), + Unsafe.ReadUnaligned<{Op2BaseType}>(ref Unsafe.As<{Op2BaseType}, byte>(ref _data2)) + }); + + ValidateResult(_data1, _data2, ({RetBaseType})result); + } + + public void RunClsVarScenario() + { + var result = {Isa}.{Method}( + _clsVar1, + _clsVar2 + ); + + ValidateResult(_clsVar1, _clsVar2, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data1 = Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data1)); + var data2 = Unsafe.ReadUnaligned<{Op2BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data2)); + var result = {Isa}.{Method}(data1, data2); + + ValidateResult(data1, data2, result); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarBinaryOpTest__{Method}{RetBaseType}(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunClassFldScenario() + { + var result = {Isa}.{Method}(_fld1, _fld2); + ValidateResult(_fld1, _fld2, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult({Op1BaseType} left, {Op2BaseType} right, {RetBaseType} result, [CallerMemberName] string method = "") + { + var isUnexpectedResult = false; + + {ValidateResult} + + if (isUnexpectedResult) + { + Console.WriteLine($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1BaseType}, {Op2BaseType}): {Method} failed:"); + Console.WriteLine($" left: {left}"); + Console.WriteLine($" right: {right}"); + Console.WriteLine($" result: {result}"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template new file mode 100644 index 000000000000..89095a08da16 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest.template @@ -0,0 +1,243 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void {Method}{RetBaseType}() + { + var test = new ScalarSimdUnaryOpTest__{Method}{RetBaseType}(); + + if (test.IsSupported) + { + // Validates basic functionality works + test.RunBasicScenario_UnsafeRead(); + + // Validates calling via reflection works + test.RunReflectionScenario_UnsafeRead(); + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works + test.RunLclVarScenario_UnsafeRead(); + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class ScalarSimdUnaryOpTest__{Method}{RetBaseType} + { + private struct TestStruct + { + public {Op1BaseType} _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = {NextValueOp1}; + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + + private static {Op1BaseType} _data; + + private static {Op1BaseType} _clsVar; + + private {Op1BaseType} _fld; + + private ScalarSimdUnaryOpTest__DataTable<{RetBaseType}> _dataTable; + + static ScalarSimdUnaryOpTest__{Method}{RetBaseType}() + { + var random = new Random(); + _clsVar = {NextValueOp1}; + } + + public ScalarSimdUnaryOpTest__{Method}{RetBaseType}() + { + Succeeded = true; + + var random = new Random(); + _fld = {NextValueOp1}; + _data = {NextValueOp1}; + _dataTable = new ScalarSimdUnaryOpTest__DataTable<{RetBaseType}>(new {RetBaseType}[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong)))); + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = {Isa}.{Method}( + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_data, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)) + }); + + Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); + ValidateResult(_data, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = {Isa}.{Method}( + _clsVar + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var data = Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)); + var result = {Isa}.{Method}(data); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(data, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new ScalarSimdUnaryOpTest__{Method}{RetBaseType}(); + var result = {Isa}.{Method}(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = {Isa}.{Method}(_fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult({Op1BaseType} firstOp, void* result, [CallerMemberName] string method = "") + { + {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); + + ValidateResult(firstOp, outArray, method); + } + + private void ValidateResult({Op1BaseType} firstOp, {RetBaseType}[] result, [CallerMemberName] string method = "") + { + if ({ValidateFirstResult}) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if ({ValidateRemainingResults}) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:"); + Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest_DataTable.cs similarity index 89% rename from tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest_DataTable.cs rename to tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest_DataTable.cs index 2d5532d7abaf..30467ae2cb6d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest_DataTable.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarSimdUnOpTest_DataTable.cs @@ -11,7 +11,7 @@ namespace JIT.HardwareIntrinsics.X86 { - public unsafe struct SimpleScalarUnaryOpTest__DataTable : IDisposable + public unsafe struct ScalarSimdUnaryOpTest__DataTable : IDisposable where TResult : struct { public byte[] outArray; @@ -20,7 +20,7 @@ public unsafe struct SimpleScalarUnaryOpTest__DataTable : IDisposable private ulong alignment; - public SimpleScalarUnaryOpTest__DataTable(TResult[] outArray, int alignment) + public ScalarSimdUnaryOpTest__DataTable(TResult[] outArray, int alignment) { int sizeOfoutArray = outArray.Length * Unsafe.SizeOf(); if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfoutArray) diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest.template index 69e1d7342e9c..8e371a88d2ca 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/ScalarUnOpTest.template @@ -21,35 +21,33 @@ namespace JIT.HardwareIntrinsics.X86 { private static void {Method}{RetBaseType}() { - bool skipIf32Bit = (typeof({Op1BaseType}) == typeof(Int64)) || - (typeof({Op1BaseType}) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__{Method}{RetBaseType}(); + var test = new ScalarUnaryOpTest__{Method}{RetBaseType}(); if (test.IsSupported) { - // Validates basic functionality works - test.RunBasicScenario(); + // Validates basic functionality works, using Unsafe.ReadUnaligned + test.RunBasicScenario_UnsafeRead(); - // Validates calling via reflection works - test.RunReflectionScenario(); + // Validates calling via reflection works, using Unsafe.ReadUnaligned + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); - // Validates passing a local works - test.RunLclVarScenario(); + // Validates passing a local works, using Unsafe.ReadUnaligned + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,71 @@ namespace JIT.HardwareIntrinsics.X86 } } - public sealed unsafe class SimpleScalarUnaryOpTest__{Method}{RetBaseType} + public sealed unsafe class ScalarUnaryOpTest__{Method}{RetBaseType} { - private static readonly int LargestVectorSize = {LargestVectorSize}; + private struct TestStruct + { + public {Op1BaseType} _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = {NextValueOp1}; + return testStruct; + } - private static readonly int RetElementCount = Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>() / sizeof({RetBaseType}); + public void RunStructFldScenario(ScalarUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld); + testClass.ValidateResult(_fld, result); + } + } - private static readonly Random Random = new Random(); + private static {Op1BaseType} _data; private static {Op1BaseType} _clsVar; private {Op1BaseType} _fld; - private SimpleScalarUnaryOpTest__DataTable<{RetBaseType}> _dataTable; - - static SimpleScalarUnaryOpTest__{Method}{RetBaseType}() + static ScalarUnaryOpTest__{Method}{RetBaseType}() { + var random = new Random(); _clsVar = {NextValueOp1}; } - public SimpleScalarUnaryOpTest__{Method}{RetBaseType}() + public ScalarUnaryOpTest__{Method}{RetBaseType}() { Succeeded = true; + var random = new Random(); + _fld = {NextValueOp1}; - _dataTable = new SimpleScalarUnaryOpTest__DataTable<{RetBaseType}>(new {RetBaseType}[RetElementCount], LargestVectorSize); + _data = {NextValueOp1}; } - public bool IsSupported => {Isa}.IsSupported; + public bool IsSupported => {Isa}.IsSupported && (Environment.Is64BitProcess || ((typeof({RetBaseType}) != typeof(long)) && (typeof({RetBaseType}) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = {NextValueOp1}; var result = {Isa}.{Method}( - firstOp + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)) ); - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, result); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = {NextValueOp1}; - var method = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1BaseType}) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)) + }); - Unsafe.Write(_dataTable.outArrayPtr, ({RetVectorType}<{RetBaseType}>)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, ({RetBaseType})result); } public void RunClsVarScenario() @@ -122,34 +135,43 @@ namespace JIT.HardwareIntrinsics.X86 _clsVar ); - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar, result); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = {NextValueOp1}; - var result = {Isa}.{Method}(firstOp); + var data = Unsafe.ReadUnaligned<{Op1BaseType}>(ref Unsafe.As<{Op1BaseType}, byte>(ref _data)); + var result = {Isa}.{Method}(data); - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__{Method}{RetBaseType}(); + var test = new ScalarUnaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld); - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld); + ValidateResult(_fld, result); + } - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -158,7 +180,7 @@ namespace JIT.HardwareIntrinsics.X86 try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { @@ -166,38 +188,17 @@ namespace JIT.HardwareIntrinsics.X86 } } - private void ValidateResult({Op1BaseType} firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult({Op1BaseType} data, {RetBaseType} result, [CallerMemberName] string method = "") { - {RetBaseType}[] outArray = new {RetBaseType}[RetElementCount]; + var isUnexpectedResult = false; - Unsafe.CopyBlockUnaligned(ref Unsafe.As<{RetBaseType}, byte>(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf<{RetVectorType}<{RetBaseType}>>()); - - ValidateResult(firstOp, outArray, method); - } - - private void ValidateResult({Op1BaseType} firstOp, {RetBaseType}[] result, [CallerMemberName] string method = "") - { - if ({ValidateFirstResult}) - { - Succeeded = false; - } - else - { - for (var i = 1; i < RetElementCount; i++) - { - if ({ValidateRemainingResults}) - { - Succeeded = false; - break; - } - } - } + {ValidateResult} - if (!Succeeded) + if (isUnexpectedResult) { - Console.WriteLine($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1BaseType}): {Method} failed:"); + Console.WriteLine($" data: {data}"); + Console.WriteLine($" result: {result}"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest.template new file mode 100644 index 000000000000..cb1c120d9752 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest.template @@ -0,0 +1,316 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void {Method}{RetBaseType}() + { + var test = new SimdScalarUnaryOpTest__{Method}{RetBaseType}(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if ({LoadIsa}.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if ({LoadIsa}.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if ({LoadIsa}.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class SimdScalarUnaryOpTest__{Method}{RetBaseType} + { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(SimdScalarUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld); + testClass.ValidateResult(_fld, result); + } + } + + private static readonly int LargestVectorSize = {LargestVectorSize}; + + private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); + + private static {Op1BaseType}[] _data = new {Op1BaseType}[Op1ElementCount]; + + private static {Op1VectorType}<{Op1BaseType}> _clsVar; + + private {Op1VectorType}<{Op1BaseType}> _fld; + + private SimdScalarUnaryOpTest__DataTable<{Op1BaseType}> _dataTable; + + static SimdScalarUnaryOpTest__{Method}{RetBaseType}() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _clsVar), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + } + + public SimdScalarUnaryOpTest__{Method}{RetBaseType}() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref _fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + _dataTable = new SimdScalarUnaryOpTest__DataTable<{Op1BaseType}>(_data, LargestVectorSize); + } + + public bool IsSupported => {Isa}.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = {Isa}.{Method}( + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_Load() + { + var result = {Isa}.{Method}( + {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunBasicScenario_LoadAligned() + { + var result = {Isa}.{Method}( + {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)) + ); + + ValidateResult(_dataTable.inArrayPtr, result); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>) }) + .Invoke(null, new object[] { + Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr) + }); + + ValidateResult(_dataTable.inArrayPtr, ({RetBaseType})(result)); + } + + public void RunReflectionScenario_Load() + { + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>) }) + .Invoke(null, new object[] { + {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, ({RetBaseType})(result)); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof({Isa}).GetMethod(nameof({Isa}.{Method}), new Type[] { typeof({Op1VectorType}<{Op1BaseType}>) }) + .Invoke(null, new object[] { + {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)) + }); + + ValidateResult(_dataTable.inArrayPtr, ({RetBaseType})(result)); + } + + public void RunClsVarScenario() + { + var result = {Isa}.{Method}( + _clsVar + ); + + ValidateResult(_clsVar, result); + } + + public void RunLclVarScenario_UnsafeRead() + { + var firstOp = Unsafe.Read<{Op1VectorType}<{Op1BaseType}>>(_dataTable.inArrayPtr); + var result = {Isa}.{Method}(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_Load() + { + var firstOp = {LoadIsa}.Load{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); + var result = {Isa}.{Method}(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunLclVarScenario_LoadAligned() + { + var firstOp = {LoadIsa}.LoadAligned{Op1VectorType}(({Op1BaseType}*)(_dataTable.inArrayPtr)); + var result = {Isa}.{Method}(firstOp); + + ValidateResult(firstOp, result); + } + + public void RunClassLclFldScenario() + { + var test = new SimdScalarUnaryOpTest__{Method}{RetBaseType}(); + var result = {Isa}.{Method}(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunClassFldScenario() + { + var result = {Isa}.{Method}(_fld); + + ValidateResult(_fld, result); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult({Op1VectorType}<{Op1BaseType}> firstOp, {RetBaseType} result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray = new {Op1BaseType}[Op1ElementCount]; + Unsafe.WriteUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray[0]), firstOp); + ValidateResult(inArray, result, method); + } + + private void ValidateResult(void* firstOp, {RetBaseType} result, [CallerMemberName] string method = "") + { + {Op1BaseType}[] inArray = new {Op1BaseType}[Op1ElementCount]; + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1BaseType}, byte>(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + ValidateResult(inArray, result, method); + } + + private void ValidateResult({Op1BaseType}[] firstOp, {RetBaseType} result, [CallerMemberName] string method = "") + { + if ({ValidateFirstResult}) + { + Succeeded = false; + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof({Isa})}.{nameof({Isa}.{Method})}<{RetBaseType}>({Op1VectorType}<{Op1BaseType}>): {method} failed:"); + Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); + Console.WriteLine($" result: result"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest_DataTable.cs new file mode 100644 index 000000000000..2317675d4bf2 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimdScalarUnOpTest_DataTable.cs @@ -0,0 +1,51 @@ +// 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.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public unsafe struct SimdScalarUnaryOpTest__DataTable : IDisposable + where TOp1 : struct + { + public byte[] inArray; + + private GCHandle inHandle; + + private ulong alignment; + + public SimdScalarUnaryOpTest__DataTable(TOp1[] inArray, int alignment) + { + int sizeOfinArray = inArray.Length * Unsafe.SizeOf(); + if ((alignment != 32 && alignment != 16) || (alignment * 2) < sizeOfinArray) + { + throw new ArgumentException("Invalid value of alignment"); + } + this.inArray = new byte[alignment * 2]; + + this.inHandle = GCHandle.Alloc(this.inArray, GCHandleType.Pinned); + + this.alignment = (ulong)alignment; + + Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef(inArrayPtr), ref Unsafe.As(ref inArray[0]), (uint)sizeOfinArray); + } + + public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), alignment); + + public void Dispose() + { + inHandle.Free(); + } + + private static unsafe void* Align(byte* buffer, ulong expectedAlignment) + { + return (void*)(((ulong)buffer + expectedAlignment - 1) & ~(expectedAlignment - 1)); + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template index 1644045e8e11..5088d80f5173 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class SimpleBinaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -242,7 +275,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2); @@ -251,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2); @@ -259,6 +292,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template index 703578ff2c0c..897a313a1fd8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class SimpleTernaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld1; + public {Op2VectorType}<{Op2BaseType}> _fld2; + public {Op3VectorType}<{Op3BaseType}> _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld1), ref Unsafe.As<{Op1BaseType}, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = {NextValueOp2}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op2VectorType}<{Op2BaseType}>, byte>(ref testStruct._fld2), ref Unsafe.As<{Op2BaseType}, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<{Op2VectorType}<{Op2BaseType}>>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = {NextValueOp3}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op3VectorType}<{Op3BaseType}>, byte>(ref _clsVar3), ref Unsafe.As<{Op3BaseType}, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<{Op3VectorType}<{Op3BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -261,7 +297,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template index d2bc824346bc..b786357121fa 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template +++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template @@ -64,11 +64,17 @@ namespace JIT.HardwareIntrinsics.X86 test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ namespace JIT.HardwareIntrinsics.X86 public sealed unsafe class SimpleUnaryOpTest__{Method}{RetBaseType} { + private struct TestStruct + { + public {Op1VectorType}<{Op1BaseType}> _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = {NextValueOp1}; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As<{Op1VectorType}<{Op1BaseType}>, byte>(ref testStruct._fld), ref Unsafe.As<{Op1BaseType}, byte>(ref _data[0]), (uint)Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__{Method}{RetBaseType} testClass) + { + var result = {Isa}.{Method}(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = {LargestVectorSize}; private static readonly int Op1ElementCount = Unsafe.SizeOf<{Op1VectorType}<{Op1BaseType}>>() / sizeof({Op1BaseType}); @@ -223,7 +253,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__{Method}{RetBaseType}(); var result = {Isa}.{Method}(test._fld); @@ -232,7 +262,7 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = {Isa}.{Method}(_fld); @@ -240,6 +270,21 @@ namespace JIT.HardwareIntrinsics.X86 ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = {Isa}.{Method}(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs index ea6ec79a1b6e..c648b6190a68 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs @@ -64,11 +64,17 @@ private static void AddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSingle() public sealed unsafe class SimpleBinaryOpTest__AddSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSingle testClass) + { + var result = Sse.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSingle(); var result = Sse.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs index a2b42bd24330..0029e55b3511 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs @@ -64,11 +64,17 @@ private static void AddScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddScalarSingle() public sealed unsafe class SimpleBinaryOpTest__AddScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddScalarSingle testClass) + { + var result = Sse.AddScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddScalarSingle(); var result = Sse.AddScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.AddScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.AddScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs index 9dc28b1a2616..73b8d2e4853a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs @@ -64,11 +64,17 @@ private static void AndSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndSingle() public sealed unsafe class SimpleBinaryOpTest__AndSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndSingle testClass) + { + var result = Sse.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndSingle(); var result = Sse.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs index 842dca0de32e..3aa09b6f9fab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs @@ -64,11 +64,17 @@ private static void AndNotSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotSingle() public sealed unsafe class SimpleBinaryOpTest__AndNotSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotSingle testClass) + { + var result = Sse.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndNotSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndNotSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotSingle(); var result = Sse.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs index 41d365c4eadc..86b3b2d0f11a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualSingle testClass) + { + var result = Sse.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualSingle(); var result = Sse.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs index 28f81e316615..1454ad433b10 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareEqualOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareEqualOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean testClass) + { + var result = Sse.CompareEqualOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean(); var result = Sse.CompareEqualOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareEqualOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareEqualOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs index 04f31d736418..9f9ed10f1b17 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualScalarSingle testClass) + { + var result = Sse.CompareEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualScalarSingle(); var result = Sse.CompareEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs index b2989738b719..5d8984cffef7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareEqualUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareEqualUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean testClass) + { + var result = Sse.CompareEqualUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean(); var result = Sse.CompareEqualUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareEqualUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareEqualUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs index ffea1c1462ce..ea2c87cabc35 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanSingle() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanSingle testClass) + { + var result = Sse.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanSingle(); var result = Sse.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs index cae02ca9fbda..29634c835727 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanOrEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle testClass) + { + var result = Sse.CompareGreaterThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle(); var result = Sse.CompareGreaterThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs index 2f82c7ba90b1..fe27fae5182b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrEqualOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareGreaterThanOrEqualOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean testClass) + { + var result = Sse.CompareGreaterThanOrEqualOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean(); var result = Sse.CompareGreaterThanOrEqualOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanOrEqualOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanOrEqualOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs index 0a36d79da306..617a741498a5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanOrEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle testClass) + { + var result = Sse.CompareGreaterThanOrEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle(); var result = Sse.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanOrEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanOrEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs index 157c1d6eb299..1e49d09b26f4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrEqualUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareGreaterThanOrEqualUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean testClass) + { + var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean( { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean( var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean(); var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs index f0160bf1a52d..95e093e167b6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareGreaterThanOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean testClass) + { + var result = Sse.CompareGreaterThanOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean(); var result = Sse.CompareGreaterThanOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs index 56239855af91..1656917c8ee2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanScalarSingle testClass) + { + var result = Sse.CompareGreaterThanScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanScalarSingle(); var result = Sse.CompareGreaterThanScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs index 7d4141f3da51..95716617fac5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareGreaterThanUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean testClass) + { + var result = Sse.CompareGreaterThanUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean(); var result = Sse.CompareGreaterThanUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareGreaterThanUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareGreaterThanUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs index f5f44bc1e56d..bea44df8feaf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs @@ -64,11 +64,17 @@ private static void CompareLessThanSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanSingle() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanSingle testClass) + { + var result = Sse.CompareLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanSingle(); var result = Sse.CompareLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs index 95a355bd04ce..7cd8df822fc5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanOrEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanOrEqualSingle testClass) + { + var result = Sse.CompareLessThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanOrEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanOrEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanOrEqualSingle(); var result = Sse.CompareLessThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs index 2c79172c5a7a..c46844258d53 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrEqualOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareLessThanOrEqualOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean testClass) + { + var result = Sse.CompareLessThanOrEqualOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean(); var result = Sse.CompareLessThanOrEqualOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanOrEqualOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanOrEqualOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs index 576add2b4a2c..d5002d2e1ed4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanOrEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle testClass) + { + var result = Sse.CompareLessThanOrEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle(); var result = Sse.CompareLessThanOrEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanOrEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanOrEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs index ea632d081894..b0f5fd11612b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrEqualUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareLessThanOrEqualUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean testClass) + { + var result = Sse.CompareLessThanOrEqualUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean(); var result = Sse.CompareLessThanOrEqualUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanOrEqualUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanOrEqualUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs index a5d49e26b207..75cbf6caa2cc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareLessThanOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean testClass) + { + var result = Sse.CompareLessThanOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean(); var result = Sse.CompareLessThanOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs index e7de0dd0b41e..7db89edda8a9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareLessThanScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanScalarSingle testClass) + { + var result = Sse.CompareLessThanScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanScalarSingle(); var result = Sse.CompareLessThanScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs index 746bd511e897..a096ca776b07 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareLessThanUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareLessThanUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean testClass) + { + var result = Sse.CompareLessThanUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean(); var result = Sse.CompareLessThanUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareLessThanUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareLessThanUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs index 6415345bff2a..a2c96fa0bd71 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotEqualSingle testClass) + { + var result = Sse.CompareNotEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotEqualSingle(); var result = Sse.CompareNotEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs index 9e62c8181ffd..ad1d49ae0ebd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareNotEqualOrderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareNotEqualOrderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean testClass) + { + var result = Sse.CompareNotEqualOrderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean(); var result = Sse.CompareNotEqualOrderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotEqualOrderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotEqualOrderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs index 68e085a70750..f9614f222fb7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotEqualScalarSingle testClass) + { + var result = Sse.CompareNotEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotEqualScalarSingle(); var result = Sse.CompareNotEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs index d5cc0d00b9f8..231ae00a13c6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs @@ -64,11 +64,17 @@ private static void CompareNotEqualUnorderedScalarBoolean() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void CompareNotEqualUnorderedScalarBoolean() public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean testClass) + { + var result = Sse.CompareNotEqualUnorderedScalar(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,9 +136,9 @@ static BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -117,13 +148,13 @@ public BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new BooleanComparisonOpTest__DataTable(_data1, _data2, LargestVectorSize); } @@ -231,7 +262,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean(); var result = Sse.CompareNotEqualUnorderedScalar(test._fld1, test._fld2); @@ -239,13 +270,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotEqualUnorderedScalar(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotEqualUnorderedScalar(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs index f23de3ae9ae1..106dc48167d6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanSingle testClass) + { + var result = Sse.CompareNotGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanSingle(); var result = Sse.CompareNotGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs index b674df86d56d..d5d1af4524ae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanOrEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanOrEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle testClass) + { + var result = Sse.CompareNotGreaterThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle(); var result = Sse.CompareNotGreaterThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotGreaterThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotGreaterThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs index ee86e1e2bdd0..d752cee48ff7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanOrEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanOrEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle testClass) + { + var result = Sse.CompareNotGreaterThanOrEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle(); var result = Sse.CompareNotGreaterThanOrEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotGreaterThanOrEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotGreaterThanOrEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs index cef197a6a5db..2b92e274e0ed 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle testClass) + { + var result = Sse.CompareNotGreaterThanScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle(); var result = Sse.CompareNotGreaterThanScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotGreaterThanScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotGreaterThanScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs index d27660d612a8..86742633bcfb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanSingle testClass) + { + var result = Sse.CompareNotLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanSingle(); var result = Sse.CompareNotLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs index 6d1f1825c547..12ff27a8a85c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanOrEqualSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanOrEqualSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle testClass) + { + var result = Sse.CompareNotLessThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle(); var result = Sse.CompareNotLessThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotLessThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotLessThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs index b5e33e77edc1..dbeb31470e7b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanOrEqualScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanOrEqualScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle testClass) + { + var result = Sse.CompareNotLessThanOrEqualScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle(); var result = Sse.CompareNotLessThanOrEqualScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotLessThanOrEqualScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotLessThanOrEqualScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs index dda2565eabf8..a1046b15e855 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanScalarSingle testClass) + { + var result = Sse.CompareNotLessThanScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanScalarSingle(); var result = Sse.CompareNotLessThanScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareNotLessThanScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareNotLessThanScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs index c61e9f0cfac3..a1b744f32b22 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs @@ -64,11 +64,17 @@ private static void CompareOrderedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareOrderedSingle() public sealed unsafe class SimpleBinaryOpTest__CompareOrderedSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareOrderedSingle testClass) + { + var result = Sse.CompareOrdered(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareOrderedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareOrderedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareOrderedSingle(); var result = Sse.CompareOrdered(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareOrdered(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareOrdered(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs index 3b4a66b94145..ac4cc435501a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareOrderedScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareOrderedScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareOrderedScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareOrderedScalarSingle testClass) + { + var result = Sse.CompareOrderedScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareOrderedScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareOrderedScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareOrderedScalarSingle(); var result = Sse.CompareOrderedScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareOrderedScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareOrderedScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs index 9523f100fa0e..48040aaf4627 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs @@ -64,11 +64,17 @@ private static void CompareUnorderedSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareUnorderedSingle() public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareUnorderedSingle testClass) + { + var result = Sse.CompareUnordered(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareUnorderedSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareUnorderedSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareUnorderedSingle(); var result = Sse.CompareUnordered(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareUnordered(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareUnordered(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs index 30545475ad2c..51af5fff5ceb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs @@ -64,11 +64,17 @@ private static void CompareUnorderedScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareUnorderedScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareUnorderedScalarSingle testClass) + { + var result = Sse.CompareUnorderedScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareUnorderedScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareUnorderedScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareUnorderedScalarSingle(); var result = Sse.CompareUnorderedScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.CompareUnorderedScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.CompareUnorderedScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs index 1ad17ed7d355..2f8bc30e713e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs @@ -64,11 +64,17 @@ private static void DivideSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideSingle() public sealed unsafe class SimpleBinaryOpTest__DivideSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideSingle testClass) + { + var result = Sse.Divide(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideSingle(); var result = Sse.Divide(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Divide(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Divide(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs index 82ac08e2d65c..12c2dcddcd05 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs @@ -64,11 +64,17 @@ private static void DivideScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideScalarSingle() public sealed unsafe class SimpleBinaryOpTest__DivideScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideScalarSingle testClass) + { + var result = Sse.DivideScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideScalarSingle(); var result = Sse.DivideScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.DivideScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.DivideScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs index 69a1112582fd..6129f1bdaba7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs @@ -64,11 +64,17 @@ private static void MaxSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxSingle() public sealed unsafe class SimpleBinaryOpTest__MaxSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxSingle testClass) + { + var result = Sse.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxSingle(); var result = Sse.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs index 7e025c9fdd18..3e202572e848 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs @@ -64,11 +64,17 @@ private static void MaxScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxScalarSingle() public sealed unsafe class SimpleBinaryOpTest__MaxScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxScalarSingle testClass) + { + var result = Sse.MaxScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxScalarSingle(); var result = Sse.MaxScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.MaxScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.MaxScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs index 6387eefcc0a0..cd03d6927b4e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs @@ -64,11 +64,17 @@ private static void MinSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinSingle() public sealed unsafe class SimpleBinaryOpTest__MinSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinSingle testClass) + { + var result = Sse.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinSingle(); var result = Sse.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs index d6089109b4a9..bb2138faab73 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs @@ -64,11 +64,17 @@ private static void MinScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinScalarSingle() public sealed unsafe class SimpleBinaryOpTest__MinScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinScalarSingle testClass) + { + var result = Sse.MinScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinScalarSingle(); var result = Sse.MinScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.MinScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.MinScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs index aab7bb9cd2d0..8f78e31e62c9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs @@ -64,11 +64,17 @@ private static void MultiplySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplySingle() public sealed unsafe class SimpleBinaryOpTest__MultiplySingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplySingle testClass) + { + var result = Sse.Multiply(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplySingle(); var result = Sse.Multiply(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Multiply(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Multiply(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs index fb730d8bef7f..2d30f76cac4f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs @@ -64,11 +64,17 @@ private static void MultiplyScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyScalarSingle() public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyScalarSingle testClass) + { + var result = Sse.MultiplyScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplyScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplyScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyScalarSingle(); var result = Sse.MultiplyScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.MultiplyScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.MultiplyScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs index 3d790f8f44b7..c4a720179e74 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs @@ -64,11 +64,17 @@ private static void OrSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrSingle() public sealed unsafe class SimpleBinaryOpTest__OrSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrSingle testClass) + { + var result = Sse.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__OrSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__OrSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrSingle(); var result = Sse.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj index c8a0b0a79920..e235286a6a31 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj @@ -84,6 +84,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj index e76a6d8dbe74..cb2f266e46f9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj @@ -84,6 +84,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs index 2b1ce21a7c2c..6ce6163ce237 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs @@ -64,11 +64,17 @@ private static void SubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSingle() public sealed unsafe class SimpleBinaryOpTest__SubtractSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSingle testClass) + { + var result = Sse.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSingle(); var result = Sse.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs index fda05d7fdfc3..537f1e57f94d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs @@ -64,11 +64,17 @@ private static void SubtractScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractScalarSingle() public sealed unsafe class SimpleBinaryOpTest__SubtractScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractScalarSingle testClass) + { + var result = Sse.SubtractScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractScalarSingle(); var result = Sse.SubtractScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.SubtractScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.SubtractScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs index 6a7c1e9c2314..60f65f194d4f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs @@ -64,11 +64,17 @@ private static void XorSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorSingle() public sealed unsafe class SimpleBinaryOpTest__XorSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorSingle testClass) + { + var result = Sse.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__XorSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__XorSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorSingle(); var result = Sse.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs index a15a98a6e5ef..c3a5068c690c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs @@ -64,11 +64,17 @@ private static void AddByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddByte() public sealed unsafe class SimpleBinaryOpTest__AddByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddByte testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddByte(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs index de3e2519b544..841bc9097b52 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs @@ -64,11 +64,17 @@ private static void AddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddDouble() public sealed unsafe class SimpleBinaryOpTest__AddDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddDouble testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddDouble(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs index 505e04214eab..868c9abe6347 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs @@ -64,11 +64,17 @@ private static void AddInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt16() public sealed unsafe class SimpleBinaryOpTest__AddInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt16 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt16(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs index 55003509fd3f..63025cea119c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs @@ -64,11 +64,17 @@ private static void AddInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt32() public sealed unsafe class SimpleBinaryOpTest__AddInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt32 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt32(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs index 4bc63205f284..197d21573637 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs @@ -64,11 +64,17 @@ private static void AddInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddInt64() public sealed unsafe class SimpleBinaryOpTest__AddInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddInt64 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddInt64(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs index d91ea41e55e9..3b05e72d3e93 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs @@ -64,11 +64,17 @@ private static void AddSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSByte() public sealed unsafe class SimpleBinaryOpTest__AddSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSByte testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSByte(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs index 20801eee38de..dbb2edae26fa 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs @@ -64,11 +64,17 @@ private static void AddUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt16() public sealed unsafe class SimpleBinaryOpTest__AddUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt16 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt16(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs index bc81f3af8109..68fa2a4cc253 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs @@ -64,11 +64,17 @@ private static void AddUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt32() public sealed unsafe class SimpleBinaryOpTest__AddUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt32 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt32(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs index e41697a1754f..b77b7732d389 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs @@ -64,11 +64,17 @@ private static void AddUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddUInt64() public sealed unsafe class SimpleBinaryOpTest__AddUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddUInt64 testClass) + { + var result = Sse2.Add(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddUInt64(); var result = Sse2.Add(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Add(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Add(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Byte.cs index 83f78493e8a0..6ca672ead0b0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Byte.cs @@ -64,11 +64,17 @@ private static void AddSaturateByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSaturateByte() public sealed unsafe class SimpleBinaryOpTest__AddSaturateByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSaturateByte testClass) + { + var result = Sse2.AddSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSaturateByte(); var result = Sse2.AddSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AddSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AddSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Int16.cs index 79f90d19c3d1..d5a1f9f5dea2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.Int16.cs @@ -64,11 +64,17 @@ private static void AddSaturateInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSaturateInt16() public sealed unsafe class SimpleBinaryOpTest__AddSaturateInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSaturateInt16 testClass) + { + var result = Sse2.AddSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSaturateInt16(); var result = Sse2.AddSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AddSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AddSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.SByte.cs index f2df53ab1536..fd568373f7ab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.SByte.cs @@ -64,11 +64,17 @@ private static void AddSaturateSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSaturateSByte() public sealed unsafe class SimpleBinaryOpTest__AddSaturateSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSaturateSByte testClass) + { + var result = Sse2.AddSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSaturateSByte(); var result = Sse2.AddSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AddSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AddSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.UInt16.cs index b1578f7ec411..a1a983c54570 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.UInt16.cs @@ -64,11 +64,17 @@ private static void AddSaturateUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSaturateUInt16() public sealed unsafe class SimpleBinaryOpTest__AddSaturateUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddSaturateUInt16 testClass) + { + var result = Sse2.AddSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddSaturateUInt16(); var result = Sse2.AddSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AddSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AddSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddScalar.Double.cs index 191f88ed99bc..56d2b643dd83 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddScalar.Double.cs @@ -64,11 +64,17 @@ private static void AddScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddScalarDouble() public sealed unsafe class SimpleBinaryOpTest__AddScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AddScalarDouble testClass) + { + var result = Sse2.AddScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AddScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AddScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AddScalarDouble(); var result = Sse2.AddScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AddScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AddScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs index 4160d32ae47b..29648cc5a46a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs @@ -64,11 +64,17 @@ private static void AndByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndByte() public sealed unsafe class SimpleBinaryOpTest__AndByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndByte testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndByte(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs index 6c91107c383f..f1ebbefd3262 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs @@ -64,11 +64,17 @@ private static void AndDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndDouble() public sealed unsafe class SimpleBinaryOpTest__AndDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndDouble testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndDouble(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs index 69e46925cc12..944cf203374e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs @@ -64,11 +64,17 @@ private static void AndInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt16() public sealed unsafe class SimpleBinaryOpTest__AndInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt16 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt16(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs index eb509cddb737..af99cd176296 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs @@ -64,11 +64,17 @@ private static void AndInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt32() public sealed unsafe class SimpleBinaryOpTest__AndInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt32 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt32(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs index 010cc8b9f558..3425f1678ebe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs @@ -64,11 +64,17 @@ private static void AndInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndInt64() public sealed unsafe class SimpleBinaryOpTest__AndInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndInt64 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndInt64(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs index ce671243c110..39ca3854a277 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs @@ -64,11 +64,17 @@ private static void AndSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndSByte() public sealed unsafe class SimpleBinaryOpTest__AndSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndSByte testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndSByte(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs index 363cfe3e353d..f5d6eb6329a1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs @@ -64,11 +64,17 @@ private static void AndUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt16() public sealed unsafe class SimpleBinaryOpTest__AndUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt16 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt16(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs index 51e5b7e3aa89..44380c4e19c9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs @@ -64,11 +64,17 @@ private static void AndUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt32() public sealed unsafe class SimpleBinaryOpTest__AndUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt32 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt32(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs index 741c3135382e..59161ca11227 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs @@ -64,11 +64,17 @@ private static void AndUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndUInt64() public sealed unsafe class SimpleBinaryOpTest__AndUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndUInt64 testClass) + { + var result = Sse2.And(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndUInt64(); var result = Sse2.And(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.And(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.And(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs index f0d111d61bc6..2d41403a1a55 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs @@ -64,11 +64,17 @@ private static void AndNotByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotByte() public sealed unsafe class SimpleBinaryOpTest__AndNotByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotByte testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotByte(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs index c2fe12e4543f..4839f21a1182 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs @@ -64,11 +64,17 @@ private static void AndNotDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotDouble() public sealed unsafe class SimpleBinaryOpTest__AndNotDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotDouble testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__AndNotDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__AndNotDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotDouble(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs index dc41c4565a77..032c1bcbc8ba 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs @@ -64,11 +64,17 @@ private static void AndNotInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt16() public sealed unsafe class SimpleBinaryOpTest__AndNotInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt16 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt16(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs index bdde65ae2d45..a17d38320c8a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs @@ -64,11 +64,17 @@ private static void AndNotInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt32() public sealed unsafe class SimpleBinaryOpTest__AndNotInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt32 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt32(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs index 34108a44bc68..99517432845e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs @@ -64,11 +64,17 @@ private static void AndNotInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotInt64() public sealed unsafe class SimpleBinaryOpTest__AndNotInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotInt64 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotInt64(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs index d02e70af35da..aa145851d013 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs @@ -64,11 +64,17 @@ private static void AndNotSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotSByte() public sealed unsafe class SimpleBinaryOpTest__AndNotSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotSByte testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotSByte(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs index f5f4a0cb46d6..a5e235e9acea 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs @@ -64,11 +64,17 @@ private static void AndNotUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt16() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt16 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt16(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs index c6c1716c0869..e2f9961a017f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs @@ -64,11 +64,17 @@ private static void AndNotUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt32() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt32 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt32(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs index 565b71ca28dd..936d29082f51 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs @@ -64,11 +64,17 @@ private static void AndNotUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AndNotUInt64() public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AndNotUInt64 testClass) + { + var result = Sse2.AndNot(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AndNotUInt64(); var result = Sse2.AndNot(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.AndNot(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.AndNot(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.Byte.cs index f60ba8f852cd..44a3ffd90317 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.Byte.cs @@ -64,11 +64,17 @@ private static void AverageByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AverageByte() public sealed unsafe class SimpleBinaryOpTest__AverageByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AverageByte testClass) + { + var result = Sse2.Average(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AverageByte(); var result = Sse2.Average(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Average(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Average(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.UInt16.cs index 4735dc81aa65..559401811839 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.UInt16.cs @@ -64,11 +64,17 @@ private static void AverageUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AverageUInt16() public sealed unsafe class SimpleBinaryOpTest__AverageUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__AverageUInt16 testClass) + { + var result = Sse2.Average(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__AverageUInt16(); var result = Sse2.Average(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Average(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Average(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs index f4717b28485d..cc1994b9dc0a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs @@ -64,11 +64,17 @@ private static void CompareEqualByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualByte() public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualByte testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualByte(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs index 82800a5750ef..08b8400950fc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualDouble testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualDouble(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs index 2ba89e3ff71e..2d6d92f0752f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt16() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt16 testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt16(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs index 42a5be79c9d1..56f44b7fe814 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt32() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt32 testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt32(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs index e497a9a367fd..406bbeffd753 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs @@ -64,11 +64,17 @@ private static void CompareEqualSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualSByte() public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualSByte testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualSByte(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs index 951309a0958e..6167e7b9c6f5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt16() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt16 testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt16(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs index b44d47219c30..49fcf493d6fc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt32() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt32 testClass) + { + var result = Sse2.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt32(); var result = Sse2.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs index d57c30a74524..e515ffb35303 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanDouble() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanDouble testClass) + { + var result = Sse2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanDouble(); var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs index 143878261a40..f1f873d70c06 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt16() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt16 testClass) + { + var result = Sse2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt16(); var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs index 9587d0d8f75b..ef7178c14a2d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt32() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt32 testClass) + { + var result = Sse2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt32(); var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs index cecf67fa9b9a..9ad2b16ec837 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanSByte() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanSByte testClass) + { + var result = Sse2.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanSByte(); var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs index fa4d06dfaaa2..2ee67b3a33e2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanOrEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanOrEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble testClass) + { + var result = Sse2.CompareGreaterThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble(); var result = Sse2.CompareGreaterThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareGreaterThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareGreaterThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs index 310f3d4e296e..bda7ac01331e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs @@ -64,11 +64,17 @@ private static void CompareLessThanDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanDouble() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanDouble testClass) + { + var result = Sse2.CompareLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanDouble(); var result = Sse2.CompareLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs index 2b2b5f5140ad..ec7d35a6f6ae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs @@ -64,11 +64,17 @@ private static void CompareLessThanInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanInt16() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanInt16 testClass) + { + var result = Sse2.CompareLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanInt16(); var result = Sse2.CompareLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs index cc4f8eefb517..32328c510ada 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs @@ -64,11 +64,17 @@ private static void CompareLessThanInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanInt32() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanInt32 testClass) + { + var result = Sse2.CompareLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanInt32(); var result = Sse2.CompareLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs index 9ce1350e7180..b0e699b547fc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs @@ -64,11 +64,17 @@ private static void CompareLessThanSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanSByte() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanSByte testClass) + { + var result = Sse2.CompareLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanSByte(); var result = Sse2.CompareLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs index 7cff72660f8b..23593b9f7393 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareLessThanOrEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareLessThanOrEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareLessThanOrEqualDouble testClass) + { + var result = Sse2.CompareLessThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareLessThanOrEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareLessThanOrEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareLessThanOrEqualDouble(); var result = Sse2.CompareLessThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareLessThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareLessThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs index 0ba136f05bdd..8f3e195c8c51 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareNotEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotEqualDouble testClass) + { + var result = Sse2.CompareNotEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotEqualDouble(); var result = Sse2.CompareNotEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareNotEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareNotEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs index 17de1547cb7c..18e24c2d9308 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanDouble() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanDouble testClass) + { + var result = Sse2.CompareNotGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanDouble(); var result = Sse2.CompareNotGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareNotGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareNotGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs index 6a625d04c7a1..4b2ffe798bf8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareNotGreaterThanOrEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotGreaterThanOrEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble testClass) + { + var result = Sse2.CompareNotGreaterThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble(); var result = Sse2.CompareNotGreaterThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareNotGreaterThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareNotGreaterThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs index 869e08a2798f..4f8644c55194 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanDouble() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanDouble testClass) + { + var result = Sse2.CompareNotLessThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanDouble(); var result = Sse2.CompareNotLessThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareNotLessThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareNotLessThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs index 0666009ae5f3..6ef7fda2803d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs @@ -64,11 +64,17 @@ private static void CompareNotLessThanOrEqualDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareNotLessThanOrEqualDouble() public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble testClass) + { + var result = Sse2.CompareNotLessThanOrEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble(); var result = Sse2.CompareNotLessThanOrEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareNotLessThanOrEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareNotLessThanOrEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs index 474ebc7ba1f5..b690b4e7fceb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs @@ -64,11 +64,17 @@ private static void CompareOrderedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareOrderedDouble() public sealed unsafe class SimpleBinaryOpTest__CompareOrderedDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareOrderedDouble testClass) + { + var result = Sse2.CompareOrdered(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareOrderedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareOrderedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareOrderedDouble(); var result = Sse2.CompareOrdered(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareOrdered(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareOrdered(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs index e38a9397972e..f1d2dda15603 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs @@ -64,11 +64,17 @@ private static void CompareUnorderedDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareUnorderedDouble() public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareUnorderedDouble testClass) + { + var result = Sse2.CompareUnordered(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CompareUnorderedDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CompareUnorderedDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareUnorderedDouble(); var result = Sse2.CompareUnordered(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.CompareUnordered(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.CompareUnordered(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs index da4e34b77f16..f239fe11ddab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs @@ -64,11 +64,17 @@ private static void DivideDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideDouble() public sealed unsafe class SimpleBinaryOpTest__DivideDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideDouble testClass) + { + var result = Sse2.Divide(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideDouble(); var result = Sse2.Divide(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Divide(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Divide(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/DivideScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/DivideScalar.Double.cs index 01f4d3be4086..df155f65e011 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/DivideScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/DivideScalar.Double.cs @@ -64,11 +64,17 @@ private static void DivideScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void DivideScalarDouble() public sealed unsafe class SimpleBinaryOpTest__DivideScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__DivideScalarDouble testClass) + { + var result = Sse2.DivideScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__DivideScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__DivideScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__DivideScalarDouble(); var result = Sse2.DivideScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.DivideScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.DivideScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs deleted file mode 100644 index f2f11953fffc..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.1.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractInt161() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt161 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt161() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt161() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse2.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse2.Extract( - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse2.Extract( - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse2.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt161(); - var result = Sse2.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse2.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Extract)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.129.cs deleted file mode 100644 index e2d3a0013509..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.Int16.129.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractInt16129() - { - var test = new SimpleUnaryOpTest__ExtractInt16129(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractInt16129 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - - private static Int16[] _data = new Int16[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractInt16129() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractInt16129() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, int.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse2.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse2.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse2.Extract( - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse2.Extract( - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse2).GetMethod(nameof(Sse2.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Int16)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse2.Extract( - _clsVar, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArrayPtr)); - var result = Sse2.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractInt16129(); - var result = Sse2.Extract(test._fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse2.Extract(_fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Int16[] inArray = new Int16[Op1ElementCount]; - Int16[] outArray = new Int16[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Int16[] firstOp, Int16[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Extract)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.1.cs index 4683cb85838b..1960d4aee5dd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt161() { - var test = new SimpleUnaryOpTest__ExtractUInt161(); - - try - { + var test = new ExtractScalarTest__ExtractUInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt161 + public sealed unsafe class ExtractScalarTest__ExtractUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt161 testClass) + { + var result = Sse2.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt161() + static ExtractScalarTest__ExtractUInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt161() + public ExtractScalarTest__ExtractUInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt161(); + var test = new ExtractScalarTest__ExtractUInt161(); var result = Sse2.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.129.cs index ce9513aa820c..5590412a5285 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Extract.UInt16.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt16129() { - var test = new SimpleUnaryOpTest__ExtractUInt16129(); - - try - { + var test = new ExtractScalarTest__ExtractUInt16129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt16129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt16129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt16129 + public sealed unsafe class ExtractScalarTest__ExtractUInt16129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt16129 testClass) + { + var result = Sse2.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt16129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt16129() + static ExtractScalarTest__ExtractUInt16129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt16129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt16129() + public ExtractScalarTest__ExtractUInt16129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt16129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt16129(); + var test = new ExtractScalarTest__ExtractUInt16129(); var result = Sse2.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.1.cs index 0f2f4e682322..72944d5fc039 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt161() { - var test = new SimpleUnaryOpTest__InsertInt161(); - - try - { + var test = new InsertScalarTest__InsertInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt161() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt161 + public sealed unsafe class InsertScalarTest__InsertInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt161 testClass) + { + var result = Sse2.Insert(_fld, (short)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt161() + static InsertScalarTest__InsertInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt161() + public InsertScalarTest__InsertInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt161(); + var test = new InsertScalarTest__InsertInt161(); var result = Sse2.Insert(test._fld, (short)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Insert(_fld, (short)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Insert(test._fld, (short)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.129.cs index 619d91856e0b..94c6788e6be9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.Int16.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt16129() { - var test = new SimpleUnaryOpTest__InsertInt16129(); - - try - { + var test = new InsertScalarTest__InsertInt16129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt16129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt16129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt16129 + public sealed unsafe class InsertScalarTest__InsertInt16129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt16129 testClass) + { + var result = Sse2.Insert(_fld, (short)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt16129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt16129() + static InsertScalarTest__InsertInt16129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt16129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt16129() + public InsertScalarTest__InsertInt16129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt16129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt16129(); + var test = new InsertScalarTest__InsertInt16129(); var result = Sse2.Insert(test._fld, (short)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Insert(_fld, (short)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Insert(test._fld, (short)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.1.cs index 70b29d1e3b4f..a159949af79d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt161() { - var test = new SimpleUnaryOpTest__InsertUInt161(); - - try - { + var test = new InsertScalarTest__InsertUInt161(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt161 + public sealed unsafe class InsertScalarTest__InsertUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt161 testClass) + { + var result = Sse2.Insert(_fld, (ushort)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt161() + static InsertScalarTest__InsertUInt161() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt161() + public InsertScalarTest__InsertUInt161() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt161() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt161(); + var test = new InsertScalarTest__InsertUInt161(); var result = Sse2.Insert(test._fld, (ushort)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Insert(_fld, (ushort)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Insert(test._fld, (ushort)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.129.cs index 2c16bc861f50..10cae4270265 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Insert.UInt16.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt16129() { - var test = new SimpleUnaryOpTest__InsertUInt16129(); - - try - { + var test = new InsertScalarTest__InsertUInt16129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt16129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt16129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt16129 + public sealed unsafe class InsertScalarTest__InsertUInt16129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)0; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt16129 testClass) + { + var result = Sse2.Insert(_fld, (ushort)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt16129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt16129() + static InsertScalarTest__InsertUInt16129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt16129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt16129() + public InsertScalarTest__InsertUInt16129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt16129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt16129(); + var test = new InsertScalarTest__InsertUInt16129(); var result = Sse2.Insert(test._fld, (ushort)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Insert(_fld, (ushort)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Insert(test._fld, (ushort)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs index 722434585840..d57d01c1b78a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs @@ -64,11 +64,17 @@ private static void MaxByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxByte() public sealed unsafe class SimpleBinaryOpTest__MaxByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxByte testClass) + { + var result = Sse2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxByte(); var result = Sse2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs index 52a2920f9831..841bd385872c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs @@ -64,11 +64,17 @@ private static void MaxDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxDouble() public sealed unsafe class SimpleBinaryOpTest__MaxDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxDouble testClass) + { + var result = Sse2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxDouble(); var result = Sse2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs index c60ad296a257..a525d69be9d3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs @@ -64,11 +64,17 @@ private static void MaxInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxInt16() public sealed unsafe class SimpleBinaryOpTest__MaxInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxInt16 testClass) + { + var result = Sse2.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxInt16(); var result = Sse2.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MaxScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MaxScalar.Double.cs index 0f72b2e1228f..b7fd43d6fe9f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MaxScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MaxScalar.Double.cs @@ -64,11 +64,17 @@ private static void MaxScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxScalarDouble() public sealed unsafe class SimpleBinaryOpTest__MaxScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxScalarDouble testClass) + { + var result = Sse2.MaxScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MaxScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MaxScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxScalarDouble(); var result = Sse2.MaxScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.MaxScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.MaxScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs index 6670eaee78f4..9c9c2626b2a9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs @@ -64,11 +64,17 @@ private static void MinByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinByte() public sealed unsafe class SimpleBinaryOpTest__MinByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MinValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinByte testClass) + { + var result = Sse2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinByte(); var result = Sse2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs index 17ed799177e8..3afcb8bea601 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs @@ -64,11 +64,17 @@ private static void MinDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinDouble() public sealed unsafe class SimpleBinaryOpTest__MinDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinDouble testClass) + { + var result = Sse2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinDouble(); var result = Sse2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs index b9a1a1ef2c49..fb9e015a6e26 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs @@ -64,11 +64,17 @@ private static void MinInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinInt16() public sealed unsafe class SimpleBinaryOpTest__MinInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinInt16 testClass) + { + var result = Sse2.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinInt16(); var result = Sse2.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MinScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MinScalar.Double.cs index 81ddf32e029a..6c73ae09a34b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MinScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MinScalar.Double.cs @@ -64,11 +64,17 @@ private static void MinScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinScalarDouble() public sealed unsafe class SimpleBinaryOpTest__MinScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinScalarDouble testClass) + { + var result = Sse2.MinScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MinScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MinScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinScalarDouble(); var result = Sse2.MinScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.MinScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.MinScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs index 5adb4d14a4de..ab426a3a0733 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyDouble() public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyDouble testClass) + { + var result = Sse2.Multiply(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplyDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplyDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyDouble(); var result = Sse2.Multiply(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Multiply(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Multiply(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyScalar.Double.cs index 7be0a029d047..e44698db11ce 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyScalar.Double.cs @@ -64,11 +64,17 @@ private static void MultiplyScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyScalarDouble() public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyScalarDouble testClass) + { + var result = Sse2.MultiplyScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__MultiplyScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__MultiplyScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyScalarDouble(); var result = Sse2.MultiplyScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.MultiplyScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.MultiplyScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs index af8e8c098ef9..53756f9192a0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs @@ -64,11 +64,17 @@ private static void OrByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrByte() public sealed unsafe class SimpleBinaryOpTest__OrByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrByte testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrByte(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs index 7c8eeb8dd8d2..fee0e3cafc94 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs @@ -64,11 +64,17 @@ private static void OrDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrDouble() public sealed unsafe class SimpleBinaryOpTest__OrDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrDouble testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__OrDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__OrDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrDouble(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs index eae8b5f433b8..f7ec38df0bc7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs @@ -64,11 +64,17 @@ private static void OrInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt16() public sealed unsafe class SimpleBinaryOpTest__OrInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt16 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt16(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs index 32d05fefb47f..78aa2cc807f7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs @@ -64,11 +64,17 @@ private static void OrInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt32() public sealed unsafe class SimpleBinaryOpTest__OrInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt32 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt32(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs index 8570ab158b47..b3fd649c8ab5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs @@ -64,11 +64,17 @@ private static void OrInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrInt64() public sealed unsafe class SimpleBinaryOpTest__OrInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrInt64 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrInt64(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs index 7775bc0812a6..a8dd737f7953 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs @@ -64,11 +64,17 @@ private static void OrSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrSByte() public sealed unsafe class SimpleBinaryOpTest__OrSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrSByte testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrSByte(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs index 0f2aa04bdcfe..14f14e200884 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs @@ -64,11 +64,17 @@ private static void OrUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt16() public sealed unsafe class SimpleBinaryOpTest__OrUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt16 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt16(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs index 4a9234c9a3c7..3401cee3fb8e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs @@ -64,11 +64,17 @@ private static void OrUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt32() public sealed unsafe class SimpleBinaryOpTest__OrUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt32 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt32(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs index 9403d32eb7f6..c472e7934728 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs @@ -64,11 +64,17 @@ private static void OrUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void OrUInt64() public sealed unsafe class SimpleBinaryOpTest__OrUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__OrUInt64 testClass) + { + var result = Sse2.Or(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__OrUInt64(); var result = Sse2.Or(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Or(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Or(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs index 10782bcced44..e2ab97d7f122 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Program.Sse2.cs @@ -72,9 +72,7 @@ static Program() ["CompareUnordered.Double"] = CompareUnorderedDouble, ["Divide.Double"] = DivideDouble, ["DivideScalar.Double"] = DivideScalarDouble, - ["Extract.Int16.1"] = ExtractInt161, ["Extract.UInt16.1"] = ExtractUInt161, - ["Extract.Int16.129"] = ExtractInt16129, ["Extract.UInt16.129"] = ExtractUInt16129, ["Insert.Int16.1"] = InsertInt161, ["Insert.UInt16.1"] = InsertUInt161, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Byte.cs index 010cd2629add..bf4a60a9b061 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Byte.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128Byte() { - bool skipIf32Bit = (typeof(Byte) == typeof(Int64)) || - (typeof(Byte) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128Byte(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Byte(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128Byte() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128Byte + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128Byte { + private struct TestStruct + { + public Byte _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (byte)(random.Next(byte.MinValue, byte.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128Byte testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); - private static readonly Random Random = new Random(); + private static Byte _data; private static Byte _clsVar; private Byte _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128Byte() + static ScalarSimdUnaryOpTest__SetAllVector128Byte() { - _clsVar = (byte)(Random.Next(byte.MinValue, byte.MaxValue)); + var random = new Random(); + _clsVar = (byte)(random.Next(byte.MinValue, byte.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128Byte() + public ScalarSimdUnaryOpTest__SetAllVector128Byte() { Succeeded = true; - _fld = (byte)(Random.Next(byte.MinValue, byte.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new Byte[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (byte)(random.Next(byte.MinValue, byte.MaxValue)); + _data = (byte)(random.Next(byte.MinValue, byte.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (byte)(Random.Next(byte.MinValue, byte.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (byte)(Random.Next(byte.MinValue, byte.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Byte) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Byte) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (byte)(Random.Next(byte.MinValue, byte.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128Byte(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Byte(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Double.cs index 190d30661c75..05e684341c93 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Double.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128Double() { - bool skipIf32Bit = (typeof(Double) == typeof(Int64)) || - (typeof(Double) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128Double(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Double(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128Double() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128Double + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128Double { + private struct TestStruct + { + public Double _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = TestLibrary.Generator.GetDouble(); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128Double testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Double); - private static readonly Random Random = new Random(); + private static Double _data; private static Double _clsVar; private Double _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128Double() + static ScalarSimdUnaryOpTest__SetAllVector128Double() { - _clsVar = Random.NextDouble(); + var random = new Random(); + _clsVar = TestLibrary.Generator.GetDouble(); } - public SimpleScalarUnaryOpTest__SetAllVector128Double() + public ScalarSimdUnaryOpTest__SetAllVector128Double() { Succeeded = true; - _fld = Random.NextDouble(); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new Double[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = TestLibrary.Generator.GetDouble(); + _data = TestLibrary.Generator.GetDouble(); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new Double[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Double) != typeof(long)) && (typeof(Double) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = Random.NextDouble(); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = Random.NextDouble(); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Double) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Double) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = Random.NextDouble(); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128Double(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Double(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int16.cs index 43d9a83388c4..d8b169851768 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int16.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128Int16() { - bool skipIf32Bit = (typeof(Int16) == typeof(Int64)) || - (typeof(Int16) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int16(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int16(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128Int16() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128Int16 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128Int16 { + private struct TestStruct + { + public Int16 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (short)(random.Next(short.MinValue, short.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128Int16 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int16); - private static readonly Random Random = new Random(); + private static Int16 _data; private static Int16 _clsVar; private Int16 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128Int16() + static ScalarSimdUnaryOpTest__SetAllVector128Int16() { - _clsVar = (short)(Random.Next(short.MinValue, short.MaxValue)); + var random = new Random(); + _clsVar = (short)(random.Next(short.MinValue, short.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128Int16() + public ScalarSimdUnaryOpTest__SetAllVector128Int16() { Succeeded = true; - _fld = (short)(Random.Next(short.MinValue, short.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new Int16[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (short)(random.Next(short.MinValue, short.MaxValue)); + _data = (short)(random.Next(short.MinValue, short.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new Int16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Int16) != typeof(long)) && (typeof(Int16) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (short)(Random.Next(short.MinValue, short.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (short)(Random.Next(short.MinValue, short.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int16) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int16) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (short)(Random.Next(short.MinValue, short.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int16(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int16(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int32.cs index 9ebad56657a2..281ee91c00e9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int32.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128Int32() { - bool skipIf32Bit = (typeof(Int32) == typeof(Int64)) || - (typeof(Int32) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int32(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int32(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128Int32() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128Int32 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128Int32 { + private struct TestStruct + { + public Int32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (int)(random.Next(int.MinValue, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128Int32 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int32); - private static readonly Random Random = new Random(); + private static Int32 _data; private static Int32 _clsVar; private Int32 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128Int32() + static ScalarSimdUnaryOpTest__SetAllVector128Int32() { - _clsVar = (int)(Random.Next(int.MinValue, int.MaxValue)); + var random = new Random(); + _clsVar = (int)(random.Next(int.MinValue, int.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128Int32() + public ScalarSimdUnaryOpTest__SetAllVector128Int32() { Succeeded = true; - _fld = (int)(Random.Next(int.MinValue, int.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new Int32[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (int)(random.Next(int.MinValue, int.MaxValue)); + _data = (int)(random.Next(int.MinValue, int.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (int)(Random.Next(int.MinValue, int.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (int)(Random.Next(int.MinValue, int.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int32) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (int)(Random.Next(int.MinValue, int.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int32(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int32(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int64.cs index c97deb51c05b..56a8a48031ee 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.Int64.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128Int64() { - bool skipIf32Bit = (typeof(Int64) == typeof(Int64)) || - (typeof(Int64) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int64(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int64(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128Int64() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128Int64 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128Int64 { + private struct TestStruct + { + public Int64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (long)(random.Next(int.MinValue, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128Int64 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Int64); - private static readonly Random Random = new Random(); + private static Int64 _data; private static Int64 _clsVar; private Int64 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128Int64() + static ScalarSimdUnaryOpTest__SetAllVector128Int64() { - _clsVar = (long)(Random.Next(int.MinValue, int.MaxValue)); + var random = new Random(); + _clsVar = (long)(random.Next(int.MinValue, int.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128Int64() + public ScalarSimdUnaryOpTest__SetAllVector128Int64() { Succeeded = true; - _fld = (long)(Random.Next(int.MinValue, int.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new Int64[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (long)(random.Next(int.MinValue, int.MaxValue)); + _data = (long)(random.Next(int.MinValue, int.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (long)(Random.Next(int.MinValue, int.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (long)(Random.Next(int.MinValue, int.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int64) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(Int64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (long)(Random.Next(int.MinValue, int.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128Int64(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128Int64(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.SByte.cs index 355d90bd967f..9b9e927f2232 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.SByte.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128SByte() { - bool skipIf32Bit = (typeof(SByte) == typeof(Int64)) || - (typeof(SByte) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128SByte(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128SByte(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128SByte() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128SByte + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128SByte { + private struct TestStruct + { + public SByte _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128SByte testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly Random Random = new Random(); + private static SByte _data; private static SByte _clsVar; private SByte _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128SByte() + static ScalarSimdUnaryOpTest__SetAllVector128SByte() { - _clsVar = (sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue)); + var random = new Random(); + _clsVar = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128SByte() + public ScalarSimdUnaryOpTest__SetAllVector128SByte() { Succeeded = true; - _fld = (sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new SByte[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); + _data = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(SByte) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(SByte) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (sbyte)(Random.Next(sbyte.MinValue, sbyte.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128SByte(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128SByte(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt16.cs index b11e3362de32..3773a7b1a2aa 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt16.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128UInt16() { - bool skipIf32Bit = (typeof(UInt16) == typeof(Int64)) || - (typeof(UInt16) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt16(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt16(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128UInt16() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128UInt16 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128UInt16 { + private struct TestStruct + { + public UInt16 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ushort)(random.Next(ushort.MinValue, ushort.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128UInt16 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt16); - private static readonly Random Random = new Random(); + private static UInt16 _data; private static UInt16 _clsVar; private UInt16 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128UInt16() + static ScalarSimdUnaryOpTest__SetAllVector128UInt16() { - _clsVar = (ushort)(Random.Next(ushort.MinValue, ushort.MaxValue)); + var random = new Random(); + _clsVar = (ushort)(random.Next(ushort.MinValue, ushort.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128UInt16() + public ScalarSimdUnaryOpTest__SetAllVector128UInt16() { Succeeded = true; - _fld = (ushort)(Random.Next(ushort.MinValue, ushort.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new UInt16[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (ushort)(random.Next(ushort.MinValue, ushort.MaxValue)); + _data = (ushort)(random.Next(ushort.MinValue, ushort.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new UInt16[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt16) != typeof(long)) && (typeof(UInt16) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (ushort)(Random.Next(ushort.MinValue, ushort.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (ushort)(Random.Next(ushort.MinValue, ushort.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt16) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt16) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (ushort)(Random.Next(ushort.MinValue, ushort.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt16(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt16(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt32.cs index 548cf6e4a117..330b3b58016c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt32.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128UInt32() { - bool skipIf32Bit = (typeof(UInt32) == typeof(Int64)) || - (typeof(UInt32) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt32(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt32(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128UInt32() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128UInt32 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128UInt32 { + private struct TestStruct + { + public UInt32 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (uint)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128UInt32 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt32); - private static readonly Random Random = new Random(); + private static UInt32 _data; private static UInt32 _clsVar; private UInt32 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128UInt32() + static ScalarSimdUnaryOpTest__SetAllVector128UInt32() { - _clsVar = (uint)(Random.Next(0, int.MaxValue)); + var random = new Random(); + _clsVar = (uint)(random.Next(0, int.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128UInt32() + public ScalarSimdUnaryOpTest__SetAllVector128UInt32() { Succeeded = true; - _fld = (uint)(Random.Next(0, int.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new UInt32[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (uint)(random.Next(0, int.MaxValue)); + _data = (uint)(random.Next(0, int.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (uint)(Random.Next(0, int.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (uint)(Random.Next(0, int.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt32) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt32) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (uint)(Random.Next(0, int.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt32(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt32(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt64.cs index 3881ae6726ab..1983b4f3a347 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetAllVector128.UInt64.cs @@ -21,35 +21,33 @@ public static partial class Program { private static void SetAllVector128UInt64() { - bool skipIf32Bit = (typeof(UInt64) == typeof(Int64)) || - (typeof(UInt64) == typeof(UInt64)); - - if (skipIf32Bit && !Environment.Is64BitProcess) - { - return; - } - - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt64(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt64(); if (test.IsSupported) { // Validates basic functionality works - test.RunBasicScenario(); + test.RunBasicScenario_UnsafeRead(); // Validates calling via reflection works - test.RunReflectionScenario(); + test.RunReflectionScenario_UnsafeRead(); // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works - test.RunLclVarScenario(); + test.RunLclVarScenario_UnsafeRead(); - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -64,56 +62,81 @@ private static void SetAllVector128UInt64() } } - public sealed unsafe class SimpleScalarUnaryOpTest__SetAllVector128UInt64 + public sealed unsafe class ScalarSimdUnaryOpTest__SetAllVector128UInt64 { + private struct TestStruct + { + public UInt64 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + testStruct._fld = (ulong)(random.Next(0, int.MaxValue)); + return testStruct; + } + + public void RunStructFldScenario(ScalarSimdUnaryOpTest__SetAllVector128UInt64 testClass) + { + var result = Sse2.SetAllVector128(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(UInt64); - private static readonly Random Random = new Random(); + private static UInt64 _data; private static UInt64 _clsVar; private UInt64 _fld; - private SimpleScalarUnaryOpTest__DataTable _dataTable; + private ScalarSimdUnaryOpTest__DataTable _dataTable; - static SimpleScalarUnaryOpTest__SetAllVector128UInt64() + static ScalarSimdUnaryOpTest__SetAllVector128UInt64() { - _clsVar = (ulong)(Random.Next(0, int.MaxValue)); + var random = new Random(); + _clsVar = (ulong)(random.Next(0, int.MaxValue)); } - public SimpleScalarUnaryOpTest__SetAllVector128UInt64() + public ScalarSimdUnaryOpTest__SetAllVector128UInt64() { Succeeded = true; - _fld = (ulong)(Random.Next(0, int.MaxValue)); - _dataTable = new SimpleScalarUnaryOpTest__DataTable(new UInt64[RetElementCount], LargestVectorSize); + var random = new Random(); + _fld = (ulong)(random.Next(0, int.MaxValue)); + _data = (ulong)(random.Next(0, int.MaxValue)); + _dataTable = new ScalarSimdUnaryOpTest__DataTable(new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse2.IsSupported; + public bool IsSupported => Sse2.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } - public void RunBasicScenario() + public void RunBasicScenario_UnsafeRead() { - var firstOp = (ulong)(Random.Next(0, int.MaxValue)); var result = Sse2.SetAllVector128( - firstOp + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } - public void RunReflectionScenario() + public void RunReflectionScenario_UnsafeRead() { - var firstOp = (ulong)(Random.Next(0, int.MaxValue)); - var method = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt64) }); - var result = method.Invoke(null, new object[] { firstOp }); + var result = typeof(Sse2).GetMethod(nameof(Sse2.SetAllVector128), new Type[] { typeof(UInt64) }) + .Invoke(null, new object[] { + Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)) + }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(_data, _dataTable.outArrayPtr); } public void RunClsVarScenario() @@ -126,25 +149,25 @@ public void RunClsVarScenario() ValidateResult(_clsVar, _dataTable.outArrayPtr); } - public void RunLclVarScenario() + public void RunLclVarScenario_UnsafeRead() { - var firstOp = (ulong)(Random.Next(0, int.MaxValue)); - var result = Sse2.SetAllVector128(firstOp); + var data = Unsafe.ReadUnaligned(ref Unsafe.As(ref _data)); + var result = Sse2.SetAllVector128(data); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(data, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleScalarUnaryOpTest__SetAllVector128UInt64(); + var test = new ScalarSimdUnaryOpTest__SetAllVector128UInt64(); var result = Sse2.SetAllVector128(test._fld); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SetAllVector128(_fld); @@ -152,13 +175,28 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SetAllVector128(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; try { - RunBasicScenario(); + RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.1.cs index 58a8d25f4c0b..8754e3a6992a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt161 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt161() + static ImmUnaryOpTest__ShiftLeftLogicalInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt161() + public ImmUnaryOpTest__ShiftLeftLogicalInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt161(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.16.cs index 2d0c6df18d04..9737b9d27adc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt1616() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt1616 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt1616 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt1616() + static ImmUnaryOpTest__ShiftLeftLogicalInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt1616() + public ImmUnaryOpTest__ShiftLeftLogicalInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt1616(); var result = Sse2.ShiftLeftLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.1.cs index 24a390ecc8f1..9fd8c2828f21 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt321 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt321() + static ImmUnaryOpTest__ShiftLeftLogicalInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt321() + public ImmUnaryOpTest__ShiftLeftLogicalInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt321(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.32.cs index 2e83c1c95a4e..9c70a61f1bb5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt3232() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt3232 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt3232 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt3232() + static ImmUnaryOpTest__ShiftLeftLogicalInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt3232() + public ImmUnaryOpTest__ShiftLeftLogicalInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt3232(); var result = Sse2.ShiftLeftLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.1.cs index 45cc4d0e720b..ce7e5dcfe469 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt641 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt641() + static ImmUnaryOpTest__ShiftLeftLogicalInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt641() + public ImmUnaryOpTest__ShiftLeftLogicalInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt641(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.64.cs index 39591dfb911b..b77dc1289b3d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.Int64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalInt6464() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalInt6464 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalInt6464 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalInt6464() + static ImmUnaryOpTest__ShiftLeftLogicalInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalInt6464() + public ImmUnaryOpTest__ShiftLeftLogicalInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalInt6464(); var result = Sse2.ShiftLeftLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.1.cs index a701aaa7657d..12e44cf13bd8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt161 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt161() + static ImmUnaryOpTest__ShiftLeftLogicalUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt161() + public ImmUnaryOpTest__ShiftLeftLogicalUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt161(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.16.cs index f1a6b7451b8a..c230bbe8fc0d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt1616() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt1616 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt1616 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() + static ImmUnaryOpTest__ShiftLeftLogicalUInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt1616() + public ImmUnaryOpTest__ShiftLeftLogicalUInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt1616(); var result = Sse2.ShiftLeftLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.1.cs index bf9223cdad6f..ac1a082d9f8d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt321 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt321() + static ImmUnaryOpTest__ShiftLeftLogicalUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt321() + public ImmUnaryOpTest__ShiftLeftLogicalUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt321(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.32.cs index 3cce6d0bbaaf..12910f44e109 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt3232() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt3232 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt3232 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() + static ImmUnaryOpTest__ShiftLeftLogicalUInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt3232() + public ImmUnaryOpTest__ShiftLeftLogicalUInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt3232(); var result = Sse2.ShiftLeftLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.1.cs index 0c5513070649..74186f517fe0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt641 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt641() + static ImmUnaryOpTest__ShiftLeftLogicalUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt641() + public ImmUnaryOpTest__ShiftLeftLogicalUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt641(); var result = Sse2.ShiftLeftLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.64.cs index 14a737bf91b9..126e58f5111a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical.UInt64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogicalUInt6464() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogicalUInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogicalUInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogicalUInt6464 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogicalUInt6464 testClass) + { + var result = Sse2.ShiftLeftLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogicalUInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() + static ImmUnaryOpTest__ShiftLeftLogicalUInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogicalUInt6464() + public ImmUnaryOpTest__ShiftLeftLogicalUInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftLeftLogicalUInt6464(); var result = Sse2.ShiftLeftLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Byte.1.cs index f7f792cea4e1..c025af080f6a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Byte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneByte1() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneByte1(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int16.1.cs index b0f048dbc5df..3e46bb3f62a7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt161(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int32.1.cs index ffb333087400..9e89f91ac638 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt321(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int64.1.cs index 9473a37f0258..ebddb62abaff 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneInt641(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.SByte.1.cs index a45eb1ec08a6..a73f75ae6946 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.SByte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneSByte1() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneSByte1(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt16.1.cs index 21d868141cbf..f5f5a427ae52 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt161() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt161(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt32.1.cs index 0ed76400d7b2..d6cc28ac6220 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt321() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt321(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt64.1.cs index fce9edd57dd2..05b09c787a31 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftLeftLogical128BitLane.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftLeftLogical128BitLaneUInt641() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftLeftLogical128BitLaneUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftLeftLogical128BitLaneUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 testClass) + { + var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() + static ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() + public ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftLeftLogical128BitLaneUInt641(); var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftLeftLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftLeftLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.1.cs index 77661070b12e..3da18be7aeb1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt161() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt161(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt161 testClass) + { + var result = Sse2.ShiftRightArithmetic(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt161() + static ImmUnaryOpTest__ShiftRightArithmeticInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt161() + public ImmUnaryOpTest__ShiftRightArithmeticInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt161(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt161(); var result = Sse2.ShiftRightArithmetic(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightArithmetic(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightArithmetic(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.16.cs index ae94e8cc4e7c..c463b72b92fd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt1616(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt1616 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt1616 testClass) + { + var result = Sse2.ShiftRightArithmetic(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt1616() + static ImmUnaryOpTest__ShiftRightArithmeticInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt1616() + public ImmUnaryOpTest__ShiftRightArithmeticInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt1616(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt1616(); var result = Sse2.ShiftRightArithmetic(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightArithmetic(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightArithmetic(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.1.cs index d0a8f7296645..3cf8b1630d96 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt321() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt321(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt321 testClass) + { + var result = Sse2.ShiftRightArithmetic(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt321() + static ImmUnaryOpTest__ShiftRightArithmeticInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt321() + public ImmUnaryOpTest__ShiftRightArithmeticInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt321(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt321(); var result = Sse2.ShiftRightArithmetic(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightArithmetic(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightArithmetic(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.32.cs index 74edfe1dc8e9..ee0a454eb65f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightArithmetic.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightArithmeticInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt3232(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightArithmeticInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightArithmeticInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightArithmeticInt3232 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightArithmeticInt3232 testClass) + { + var result = Sse2.ShiftRightArithmetic(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightArithmeticInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightArithmeticInt3232() + static ImmUnaryOpTest__ShiftRightArithmeticInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightArithmeticInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightArithmeticInt3232() + public ImmUnaryOpTest__ShiftRightArithmeticInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightArithmeticInt3232(); + var test = new ImmUnaryOpTest__ShiftRightArithmeticInt3232(); var result = Sse2.ShiftRightArithmetic(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightArithmetic(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightArithmetic(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.1.cs index 40d3f043dde7..6ce2efecefd8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt161 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt161() + static ImmUnaryOpTest__ShiftRightLogicalInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt161() + public ImmUnaryOpTest__ShiftRightLogicalInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt161(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.16.cs index 528e674bc7cf..528987a98237 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt1616 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(0, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt1616 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt1616() + static ImmUnaryOpTest__ShiftRightLogicalInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt1616() + public ImmUnaryOpTest__ShiftRightLogicalInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt1616(); var result = Sse2.ShiftRightLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.1.cs index 72bc20b35d34..c3b5562eeac9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt321 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt321() + static ImmUnaryOpTest__ShiftRightLogicalInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt321() + public ImmUnaryOpTest__ShiftRightLogicalInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt321(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.32.cs index 65c0a1dbf23c..b6ba6ce70045 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt3232 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt3232 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt3232() + static ImmUnaryOpTest__ShiftRightLogicalInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt3232() + public ImmUnaryOpTest__ShiftRightLogicalInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt3232(); var result = Sse2.ShiftRightLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.1.cs index 3c5806c59fc1..2a1af230efe1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt641 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt641() + static ImmUnaryOpTest__ShiftRightLogicalInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt641() + public ImmUnaryOpTest__ShiftRightLogicalInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt641(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.64.cs index c3b9f43bebad..983b117f084f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.Int64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalInt6464() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalInt6464 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalInt6464 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalInt6464() + static ImmUnaryOpTest__ShiftRightLogicalInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalInt6464() + public ImmUnaryOpTest__ShiftRightLogicalInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalInt6464(); var result = Sse2.ShiftRightLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.1.cs index 09dae4f4c10f..eee049ce184f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt161 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt161() + static ImmUnaryOpTest__ShiftRightLogicalUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt161() + public ImmUnaryOpTest__ShiftRightLogicalUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt161(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.16.cs index 5a1834ab58ef..af87a8d1ec92 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt16.16.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt1616() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt1616(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt1616() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt1616() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt1616 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt1616 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt1616 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt1616 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt1616() + static ImmUnaryOpTest__ShiftRightLogicalUInt1616() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt1616() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt1616() + public ImmUnaryOpTest__ShiftRightLogicalUInt1616() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt1616(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt1616(); var result = Sse2.ShiftRightLogical(test._fld, 16); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 16); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.1.cs index 9f72c36ec745..7c3d4debc9e8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt321 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt321() + static ImmUnaryOpTest__ShiftRightLogicalUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt321() + public ImmUnaryOpTest__ShiftRightLogicalUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt321(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.32.cs index a9b488a186ee..18e686e86ae5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt32.32.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt3232() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt3232(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt3232() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt3232() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt3232 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt3232 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt3232 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt3232 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt3232() + static ImmUnaryOpTest__ShiftRightLogicalUInt3232() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt3232() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt3232() + public ImmUnaryOpTest__ShiftRightLogicalUInt3232() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt3232(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt3232(); var result = Sse2.ShiftRightLogical(test._fld, 32); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 32); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.1.cs index b7b06facf6e9..f03725a1850a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt641 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt641() + static ImmUnaryOpTest__ShiftRightLogicalUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt641() + public ImmUnaryOpTest__ShiftRightLogicalUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt641(); var result = Sse2.ShiftRightLogical(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.64.cs index a240f3c1354d..d67b64dfbfd9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical.UInt64.64.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogicalUInt6464() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt6464(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogicalUInt6464() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogicalUInt6464() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt6464 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogicalUInt6464 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogicalUInt6464 testClass) + { + var result = Sse2.ShiftRightLogical(_fld, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogicalUInt6464 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogicalUInt6464() + static ImmUnaryOpTest__ShiftRightLogicalUInt6464() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogicalUInt6464() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogicalUInt6464() + public ImmUnaryOpTest__ShiftRightLogicalUInt6464() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogicalUInt6464(); + var test = new ImmUnaryOpTest__ShiftRightLogicalUInt6464(); var result = Sse2.ShiftRightLogical(test._fld, 64); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical(_fld, 64); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical(test._fld, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Byte.1.cs index 4629e1055159..ba1a3d951a29 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Byte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneByte1() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneByte1(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int16.1.cs index ae70e60011d4..b8ccee319d69 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt161(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int32.1.cs index 8e2b7b006a80..647b7c68299d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt321(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int64.1.cs index 5ad3c2e2858a..51e0d832d8c0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.Int64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneInt641(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.SByte.1.cs index a90ee473ccc9..71740a82f222 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.SByte.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneSByte1() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneSByte1(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt16.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt16.1.cs index 71217bd4566e..14585c1d46c1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt16.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt16.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt161() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt161() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt161() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt161(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt32.1.cs index a0e439f66413..028880c94c48 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt32.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt321() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt321(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt64.1.cs index 55e9d47418f6..0c9f9dffa7fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ShiftRightLogical128BitLane.UInt64.1.cs @@ -21,7 +21,7 @@ public static partial class Program { private static void ShiftRightLogical128BitLaneUInt641() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); if (test.IsSupported) { @@ -64,11 +64,17 @@ private static void ShiftRightLogical128BitLaneUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -83,8 +89,32 @@ private static void ShiftRightLogical128BitLaneUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641 + public sealed unsafe class ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)8; } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641 testClass) + { + var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() + static ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641() { var random = new Random(); @@ -106,7 +136,7 @@ static SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641() + public ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641() { Succeeded = true; @@ -230,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); + var test = new ImmUnaryOpTest__ShiftRightLogical128BitLaneUInt641(); var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.ShiftRightLogical128BitLane(_fld, 1); @@ -247,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.ShiftRightLogical128BitLane(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj index fec034cb5168..2188ab4a40fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_r.csproj @@ -87,9 +87,7 @@ - - @@ -194,9 +192,12 @@ - + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj index 8c82568c0c9a..097cd0da6a00 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sse2_ro.csproj @@ -87,9 +87,7 @@ - - @@ -194,9 +192,12 @@ - + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs index c8de3ae5a57f..a513f006d5fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs @@ -64,11 +64,17 @@ private static void SubtractByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractByte() public sealed unsafe class SimpleBinaryOpTest__SubtractByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractByte testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractByte(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs index 98c5826e16be..9c20d15e6386 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs @@ -64,11 +64,17 @@ private static void SubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractDouble() public sealed unsafe class SimpleBinaryOpTest__SubtractDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractDouble testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractDouble(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs index 0906300e61ab..3bd5f57ce052 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs @@ -64,11 +64,17 @@ private static void SubtractInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt16 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt16(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs index 7c2dc5dbf1ba..93f90607af96 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs @@ -64,11 +64,17 @@ private static void SubtractInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt32() public sealed unsafe class SimpleBinaryOpTest__SubtractInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt32 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt32(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs index 5a67978f7f70..b404f2117b57 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs @@ -64,11 +64,17 @@ private static void SubtractInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractInt64() public sealed unsafe class SimpleBinaryOpTest__SubtractInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractInt64 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractInt64(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs index 54f955b3773d..726c654ad93e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs @@ -64,11 +64,17 @@ private static void SubtractSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSByte() public sealed unsafe class SimpleBinaryOpTest__SubtractSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSByte testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSByte(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs index 8e160381922c..f266e34686bd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs @@ -64,11 +64,17 @@ private static void SubtractUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt16 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt16(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs index 263c3531d4b4..851d321b509c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs @@ -64,11 +64,17 @@ private static void SubtractUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt32() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt32 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt32(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs index fa624496319d..297ee439daaf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs @@ -64,11 +64,17 @@ private static void SubtractUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractUInt64() public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractUInt64 testClass) + { + var result = Sse2.Subtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractUInt64(); var result = Sse2.Subtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Subtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Subtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Byte.cs index 2f72bb0d86a9..1079bcb04a24 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Byte.cs @@ -64,11 +64,17 @@ private static void SubtractSaturateByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSaturateByte() public sealed unsafe class SimpleBinaryOpTest__SubtractSaturateByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturateByte testClass) + { + var result = Sse2.SubtractSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSaturateByte(); var result = Sse2.SubtractSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SubtractSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SubtractSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Int16.cs index 9d9e2a5516ae..81a812022879 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.Int16.cs @@ -64,11 +64,17 @@ private static void SubtractSaturateInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSaturateInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractSaturateInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturateInt16 testClass) + { + var result = Sse2.SubtractSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSaturateInt16(); var result = Sse2.SubtractSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SubtractSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SubtractSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.SByte.cs index 2afaabd494f4..037ce8e57f43 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.SByte.cs @@ -64,11 +64,17 @@ private static void SubtractSaturateSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSaturateSByte() public sealed unsafe class SimpleBinaryOpTest__SubtractSaturateSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturateSByte testClass) + { + var result = Sse2.SubtractSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSaturateSByte(); var result = Sse2.SubtractSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SubtractSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SubtractSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.UInt16.cs index c7d80e1d829b..43f5a129ea07 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.UInt16.cs @@ -64,11 +64,17 @@ private static void SubtractSaturateUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractSaturateUInt16() public sealed unsafe class SimpleBinaryOpTest__SubtractSaturateUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(ushort.MinValue,ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractSaturateUInt16 testClass) + { + var result = Sse2.SubtractSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractSaturateUInt16(); var result = Sse2.SubtractSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SubtractSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SubtractSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractScalar.Double.cs index eb9aeefd0d19..9391333bd835 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractScalar.Double.cs @@ -64,11 +64,17 @@ private static void SubtractScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SubtractScalarDouble() public sealed unsafe class SimpleBinaryOpTest__SubtractScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SubtractScalarDouble testClass) + { + var result = Sse2.SubtractScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__SubtractScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__SubtractScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SubtractScalarDouble(); var result = Sse2.SubtractScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.SubtractScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.SubtractScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs index 7ca399c5220f..48eca30ec30d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs @@ -64,11 +64,17 @@ private static void XorByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorByte() public sealed unsafe class SimpleBinaryOpTest__XorByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorByte testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorByte(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs index 1b0f5bc46b6a..2f7697acb17f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs @@ -64,11 +64,17 @@ private static void XorDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorDouble() public sealed unsafe class SimpleBinaryOpTest__XorDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorDouble testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__XorDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__XorDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorDouble(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs index 28a768f7cb50..1f6afd5c5cb9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs @@ -64,11 +64,17 @@ private static void XorInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt16() public sealed unsafe class SimpleBinaryOpTest__XorInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt16 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt16(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs index 2a3d6f78bd93..c56b27a18b2a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs @@ -64,11 +64,17 @@ private static void XorInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt32() public sealed unsafe class SimpleBinaryOpTest__XorInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt32 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt32(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs index 6c2fc07308fb..71b32c308266 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs @@ -64,11 +64,17 @@ private static void XorInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorInt64() public sealed unsafe class SimpleBinaryOpTest__XorInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorInt64 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorInt64(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs index 5edc54402f94..a22386e9a737 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs @@ -64,11 +64,17 @@ private static void XorSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorSByte() public sealed unsafe class SimpleBinaryOpTest__XorSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorSByte testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorSByte(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs index 63888399a221..ebd1df625c19 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs @@ -64,11 +64,17 @@ private static void XorUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt16() public sealed unsafe class SimpleBinaryOpTest__XorUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt16 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt16(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs index 65625241b40e..6e0c801510bf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs @@ -64,11 +64,17 @@ private static void XorUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt32() public sealed unsafe class SimpleBinaryOpTest__XorUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt32 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt32(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs index 7cbf13db5e85..2bb6ebca742a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs @@ -64,11 +64,17 @@ private static void XorUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void XorUInt64() public sealed unsafe class SimpleBinaryOpTest__XorUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__XorUInt64 testClass) + { + var result = Sse2.Xor(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__XorUInt64(); var result = Sse2.Xor(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse2.Xor(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse2.Xor(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Double.cs index 19afb61f2055..452f45fb75f6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Double.cs @@ -64,11 +64,17 @@ private static void AddSubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSubtractDouble() public sealed unsafe class AlternatingBinaryOpTest__AddSubtractDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingBinaryOpTest__AddSubtractDouble testClass) + { + var result = Sse3.AddSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static AlternatingBinaryOpTest__AddSubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public AlternatingBinaryOpTest__AddSubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new AlternatingBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingBinaryOpTest__AddSubtractDouble(); var result = Sse3.AddSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.AddSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.AddSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Single.cs index 8021924e0782..e80cd9d482ae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/AddSubtract.Single.cs @@ -64,11 +64,17 @@ private static void AddSubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void AddSubtractSingle() public sealed unsafe class AlternatingBinaryOpTest__AddSubtractSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(AlternatingBinaryOpTest__AddSubtractSingle testClass) + { + var result = Sse3.AddSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static AlternatingBinaryOpTest__AddSubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public AlternatingBinaryOpTest__AddSubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new AlternatingBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new AlternatingBinaryOpTest__AddSubtractSingle(); var result = Sse3.AddSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.AddSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.AddSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Double.cs index 432d3b5c8788..aedd256d85a0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Double.cs @@ -64,11 +64,17 @@ private static void HorizontalAddDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalAddDouble() public sealed unsafe class HorizontalBinaryOpTest__HorizontalAddDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalAddDouble testClass) + { + var result = Sse3.HorizontalAdd(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static HorizontalBinaryOpTest__HorizontalAddDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public HorizontalBinaryOpTest__HorizontalAddDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new HorizontalBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalAddDouble(); var result = Sse3.HorizontalAdd(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.HorizontalAdd(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.HorizontalAdd(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Single.cs index 4ade0e035dc6..4cba0a747c8f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalAdd.Single.cs @@ -64,11 +64,17 @@ private static void HorizontalAddSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalAddSingle() public sealed unsafe class HorizontalBinaryOpTest__HorizontalAddSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalAddSingle testClass) + { + var result = Sse3.HorizontalAdd(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static HorizontalBinaryOpTest__HorizontalAddSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public HorizontalBinaryOpTest__HorizontalAddSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new HorizontalBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalAddSingle(); var result = Sse3.HorizontalAdd(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.HorizontalAdd(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.HorizontalAdd(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Double.cs index 823fa9f4b516..4b606ea785b7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Double.cs @@ -64,11 +64,17 @@ private static void HorizontalSubtractDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalSubtractDouble() public sealed unsafe class HorizontalBinaryOpTest__HorizontalSubtractDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractDouble testClass) + { + var result = Sse3.HorizontalSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static HorizontalBinaryOpTest__HorizontalSubtractDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public HorizontalBinaryOpTest__HorizontalSubtractDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new HorizontalBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalSubtractDouble(); var result = Sse3.HorizontalSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.HorizontalSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.HorizontalSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Single.cs index 2a7a413085a7..8964abc974fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/HorizontalSubtract.Single.cs @@ -64,11 +64,17 @@ private static void HorizontalSubtractSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalSubtractSingle() public sealed unsafe class HorizontalBinaryOpTest__HorizontalSubtractSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractSingle testClass) + { + var result = Sse3.HorizontalSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static HorizontalBinaryOpTest__HorizontalSubtractSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public HorizontalBinaryOpTest__HorizontalSubtractSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new HorizontalBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalSubtractSingle(); var result = Sse3.HorizontalSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse3.HorizontalSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse3.HorizontalSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_r.csproj index 523c4f5084f0..a1229ea0cd30 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_r.csproj @@ -38,6 +38,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_ro.csproj index 9a4933ecfca4..c011a74cc922 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse3/Sse3_ro.csproj @@ -38,6 +38,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Byte.cs index 99ff3ef49ced..33db0c9d9815 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Byte.cs @@ -64,11 +64,17 @@ private static void BlendVariableByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableByte() public sealed unsafe class SimpleTernaryOpTest__BlendVariableByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableByte testClass) + { + var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableByte(); var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Double.cs index 24f57157dc39..4d98a5f613ae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Double.cs @@ -64,11 +64,17 @@ private static void BlendVariableDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableDouble() public sealed unsafe class SimpleTernaryOpTest__BlendVariableDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableDouble testClass) + { + var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -110,9 +146,9 @@ static SimpleTernaryOpTest__BlendVariableDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); @@ -124,15 +160,15 @@ public SimpleTernaryOpTest__BlendVariableDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableDouble(); var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.SByte.cs index fcbbb7dda2e9..7d34f7d56535 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.SByte.cs @@ -64,11 +64,17 @@ private static void BlendVariableSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableSByte() public sealed unsafe class SimpleTernaryOpTest__BlendVariableSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableSByte testClass) + { + var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableSByte(); var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Single.cs index e1b2263d3c86..a3ce0d6750ba 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/BlendVariable.Single.cs @@ -64,11 +64,17 @@ private static void BlendVariableSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,36 @@ private static void BlendVariableSingle() public sealed unsafe class SimpleTernaryOpTest__BlendVariableSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + public Vector128 _fld3; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleTernaryOpTest__BlendVariableSingle testClass) + { + var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -110,9 +146,9 @@ static SimpleTernaryOpTest__BlendVariableSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); @@ -124,15 +160,15 @@ public SimpleTernaryOpTest__BlendVariableSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld3), ref Unsafe.As(ref _data3[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); } _dataTable = new SimpleTernaryOpTest__DataTable(_data1, _data2, _data3, new Single[RetElementCount], LargestVectorSize); } @@ -261,7 +297,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleTernaryOpTest__BlendVariableSingle(); var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); @@ -270,7 +306,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.BlendVariable(_fld1, _fld2, _fld3); @@ -278,6 +314,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.BlendVariable(test._fld1, test._fld2, test._fld3); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Double.cs index 34a80ca358c9..230985571175 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Double.cs @@ -64,11 +64,17 @@ private static void CeilingDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void CeilingDouble() public sealed unsafe class SimpleUnaryOpTest__CeilingDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__CeilingDouble testClass) + { + var result = Sse41.Ceiling(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__CeilingDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__CeilingDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__CeilingDouble(); var result = Sse41.Ceiling(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Ceiling(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Ceiling(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Single.cs index 3638f258a4f9..ba572921d42b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Ceiling.Single.cs @@ -64,11 +64,17 @@ private static void CeilingSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void CeilingSingle() public sealed unsafe class SimpleUnaryOpTest__CeilingSingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__CeilingSingle testClass) + { + var result = Sse41.Ceiling(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__CeilingSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__CeilingSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__CeilingSingle(); var result = Sse41.Ceiling(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Ceiling(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Ceiling(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Double.cs index ab1f72df7c09..1e7e6674e953 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Double.cs @@ -64,11 +64,17 @@ private static void CeilingScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CeilingScalarDouble() public sealed unsafe class SimpleBinaryOpTest__CeilingScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CeilingScalarDouble testClass) + { + var result = Sse41.CeilingScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CeilingScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CeilingScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CeilingScalarDouble(); var result = Sse41.CeilingScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.CeilingScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.CeilingScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Single.cs index 0f26dd152ebc..fe4310a8ddac 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CeilingScalar.Single.cs @@ -64,11 +64,17 @@ private static void CeilingScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CeilingScalarSingle() public sealed unsafe class SimpleBinaryOpTest__CeilingScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CeilingScalarSingle testClass) + { + var result = Sse41.CeilingScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__CeilingScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__CeilingScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CeilingScalarSingle(); var result = Sse41.CeilingScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.CeilingScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.CeilingScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs index ddfb665df73c..2c6572857a76 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs @@ -64,11 +64,17 @@ private static void CompareEqualInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualInt64() public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualInt64 testClass) + { + var result = Sse41.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualInt64(); var result = Sse41.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs index ac372c3901db..e287e8399c75 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs @@ -64,11 +64,17 @@ private static void CompareEqualUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareEqualUInt64() public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareEqualUInt64 testClass) + { + var result = Sse41.CompareEqual(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareEqualUInt64(); var result = Sse41.CompareEqual(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.CompareEqual(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.CompareEqual(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.1.cs index da59ecd7edb0..23eb41c68635 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractByte1() { - var test = new SimpleUnaryOpTest__ExtractByte1(); - - try - { + var test = new ExtractScalarTest__ExtractByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractByte1() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractByte1 + public sealed unsafe class ExtractScalarTest__ExtractByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractByte1 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractByte1() + static ExtractScalarTest__ExtractByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractByte1() + public ExtractScalarTest__ExtractByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractByte1(); + var test = new ExtractScalarTest__ExtractByte1(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.129.cs index 8cc0b1c3c954..ff407b9631a1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Byte.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractByte129() { - var test = new SimpleUnaryOpTest__ExtractByte129(); - - try - { + var test = new ExtractScalarTest__ExtractByte129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractByte129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractByte129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractByte129 + public sealed unsafe class ExtractScalarTest__ExtractByte129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractByte129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractByte129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractByte129() + static ExtractScalarTest__ExtractByte129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractByte129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractByte129() + public ExtractScalarTest__ExtractByte129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractByte129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractByte129(); + var test = new ExtractScalarTest__ExtractByte129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.1.cs index 3e78afdbc04d..63d8d00cf9f8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt321() { - var test = new SimpleUnaryOpTest__ExtractInt321(); - - try - { + var test = new ExtractScalarTest__ExtractInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt321 + public sealed unsafe class ExtractScalarTest__ExtractInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt321 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt321() + static ExtractScalarTest__ExtractInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt321() + public ExtractScalarTest__ExtractInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt321(); + var test = new ExtractScalarTest__ExtractInt321(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.129.cs index d8c9565bdf31..6de15f7dd33a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int32.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt32129() { - var test = new SimpleUnaryOpTest__ExtractInt32129(); - - try - { + var test = new ExtractScalarTest__ExtractInt32129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt32129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt32129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt32129 + public sealed unsafe class ExtractScalarTest__ExtractInt32129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt32129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt32129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt32129() + static ExtractScalarTest__ExtractInt32129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt32129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt32129() + public ExtractScalarTest__ExtractInt32129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt32129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt32129(); + var test = new ExtractScalarTest__ExtractInt32129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.1.cs index 1e6f97bcf18b..3238555cded9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt641() { - var test = new SimpleUnaryOpTest__ExtractInt641(); - - try - { + var test = new ExtractScalarTest__ExtractInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt641 + public sealed unsafe class ExtractScalarTest__ExtractInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt641 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt641() + static ExtractScalarTest__ExtractInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt641() + public ExtractScalarTest__ExtractInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt641(); + var test = new ExtractScalarTest__ExtractInt641(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.129.cs index 948c09a72c64..e0cb83091402 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Int64.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractInt64129() { - var test = new SimpleUnaryOpTest__ExtractInt64129(); - - try - { + var test = new ExtractScalarTest__ExtractInt64129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractInt64129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractInt64129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractInt64129 + public sealed unsafe class ExtractScalarTest__ExtractInt64129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractInt64129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractInt64129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractInt64129() + static ExtractScalarTest__ExtractInt64129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractInt64129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractInt64129() + public ExtractScalarTest__ExtractInt64129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractInt64129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractInt64129(); + var test = new ExtractScalarTest__ExtractInt64129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs deleted file mode 100644 index 82650303230e..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.1.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractSByte1() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte1 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte1() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte1() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Extract( - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Extract( - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)1 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Extract( - _clsVar, - 1 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte1(); - var result = Sse41.Extract(test._fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Extract(_fld, 1); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Extract)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.129.cs deleted file mode 100644 index f4c2258f66ec..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.SByte.129.cs +++ /dev/null @@ -1,309 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void ExtractSByte129() - { - var test = new SimpleUnaryOpTest__ExtractSByte129(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Sse2.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__ExtractSByte129 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(SByte); - - private static SByte[] _data = new SByte[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__ExtractSByte129() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__ExtractSByte129() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Extract( - Unsafe.Read>(_dataTable.inArrayPtr), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Extract( - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Extract( - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Extract), new Type[] { typeof(Vector128), typeof(byte) }) - .Invoke(null, new object[] { - Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)), - (byte)129 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (SByte)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Extract( - _clsVar, - 129 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse2.LoadVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArrayPtr)); - var result = Sse41.Extract(firstOp, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__ExtractSByte129(); - var result = Sse41.Extract(test._fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Extract(_fld, 129); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - SByte[] inArray = new SByte[Op1ElementCount]; - SByte[] outArray = new SByte[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(SByte[] firstOp, SByte[] result, [CallerMemberName] string method = "") - { - if ((result[0] != firstOp[1])) - { - Succeeded = false; - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Extract)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.1.cs index d82cd423b6bc..b8ac2e2bcbb1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractSingle1() { - var test = new SimpleUnaryOpTest__ExtractSingle1(); - - try - { + var test = new ExtractScalarTest__ExtractSingle1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractSingle1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractSingle1() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractSingle1 + public sealed unsafe class ExtractScalarTest__ExtractSingle1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractSingle1 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,28 +128,28 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractSingle1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractSingle1() + static ExtractScalarTest__ExtractSingle1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractSingle1() + public ExtractScalarTest__ExtractSingle1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Single) != typeof(long)) && (typeof(Single) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractSingle1(); + var test = new ExtractScalarTest__ExtractSingle1(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.129.cs index f9d6e7bef77e..be1331ee3ee0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.Single.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractSingle129() { - var test = new SimpleUnaryOpTest__ExtractSingle129(); - - try - { + var test = new ExtractScalarTest__ExtractSingle129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractSingle129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractSingle129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractSingle129 + public sealed unsafe class ExtractScalarTest__ExtractSingle129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractSingle129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -105,28 +128,28 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractSingle129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractSingle129() + static ExtractScalarTest__ExtractSingle129() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractSingle129() + public ExtractScalarTest__ExtractSingle129() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Single) != typeof(long)) && (typeof(Single) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractSingle129(); + var test = new ExtractScalarTest__ExtractSingle129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.1.cs index 0e9cf6807be7..66392f446339 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt321() { - var test = new SimpleUnaryOpTest__ExtractUInt321(); - - try - { + var test = new ExtractScalarTest__ExtractUInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt321 + public sealed unsafe class ExtractScalarTest__ExtractUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt321 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt321() + static ExtractScalarTest__ExtractUInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt321() + public ExtractScalarTest__ExtractUInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt321(); + var test = new ExtractScalarTest__ExtractUInt321(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.129.cs index 95182b0ca3f8..04055a8a7680 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt32.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt32129() { - var test = new SimpleUnaryOpTest__ExtractUInt32129(); - - try - { + var test = new ExtractScalarTest__ExtractUInt32129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt32129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt32129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt32129 + public sealed unsafe class ExtractScalarTest__ExtractUInt32129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt32129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt32129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt32129() + static ExtractScalarTest__ExtractUInt32129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt32129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt32129() + public ExtractScalarTest__ExtractUInt32129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt32129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt32129(); + var test = new ExtractScalarTest__ExtractUInt32129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.1.cs index c67da3dece52..03f7f846958b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt641() { - var test = new SimpleUnaryOpTest__ExtractUInt641(); - - try - { + var test = new ExtractScalarTest__ExtractUInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt641 + public sealed unsafe class ExtractScalarTest__ExtractUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt641 testClass) + { + var result = Sse41.Extract(_fld, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt641() + static ExtractScalarTest__ExtractUInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt641() + public ExtractScalarTest__ExtractUInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt641(); + var test = new ExtractScalarTest__ExtractUInt641(); var result = Sse41.Extract(test._fld, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 1); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.129.cs index 0a8598ab78cb..e9b8421d1f65 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Extract.UInt64.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void ExtractUInt64129() { - var test = new SimpleUnaryOpTest__ExtractUInt64129(); - - try - { + var test = new ExtractScalarTest__ExtractUInt64129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void ExtractUInt64129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void ExtractUInt64129() } } - public sealed unsafe class SimpleUnaryOpTest__ExtractUInt64129 + public sealed unsafe class ExtractScalarTest__ExtractUInt64129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(ExtractScalarTest__ExtractUInt64129 testClass) + { + var result = Sse41.Extract(_fld, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__ExtractUInt64129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__ExtractUInt64129() + static ExtractScalarTest__ExtractUInt64129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__ExtractUInt64129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__ExtractUInt64129() + public ExtractScalarTest__ExtractUInt64129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__ExtractUInt64129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -237,16 +260,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__ExtractUInt64129(); + var test = new ExtractScalarTest__ExtractUInt64129(); var result = Sse41.Extract(test._fld, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Extract(_fld, 129); @@ -254,6 +277,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Extract(test._fld, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Double.cs index 9be27a2cd20d..a77a8658d0ca 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Double.cs @@ -64,11 +64,17 @@ private static void FloorDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void FloorDouble() public sealed unsafe class SimpleUnaryOpTest__FloorDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__FloorDouble testClass) + { + var result = Sse41.Floor(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__FloorDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__FloorDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__FloorDouble(); var result = Sse41.Floor(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Floor(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Floor(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Single.cs index 125584edf607..f0d542b01f08 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Floor.Single.cs @@ -64,11 +64,17 @@ private static void FloorSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void FloorSingle() public sealed unsafe class SimpleUnaryOpTest__FloorSingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__FloorSingle testClass) + { + var result = Sse41.Floor(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__FloorSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__FloorSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__FloorSingle(); var result = Sse41.Floor(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Floor(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Floor(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Double.cs index 1a2b520655f7..387ac53c6c9e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Double.cs @@ -64,11 +64,17 @@ private static void FloorScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void FloorScalarDouble() public sealed unsafe class SimpleBinaryOpTest__FloorScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__FloorScalarDouble testClass) + { + var result = Sse41.FloorScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__FloorScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__FloorScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__FloorScalarDouble(); var result = Sse41.FloorScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.FloorScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.FloorScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Single.cs index d646f4b32034..ea52b0f0a31b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/FloorScalar.Single.cs @@ -64,11 +64,17 @@ private static void FloorScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void FloorScalarSingle() public sealed unsafe class SimpleBinaryOpTest__FloorScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__FloorScalarSingle testClass) + { + var result = Sse41.FloorScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__FloorScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__FloorScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__FloorScalarSingle(); var result = Sse41.FloorScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.FloorScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.FloorScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.1.cs index de94118fcb9e..6bae0f6f89b7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertByte1() { - var test = new SimpleUnaryOpTest__InsertByte1(); - - try - { + var test = new InsertScalarTest__InsertByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertByte1() } } - public sealed unsafe class SimpleUnaryOpTest__InsertByte1 + public sealed unsafe class InsertScalarTest__InsertByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertByte1 testClass) + { + var result = Sse41.Insert(_fld, (byte)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertByte1() + static InsertScalarTest__InsertByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertByte1() + public InsertScalarTest__InsertByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertByte1(); + var test = new InsertScalarTest__InsertByte1(); var result = Sse41.Insert(test._fld, (byte)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (byte)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (byte)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.129.cs index 6c4f2d59089b..07628a641ce4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Byte.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertByte129() { - var test = new SimpleUnaryOpTest__InsertByte129(); - - try - { + var test = new InsertScalarTest__InsertByte129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertByte129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertByte129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertByte129 + public sealed unsafe class InsertScalarTest__InsertByte129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertByte129 testClass) + { + var result = Sse41.Insert(_fld, (byte)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertByte129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertByte129() + static InsertScalarTest__InsertByte129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertByte129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertByte129() + public InsertScalarTest__InsertByte129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertByte129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Byte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Byte) != typeof(long)) && (typeof(Byte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertByte129(); + var test = new InsertScalarTest__InsertByte129(); var result = Sse41.Insert(test._fld, (byte)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (byte)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (byte)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.1.cs index a89626622c8c..1519841e6c4c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt321() { - var test = new SimpleUnaryOpTest__InsertInt321(); - - try - { + var test = new InsertScalarTest__InsertInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt321() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt321 + public sealed unsafe class InsertScalarTest__InsertInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt321 testClass) + { + var result = Sse41.Insert(_fld, (int)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt321() + static InsertScalarTest__InsertInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt321() + public InsertScalarTest__InsertInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt321(); + var test = new InsertScalarTest__InsertInt321(); var result = Sse41.Insert(test._fld, (int)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (int)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (int)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.129.cs index c257663651c0..b5380b2f5ff4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int32.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt32129() { - var test = new SimpleUnaryOpTest__InsertInt32129(); - - try - { + var test = new InsertScalarTest__InsertInt32129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt32129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt32129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt32129 + public sealed unsafe class InsertScalarTest__InsertInt32129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt32129 testClass) + { + var result = Sse41.Insert(_fld, (int)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt32129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt32129() + static InsertScalarTest__InsertInt32129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt32129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt32129() + public InsertScalarTest__InsertInt32129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt32129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int32) != typeof(long)) && (typeof(Int32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt32129(); + var test = new InsertScalarTest__InsertInt32129(); var result = Sse41.Insert(test._fld, (int)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (int)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (int)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.1.cs index c673ce63220c..23cea92147dc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt641() { - var test = new SimpleUnaryOpTest__InsertInt641(); - - try - { + var test = new InsertScalarTest__InsertInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt641() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt641 + public sealed unsafe class InsertScalarTest__InsertInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt641 testClass) + { + var result = Sse41.Insert(_fld, (long)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt641() + static InsertScalarTest__InsertInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt641() + public InsertScalarTest__InsertInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt641(); + var test = new InsertScalarTest__InsertInt641(); var result = Sse41.Insert(test._fld, (long)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (long)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (long)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.129.cs index 6cd83adc408b..2358923e0fd7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Int64.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertInt64129() { - var test = new SimpleUnaryOpTest__InsertInt64129(); - - try - { + var test = new InsertScalarTest__InsertInt64129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertInt64129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertInt64129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertInt64129 + public sealed unsafe class InsertScalarTest__InsertInt64129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertInt64129 testClass) + { + var result = Sse41.Insert(_fld, (long)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertInt64129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertInt64129() + static InsertScalarTest__InsertInt64129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertInt64129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertInt64129() + public InsertScalarTest__InsertInt64129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertInt64129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Int64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(Int64) != typeof(long)) && (typeof(Int64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertInt64129(); + var test = new InsertScalarTest__InsertInt64129(); var result = Sse41.Insert(test._fld, (long)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (long)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (long)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.1.cs index f0a4dcf47c67..a30b1b148423 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertSByte1() { - var test = new SimpleUnaryOpTest__InsertSByte1(); - - try - { + var test = new InsertScalarTest__InsertSByte1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertSByte1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertSByte1() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSByte1 + public sealed unsafe class InsertScalarTest__InsertSByte1 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertSByte1 testClass) + { + var result = Sse41.Insert(_fld, (sbyte)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertSByte1 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSByte1() + static InsertScalarTest__InsertSByte1() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertSByte1() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSByte1() + public InsertScalarTest__InsertSByte1() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertSByte1() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertSByte1(); + var test = new InsertScalarTest__InsertSByte1(); var result = Sse41.Insert(test._fld, (sbyte)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (sbyte)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (sbyte)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.129.cs index 7bad860ba41b..77bb6ef2cfb0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.SByte.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertSByte129() { - var test = new SimpleUnaryOpTest__InsertSByte129(); - - try - { + var test = new InsertScalarTest__InsertSByte129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertSByte129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertSByte129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSByte129 + public sealed unsafe class InsertScalarTest__InsertSByte129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(0, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertSByte129 testClass) + { + var result = Sse41.Insert(_fld, (sbyte)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertSByte129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSByte129() + static InsertScalarTest__InsertSByte129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertSByte129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSByte129() + public InsertScalarTest__InsertSByte129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertSByte129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new SByte[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(SByte) != typeof(long)) && (typeof(SByte) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertSByte129(); + var test = new InsertScalarTest__InsertSByte129(); var result = Sse41.Insert(test._fld, (sbyte)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (sbyte)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (sbyte)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.0.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.0.cs index 5ee20531daf8..053b9c6698fe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.0.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.0.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle0() { - var test = new SimpleUnaryOpTest__InsertSingle0(); - - try - { + var test = new InsertVector128Test__InsertSingle0(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle0() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle0() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle0 + public sealed unsafe class InsertVector128Test__InsertSingle0 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle0 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 0); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle0() + static InsertVector128Test__InsertSingle0() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle0() + public InsertVector128Test__InsertSingle0() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle0() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 0 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 0 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 0 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)0 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)0 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)0 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 0 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 0); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 0); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 0); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 0); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 0); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 0); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle0(); + var result = Sse41.Insert(test._fld1, test._fld2, 0); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle0(); - var result = Sse41.Insert(test._fld, (float)2, 0); + var result = Sse41.Insert(_fld1, _fld2, 0); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 0); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 0); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.0): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.1.cs index 537fe667027c..96ad13e3cf34 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.1.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle1() { - var test = new SimpleUnaryOpTest__InsertSingle1(); - - try - { + var test = new InsertVector128Test__InsertSingle1(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle1() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle1() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle1 + public sealed unsafe class InsertVector128Test__InsertSingle1 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle1 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle1() + static InsertVector128Test__InsertSingle1() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle1() + public InsertVector128Test__InsertSingle1() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle1() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)1 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 1 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 1); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 1); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 1); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 1); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 1); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle1(); + var result = Sse41.Insert(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle1(); - var result = Sse41.Insert(test._fld, (float)2, 1); + var result = Sse41.Insert(_fld1, _fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 1); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(0.0f)) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.1): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.cs index 0ca49317765a..0354b187f5a6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.128.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle128() { - var test = new SimpleUnaryOpTest__InsertSingle128(); - - try - { + var test = new InsertVector128Test__InsertSingle128(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle128() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle128() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle128 + public sealed unsafe class InsertVector128Test__InsertSingle128 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle128 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 128); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle128() + static InsertVector128Test__InsertSingle128() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle128() + public InsertVector128Test__InsertSingle128() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle128() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 128 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 128 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 128 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)128 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)128 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)128 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 128 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 128); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 128); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 128); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 128); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 128); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 128); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle128(); + var result = Sse41.Insert(test._fld1, test._fld2, 128); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle128(); - var result = Sse41.Insert(test._fld, (float)2, 128); + var result = Sse41.Insert(_fld1, _fld2, 128); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 128); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 128); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[2])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.cs index 8b30e9f31936..725be57d7587 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.129.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle129() { - var test = new SimpleUnaryOpTest__InsertSingle129(); - - try - { + var test = new InsertVector128Test__InsertSingle129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle129 + public sealed unsafe class InsertVector128Test__InsertSingle129 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle129 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle129() + static InsertVector128Test__InsertSingle129() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle129() + public InsertVector128Test__InsertSingle129() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle129() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 129 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 129 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 129 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)129 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)129 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)129 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 129 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 129); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 129); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 129); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 129); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 129); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle129(); + var result = Sse41.Insert(test._fld1, test._fld2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle129(); - var result = Sse41.Insert(test._fld, (float)2, 129); + var result = Sse41.Insert(_fld1, _fld2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 129); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(0.0f)) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.129): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.cs index a491c1029193..c4a8a1ce03db 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.16.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle16() { - var test = new SimpleUnaryOpTest__InsertSingle16(); - - try - { + var test = new InsertVector128Test__InsertSingle16(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle16() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle16 + public sealed unsafe class InsertVector128Test__InsertSingle16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle16 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 16); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle16() + static InsertVector128Test__InsertSingle16() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle16() + public InsertVector128Test__InsertSingle16() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle16() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 16 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 16 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 16 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)16 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)16 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)16 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 16 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 16); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 16); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 16); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 16); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 16); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 16); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle16(); + var result = Sse41.Insert(test._fld1, test._fld2, 16); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle16(); - var result = Sse41.Insert(test._fld, (float)2, 16); + var result = Sse41.Insert(_fld1, _fld2, 16); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 16); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 16); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])) + { + Succeeded = false; + } + else { - if ((i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.16): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.cs index f8908e3588f8..a2a2c3dbbcbb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.192.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle192() { - var test = new SimpleUnaryOpTest__InsertSingle192(); - - try - { + var test = new InsertVector128Test__InsertSingle192(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle192() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle192() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle192 + public sealed unsafe class InsertVector128Test__InsertSingle192 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle192 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 192); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle192() + static InsertVector128Test__InsertSingle192() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle192() + public InsertVector128Test__InsertSingle192() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle192() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 192 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 192 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 192 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)192 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)192 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)192 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 192 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 192); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 192); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 192); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 192); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 192); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 192); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle192(); + var result = Sse41.Insert(test._fld1, test._fld2, 192); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle192(); - var result = Sse41.Insert(test._fld, (float)2, 192); + var result = Sse41.Insert(_fld1, _fld2, 192); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 192); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 192); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[3])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.192): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.cs index 44ead60aec3d..4c2fa66ed5d1 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.2.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle2() { - var test = new SimpleUnaryOpTest__InsertSingle2(); - - try - { + var test = new InsertVector128Test__InsertSingle2(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle2() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle2() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle2 + public sealed unsafe class InsertVector128Test__InsertSingle2 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle2 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle2() + static InsertVector128Test__InsertSingle2() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle2() + public InsertVector128Test__InsertSingle2() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle2() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 2 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 2 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 2 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)2 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)2 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)2 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 2 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 2); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 2); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 2); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 2); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 2); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle2(); + var result = Sse41.Insert(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle2(); - var result = Sse41.Insert(test._fld, (float)2, 2); + var result = Sse41.Insert(_fld1, _fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 2); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 2); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 1 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.2): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.217.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.217.cs deleted file mode 100644 index 64872177fdff..000000000000 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.217.cs +++ /dev/null @@ -1,321 +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. - -/****************************************************************************** - * This file is auto-generated from a template file by the GenerateTests.csx * - * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * - * changes, please update the corresponding template and run according to the * - * directions listed in the file. * - ******************************************************************************/ - -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Runtime.Intrinsics; -using System.Runtime.Intrinsics.X86; - -namespace JIT.HardwareIntrinsics.X86 -{ - public static partial class Program - { - private static void InsertSingle217() - { - var test = new SimpleUnaryOpTest__InsertSingle217(); - - try - { - if (test.IsSupported) - { - // Validates basic functionality works, using Unsafe.Read - test.RunBasicScenario_UnsafeRead(); - - if (Sse.IsSupported) - { - // Validates basic functionality works, using Load - test.RunBasicScenario_Load(); - - // Validates basic functionality works, using LoadAligned - test.RunBasicScenario_LoadAligned(); - } - - // Validates calling via reflection works, using Unsafe.Read - test.RunReflectionScenario_UnsafeRead(); - - if (Sse.IsSupported) - { - // Validates calling via reflection works, using Load - test.RunReflectionScenario_Load(); - - // Validates calling via reflection works, using LoadAligned - test.RunReflectionScenario_LoadAligned(); - } - - // Validates passing a static member works - test.RunClsVarScenario(); - - // Validates passing a local works, using Unsafe.Read - test.RunLclVarScenario_UnsafeRead(); - - if (Sse.IsSupported) - { - // Validates passing a local works, using Load - test.RunLclVarScenario_Load(); - - // Validates passing a local works, using LoadAligned - test.RunLclVarScenario_LoadAligned(); - } - - // Validates passing the field of a local works - test.RunLclFldScenario(); - - // Validates passing an instance member works - test.RunFldScenario(); - } - else - { - // Validates we throw on unsupported hardware - test.RunUnsupportedScenario(); - } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } - - if (!test.Succeeded) - { - throw new Exception("One or more scenarios did not complete as expected."); - } - } - } - - public sealed unsafe class SimpleUnaryOpTest__InsertSingle217 - { - private static readonly int LargestVectorSize = 16; - - private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - - private static Single[] _data = new Single[Op1ElementCount]; - - private static Vector128 _clsVar; - - private Vector128 _fld; - - private SimpleUnaryOpTest__DataTable _dataTable; - - static SimpleUnaryOpTest__InsertSingle217() - { - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - } - - public SimpleUnaryOpTest__InsertSingle217() - { - Succeeded = true; - - var random = new Random(); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); - } - - public bool IsSupported => Sse41.IsSupported; - - public bool Succeeded { get; set; } - - public void RunBasicScenario_UnsafeRead() - { - var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_Load() - { - var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunBasicScenario_LoadAligned() - { - var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_UnsafeRead() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_Load() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunReflectionScenario_LoadAligned() - { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) - .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, - (byte)217 - }); - - Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); - } - - public void RunClsVarScenario() - { - var result = Sse41.Insert( - _clsVar, - (float)2, - 217 - ); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_UnsafeRead() - { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_Load() - { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclVarScenario_LoadAligned() - { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); - } - - public void RunLclFldScenario() - { - var test = new SimpleUnaryOpTest__InsertSingle217(); - var result = Sse41.Insert(test._fld, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); - } - - public void RunFldScenario() - { - var result = Sse41.Insert(_fld, (float)2, 217); - - Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); - } - - public void RunUnsupportedScenario() - { - Succeeded = false; - - try - { - RunBasicScenario_UnsafeRead(); - } - catch (PlatformNotSupportedException) - { - Succeeded = true; - } - } - - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") - { - Single[] inArray = new Single[Op1ElementCount]; - Single[] outArray = new Single[RetElementCount]; - - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - - ValidateResult(inArray, outArray, method); - } - - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") - { - - for (var i = 0; i < RetElementCount; i++) - { - if ((i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((float)0))) - { - Succeeded = false; - break; - } - } - - if (!Succeeded) - { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); - Console.WriteLine(); - } - } - } -} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.cs index 6d647afde19c..4480f58cfa0d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.32.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle32() { - var test = new SimpleUnaryOpTest__InsertSingle32(); - - try - { + var test = new InsertVector128Test__InsertSingle32(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle32() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle32 + public sealed unsafe class InsertVector128Test__InsertSingle32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle32 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 32); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle32() + static InsertVector128Test__InsertSingle32() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle32() + public InsertVector128Test__InsertSingle32() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle32() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 32 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 32 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 32 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)32 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)32 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)32 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 32 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 32); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 32); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 32); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 32); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 32); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 32); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle32(); + var result = Sse41.Insert(test._fld1, test._fld2, 32); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle32(); - var result = Sse41.Insert(test._fld, (float)2, 32); + var result = Sse41.Insert(_fld1, _fld2, 32); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 32); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 32); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])) + { + Succeeded = false; + } + else { - if ((i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.32): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.cs index c47c9d28e934..adb8ddd9bd5d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.4.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle4() { - var test = new SimpleUnaryOpTest__InsertSingle4(); - - try - { + var test = new InsertVector128Test__InsertSingle4(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle4() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle4() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle4 + public sealed unsafe class InsertVector128Test__InsertSingle4 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle4 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 4); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle4() + static InsertVector128Test__InsertSingle4() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle4() + public InsertVector128Test__InsertSingle4() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle4() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 4 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 4 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 4 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)4 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)4 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)4 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 4 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 4); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 4); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 4); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 4); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 4); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 4); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle4(); + var result = Sse41.Insert(test._fld1, test._fld2, 4); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle4(); - var result = Sse41.Insert(test._fld, (float)2, 4); + var result = Sse41.Insert(_fld1, _fld2, 4); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 4); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 4); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 2 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.4): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.cs index 4a8eef9c61e6..1db2d3b57295 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.48.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle48() { - var test = new SimpleUnaryOpTest__InsertSingle48(); - - try - { + var test = new InsertVector128Test__InsertSingle48(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle48() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle48() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle48 + public sealed unsafe class InsertVector128Test__InsertSingle48 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle48 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 48); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle48() + static InsertVector128Test__InsertSingle48() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle48() + public InsertVector128Test__InsertSingle48() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle48() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 48 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 48 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 48 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)48 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)48 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)48 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 48 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 48); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 48); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 48); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 48); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 48); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 48); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle48(); + var result = Sse41.Insert(test._fld1, test._fld2, 48); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle48(); - var result = Sse41.Insert(test._fld, (float)2, 48); + var result = Sse41.Insert(_fld1, _fld2, 48); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 48); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 48); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(left[0])) + { + Succeeded = false; + } + else { - if ((i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(right[0]) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.48): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.cs index feddaad2e68f..90de0aa85f3d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.64.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle64() { - var test = new SimpleUnaryOpTest__InsertSingle64(); - - try - { + var test = new InsertVector128Test__InsertSingle64(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle64() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle64 + public sealed unsafe class InsertVector128Test__InsertSingle64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle64 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 64); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle64() + static InsertVector128Test__InsertSingle64() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle64() + public InsertVector128Test__InsertSingle64() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle64() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 64 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 64 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 64 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)64 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)64 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)64 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 64 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 64); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 64); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 64); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 64); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 64); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 64); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle64(); + var result = Sse41.Insert(test._fld1, test._fld2, 64); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle64(); - var result = Sse41.Insert(test._fld, (float)2, 64); + var result = Sse41.Insert(_fld1, _fld2, 64); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 64); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 64); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[1])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.64): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.cs index b81444ccb044..11bea544a411 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.Single.8.cs @@ -14,6 +14,8 @@ using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; +using static System.Runtime.Intrinsics.X86.Sse; +using static System.Runtime.Intrinsics.X86.Sse2; namespace JIT.HardwareIntrinsics.X86 { @@ -21,10 +23,8 @@ public static partial class Program { private static void InsertSingle8() { - var test = new SimpleUnaryOpTest__InsertSingle8(); - - try - { + var test = new InsertVector128Test__InsertSingle8(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +66,23 @@ private static void InsertSingle8() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,40 +91,76 @@ private static void InsertSingle8() } } - public sealed unsafe class SimpleUnaryOpTest__InsertSingle8 + public sealed unsafe class InsertVector128Test__InsertSingle8 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertVector128Test__InsertSingle8 testClass) + { + var result = Sse41.Insert(_fld1, _fld2, 8); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Single); private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Single); - private static Single[] _data = new Single[Op1ElementCount]; + private static Single[] _data1 = new Single[Op1ElementCount]; + private static Single[] _data2 = new Single[Op2ElementCount]; - private static Vector128 _clsVar; + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; - private Vector128 _fld; + private Vector128 _fld1; + private Vector128 _fld2; - private SimpleUnaryOpTest__DataTable _dataTable; + private SimpleBinaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertSingle8() + static InsertVector128Test__InsertSingle8() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertSingle8() + public InsertVector128Test__InsertSingle8() { Succeeded = true; var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } - _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } public bool IsSupported => Sse41.IsSupported; @@ -133,132 +170,150 @@ public SimpleUnaryOpTest__InsertSingle8() public void RunBasicScenario_UnsafeRead() { var result = Sse41.Insert( - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), 8 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { var result = Sse41.Insert( - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), 8 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { var result = Sse41.Insert( - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), 8 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Unsafe.Read>(_dataTable.inArrayPtr), - (float)2, + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr), (byte)8 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)), + LoadVector128((Single*)(_dataTable.inArray2Ptr)), (byte)8 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { - var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Single), typeof(byte) }) + var result = typeof(Sse41).GetMethod(nameof(Sse41.Insert), new Type[] { typeof(Vector128), typeof(Vector128), typeof(byte) }) .Invoke(null, new object[] { - Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)), - (float)2, + Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)), + LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)), (byte)8 }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); - ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { var result = Sse41.Insert( - _clsVar, - (float)2, + _clsVar1, + _clsVar2, 8 ); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_clsVar, _dataTable.outArrayPtr); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { - var firstOp = Unsafe.Read>(_dataTable.inArrayPtr); - var result = Sse41.Insert(firstOp, (float)2, 8); + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Sse41.Insert(left, right, 8); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { - var firstOp = Sse.LoadVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 8); + var left = Sse.LoadVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 8); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(left, right, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { - var firstOp = Sse.LoadAlignedVector128((Single*)(_dataTable.inArrayPtr)); - var result = Sse41.Insert(firstOp, (float)2, 8); + var left = Sse.LoadAlignedVector128((Single*)(_dataTable.inArray1Ptr)); + var right = LoadAlignedVector128((Single*)(_dataTable.inArray2Ptr)); + var result = Sse41.Insert(left, right, 8); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new InsertVector128Test__InsertSingle8(); + var result = Sse41.Insert(test._fld1, test._fld2, 8); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(firstOp, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassFldScenario() { - var test = new SimpleUnaryOpTest__InsertSingle8(); - var result = Sse41.Insert(test._fld, (float)2, 8); + var result = Sse41.Insert(_fld1, _fld2, 8); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(test._fld, _dataTable.outArrayPtr); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunStructLclFldScenario() { - var result = Sse41.Insert(_fld, (float)2, 8); + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld1, test._fld2, 8); Unsafe.Write(_dataTable.outArrayPtr, result); - ValidateResult(_fld, _dataTable.outArrayPtr); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); } public void RunUnsupportedScenario() @@ -275,45 +330,56 @@ public void RunUnsupportedScenario() } } - private void ValidateResult(Vector128 firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray[0]), firstOp); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "") + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") { - Single[] inArray = new Single[Op1ElementCount]; + Single[] inArray1 = new Single[Op1ElementCount]; + Single[] inArray2 = new Single[Op2ElementCount]; Single[] outArray = new Single[RetElementCount]; - Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray[0]), ref Unsafe.AsRef(firstOp), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); - ValidateResult(inArray, outArray, method); + ValidateResult(inArray1, inArray2, outArray, method); } - private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "") + private void ValidateResult(Single[] left, Single[] right, Single[] result, [CallerMemberName] string method = "") { - - for (var i = 0; i < RetElementCount; i++) + if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(right[0])) + { + Succeeded = false; + } + else { - if ((i == 0 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(2.0f) : i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(firstOp[i]))) + for (var i = 1; i < RetElementCount; i++) { - Succeeded = false; - break; + if (i == 3 ? BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(0.0f) : BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(left[i])) + { + Succeeded = false; + break; + } } } if (!Succeeded) { - Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128<9>): {method} failed:"); - Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})"); - Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.Insert)}(Vector128, Vector128.8): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); Console.WriteLine(); } } diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.1.cs index ab82f5f1bf08..8c598a717e1c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt321() { - var test = new SimpleUnaryOpTest__InsertUInt321(); - - try - { + var test = new InsertScalarTest__InsertUInt321(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt321() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt321() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt321 + public sealed unsafe class InsertScalarTest__InsertUInt321 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt321 testClass) + { + var result = Sse41.Insert(_fld, (uint)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt321 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt321() + static InsertScalarTest__InsertUInt321() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt321() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt321() + public InsertScalarTest__InsertUInt321() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt321() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt321(); + var test = new InsertScalarTest__InsertUInt321(); var result = Sse41.Insert(test._fld, (uint)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (uint)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (uint)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.129.cs index 27177f67f28e..da2b85bb499a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt32.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt32129() { - var test = new SimpleUnaryOpTest__InsertUInt32129(); - - try - { + var test = new InsertScalarTest__InsertUInt32129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt32129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt32129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt32129 + public sealed unsafe class InsertScalarTest__InsertUInt32129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt32129 testClass) + { + var result = Sse41.Insert(_fld, (uint)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt32129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt32129() + static InsertScalarTest__InsertUInt32129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt32129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt32129() + public InsertScalarTest__InsertUInt32129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt32129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt32[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt32) != typeof(long)) && (typeof(UInt32) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt32129(); + var test = new InsertScalarTest__InsertUInt32129(); var result = Sse41.Insert(test._fld, (uint)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (uint)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (uint)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.1.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.1.cs index d4d9f9981923..ae2c24384617 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.1.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.1.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt641() { - var test = new SimpleUnaryOpTest__InsertUInt641(); - - try - { + var test = new InsertScalarTest__InsertUInt641(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt641() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt641() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt641 + public sealed unsafe class InsertScalarTest__InsertUInt641 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt641 testClass) + { + var result = Sse41.Insert(_fld, (ulong)2, 1); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt641 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt641() + static InsertScalarTest__InsertUInt641() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt641() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt641() + public InsertScalarTest__InsertUInt641() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt641() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt641(); + var test = new InsertScalarTest__InsertUInt641(); var result = Sse41.Insert(test._fld, (ulong)2, 1); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (ulong)2, 1); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (ulong)2, 1); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.129.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.129.cs index 62ce511405c8..41adb2ed189a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.129.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Insert.UInt64.129.cs @@ -21,10 +21,8 @@ public static partial class Program { private static void InsertUInt64129() { - var test = new SimpleUnaryOpTest__InsertUInt64129(); - - try - { + var test = new InsertScalarTest__InsertUInt64129(); + if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read @@ -66,22 +64,23 @@ private static void InsertUInt64129() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } - } - catch (PlatformNotSupportedException) - { - test.Succeeded = true; - } if (!test.Succeeded) { @@ -90,8 +89,32 @@ private static void InsertUInt64129() } } - public sealed unsafe class SimpleUnaryOpTest__InsertUInt64129 + public sealed unsafe class InsertScalarTest__InsertUInt64129 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(InsertScalarTest__InsertUInt64129 testClass) + { + var result = Sse41.Insert(_fld, (ulong)2, 129); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -105,7 +128,7 @@ public sealed unsafe class SimpleUnaryOpTest__InsertUInt64129 private SimpleUnaryOpTest__DataTable _dataTable; - static SimpleUnaryOpTest__InsertUInt64129() + static InsertScalarTest__InsertUInt64129() { var random = new Random(); @@ -113,7 +136,7 @@ static SimpleUnaryOpTest__InsertUInt64129() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public SimpleUnaryOpTest__InsertUInt64129() + public InsertScalarTest__InsertUInt64129() { Succeeded = true; @@ -126,7 +149,7 @@ public SimpleUnaryOpTest__InsertUInt64129() _dataTable = new SimpleUnaryOpTest__DataTable(_data, new UInt64[RetElementCount], LargestVectorSize); } - public bool IsSupported => Sse41.IsSupported; + public bool IsSupported => Sse41.IsSupported && (Environment.Is64BitProcess || ((typeof(UInt64) != typeof(long)) && (typeof(UInt64) != typeof(ulong)))); public bool Succeeded { get; set; } @@ -244,16 +267,16 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new SimpleUnaryOpTest__InsertUInt64129(); + var test = new InsertScalarTest__InsertUInt64129(); var result = Sse41.Insert(test._fld, (ulong)2, 129); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Insert(_fld, (ulong)2, 129); @@ -261,6 +284,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Insert(test._fld, (ulong)2, 129); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.Int32.cs index d7ff58d93105..f4066c205c29 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.Int32.cs @@ -64,11 +64,17 @@ private static void MaxInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxInt32() public sealed unsafe class SimpleBinaryOpTest__MaxInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxInt32 testClass) + { + var result = Sse41.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxInt32(); var result = Sse41.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.SByte.cs index 17baef2bd193..6a35591ba87d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.SByte.cs @@ -64,11 +64,17 @@ private static void MaxSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxSByte() public sealed unsafe class SimpleBinaryOpTest__MaxSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxSByte testClass) + { + var result = Sse41.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxSByte(); var result = Sse41.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt16.cs index 8c31b7525241..92feeb8a8a9f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt16.cs @@ -64,11 +64,17 @@ private static void MaxUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxUInt16() public sealed unsafe class SimpleBinaryOpTest__MaxUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxUInt16 testClass) + { + var result = Sse41.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxUInt16(); var result = Sse41.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt32.cs index 15740cee8ab2..5197e6763eb6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Max.UInt32.cs @@ -64,11 +64,17 @@ private static void MaxUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MaxUInt32() public sealed unsafe class SimpleBinaryOpTest__MaxUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MaxUInt32 testClass) + { + var result = Sse41.Max(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MaxUInt32(); var result = Sse41.Max(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Max(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Max(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.Int32.cs index 8dca101e429a..906127bedda8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.Int32.cs @@ -64,11 +64,17 @@ private static void MinInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinInt32() public sealed unsafe class SimpleBinaryOpTest__MinInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinInt32 testClass) + { + var result = Sse41.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinInt32(); var result = Sse41.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.SByte.cs index e7abc4d19803..061ef3f46bcb 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.SByte.cs @@ -64,11 +64,17 @@ private static void MinSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinSByte() public sealed unsafe class SimpleBinaryOpTest__MinSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinSByte testClass) + { + var result = Sse41.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinSByte(); var result = Sse41.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt16.cs index 8488da65fb14..ae652c816896 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt16.cs @@ -64,11 +64,17 @@ private static void MinUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinUInt16() public sealed unsafe class SimpleBinaryOpTest__MinUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinUInt16 testClass) + { + var result = Sse41.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinUInt16(); var result = Sse41.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt32.cs index 14e80d7b45fc..6e3636a67d38 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Min.UInt32.cs @@ -64,11 +64,17 @@ private static void MinUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MinUInt32() public sealed unsafe class SimpleBinaryOpTest__MinUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MinUInt32 testClass) + { + var result = Sse41.Min(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MinUInt32(); var result = Sse41.Min(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.Min(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.Min(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/MultiplyLow.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/MultiplyLow.Int32.cs index e5f348ee4758..2a936ed646f7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/MultiplyLow.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/MultiplyLow.Int32.cs @@ -64,11 +64,17 @@ private static void MultiplyLowInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyLowInt32() public sealed unsafe class SimpleBinaryOpTest__MultiplyLowInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyLowInt32 testClass) + { + var result = Sse41.MultiplyLow(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyLowInt32(); var result = Sse41.MultiplyLow(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.MultiplyLow(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.MultiplyLow(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/PackUnsignedSaturate.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/PackUnsignedSaturate.UInt16.cs index 556ff291b083..50539af22751 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/PackUnsignedSaturate.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/PackUnsignedSaturate.UInt16.cs @@ -64,11 +64,17 @@ private static void PackUnsignedSaturateUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void PackUnsignedSaturateUInt16() public sealed unsafe class HorizontalBinaryOpTest__PackUnsignedSaturateUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__PackUnsignedSaturateUInt16 testClass) + { + var result = Sse41.PackUnsignedSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__PackUnsignedSaturateUInt16(); var result = Sse41.PackUnsignedSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.PackUnsignedSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.PackUnsignedSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs index 195e1865b2b4..542e9364bf58 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Program.Sse41.cs @@ -23,14 +23,12 @@ static Program() ["CompareEqual.Int64"] = CompareEqualInt64, ["CompareEqual.UInt64"] = CompareEqualUInt64, ["Extract.Byte.1"] = ExtractByte1, - ["Extract.SByte.1"] = ExtractSByte1, ["Extract.Int32.1"] = ExtractInt321, ["Extract.UInt32.1"] = ExtractUInt321, ["Extract.Int64.1"] = ExtractInt641, ["Extract.UInt64.1"] = ExtractUInt641, ["Extract.Single.1"] = ExtractSingle1, ["Extract.Byte.129"] = ExtractByte129, - ["Extract.SByte.129"] = ExtractSByte129, ["Extract.Int32.129"] = ExtractInt32129, ["Extract.UInt32.129"] = ExtractUInt32129, ["Extract.Int64.129"] = ExtractInt64129, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Double.cs index 4eeedb70cd77..d86d8df9ac96 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Double.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundCurrentDirectionDouble() public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundCurrentDirectionDouble testClass) + { + var result = Sse41.RoundCurrentDirection(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundCurrentDirectionDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundCurrentDirectionDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundCurrentDirectionDouble(); var result = Sse41.RoundCurrentDirection(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundCurrentDirection(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundCurrentDirection(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Single.cs index 987a7d6db7a0..658ddbb1490c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirection.Single.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundCurrentDirectionSingle() public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionSingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundCurrentDirectionSingle testClass) + { + var result = Sse41.RoundCurrentDirection(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundCurrentDirectionSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundCurrentDirectionSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundCurrentDirectionSingle(); var result = Sse41.RoundCurrentDirection(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundCurrentDirection(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundCurrentDirection(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Double.cs index d1a94bf212f0..157cfe3e27c8 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Double.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundCurrentDirectionScalarDouble() public sealed unsafe class SimpleBinaryOpTest__RoundCurrentDirectionScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundCurrentDirectionScalarDouble testClass) + { + var result = Sse41.RoundCurrentDirectionScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundCurrentDirectionScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundCurrentDirectionScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundCurrentDirectionScalarDouble(); var result = Sse41.RoundCurrentDirectionScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundCurrentDirectionScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundCurrentDirectionScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Single.cs index 812d9809c905..2b2fe4c3ef35 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundCurrentDirectionScalar.Single.cs @@ -64,11 +64,17 @@ private static void RoundCurrentDirectionScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundCurrentDirectionScalarSingle() public sealed unsafe class SimpleBinaryOpTest__RoundCurrentDirectionScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundCurrentDirectionScalarSingle testClass) + { + var result = Sse41.RoundCurrentDirectionScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundCurrentDirectionScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundCurrentDirectionScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundCurrentDirectionScalarSingle(); var result = Sse41.RoundCurrentDirectionScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundCurrentDirectionScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundCurrentDirectionScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Double.cs index 9d98e5570467..c8d6a01a3408 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNearestIntegerDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNearestIntegerDouble testClass) + { + var result = Sse41.RoundToNearestInteger(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNearestIntegerDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNearestIntegerDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNearestIntegerDouble(); var result = Sse41.RoundToNearestInteger(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNearestInteger(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNearestInteger(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Single.cs index b4d42a250804..c1f331d72856 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestInteger.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNearestIntegerSingle() public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerSingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNearestIntegerSingle testClass) + { + var result = Sse41.RoundToNearestInteger(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNearestIntegerSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNearestIntegerSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNearestIntegerSingle(); var result = Sse41.RoundToNearestInteger(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNearestInteger(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNearestInteger(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Double.cs index b715709c4e64..a92e1b912526 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToNearestIntegerScalarDouble() public sealed unsafe class SimpleBinaryOpTest__RoundToNearestIntegerScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToNearestIntegerScalarDouble testClass) + { + var result = Sse41.RoundToNearestIntegerScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToNearestIntegerScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToNearestIntegerScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToNearestIntegerScalarDouble(); var result = Sse41.RoundToNearestIntegerScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNearestIntegerScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNearestIntegerScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Single.cs index b00afe9cefd0..a2e265a72141 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNearestIntegerScalar.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNearestIntegerScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToNearestIntegerScalarSingle() public sealed unsafe class SimpleBinaryOpTest__RoundToNearestIntegerScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToNearestIntegerScalarSingle testClass) + { + var result = Sse41.RoundToNearestIntegerScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToNearestIntegerScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToNearestIntegerScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToNearestIntegerScalarSingle(); var result = Sse41.RoundToNearestIntegerScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNearestIntegerScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNearestIntegerScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Double.cs index cd7c55f7ab5b..53d998b0ddd6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinityDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNegativeInfinityDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinityDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNegativeInfinityDouble testClass) + { + var result = Sse41.RoundToNegativeInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNegativeInfinityDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNegativeInfinityDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNegativeInfinityDouble(); var result = Sse41.RoundToNegativeInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNegativeInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNegativeInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Single.cs index 0b12a931ae20..0124534135b3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinity.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinitySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToNegativeInfinitySingle() public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinitySingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToNegativeInfinitySingle testClass) + { + var result = Sse41.RoundToNegativeInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToNegativeInfinitySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToNegativeInfinitySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToNegativeInfinitySingle(); var result = Sse41.RoundToNegativeInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNegativeInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNegativeInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Double.cs index 2c67fe099d81..076644612132 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Double.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinityScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToNegativeInfinityScalarDouble() public sealed unsafe class SimpleBinaryOpTest__RoundToNegativeInfinityScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToNegativeInfinityScalarDouble testClass) + { + var result = Sse41.RoundToNegativeInfinityScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToNegativeInfinityScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToNegativeInfinityScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToNegativeInfinityScalarDouble(); var result = Sse41.RoundToNegativeInfinityScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNegativeInfinityScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNegativeInfinityScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Single.cs index 3b5ea8c33bdc..055a757050dd 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToNegativeInfinityScalar.Single.cs @@ -64,11 +64,17 @@ private static void RoundToNegativeInfinityScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToNegativeInfinityScalarSingle() public sealed unsafe class SimpleBinaryOpTest__RoundToNegativeInfinityScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToNegativeInfinityScalarSingle testClass) + { + var result = Sse41.RoundToNegativeInfinityScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToNegativeInfinityScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToNegativeInfinityScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToNegativeInfinityScalarSingle(); var result = Sse41.RoundToNegativeInfinityScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToNegativeInfinityScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToNegativeInfinityScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Double.cs index 66e782f7034a..d0fc24462620 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Double.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinityDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToPositiveInfinityDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinityDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToPositiveInfinityDouble testClass) + { + var result = Sse41.RoundToPositiveInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToPositiveInfinityDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToPositiveInfinityDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToPositiveInfinityDouble(); var result = Sse41.RoundToPositiveInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToPositiveInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToPositiveInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Single.cs index f9308c0e54d9..7f6875375ea5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinity.Single.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinitySingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToPositiveInfinitySingle() public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinitySingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToPositiveInfinitySingle testClass) + { + var result = Sse41.RoundToPositiveInfinity(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToPositiveInfinitySingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToPositiveInfinitySingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToPositiveInfinitySingle(); var result = Sse41.RoundToPositiveInfinity(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToPositiveInfinity(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToPositiveInfinity(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Double.cs index 54bd3c22fbbe..a880de5d71e4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Double.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinityScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToPositiveInfinityScalarDouble() public sealed unsafe class SimpleBinaryOpTest__RoundToPositiveInfinityScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToPositiveInfinityScalarDouble testClass) + { + var result = Sse41.RoundToPositiveInfinityScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToPositiveInfinityScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToPositiveInfinityScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToPositiveInfinityScalarDouble(); var result = Sse41.RoundToPositiveInfinityScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToPositiveInfinityScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToPositiveInfinityScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Single.cs index 24565086a991..bd780437d0b3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToPositiveInfinityScalar.Single.cs @@ -64,11 +64,17 @@ private static void RoundToPositiveInfinityScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToPositiveInfinityScalarSingle() public sealed unsafe class SimpleBinaryOpTest__RoundToPositiveInfinityScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToPositiveInfinityScalarSingle testClass) + { + var result = Sse41.RoundToPositiveInfinityScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToPositiveInfinityScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToPositiveInfinityScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToPositiveInfinityScalarSingle(); var result = Sse41.RoundToPositiveInfinityScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToPositiveInfinityScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToPositiveInfinityScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Double.cs index a58150b542fc..06877892d0c6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Double.cs @@ -64,11 +64,17 @@ private static void RoundToZeroDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToZeroDouble() public sealed unsafe class SimpleUnaryOpTest__RoundToZeroDouble { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToZeroDouble testClass) + { + var result = Sse41.RoundToZero(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToZeroDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToZeroDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Double[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToZeroDouble(); var result = Sse41.RoundToZero(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToZero(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToZero(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Single.cs index 30fc2ddf337b..3e5c3632cee6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZero.Single.cs @@ -64,11 +64,17 @@ private static void RoundToZeroSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void RoundToZeroSingle() public sealed unsafe class SimpleUnaryOpTest__RoundToZeroSingle { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__RoundToZeroSingle testClass) + { + var result = Sse41.RoundToZero(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -102,7 +132,7 @@ static SimpleUnaryOpTest__RoundToZeroSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } @@ -112,10 +142,10 @@ public SimpleUnaryOpTest__RoundToZeroSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleUnaryOpTest__DataTable(_data, new Single[RetElementCount], LargestVectorSize); } @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__RoundToZeroSingle(); var result = Sse41.RoundToZero(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToZero(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToZero(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Double.cs index 6ee0e0ed94a2..8435e9c03d14 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Double.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Double.cs @@ -64,11 +64,17 @@ private static void RoundToZeroScalarDouble() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToZeroScalarDouble() public sealed unsafe class SimpleBinaryOpTest__RoundToZeroScalarDouble { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToZeroScalarDouble testClass) + { + var result = Sse41.RoundToZeroScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Double); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToZeroScalarDouble() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToZeroScalarDouble() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Double[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToZeroScalarDouble(); var result = Sse41.RoundToZeroScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToZeroScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToZeroScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Single.cs index c65383800483..a6ce47c2328d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Single.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/RoundToZeroScalar.Single.cs @@ -64,11 +64,17 @@ private static void RoundToZeroScalarSingle() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void RoundToZeroScalarSingle() public sealed unsafe class SimpleBinaryOpTest__RoundToZeroScalarSingle { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__RoundToZeroScalarSingle testClass) + { + var result = Sse41.RoundToZeroScalar(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Single); @@ -106,9 +139,9 @@ static SimpleBinaryOpTest__RoundToZeroScalarSingle() { var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); } @@ -118,13 +151,13 @@ public SimpleBinaryOpTest__RoundToZeroScalarSingle() var random = new Random(); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); - for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); } - for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); } + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetSingle(); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetSingle(); } _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Single[RetElementCount], LargestVectorSize); } @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__RoundToZeroScalarSingle(); var result = Sse41.RoundToZeroScalar(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.RoundToZeroScalar(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.RoundToZeroScalar(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj index e98e0c2acba7..ae14ac373759 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_r.csproj @@ -120,14 +120,12 @@ - - @@ -140,14 +138,14 @@ - - - - - - - - + + + + + + + + @@ -155,7 +153,7 @@ - + @@ -167,6 +165,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj index 171f917b8625..92ba44da6b3a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/Sse41_ro.csproj @@ -120,14 +120,12 @@ - - @@ -140,14 +138,14 @@ - - - - - - - - + + + + + + + + @@ -155,7 +153,7 @@ - + @@ -167,6 +165,9 @@ + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Byte.cs index 9cd052cfde7a..92069c78b711 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Byte.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesByte() { - var test = new BooleanComparisonOpTest__TestAllOnesByte(); + var test = new BooleanUnaryOpTest__TestAllOnesByte(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesByte() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesByte + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesByte testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesByte private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesByte() + static BooleanUnaryOpTest__TestAllOnesByte() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesByte() + public BooleanUnaryOpTest__TestAllOnesByte() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesByte(); + var test = new BooleanUnaryOpTest__TestAllOnesByte(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int16.cs index f14704207b41..e147a7aa0113 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int16.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesInt16() { - var test = new BooleanComparisonOpTest__TestAllOnesInt16(); + var test = new BooleanUnaryOpTest__TestAllOnesInt16(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesInt16() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt16 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesInt16 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt16 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesInt16() + static BooleanUnaryOpTest__TestAllOnesInt16() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesInt16() + public BooleanUnaryOpTest__TestAllOnesInt16() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesInt16(); + var test = new BooleanUnaryOpTest__TestAllOnesInt16(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int32.cs index cea53a44eb48..9c731c93f6e6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int32.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesInt32() { - var test = new BooleanComparisonOpTest__TestAllOnesInt32(); + var test = new BooleanUnaryOpTest__TestAllOnesInt32(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesInt32() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt32 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesInt32 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt32 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesInt32() + static BooleanUnaryOpTest__TestAllOnesInt32() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesInt32() + public BooleanUnaryOpTest__TestAllOnesInt32() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesInt32(); + var test = new BooleanUnaryOpTest__TestAllOnesInt32(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int64.cs index d79048dad821..97032d1a5e37 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.Int64.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesInt64() { - var test = new BooleanComparisonOpTest__TestAllOnesInt64(); + var test = new BooleanUnaryOpTest__TestAllOnesInt64(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesInt64() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt64 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesInt64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesInt64 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesInt64 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesInt64() + static BooleanUnaryOpTest__TestAllOnesInt64() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesInt64() + public BooleanUnaryOpTest__TestAllOnesInt64() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesInt64(); + var test = new BooleanUnaryOpTest__TestAllOnesInt64(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.SByte.cs index 23ba8fd8f8ab..36acdef4ab73 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.SByte.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesSByte() { - var test = new BooleanComparisonOpTest__TestAllOnesSByte(); + var test = new BooleanUnaryOpTest__TestAllOnesSByte(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesSByte() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesSByte + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesSByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesSByte testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesSByte private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesSByte() + static BooleanUnaryOpTest__TestAllOnesSByte() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesSByte() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesSByte() + public BooleanUnaryOpTest__TestAllOnesSByte() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesSByte(); + var test = new BooleanUnaryOpTest__TestAllOnesSByte(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt16.cs index 25a81c9d848c..334df4a2c65f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt16.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesUInt16() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt16(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt16(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesUInt16() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt16 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesUInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesUInt16 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt16 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesUInt16() + static BooleanUnaryOpTest__TestAllOnesUInt16() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesUInt16() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesUInt16() + public BooleanUnaryOpTest__TestAllOnesUInt16() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt16(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt16(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt32.cs index 35fac0dd3081..06cad7218e38 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt32.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesUInt32() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt32(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt32(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesUInt32() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt32 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesUInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesUInt32 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt32 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesUInt32() + static BooleanUnaryOpTest__TestAllOnesUInt32() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesUInt32() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesUInt32() + public BooleanUnaryOpTest__TestAllOnesUInt32() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt32(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt32(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt64.cs index e03327885b16..66a25cf073c9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllOnes.UInt64.cs @@ -22,7 +22,7 @@ public static partial class Program { private static void TestAllOnesUInt64() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt64(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt64(); if (test.IsSupported) { @@ -65,11 +65,17 @@ private static void TestAllOnesUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -84,8 +90,30 @@ private static void TestAllOnesUInt64() } } - public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt64 + public sealed unsafe class BooleanUnaryOpTest__TestAllOnesUInt64 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanUnaryOpTest__TestAllOnesUInt64 testClass) + { + var result = Sse41.TestAllOnes(_fld); + testClass.ValidateResult(_fld, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -98,7 +126,7 @@ public sealed unsafe class BooleanComparisonOpTest__TestAllOnesUInt64 private BooleanUnaryOpTest__DataTable _dataTable; - static BooleanComparisonOpTest__TestAllOnesUInt64() + static BooleanUnaryOpTest__TestAllOnesUInt64() { var random = new Random(); @@ -106,7 +134,7 @@ static BooleanComparisonOpTest__TestAllOnesUInt64() Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); } - public BooleanComparisonOpTest__TestAllOnesUInt64() + public BooleanUnaryOpTest__TestAllOnesUInt64() { Succeeded = true; @@ -213,21 +241,34 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(value, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { - var test = new BooleanComparisonOpTest__TestAllOnesUInt64(); + var test = new BooleanUnaryOpTest__TestAllOnesUInt64(); var result = Sse41.TestAllOnes(test._fld); ValidateResult(test._fld, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllOnes(_fld); ValidateResult(_fld, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllOnes(test._fld); + ValidateResult(test._fld, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Byte.cs index d329b3cf248d..3d3820cf9be6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Byte.cs @@ -64,11 +64,17 @@ private static void TestAllZerosByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosByte() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosByte testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosByte(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int16.cs index 7f190d7573eb..425b2cf73f21 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int16.cs @@ -64,11 +64,17 @@ private static void TestAllZerosInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosInt16() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosInt16 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosInt16(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int32.cs index 2cb24b400ab4..4749fd54ee0d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int32.cs @@ -64,11 +64,17 @@ private static void TestAllZerosInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosInt32() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosInt32 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosInt32(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int64.cs index f9747826accb..22d16e005698 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int64.cs @@ -64,11 +64,17 @@ private static void TestAllZerosInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosInt64() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosInt64 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosInt64(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.SByte.cs index 89147982bd3f..5eeb1ce2456c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.SByte.cs @@ -64,11 +64,17 @@ private static void TestAllZerosSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosSByte() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosSByte testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosSByte(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt16.cs index b307e480a92a..401310828447 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt16.cs @@ -64,11 +64,17 @@ private static void TestAllZerosUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosUInt16() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosUInt16 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosUInt16(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt32.cs index bbe9c771d69c..7c8a54802d13 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt32.cs @@ -64,11 +64,17 @@ private static void TestAllZerosUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosUInt32() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosUInt32 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosUInt32(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt64.cs index 4dd5c9fe49c7..da53d7f17cf2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt64.cs @@ -64,11 +64,17 @@ private static void TestAllZerosUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestAllZerosUInt64() public sealed unsafe class BooleanBinaryOpTest__TestAllZerosUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestAllZerosUInt64 testClass) + { + var result = Sse41.TestAllZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestAllZerosUInt64(); var result = Sse41.TestAllZeros(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestAllZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestAllZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Byte.cs index ea338296649a..6d234f7dfae2 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Byte.cs @@ -64,11 +64,17 @@ private static void TestCByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCByte() public sealed unsafe class BooleanBinaryOpTest__TestCByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCByte testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCByte(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int16.cs index d677f97e45ce..7a1889e72442 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int16.cs @@ -64,11 +64,17 @@ private static void TestCInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt16() public sealed unsafe class BooleanBinaryOpTest__TestCInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt16 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt16(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int32.cs index cc53b741dd76..813047d2842c 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int32.cs @@ -64,11 +64,17 @@ private static void TestCInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt32() public sealed unsafe class BooleanBinaryOpTest__TestCInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt32 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt32(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int64.cs index 951ab0a56fc4..518bc7f0dd09 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int64.cs @@ -64,11 +64,17 @@ private static void TestCInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCInt64() public sealed unsafe class BooleanBinaryOpTest__TestCInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCInt64 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCInt64(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.SByte.cs index c69e298f16eb..69fe53c19d5a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.SByte.cs @@ -64,11 +64,17 @@ private static void TestCSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCSByte() public sealed unsafe class BooleanBinaryOpTest__TestCSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCSByte testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCSByte(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt16.cs index c071eb873fdc..6b4c22200a36 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt16.cs @@ -64,11 +64,17 @@ private static void TestCUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt16() public sealed unsafe class BooleanBinaryOpTest__TestCUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt16 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt16(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt32.cs index 54efe4c3a784..fce8e689beac 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt32.cs @@ -64,11 +64,17 @@ private static void TestCUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt32() public sealed unsafe class BooleanBinaryOpTest__TestCUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt32 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt32(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt64.cs index 25b5691478ae..ca9c589138bc 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt64.cs @@ -64,11 +64,17 @@ private static void TestCUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestCUInt64() public sealed unsafe class BooleanBinaryOpTest__TestCUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestCUInt64 testClass) + { + var result = Sse41.TestC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestCUInt64(); var result = Sse41.TestC(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Byte.cs index a044b9622b0a..0b70512fbfc5 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Byte.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosByte testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosByte(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int16.cs index 1ffc56b094df..832344886ba4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int16.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosInt16 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosInt16(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int32.cs index f2d75b6ce622..3fa11776bb1f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int32.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosInt32 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosInt32(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int64.cs index a9e44fea5ea4..7ddd00ff815b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int64.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosInt64 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosInt64(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.SByte.cs index db9e226655ab..860b83070742 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.SByte.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosSByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosSByte testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosSByte(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt16.cs index 082d5b2dfe6d..f339775294d6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt16.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosUInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosUInt16 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosUInt16(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt32.cs index b03d93278ea4..5afaa7ff1e44 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt32.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosUInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosUInt32 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosUInt32(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt64.cs index d4b5693b8356..ca2b1cd9915f 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt64.cs @@ -64,11 +64,17 @@ private static void TestMixOnesZerosUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestMixOnesZerosUInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestMixOnesZerosUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestMixOnesZerosUInt64 testClass) + { + var result = Sse41.TestMixOnesZeros(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestMixOnesZerosUInt64(); var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestMixOnesZeros(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestMixOnesZeros(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Byte.cs index bd5c61caa409..0effd4cce77a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Byte.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCByte testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCByte(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int16.cs index f9d7dbd77812..63073e70c3c6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int16.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt16 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt16(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int32.cs index 207c6d7c0256..9fc94c00a445 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int32.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt32 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt32(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int64.cs index 7fd51e2c0078..c8f652ff91d6 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int64.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCInt64 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt64(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.SByte.cs index af0aeb2f48f0..e820b08cef5a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.SByte.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCSByte() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCSByte testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCSByte(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt16.cs index b3e015a46196..b9efa0099831 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt16.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt16() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt32.cs index 8b20066446d4..d5a15bdf1544 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt32.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt32() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt64.cs index 51910e00cd82..cc9880143afe 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt64.cs @@ -64,11 +64,17 @@ private static void TestNotZAndNotCUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestNotZAndNotCUInt64() public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64 testClass) + { + var result = Sse41.TestNotZAndNotC(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -193,7 +224,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -242,7 +273,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64(); var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); @@ -250,13 +281,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestNotZAndNotC(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestNotZAndNotC(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs index b4be6da0ddd5..f92d6bd3c5a0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs @@ -64,11 +64,17 @@ private static void TestZByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZByte() public sealed unsafe class BooleanBinaryOpTest__TestZByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZByte testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZByte(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int16.cs index c5311a064805..f6efc4d6e68b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int16.cs @@ -64,11 +64,17 @@ private static void TestZInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt16() public sealed unsafe class BooleanBinaryOpTest__TestZInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt16 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt16(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int32.cs index 517be605407a..dc28e35de3d7 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int32.cs @@ -64,11 +64,17 @@ private static void TestZInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt32() public sealed unsafe class BooleanBinaryOpTest__TestZInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt32 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt32(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int64.cs index 73f604343ae3..ef295e3a1b46 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int64.cs @@ -64,11 +64,17 @@ private static void TestZInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZInt64() public sealed unsafe class BooleanBinaryOpTest__TestZInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZInt64 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZInt64(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.SByte.cs index 2c1e9441018f..dee261552967 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.SByte.cs @@ -64,11 +64,17 @@ private static void TestZSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZSByte() public sealed unsafe class BooleanBinaryOpTest__TestZSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZSByte testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZSByte(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt16.cs index d7ca47569718..af67bfa214ff 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt16.cs @@ -64,11 +64,17 @@ private static void TestZUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt16() public sealed unsafe class BooleanBinaryOpTest__TestZUInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt16 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt16); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt16(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt32.cs index c741395f4896..c1284297dce3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt32.cs @@ -64,11 +64,17 @@ private static void TestZUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt32() public sealed unsafe class BooleanBinaryOpTest__TestZUInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt32 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt32); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt32(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt64.cs index 82717fa63885..948078f66389 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt64.cs @@ -64,11 +64,17 @@ private static void TestZUInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,31 @@ private static void TestZUInt64() public sealed unsafe class BooleanBinaryOpTest__TestZUInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(BooleanBinaryOpTest__TestZUInt64 testClass) + { + var result = Sse41.TestZ(_fld1, _fld2); + testClass.ValidateResult(_fld1, _fld2, result); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(UInt64); @@ -164,7 +195,7 @@ public void RunBasicScenario_LoadAligned() public void RunReflectionScenario_UnsafeRead() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -179,7 +210,7 @@ public void RunReflectionScenario_UnsafeRead() public void RunReflectionScenario_Load() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -194,7 +225,7 @@ public void RunReflectionScenario_Load() public void RunReflectionScenario_LoadAligned() { var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128), typeof(Vector128) }); - + if (method != null) { var result = method.Invoke(null, new object[] { @@ -243,7 +274,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, result); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new BooleanBinaryOpTest__TestZUInt64(); var result = Sse41.TestZ(test._fld1, test._fld2); @@ -251,13 +282,26 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, result); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse41.TestZ(_fld1, _fld2); ValidateResult(_fld1, _fld2, result); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse41.TestZ(test._fld1, test._fld2); + ValidateResult(test._fld1, test._fld2, result); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs index 0520e3ea12d0..df6dfc78faae 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs @@ -64,11 +64,17 @@ private static void CompareGreaterThanInt64() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void CompareGreaterThanInt64() public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__CompareGreaterThanInt64 testClass) + { + var result = Sse42.CompareGreaterThan(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int64); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__CompareGreaterThanInt64(); var result = Sse42.CompareGreaterThan(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Sse42.CompareGreaterThan(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Sse42.CompareGreaterThan(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.Byte.cs index 43f6a6ab4fba..f056f4859cde 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.Byte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.Byte.cs @@ -64,11 +64,17 @@ private static void AbsByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void AbsByte() public sealed unsafe class SimpleUnaryOpTest__AbsByte { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (sbyte)(random.Next(sbyte.MinValue + 1, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__AbsByte testClass) + { + var result = Ssse3.Abs(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__AbsByte(); var result = Ssse3.Abs(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Abs(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Abs(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt16.cs index f1ead046a0dc..984782086abf 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt16.cs @@ -64,11 +64,17 @@ private static void AbsUInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void AbsUInt16() public sealed unsafe class SimpleUnaryOpTest__AbsUInt16 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (short)(random.Next(short.MinValue + 1, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__AbsUInt16 testClass) + { + var result = Ssse3.Abs(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__AbsUInt16(); var result = Ssse3.Abs(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Abs(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Abs(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt32.cs index 5a8fd7d9194a..2ae298b309a9 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Abs.UInt32.cs @@ -64,11 +64,17 @@ private static void AbsUInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,30 @@ private static void AbsUInt32() public sealed unsafe class SimpleUnaryOpTest__AbsUInt32 { + private struct TestStruct + { + public Vector128 _fld; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (int)(random.Next(int.MinValue + 1, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld), ref Unsafe.As(ref _data[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleUnaryOpTest__AbsUInt32 testClass) + { + var result = Ssse3.Abs(_fld); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -223,7 +253,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(firstOp, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleUnaryOpTest__AbsUInt32(); var result = Ssse3.Abs(test._fld); @@ -232,7 +262,7 @@ public void RunLclFldScenario() ValidateResult(test._fld, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Abs(_fld); @@ -240,6 +270,21 @@ public void RunFldScenario() ValidateResult(_fld, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Abs(test._fld); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int16.cs index 0ea25e566f65..4e1e2f01f9d0 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int16.cs @@ -64,11 +64,17 @@ private static void HorizontalAddInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalAddInt16() public sealed unsafe class HorizontalBinaryOpTest__HorizontalAddInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalAddInt16 testClass) + { + var result = Ssse3.HorizontalAdd(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalAddInt16(); var result = Ssse3.HorizontalAdd(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalAdd(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalAdd(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int32.cs index e6f00bb4b948..5065681bec95 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAdd.Int32.cs @@ -64,11 +64,17 @@ private static void HorizontalAddInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalAddInt32() public sealed unsafe class HorizontalBinaryOpTest__HorizontalAddInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalAddInt32 testClass) + { + var result = Ssse3.HorizontalAdd(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalAddInt32(); var result = Ssse3.HorizontalAdd(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalAdd(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalAdd(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAddSaturate.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAddSaturate.Int16.cs index 90406774b9ac..5dc5d9d58b0d 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAddSaturate.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalAddSaturate.Int16.cs @@ -64,11 +64,17 @@ private static void HorizontalAddSaturateInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalAddSaturateInt16() public sealed unsafe class HorizontalBinaryOpTest__HorizontalAddSaturateInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalAddSaturateInt16 testClass) + { + var result = Ssse3.HorizontalAddSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalAddSaturateInt16(); var result = Ssse3.HorizontalAddSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalAddSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalAddSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int16.cs index 6ce559137a93..cab677116be3 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int16.cs @@ -64,11 +64,17 @@ private static void HorizontalSubtractInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalSubtractInt16() public sealed unsafe class HorizontalBinaryOpTest__HorizontalSubtractInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractInt16 testClass) + { + var result = Ssse3.HorizontalSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalSubtractInt16(); var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int32.cs index b94727047260..fff6e43e0307 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtract.Int32.cs @@ -64,11 +64,17 @@ private static void HorizontalSubtractInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalSubtractInt32() public sealed unsafe class HorizontalBinaryOpTest__HorizontalSubtractInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractInt32 testClass) + { + var result = Ssse3.HorizontalSubtract(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalSubtractInt32(); var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalSubtract(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalSubtract(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtractSaturate.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtractSaturate.Int16.cs index ec96f733f046..a5ccd486b31b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtractSaturate.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/HorizontalSubtractSaturate.Int16.cs @@ -64,11 +64,17 @@ private static void HorizontalSubtractSaturateInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void HorizontalSubtractSaturateInt16() public sealed unsafe class HorizontalBinaryOpTest__HorizontalSubtractSaturateInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(HorizontalBinaryOpTest__HorizontalSubtractSaturateInt16 testClass) + { + var result = Ssse3.HorizontalSubtractSaturate(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new HorizontalBinaryOpTest__HorizontalSubtractSaturateInt16(); var result = Ssse3.HorizontalSubtractSaturate(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.HorizontalSubtractSaturate(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.HorizontalSubtractSaturate(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyAddAdjacent.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyAddAdjacent.Int16.cs index 6b24d63c3fe7..f05d44cbb965 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyAddAdjacent.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyAddAdjacent.Int16.cs @@ -64,11 +64,17 @@ private static void MultiplyAddAdjacentInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyAddAdjacentInt16() public sealed unsafe class SimpleBinaryOpTest__MultiplyAddAdjacentInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyAddAdjacentInt16 testClass) + { + var result = Ssse3.MultiplyAddAdjacent(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyAddAdjacentInt16(); var result = Ssse3.MultiplyAddAdjacent(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.MultiplyAddAdjacent(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.MultiplyAddAdjacent(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyHighRoundScale.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyHighRoundScale.Int16.cs index 9e6225e8c5bb..5325c190b123 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyHighRoundScale.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/MultiplyHighRoundScale.Int16.cs @@ -64,11 +64,17 @@ private static void MultiplyHighRoundScaleInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void MultiplyHighRoundScaleInt16() public sealed unsafe class SimpleBinaryOpTest__MultiplyHighRoundScaleInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__MultiplyHighRoundScaleInt16 testClass) + { + var result = Ssse3.MultiplyHighRoundScale(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__MultiplyHighRoundScaleInt16(); var result = Ssse3.MultiplyHighRoundScale(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.MultiplyHighRoundScale(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.MultiplyHighRoundScale(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Program.Ssse3.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Program.Ssse3.cs index bb22c09b1873..c49a41a7629e 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Program.Ssse3.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Program.Ssse3.cs @@ -23,6 +23,7 @@ static Program() ["HorizontalSubtractSaturate.Int16"] = HorizontalSubtractSaturateInt16, ["MultiplyAddAdjacent.Int16"] = MultiplyAddAdjacentInt16, ["MultiplyHighRoundScale.Int16"] = MultiplyHighRoundScaleInt16, + ["Shuffle.Byte"] = ShuffleByte, ["Shuffle.SByte"] = ShuffleSByte, ["Sign.SByte"] = SignSByte, ["Sign.Int16"] = SignInt16, diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.Byte.cs new file mode 100644 index 000000000000..cb33d761ca2a --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.Byte.cs @@ -0,0 +1,378 @@ +// 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. + +/****************************************************************************** + * This file is auto-generated from a template file by the GenerateTests.csx * + * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * + * changes, please update the corresponding template and run according to the * + * directions listed in the file. * + ******************************************************************************/ + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +namespace JIT.HardwareIntrinsics.X86 +{ + public static partial class Program + { + private static void ShuffleByte() + { + var test = new SimpleBinaryOpTest__ShuffleByte(); + + if (test.IsSupported) + { + // Validates basic functionality works, using Unsafe.Read + test.RunBasicScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates basic functionality works, using Load + test.RunBasicScenario_Load(); + + // Validates basic functionality works, using LoadAligned + test.RunBasicScenario_LoadAligned(); + } + + // Validates calling via reflection works, using Unsafe.Read + test.RunReflectionScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates calling via reflection works, using Load + test.RunReflectionScenario_Load(); + + // Validates calling via reflection works, using LoadAligned + test.RunReflectionScenario_LoadAligned(); + } + + // Validates passing a static member works + test.RunClsVarScenario(); + + // Validates passing a local works, using Unsafe.Read + test.RunLclVarScenario_UnsafeRead(); + + if (Sse2.IsSupported) + { + // Validates passing a local works, using Load + test.RunLclVarScenario_Load(); + + // Validates passing a local works, using LoadAligned + test.RunLclVarScenario_LoadAligned(); + } + + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); + + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); + } + else + { + // Validates we throw on unsupported hardware + test.RunUnsupportedScenario(); + } + + if (!test.Succeeded) + { + throw new Exception("One or more scenarios did not complete as expected."); + } + } + } + + public sealed unsafe class SimpleBinaryOpTest__ShuffleByte + { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__ShuffleByte testClass) + { + var result = Ssse3.Shuffle(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + + private static readonly int LargestVectorSize = 16; + + private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Byte); + private static readonly int Op2ElementCount = Unsafe.SizeOf>() / sizeof(Byte); + private static readonly int RetElementCount = Unsafe.SizeOf>() / sizeof(Byte); + + private static Byte[] _data1 = new Byte[Op1ElementCount]; + private static Byte[] _data2 = new Byte[Op2ElementCount]; + + private static Vector128 _clsVar1; + private static Vector128 _clsVar2; + + private Vector128 _fld1; + private Vector128 _fld2; + + private SimpleBinaryOpTest__DataTable _dataTable; + + static SimpleBinaryOpTest__ShuffleByte() + { + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _clsVar2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + } + + public SimpleBinaryOpTest__ShuffleByte() + { + Succeeded = true; + + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref _fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); } + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); } + _dataTable = new SimpleBinaryOpTest__DataTable(_data1, _data2, new Byte[RetElementCount], LargestVectorSize); + } + + public bool IsSupported => Ssse3.IsSupported; + + public bool Succeeded { get; set; } + + public void RunBasicScenario_UnsafeRead() + { + var result = Ssse3.Shuffle( + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_Load() + { + var result = Ssse3.Shuffle( + Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunBasicScenario_LoadAligned() + { + var result = Ssse3.Shuffle( + Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_UnsafeRead() + { + var result = typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), new Type[] { typeof(Vector128), typeof(Vector128) }) + .Invoke(null, new object[] { + Unsafe.Read>(_dataTable.inArray1Ptr), + Unsafe.Read>(_dataTable.inArray2Ptr) + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_Load() + { + var result = typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), new Type[] { typeof(Vector128), typeof(Vector128) }) + .Invoke(null, new object[] { + Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)), + Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)) + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunReflectionScenario_LoadAligned() + { + var result = typeof(Ssse3).GetMethod(nameof(Ssse3.Shuffle), new Type[] { typeof(Vector128), typeof(Vector128) }) + .Invoke(null, new object[] { + Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)), + Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)) + }); + + Unsafe.Write(_dataTable.outArrayPtr, (Vector128)(result)); + ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr); + } + + public void RunClsVarScenario() + { + var result = Ssse3.Shuffle( + _clsVar1, + _clsVar2 + ); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_clsVar1, _clsVar2, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_UnsafeRead() + { + var left = Unsafe.Read>(_dataTable.inArray1Ptr); + var right = Unsafe.Read>(_dataTable.inArray2Ptr); + var result = Ssse3.Shuffle(left, right); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_Load() + { + var left = Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr)); + var result = Ssse3.Shuffle(left, right); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunLclVarScenario_LoadAligned() + { + var left = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)); + var right = Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr)); + var result = Ssse3.Shuffle(left, right); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(left, right, _dataTable.outArrayPtr); + } + + public void RunClassLclFldScenario() + { + var test = new SimpleBinaryOpTest__ShuffleByte(); + var result = Ssse3.Shuffle(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunClassFldScenario() + { + var result = Ssse3.Shuffle(_fld1, _fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); + } + + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Shuffle(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + + public void RunUnsupportedScenario() + { + Succeeded = false; + + try + { + RunBasicScenario_UnsafeRead(); + } + catch (PlatformNotSupportedException) + { + Succeeded = true; + } + } + + private void ValidateResult(Vector128 left, Vector128 right, void* result, [CallerMemberName] string method = "") + { + Byte[] inArray1 = new Byte[Op1ElementCount]; + Byte[] inArray2 = new Byte[Op2ElementCount]; + Byte[] outArray = new Byte[RetElementCount]; + + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray1[0]), left); + Unsafe.WriteUnaligned(ref Unsafe.As(ref inArray2[0]), right); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "") + { + Byte[] inArray1 = new Byte[Op1ElementCount]; + Byte[] inArray2 = new Byte[Op2ElementCount]; + Byte[] outArray = new Byte[RetElementCount]; + + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray1[0]), ref Unsafe.AsRef(left), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref inArray2[0]), ref Unsafe.AsRef(right), (uint)Unsafe.SizeOf>()); + Unsafe.CopyBlockUnaligned(ref Unsafe.As(ref outArray[0]), ref Unsafe.AsRef(result), (uint)Unsafe.SizeOf>()); + + ValidateResult(inArray1, inArray2, outArray, method); + } + + private void ValidateResult(Byte[] left, Byte[] right, Byte[] result, [CallerMemberName] string method = "") + { + if (result[0] != ((right[0] > 127) ? 0 : left[right[0] & 0x0F])) + { + Succeeded = false; + } + else + { + for (var i = 1; i < RetElementCount; i++) + { + if (result[i] != ((right[i] > 127) ? 0 : left[right[i] & 0x0F])) + { + Succeeded = false; + break; + } + } + } + + if (!Succeeded) + { + Console.WriteLine($"{nameof(Ssse3)}.{nameof(Ssse3.Shuffle)}(Vector128, Vector128): {method} failed:"); + Console.WriteLine($" left: ({string.Join(", ", left)})"); + Console.WriteLine($" right: ({string.Join(", ", right)})"); + Console.WriteLine($" result: ({string.Join(", ", result)})"); + Console.WriteLine(); + } + } + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.SByte.cs index b1adce8c1cd8..8ea8c4e2d441 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Shuffle.SByte.cs @@ -64,11 +64,17 @@ private static void ShuffleSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void ShuffleSByte() public sealed unsafe class SimpleBinaryOpTest__ShuffleSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__ShuffleSByte testClass) + { + var result = Ssse3.Shuffle(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__ShuffleSByte(); var result = Ssse3.Shuffle(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Shuffle(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Shuffle(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int16.cs index aac13e975287..bff9f216335a 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int16.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int16.cs @@ -64,11 +64,17 @@ private static void SignInt16() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SignInt16() public sealed unsafe class SimpleBinaryOpTest__SignInt16 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue + 1, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SignInt16 testClass) + { + var result = Ssse3.Sign(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int16); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SignInt16(); var result = Ssse3.Sign(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Sign(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Sign(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int32.cs index 541ed84282d4..93a376bcc5ca 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int32.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.Int32.cs @@ -64,11 +64,17 @@ private static void SignInt32() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SignInt32() public sealed unsafe class SimpleBinaryOpTest__SignInt32 { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue + 1, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SignInt32 testClass) + { + var result = Ssse3.Sign(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(Int32); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SignInt32(); var result = Ssse3.Sign(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Sign(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Sign(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.SByte.cs index 21e07f58043b..085cbf04d9f4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.SByte.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Sign.SByte.cs @@ -64,11 +64,17 @@ private static void SignSByte() test.RunLclVarScenario_LoadAligned(); } - // Validates passing the field of a local works - test.RunLclFldScenario(); + // Validates passing the field of a local class works + test.RunClassLclFldScenario(); - // Validates passing an instance member works - test.RunFldScenario(); + // Validates passing an instance member of a class works + test.RunClassFldScenario(); + + // Validates passing the field of a local struct works + test.RunStructLclFldScenario(); + + // Validates passing an instance member of a struct works + test.RunStructFldScenario(); } else { @@ -85,6 +91,33 @@ private static void SignSByte() public sealed unsafe class SimpleBinaryOpTest__SignSByte { + private struct TestStruct + { + public Vector128 _fld1; + public Vector128 _fld2; + + public static TestStruct Create() + { + var testStruct = new TestStruct(); + var random = new Random(); + + for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue + 1, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld1), ref Unsafe.As(ref _data1[0]), (uint)Unsafe.SizeOf>()); + for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); } + Unsafe.CopyBlockUnaligned(ref Unsafe.As, byte>(ref testStruct._fld2), ref Unsafe.As(ref _data2[0]), (uint)Unsafe.SizeOf>()); + + return testStruct; + } + + public void RunStructFldScenario(SimpleBinaryOpTest__SignSByte testClass) + { + var result = Ssse3.Sign(_fld1, _fld2); + + Unsafe.Write(testClass._dataTable.outArrayPtr, result); + testClass.ValidateResult(_fld1, _fld2, testClass._dataTable.outArrayPtr); + } + } + private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf>() / sizeof(SByte); @@ -242,7 +275,7 @@ public void RunLclVarScenario_LoadAligned() ValidateResult(left, right, _dataTable.outArrayPtr); } - public void RunLclFldScenario() + public void RunClassLclFldScenario() { var test = new SimpleBinaryOpTest__SignSByte(); var result = Ssse3.Sign(test._fld1, test._fld2); @@ -251,7 +284,7 @@ public void RunLclFldScenario() ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); } - public void RunFldScenario() + public void RunClassFldScenario() { var result = Ssse3.Sign(_fld1, _fld2); @@ -259,6 +292,21 @@ public void RunFldScenario() ValidateResult(_fld1, _fld2, _dataTable.outArrayPtr); } + public void RunStructLclFldScenario() + { + var test = TestStruct.Create(); + var result = Ssse3.Sign(test._fld1, test._fld2); + + Unsafe.Write(_dataTable.outArrayPtr, result); + ValidateResult(test._fld1, test._fld2, _dataTable.outArrayPtr); + } + + public void RunStructFldScenario() + { + var test = TestStruct.Create(); + test.RunStructFldScenario(this); + } + public void RunUnsupportedScenario() { Succeeded = false; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_r.csproj index fc18de279b62..8f5763f7033b 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_r.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_r.csproj @@ -38,6 +38,7 @@ + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_ro.csproj index 8bad57d65561..0391fb6d26ab 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_ro.csproj +++ b/tests/src/JIT/HardwareIntrinsics/X86/Ssse3/Ssse3_ro.csproj @@ -38,6 +38,7 @@ + diff --git a/tests/src/JIT/Methodical/inlining/bug505642/test.cs b/tests/src/JIT/Methodical/inlining/bug505642/test.cs index e54c0005e257..94153f8c7b4c 100644 --- a/tests/src/JIT/Methodical/inlining/bug505642/test.cs +++ b/tests/src/JIT/Methodical/inlining/bug505642/test.cs @@ -5,7 +5,7 @@ /* * Some comments about the test: * Expected: The code runs and completes successfully. - * Acutal: The application hangs when it is run. + * Actual: The application hangs when it is run. * The csharp compiler seems to be generating the same IL in both the cases. * * Some comments about the bug: diff --git a/tests/src/JIT/Methodical/structs/ExplicitLayout.cs b/tests/src/JIT/Methodical/structs/ExplicitLayout.cs new file mode 100644 index 000000000000..c1aa79cd5447 --- /dev/null +++ b/tests/src/JIT/Methodical/structs/ExplicitLayout.cs @@ -0,0 +1,57 @@ +// 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.Runtime.InteropServices; + +class ExplicitLayout +{ + [StructLayout(LayoutKind.Explicit, Size = SIZE)] + internal unsafe struct TestStruct + { + public const int SIZE = 32; + + [FieldOffset(0)] + private fixed byte _data[SIZE]; + + [FieldOffset(0), MarshalAs(UnmanagedType.Struct, SizeConst = 16)] + public Guid Guid1; + + [FieldOffset(16), MarshalAs(UnmanagedType.Struct, SizeConst = 16)] + public Guid Guid2; + } + + internal class Program + { + private static int Main() + { + int returnVal = 100; + + TestStruct t = new TestStruct(); + t.Guid1 = Guid.NewGuid(); + t.Guid2 = t.Guid1; + + if (t.Guid1 != t.Guid2) + { + Console.WriteLine("FAIL self-copy"); + returnVal = -1; + } + + TestStruct t2 = new TestStruct(); + Guid newGuid = Guid.NewGuid(); + t2.Guid1 = newGuid; + t2.Guid2 = newGuid; + + if (t2.Guid1 != t2.Guid2) + { + Console.WriteLine("FAIL other-copy"); + returnVal = -1; + } + + return returnVal; + } + } +} diff --git a/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj b/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj new file mode 100644 index 000000000000..cb869c3a8825 --- /dev/null +++ b/tests/src/JIT/Methodical/structs/ExplicitLayout.csproj @@ -0,0 +1,36 @@ + + + + + Debug + AnyCPU + 2.0 + {0B8F1AF4-9355-4307-BC68-08A2947AD3B9} + Exe + true + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + 1 + + + + + + PdbOnly + True + + + + False + + + + + + + + + + + diff --git a/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs b/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs index 60684f65df21..1d2bdaf88b6a 100644 --- a/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs +++ b/tests/src/JIT/Performance/CodeQuality/Layout/SearchLoops.cs @@ -47,13 +47,13 @@ public SearchLoops() } [Benchmark(InnerIterationCount = 20000000)] - public void LoopReturn() + public void LoopReturnIter() { Benchmark.Iterate(() => LoopReturn(test1, test2)); } [Benchmark(InnerIterationCount = 20000000)] - public void LoopGoto() + public void LoopGotoIter() { Benchmark.Iterate(() => LoopGoto(test1, test2)); } diff --git a/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs b/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs index bfa1f43a5ff1..ed7ec6157ea8 100644 --- a/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs +++ b/tests/src/JIT/Performance/CodeQuality/SIMD/SeekUnroll/SeekUnroll.cs @@ -127,7 +127,7 @@ static bool Test(int index, bool isXunitBenchmark) // Entrypoint for xunit-perf to call the benchmark [Benchmark] [MemberData(nameof(ArrayedBoxedIndicesToTest))] - public static bool Test(object boxedIndex) + public static bool TestWithXunit(object boxedIndex) { return Test((int)boxedIndex, true); } diff --git a/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b152292/b152292.cs b/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b152292/b152292.cs index 1b816ce7e231..f430833fedad 100644 --- a/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b152292/b152292.cs +++ b/tests/src/JIT/Regression/CLR-x86-JIT/v2.1/b152292/b152292.cs @@ -4,11 +4,11 @@ // /* - On windows the address range from 0 - 64 kb is protected + On windows the address range from 0 - 64 kb is protected by the os, if code tries to access it, an access violation is triggered, which is translated into a NullReferenceException by the runtime. If the offset to the field of the class is above - 32 KB, we add some addtional code that checks for null accesses. The address range on mac is - much smaller, 0-4 KB, and if the field offset is above 2 KB we are adding this additional code again. + 32 KB, we add some additional code that checks for null accesses. The address range on mac is + much smaller, 0-4 KB, and if the field offset is above 2 KB we are adding this additional code again. */ using System; diff --git a/tests/src/JIT/Regression/Dev11/External/dev11_239804/ShowLocallocAlignment.cs b/tests/src/JIT/Regression/Dev11/External/dev11_239804/ShowLocallocAlignment.cs index 74ea313f293b..1eef50e931df 100644 --- a/tests/src/JIT/Regression/Dev11/External/dev11_239804/ShowLocallocAlignment.cs +++ b/tests/src/JIT/Regression/Dev11/External/dev11_239804/ShowLocallocAlignment.cs @@ -2,8 +2,17 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +// Check that localloc return properly aligned memory. +// The JIT guarantees that the localloc return value is at least as aligned as the platform stack alignment, which is: +// x86 Windows: 4 bytes +// x86 Linux: 16 bytes +// x64: 16 bytes +// arm32: 8 bytes +// arm64: 16 bytes + using System; using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; namespace ShowLocallocAlignment { @@ -37,28 +46,41 @@ private unsafe static int RunAlignmentCheckScenario() { UInt64 address1; UInt64 address2; + UInt64 required_alignment; bool fAligned1; bool fAligned2; void* ptr1; void* ptr2; + required_alignment = 16; // Default to the biggest alignment required + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && (RuntimeInformation.ProcessArchitecture == Architecture.X86)) + { + required_alignment = 4; + } + else if (RuntimeInformation.ProcessArchitecture == Architecture.Arm) + { + required_alignment = 8; + } + ptr1 = App.SnapLocallocBufferAddress1(1, 2, 3, 4, 5, 6); ptr2 = App.SnapLocallocBufferAddress2(1, 2, 3, 4, 5, 6); address1 = unchecked((UInt64)(new IntPtr(ptr1)).ToInt64()); address2 = unchecked((UInt64)(new IntPtr(ptr2)).ToInt64()); - fAligned1 = ((address1 % 8) == 0); - fAligned2 = ((address2 % 8) == 0); + fAligned1 = ((address1 % required_alignment) == 0); + fAligned2 = ((address2 % required_alignment) == 0); Console.Write( "\r\n" + "Address1: {0} ({1:x16})\r\n" + "Address2: {2} ({3:x16})\r\n" + + "Required alignment: {4}\r\n" + "\r\n", (fAligned1 ? "Aligned" : "Misaligned"), address1, - (fAligned2 ? "Aligned" : "Misaligned"), address2 + (fAligned2 ? "Aligned" : "Misaligned"), address2, + required_alignment ); if (fAligned1 && fAligned2) diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.cs new file mode 100644 index 000000000000..190d2d371b70 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.cs @@ -0,0 +1,22 @@ +// 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; + +class C0 +{ + public sbyte F; +} + +public class Program +{ + public static int Main() + { + C0 var0 = new C0 { F = -1 }; + // The JIT was giving (byte)var0.F the same value number as the -1 assigned + // above, which was causing the OR below to be discarded. + ulong var1 = (ulong)(1000 | (byte)var0.F); + return var1 == 1023 ? 100 : 0; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.csproj new file mode 100644 index 000000000000..ecc6def53e5a --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_1.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.cs new file mode 100644 index 000000000000..d3280d942727 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.cs @@ -0,0 +1,28 @@ +// 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. + +struct S0 +{ + public uint F0; + public byte F2; + public int F3; + public sbyte F5; + public long F8; +} + +public class Program +{ + static uint s_0; + public static int Main() + { + S0 vr3 = new S0(); + vr3.F0 = 0x10001; + // The JIT was giving the RHS below the same value-number as + // 0x10001 above, which was then constant propagated to + // usages of vr4, even though it should be narrowed. + uint vr4 = (ushort)vr3.F0; + s_0 = vr4; + return vr4 == 1 ? 100 : 0; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.csproj new file mode 100644 index 000000000000..ecc6def53e5a --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18235/GitHub_18235_2.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.cs new file mode 100644 index 000000000000..ac8e21b6f975 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.cs @@ -0,0 +1,141 @@ +// 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; + +// Regression tests for bugs in fgMorphCast and optNarrowTree. + +struct S0 +{ + public byte F0; + public sbyte F1; + public sbyte F2; + public S0 (byte f0, sbyte f1, sbyte f2) + { + F0 = f0; + F1 = f1; + F2 = f2; + } +} + +struct S1 +{ + public bool F0; + public short F1; + public S1 (short f1) : this () + { + F1 = f1; + F0 = true; + } +} + +static class GitHub_18238 +{ + static int Main() + { + bool passed = true; + + ulong result1 = Test1.Run(); + ulong expectedResult1 = 64537; + if (result1 != expectedResult1) + { + passed = false; + Console.WriteLine(String.Format("Failed Test1: expected = {0}, actual = {1}", expectedResult1, result1)); + } + + S0 vr45 = new S0(0, 0, 0); + int result2 = Test2.Run(vr45); + int expectedResult2 = 65487; + if (result2 != expectedResult2) { + passed = false; + Console.WriteLine(String.Format("Failed Test2: expected = {0}, actual = {1}", expectedResult2, result2)); + } + + int result3 = Test3.Run(); + int expectedResult3 = 65535; + if (result3 != expectedResult3) { + passed = false; + Console.WriteLine(String.Format("Failed Test3: expected = {0}, actual = {1}", expectedResult3, result3)); + } + + uint result4 = Test4.Run (); + uint expectedResult4 = 32779; + if (result4 != expectedResult4) { + passed = false; + Console.WriteLine (String.Format ("Failed Test4: expected = {0}, actual = {1}", expectedResult4, result4)); + } + + if (passed) + { + Console.WriteLine("PASSED"); + return 100; + } + else + { + Console.WriteLine("FAILED"); + return -1; + } + } +} + +static class Test1 +{ + static short s_2 = -1000; + + [MethodImpl(MethodImplOptions.NoInlining)] + public static ulong Run() + { + ulong var1 = (ushort)(1U ^ s_2); + return var1; + } +} + +static class Test2 +{ + static bool [] [] s_9 = new bool [] [] { new bool [] { true } }; + + [MethodImpl (MethodImplOptions.NoInlining)] + public static int Run(S0 arg1) + { + arg1 = new S0 (0, -50, 0); + char var0 = (char)(1U ^ arg1.F1); + return s_9 [0] [0] ? (int)var0 : 0; + } +} + +static class Test3 +{ + static int s_1 = 0xff; + + [MethodImpl (MethodImplOptions.NoInlining)] + public static int Run() + { + int vr14 = (ushort)(sbyte)s_1; + return (vr14); + } +} + +static class Test4 +{ + static S1 s_1; + + [MethodImpl (MethodImplOptions.NoInlining)] + public static uint Run() + { + char var0 = default(char); + s_1 = new S1(-32767); + var vr6 = s_1.F0; + uint result = Run1(var0, 0, (ushort)(10L | s_1.F1), vr6, s_1.F1); + return result; + } + + + [MethodImpl (MethodImplOptions.NoInlining)] + static uint Run1(char arg0, long arg1, uint arg2, bool arg3, short arg4) + { + return arg2; + } +} + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.csproj new file mode 100644 index 000000000000..e191e01217e9 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18238/GitHub_18238.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.il b/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.il new file mode 100644 index 000000000000..d7f1752467e3 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.il @@ -0,0 +1,189 @@ +// 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 test showed an error in `Compiler::optVNConstantPropOnJTrue`, that +// tried to remove the same tree twice. `IL_0083: brtrue` has known value +// and its side effects is extracted in a separate statement that is placed +// before the jump, but if this statement has unconditional throw call, then +// it tries to remove the jump during its optimization. + +.assembly extern System.Runtime +{ +} +.assembly extern System.Runtime.Extensions +{ +} +.assembly GitHub_18291 +{ +} + +.class private auto ansi beforefieldinit GitHub_18291 + extends [System.Runtime]System.Object +{ + .method static uint16 ILGEN_METHOD(native unsigned int, int8, native int) + { + .maxstack 339 + .locals init (char, float64) + IL_0000: ldc.i8 0xfd32d272ad594ff4 + IL_0009: ldc.i8 0x64c364b9c2b819ca + IL_0012: rem + IL_0013: pop + IL_0014: ldc.i8 0x1917394023ae4269 + IL_001d: ldc.i8 0x81bdec3ee0298c86 + IL_0026: ldc.i8 0xa89686c29dae8e55 + IL_002f: add.ovf.un + IL_0030: sub + IL_0031: conv.r8 + IL_0032: ldc.r8 float64(0xfb02a0dfac22a4d8) + IL_003b: pop + IL_003c: neg + IL_003d: ckfinite + IL_003e: neg + IL_003f: ldc.i8 0x8e6b6f2945ce019e + IL_0048: conv.r8 + IL_0049: pop + IL_004a: ldloc.s 0x01 + IL_004c: ldloc 0x0001 + IL_0050: mul + IL_0051: clt.un + IL_0053: ldc.i8 0xfc97bfa772027108 + IL_005c: ldc.i8 0x233cd8b922d142f1 + IL_0065: clt.un + IL_0067: ldloc 0x0001 + IL_006b: ldc.r8 float64(0x895c435fe82a3459) + IL_0074: cgt.un + IL_0076: ldloc 0x0001 + IL_007a: ldloc.s 0x01 + IL_007c: clt.un + IL_007e: cgt + IL_0080: shr.un + IL_0081: mul + IL_0082: not + IL_0083: brtrue + IL_00f7 + IL_0088: ldc.i8 0xb04a6130e573d9b7 + IL_0091: ldc.i8 0x30abe634c9c86493 + IL_009a: div.un + IL_009b: ldc.i8 0x3e2e26d76c796837 + IL_00a4: ldc.i8 0x80df80b810563352 + IL_00ad: cgt + IL_00af: ldarg 0x0000 + IL_00b3: ldloc.s 0x01 + IL_00b5: ldloc 0x0001 + IL_00b9: clt.un + IL_00bb: xor + IL_00bc: shr + IL_00bd: conv.i2 + IL_00be: shr + IL_00bf: not + IL_00c0: ldc.i8 0xc4b53aec3c888995 + IL_00c9: ldc.i8 0xa56d8ec44e7a1509 + IL_00d2: ceq + IL_00d4: neg + IL_00d5: ldc.i8 0x327f25ebf903a46f + IL_00de: conv.ovf.u4 + IL_00df: neg + IL_00e0: ldarg.s 0x01 + IL_00e2: not + IL_00e3: ldarg.s 0x00 + IL_00e5: shr.un + IL_00e6: sub.ovf.un + IL_00e7: mul.ovf.un + IL_00e8: conv.ovf.i8.un + IL_00e9: add.ovf.un + IL_00ea: nop + IL_00eb: ldc.i8 0x76e238de4bd30317 + IL_00f4: div + IL_00f5: conv.r.un + IL_00f6: pop + IL_00f7: ldarg.s 0x00 + IL_00f9: conv.ovf.u1.un + IL_00fa: ldarg.s 0x02 + IL_00fc: ldc.r8 float64(0x2987021098838673) + IL_0105: conv.ovf.u1.un + IL_0106: shl + IL_0107: not + IL_0108: ceq + IL_010a: ldc.i4 0x280ab454 + IL_010f: conv.ovf.i2.un + IL_0110: ldc.i8 0x92a914fa3ddce305 + IL_0119: ldc.i8 0xc0bc06b564a01c98 + IL_0122: and + IL_0123: not + IL_0124: ldloc.s 0x01 + IL_0126: ckfinite + IL_0127: conv.ovf.u8 + IL_0128: cgt + IL_012a: shl + IL_012b: conv.r.un + IL_012c: conv.r8 + IL_012d: ckfinite + IL_012e: conv.r.un + IL_012f: ldc.r8 float64(0x0274f44dfcbb9658) + IL_0138: ldloc 0x0001 + IL_013c: rem + IL_013d: neg + IL_013e: clt + IL_0140: ldarg 0x0001 + IL_0144: neg + IL_0145: ldc.i8 0x576c1f39a5a88241 + IL_014e: conv.u1 + IL_014f: and + IL_0150: pop + IL_0151: shr.un + IL_0152: ret + } + + + .method private hidebysig static int32 + Main(string[] args) cil managed + { + .entrypoint + // Code size 27 (0x1b) + .maxstack 3 + .locals init (int32 V_0) + IL_0000: nop + .try + { + IL_0001: nop + IL_0002: ldc.i4.0 + IL_0003: ldc.i4.2 + IL_0004: ldc.i4.3 + IL_0005: call uint16 GitHub_18291::ILGEN_METHOD(native unsigned int, + int8, + native int) + IL_000a: pop + IL_000b: nop + IL_000c: leave.s IL_0015 + + } // end .try + catch [System.Runtime]System.Object + { + IL_000e: pop + IL_000f: nop + IL_0010: ldc.i4.s 100 + IL_0012: stloc.0 + IL_0013: leave.s IL_0019 + + } // end handler + IL_0015: ldc.i4.m1 + IL_0016: stloc.0 + IL_0017: br.s IL_0019 + + IL_0019: ldloc.0 + IL_001a: ret + } // end of method Program::Main + + .method public hidebysig specialname rtspecialname + instance void .ctor() cil managed + { + // Code size 8 (0x8) + .maxstack 8 + IL_0000: ldarg.0 + IL_0001: call instance void [System.Runtime]System.Object::.ctor() + IL_0006: nop + IL_0007: ret + } // end of method Program::.ctor + +} // end of class GitHub_18291 \ No newline at end of file diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.ilproj b/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.ilproj new file mode 100644 index 000000000000..11ee89b9db09 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18291/GitHub_18291.ilproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.il b/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.il new file mode 100644 index 000000000000..fc17cf3d05ea --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.il @@ -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. + +.assembly extern mscorlib { auto } +.assembly extern System.Console {auto} +.assembly UnusedValueBug { } + +// This bug was found on desktop CLR using ILGEN. +// The expression ending in the 'mul' below is all dead, but not all the dead code +// gets eliminated. On ARM, there is a SETCC resulting from the first 'cgt' that remains, +// and it is marked as an 'UnusedValue', but the BuildSimple method wasn't creating a def +// for an unused value. This led to an assert in the code generator. +// +.class private auto ansi beforefieldinit GitHub_18295 + extends [mscorlib]System.Object +{ + .method private hidebysig static int32 Test(int64 l, int32 i) cil managed + { + .locals init ([0] int32 loc6, + [1] float32 loc8) + + ldloc 0 + ldloc 1 + conv.ovf.i8.un + ldarg 0 + not + cgt + cgt.un + ldloc 0 + nop + not + not + mul + ret + } + + .method private hidebysig static int32 Main() cil managed + { + .entrypoint + .vtentry 11 : 1 + // Code size 131 (0x83) + .maxstack 4 + .locals ([0] int32 returnVal) + + // returnVal = 100; + ldc.i4.s 100 + stloc returnVal + + // if (Test(1,1) != 1) goto F1 + ldc.i4 1 + ldc.i8 1 + call int32 GitHub_18295::Test(int64, int32) + + ldc.i4.0 + beq.s L2 + + F1: + // Console.WriteLine("FAIL"); + ldstr "FAIL" + call void [System.Console]System.Console::WriteLine(string) + // returnVal = -1; + ldc.i4.m1 + stloc returnVal + br L3 + + L2: + // Console.WriteLine("PASS"); + ldstr "PASS" + call void [System.Console]System.Console::WriteLine(string) + + L3: + ldloc returnVal + ret + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.ilproj b/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.ilproj new file mode 100644 index 000000000000..5934cf63ac17 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18295/GitHub_18295.ilproj @@ -0,0 +1,23 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + ..\..\ + + + + + None + True + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs new file mode 100644 index 000000000000..695ca20981a5 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.cs @@ -0,0 +1,112 @@ +// 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; + +// This is a struct that will be passed as a split struct +struct S +{ + public double d1; + public double d2; +}; + +static class GitHub_18362 +{ + private static bool AreSameInfinity(double d1, double d2) + { + return + double.IsNegativeInfinity(d1) == double.IsNegativeInfinity(d2) && + double.IsPositiveInfinity(d1) == double.IsPositiveInfinity(d2); + } + + private static bool IsDiffTolerable(double d1, double d2) + { + if (double.IsInfinity(d1)) + { + return AreSameInfinity(d1, d2 * 10); + } + if (double.IsInfinity(d2)) + { + return AreSameInfinity(d1 * 10, d2); + } + double diffRatio = (d1 - d2) / d1; + diffRatio *= Math.Pow(10, 6); + return Math.Abs(diffRatio) < 1; + } + + private static void VerifyRealImaginaryProperties(Complex complex, double real, double imaginary, [CallerLineNumber] int lineNumber = 0) + { + if (!real.Equals(complex.Real) && !IsDiffTolerable(complex.Real, real)) + { + Console.WriteLine("Failure at line {0}. Expected real: {1}. Actual real: {2}", lineNumber, real, complex.Real); + throw new Exception(); + } + if (!imaginary.Equals(complex.Imaginary) && !IsDiffTolerable(complex.Imaginary, imaginary)) + { + Console.WriteLine("Failure at line {0}. Expected imaginary: {1}. Actual imaginary: {2}", lineNumber, imaginary, complex.Imaginary); + throw new Exception(); + } + } + + + private static void VerifyMagnitudePhaseProperties(Complex complex, double magnitude, double phase, [CallerLineNumber] int lineNumber = 0) + { + // The magnitude (m) of a complex number (z = x + yi) is the absolute value - |z| = sqrt(x^2 + y^2) + // Verification is done using the square of the magnitude since m^2 = x^2 + y^2 + double expectedMagnitudeSquared = magnitude * magnitude; + double actualMagnitudeSquared = complex.Magnitude * complex.Magnitude; + + if (!expectedMagnitudeSquared.Equals(actualMagnitudeSquared) && !IsDiffTolerable(actualMagnitudeSquared, expectedMagnitudeSquared)) + { + Console.WriteLine("Failure at line {0}. Expected magnitude squared: {1}. Actual magnitude squared: {2}", lineNumber, expectedMagnitudeSquared, actualMagnitudeSquared); + throw new Exception(); + } + + if (double.IsNaN(magnitude)) + { + phase = double.NaN; + } + else if (magnitude == 0) + { + phase = 0; + } + else if (magnitude < 0) + { + phase += (phase < 0) ? Math.PI : -Math.PI; + } + + if (!phase.Equals(complex.Phase) && !IsDiffTolerable(complex.Phase, phase)) + { + Console.WriteLine("Failure at line {0}. Expected phase: {1}. Actual phase: {2}", lineNumber, phase, complex.Phase); + throw new Exception(); + } + } + + public static void Conjugate(double real, double imaginary) + { + int returnVal = 100; + + var complex = new Complex(real, imaginary); + Complex result = Complex.Conjugate(complex); + + VerifyRealImaginaryProperties(result, real, -imaginary); + VerifyMagnitudePhaseProperties(result, complex.Magnitude, -complex.Phase); + } + + [MethodImpl(MethodImplOptions.NoOptimization)] + static int Main() + { + try + { + Conjugate(2.0, 3.0); + } + catch (Exception e) + { + return -1; + } + return 100; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj new file mode 100644 index 000000000000..ea8e8a7e429f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18362/GitHub_18362.csproj @@ -0,0 +1,45 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + True + + + + + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.cs new file mode 100644 index 000000000000..6b0399dd6e37 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.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. + +using System; +using System.Reflection; +using System.Threading; +using System.Runtime.CompilerServices; + +class MetadataReader +{ + [MethodImpl(MethodImplOptions.NoInlining)] + public Method GetMethod(MethodHandle handle) + { + return new Method(this, handle, MethodAttributes.Abstract); + } + +} + +struct Handle +{ + int _value; + + public MethodHandle ToMethodHandle(MetadataReader reader) + { + return new MethodHandle(this); + } + + public int GetValue() + { + return _value; + } +} + +static class MetadataReaderExtensions +{ + public static unsafe Handle AsHandle(this int token) + { + return *(Handle*)&token; + } +} + +struct MethodHandle +{ + internal int _value; + + [MethodImpl(MethodImplOptions.NoInlining)] + internal MethodHandle(Handle value) + { + _value = value.GetValue(); + } + + public Method GetMethod(MetadataReader reader) + { + return reader.GetMethod(this); + } +} + +struct Method +{ + internal MetadataReader _reader; + internal MethodHandle _handle; + internal MethodAttributes _flags; + + public Method(MetadataReader r, MethodHandle h, MethodAttributes f) + { + _reader = r; + _handle = h; + _flags = f; + } + + public MethodAttributes Flags => _flags; +} + +struct QMethodDefinition +{ + private QMethodDefinition(MetadataReader reader, int token) + { + _reader = reader; + _handle = token; + } + + public static QMethodDefinition FromObjectAndInt(MetadataReader reader, int token) + { + return new QMethodDefinition(reader, token); + } + + public MetadataReader Reader { get { return _reader; } } + public int Token { get { return _handle; } } + + public bool IsValid { get { return _reader == null; } } + + private readonly MetadataReader _reader; + private readonly int _handle; + + public MetadataReader NativeFormatReader { get { return _reader; } } + public MethodHandle NativeFormatHandle { get { return _handle.AsHandle().ToMethodHandle(NativeFormatReader); } } +} + +class GitHub_18408 +{ + [MethodImpl(MethodImplOptions.NoInlining)] + static object foo(QMethodDefinition methodHandle) + { + Method method = methodHandle.NativeFormatHandle.GetMethod(methodHandle.NativeFormatReader); + return (method.Flags != (MethodAttributes)0) ? new object() : null; + } + + public static int Main(string[] args) + { + MetadataReader r = new MetadataReader(); + + if (foo(QMethodDefinition.FromObjectAndInt(r, 1)) == null) + { + Console.WriteLine("FAIL"); + return -1; + } + + Console.WriteLine("PASS"); + return 100; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.csproj new file mode 100644 index 000000000000..0b9fa76d893f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18408/GitHub_18408.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.cs new file mode 100644 index 000000000000..fc7f62d3a3f9 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.cs @@ -0,0 +1,41 @@ +// 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 struct SequentialStruct +{ + public short f0; + public int f1; + public float f2; + public IntPtr f3; +} + +class Test +{ + [MethodImpl(MethodImplOptions.NoInlining)] + static int foo(SequentialStruct s) + { + if ((s.f0 != 100) || (s.f1 != 1) || ((int) s.f2 != 10) || ((int)s.f3 != 42)) + { + Console.WriteLine(s.f0); + Console.WriteLine(s.f1); + Console.WriteLine(s.f2); + Console.WriteLine(s.f3); + return -1; + } + return 100; + } + + static int Main() + { + SequentialStruct ss = new SequentialStruct(); + ss.f0 = 100; + ss.f1 = 1; + ss.f2 = 10.0f; + ss.f3 = new IntPtr(42); + return foo(ss); + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.csproj new file mode 100644 index 000000000000..0b9fa76d893f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18482/GitHub_18482.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.cs new file mode 100644 index 000000000000..c4359584f919 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.cs @@ -0,0 +1,53 @@ +// 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; + +struct S +{ + public Vector v1; + public Vector v2; +}; + +static class GitHub_18497 +{ + static S sStatic; + + [MethodImpl(MethodImplOptions.NoInlining)] + static Vector Sum(S s) + { + return s.v1 + s.v2; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static Vector Test() + { + S sLocal = sStatic; + return Sum(sLocal); + } + + static int Main() + { + bool pass = true; + sStatic.v1 = new Vector(0.0F); + sStatic.v2 = new Vector(1.0F); + Vector v = Test(); + + for (int i = 0; i < Vector.Count; i++) + { + if (Math.Abs((double)(v[i] - 1.0F)) > (double)Single.Epsilon) + { + pass = false; + } + } + if (!pass) + { + Console.WriteLine("Failed: v = " + v.ToString()); + return -1; + } + return 100; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.csproj new file mode 100644 index 000000000000..0b9fa76d893f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18497/GitHub_18497.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.cs new file mode 100644 index 000000000000..8cbcc6e5b8b1 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.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; + +// Based on a program generated by Fuzzlyn + +struct S0 +{ + public ushort F0; +} + +struct S1 +{ + public S0 F0; + public ushort F1; +} + +public class GitHub_18522 +{ + static S1 s_36; + + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M113, and so + // inadvertently overwriting the F1 field of s_36 on return from + // the (inlined) call. + public static int Main() + { + s_36.F1 = 0xAA; + s_36.F0 = M113(); + return (s_36.F1 == 0xAA ? 100 : 0); + } + + static S0 M113() + { + return new S0(); + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.cs new file mode 100644 index 000000000000..a5726451fb6c --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.cs @@ -0,0 +1,52 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_1 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the (inlined) call. + s_13[0].F3 = M16(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 M16() + { + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_1.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.cs new file mode 100644 index 000000000000..ab4090d0d369 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.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.CompilerServices; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_2 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the (not inlined) call. + s_13[0].F3 = M16(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static S0 M16() + { + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_2.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.cs new file mode 100644 index 000000000000..9d6960cfcb76 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.cs @@ -0,0 +1,66 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_3 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call (which was an inline candidate, but not inlined). + s_13[0].F3 = M16(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 M16() + { + // This bit of code is intended to allow M16 to be an + // inline candidate that ultimately does not get inlined. + short x = 0; + for (int i = 0; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + x++; + } + } + s_6.F0 = x; + + // Actual interesting part + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_3.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.cs new file mode 100644 index 000000000000..b6f54dc61507 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.cs @@ -0,0 +1,62 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_4 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call. + // + // Here we make sure we properly handle an inline call that + // resolves to a noinline call. + s_13[0].F3 = W(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 W() + { + return M16(); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static S0 M16() + { + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_4.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.cs new file mode 100644 index 000000000000..fdb2a72dc9ca --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.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.CompilerServices; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_5 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call. + // + // Here we make sure we properly handle an inlined call that + // resolves to a rejected inline candidate. + s_13[0].F3 = W(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 W() + { + return M16(); + } + + static S0 M16() + { + // This bit of code is intended to allow M16 to be an + // inline candidate that ultimately does not get inlined. + short x = 0; + for (int i = 0; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + x++; + } + } + s_6.F0 = x; + + // Actual interesting part + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_5.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.cs new file mode 100644 index 000000000000..5a3990f509ae --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.cs @@ -0,0 +1,61 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +struct S0 +{ + public sbyte F0; + public char F1; + public ushort F2; +} + +struct S1 +{ + public short F0; + public S0 F1; + public S0 F2; + public S0 F3; + public int F4; + public S1(int f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_6 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call. + // + // Here we make sure we properly handle an inlined call that + // resolves to another inlined call. + s_13[0].F3 = W(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 W() + { + return M16(); + } + + static S0 M16() + { + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_6.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.cs new file mode 100644 index 000000000000..e59d3ded8b19 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.cs @@ -0,0 +1,67 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +// Similar to other variants but using a 3 byte struct instead of 6. + +struct S0 +{ + public byte F0; + public byte F1; + public byte F2; +} + +struct S1 +{ + public S0 F3; + public sbyte F4; + public short F0; + public S1(sbyte f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_7 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call. + // + // Here we make sure we properly handle the failed inline case. + s_13[0].F3 = M16(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 M16() + { + // This bit of code is intended to allow M16 to be an + // inline candidate that ultimately does not get inlined. + short x = 0; + for (int i = 0; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + x++; + } + } + s_6.F0 = x; + + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_7.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.cs new file mode 100644 index 000000000000..9bd91be9125e --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.cs @@ -0,0 +1,65 @@ +// 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; + +// Based on +// Original generated by Fuzzlyn on 2018-06-20 00:58:58 +// Seed: 11049252875418439527 +// Reduced from 97.5 KiB to 0.5 KiB +// Debug: Outputs -1 +// Release: Outputs -65536 + +// Similar to other variants but using an empty (~ 1 byte) struct +// (which oddly enough currently is returned by ref) + +struct S0 +{ +} + +struct S1 +{ + public S0 F3; + public sbyte F4; + public short F0; + public S1(sbyte f4): this() + { + F4 = f4; + } +} + +public class GitHub_18522_8 +{ + static S1 s_6; + static S1[] s_13 = new S1[]{new S1(-1)}; + public static int Main() + { + // When generating code for the x64 SysV ABI, the jit was + // incorrectly typing the return type from M16, and so + // inadvertently overwriting the F4 field of s_13[0] on return + // from the call. + // + // Here we make sure we properly handle the failed inline case. + s_13[0].F3 = M16(); + return s_13[0].F4 == -1 ? 100 : 0; + } + + static S0 M16() + { + // This bit of code is intended to allow M16 to be an + // inline candidate that ultimately does not get inlined. + short x = 0; + for (int i = 0; i < 10; i++) + { + for (int j = 0; j < 10; j++) + { + x++; + } + } + s_6.F0 = x; + + return s_6.F3; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18522/GitHub_18522_8.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.cs new file mode 100644 index 000000000000..1833fe5c3234 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.cs @@ -0,0 +1,46 @@ +// 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.Runtime.CompilerServices; + +public class GitHub_18780 +{ + public static int Main() + { + bool ok = true; + ok &= M1(0); + ok &= M2(); + ok &= M3(); + return ok ? 100 : -1; + } + + // The multiplication by uint.MaxValue was optimized to a NEG + // which was typed as the second operand, giving a byte NEG node. + // With x86/ARM32 RyuJIT the cast to ulong would then treat vr13 + // as a byte instead of a uint and zero extend from 8 bits. + [MethodImpl(MethodImplOptions.NoInlining)] + static bool M1(byte arg2) + { + byte vr23 = arg2++; + return (ulong)(uint.MaxValue * arg2) == uint.MaxValue; + } + + // Like above, the -1 multiplication was turned into a byte NEG node. + // The byte cast was then removed, but since the NEG byte node still + // produces a wide result this meant (byte)val was -1. + static byte s_1 = 1; + [MethodImpl(MethodImplOptions.NoInlining)] + static bool M2() + { + return (byte)(-1 * s_1) == 255; + } + + // Exactly the same as above, but this tests the optimization for + // transforming (0 - expr) into -expr. + [MethodImpl(MethodImplOptions.NoInlining)] + static bool M3() + { + return (byte)(0 - s_1) == 255; + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18780/GitHub_18780.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs new file mode 100644 index 000000000000..1cd9085bbe35 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.cs @@ -0,0 +1,82 @@ +// 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. + +// This bug had to do with the handling (reserving and killing) of RCX +// for variable shift operations on X64. + +using System; +using System.Collections.Specialized; +using System.Runtime.CompilerServices; + +static class GitHub_18884 +{ + static ushort s_3; + static long s_5; + static int returnVal = 100; + + public static int Main() + { + s_3 = 0; // avoid runtime checks in M15 + ReproWindows(0, 0, 1, 0); + ReproUx(0, 0, 1, 0); + Set_Mask_AllTest(); + return returnVal; + } + + static void ReproWindows(byte arg0, long arg1, ushort arg2, ulong arg3) + { + s_5 >>= 50 / arg2; // the value shifted by here + if (arg0 != 0) + { + s_3 = s_3; + } + + // Is in arg0 here + if (arg0 != 0) + { + Console.WriteLine("FAIL: ReproWindows"); + returnVal = -1; + } + } + static void ReproUx(ulong arg0, long arg1, ushort arg2, byte arg3) + { + s_5 >>= 50 / arg2; // the value shifted by here + if (arg3 != 0) + { + s_3 = s_3; + } + + // Is in arg3 here + if (arg3 != 0) + { + Console.WriteLine("FAIL: ReproUx"); + returnVal = -1; + } + } + [MethodImpl(MethodImplOptions.NoInlining)] + public static void CheckValue(int value, int expectedValue) + { + if (value != expectedValue) + { + returnVal = -1; + Console.WriteLine("FAIL: Set_Mask_AllTest"); + } + } + + // While fixing the above failures, this test (from corefx) failed. + public static void Set_Mask_AllTest() + { + BitVector32 flip = new BitVector32(); + int mask = 0; + for (int bit = 1; bit < 32 + 1; bit++) + { + mask = BitVector32.CreateMask(mask); + BitVector32 single = new BitVector32(); + single[mask] = true; + + // The bug was exposed by passing the result of a shift in RCX on x64/ux. + CheckValue(1 << (bit - 1), single.Data); + } + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj new file mode 100644 index 000000000000..ea8e8a7e429f --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18884/GitHub_18884.csproj @@ -0,0 +1,45 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + True + + + + + + + + + + + + + + diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.cs b/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.cs new file mode 100644 index 000000000000..c51de26735b7 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.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. + +using System; +using System.Threading; +using System.Runtime.CompilerServices; + +internal class BufferState +{ + internal const int Idle = 0; + internal const int InUse = 1; + + private int currentState; + + internal BufferState() + { + this.currentState = Idle; + } + + internal bool IsIdle + { + get { return this.currentState == Idle; } + } + + internal bool EnterInUseState() + { + return this.TransitionState(Idle, InUse); + } + + internal bool EnterIdleState() + { + return this.TransitionState(InUse, Idle); + } + + private bool TransitionState(int expectedCurrentState, int desiredState) + { + if (Interlocked.CompareExchange(ref this.currentState, + desiredState, + expectedCurrentState) == expectedCurrentState) + { + return true; + } + + return false; + } +} + +class Program +{ + bool forceUpload; + BufferState currentState; + + Program() + { + this.forceUpload = false; + this.currentState = new BufferState(); + while(!this.currentState.EnterInUseState()) + { + Console.WriteLine("Failed to enterInUseState"); + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public void ThrowIfDisposed() + { + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public void QueueCurrentBufferForUploadAndSetNewBuffer() + { + } + + public void Test() + { + this.ThrowIfDisposed(); + + try + { + if (forceUpload == true) + { + // Queue the buffer for upload. + this.QueueCurrentBufferForUploadAndSetNewBuffer(); + } + } + finally + { + // Always transition back to the idle state. + this.currentState.EnterIdleState(); + } + } + + public static int Main() + { + Program p = new Program(); + if (p.currentState.IsIdle) + { + Console.WriteLine("Failed! - 102"); + return 102; + } + + p.Test(); + + if (p.currentState.IsIdle) + { + Console.WriteLine("Passed!"); + return 100; + } + else + { + Console.WriteLine("Failed! - 101"); + return 101; + } + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.csproj new file mode 100644 index 000000000000..95aba995a255 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_18887/GitHub_18887.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + + False + + + + + True + + + + + + + + + + diff --git a/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj b/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj index 563a9a708704..881d84ff55c0 100644 --- a/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj +++ b/tests/src/JIT/config/benchmark+roslyn/benchmark+roslyn.csproj @@ -82,8 +82,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj b/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj index d554c165f6b4..d2789e5957ad 100644 --- a/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj +++ b/tests/src/JIT/config/benchmark+serialize/benchmark+serialize.csproj @@ -79,8 +79,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/tests/src/JIT/config/benchmark/benchmark.csproj b/tests/src/JIT/config/benchmark/benchmark.csproj index 4d49fdee3ead..aecfdec2773e 100644 --- a/tests/src/JIT/config/benchmark/benchmark.csproj +++ b/tests/src/JIT/config/benchmark/benchmark.csproj @@ -97,8 +97,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/tests/src/JIT/jit64/opt/cse/HugeArray.csproj b/tests/src/JIT/jit64/opt/cse/HugeArray.csproj index a3709f8d0e98..23bf8eba4660 100644 --- a/tests/src/JIT/jit64/opt/cse/HugeArray.csproj +++ b/tests/src/JIT/jit64/opt/cse/HugeArray.csproj @@ -11,7 +11,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ - true + true 1 @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/JIT/opt/Structs/structpop.cs b/tests/src/JIT/opt/Structs/structpop.cs new file mode 100644 index 000000000000..7244d1f913de --- /dev/null +++ b/tests/src/JIT/opt/Structs/structpop.cs @@ -0,0 +1,83 @@ +// 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. + +// Optimization of pop with struct types +// Codegen for TestByRef and TestByPtr should be similar +// +// See CoreClr#18710 + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[StructLayout(LayoutKind.Sequential)] +struct VT +{ + public static readonly int Size = Marshal.SizeOf(); + + public int F1, F2, F3; + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Get(out int v1, out int v2, out int v3) + { + v1 = F1; + v2 = F2; + v3 = F3; + } +} + +class P +{ + [MethodImpl(MethodImplOptions.NoInlining)] + unsafe static int TestMethodInlining(VT* pVT) + { + int v1, v2, v3; + pVT->Get(out v1, out v2, out v3); + return Do(v1, v2); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static int TestByRef(ref VT VTRef) + { + int v1, v2, v3; + v1 = VTRef.F1; + v2 = VTRef.F2; + v3 = VTRef.F3; + return Do(v1, v2); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + unsafe static int TestByPtr(VT* pVT) + { + int v1, v2, v3; + v1 = pVT->F1; + v2 = pVT->F2; + v3 = pVT->F3; + return Do(v1, v2); + } + + unsafe static int Main(string[] args) + { + byte* pDataBytes = stackalloc byte[VT.Size]; + VT* pVT = (VT*)pDataBytes; + pVT->F1 = 44; + pVT->F2 = 56; + pVT->F3 = 3; + + int result = -200; + result += TestMethodInlining(pVT); + result += TestByRef(ref *pVT); + result += TestByPtr(pVT); + + return result; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static int Do(int v1, int v2) + { + return v1 + v2; + } +} + + diff --git a/tests/src/JIT/opt/Structs/structpop.csproj b/tests/src/JIT/opt/Structs/structpop.csproj new file mode 100644 index 000000000000..c955a50c957b --- /dev/null +++ b/tests/src/JIT/opt/Structs/structpop.csproj @@ -0,0 +1,39 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT .0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + + + + + + + False + + + + None + True + True + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/JIT/opt/Structs/structpop2.cs b/tests/src/JIT/opt/Structs/structpop2.cs new file mode 100644 index 000000000000..6a3b27075f6c --- /dev/null +++ b/tests/src/JIT/opt/Structs/structpop2.cs @@ -0,0 +1,63 @@ +// 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. + +// Optimization of pop with struct types +// Codegen for TestByPtr should be minimal +// +// See CoreClr#18710 + +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[StructLayout(LayoutKind.Sequential)] +struct VT +{ + public static readonly int Size = Marshal.SizeOf(); + + public int F1, F2, F3, F4, F5, F6, F7, F8; +} + +class P +{ + [MethodImpl(MethodImplOptions.NoInlining)] + static int Do(int v1) + { + Console.WriteLine("v1={0}", v1); + return v1; + } + + [MethodImpl(MethodImplOptions.NoInlining)] + unsafe static int TestByPtr(VT* pVT) + { + int v1, v2, v3, v4, v5, v6, v7, v8; + v1 = pVT->F1; + v2 = pVT->F2; + v3 = pVT->F3; + v4 = pVT->F4; + v5 = pVT->F5; + v6 = pVT->F6; + v7 = pVT->F7; + v8 = pVT->F8; + return Do(v1); + } + + unsafe static int Main(string[] args) + { + byte* pDataBytes = stackalloc byte[VT.Size]; + VT* pVT = (VT*)pDataBytes; + pVT->F1 = 1; + pVT->F2 = 2; + pVT->F3 = 3; + pVT->F4 = 4; + pVT->F5 = 5; + pVT->F6 = 6; + pVT->F7 = 7; + pVT->F8 = 8; + int result = TestByPtr(pVT); + return result + 99; + } +} + + diff --git a/tests/src/JIT/opt/Structs/structpop2.csproj b/tests/src/JIT/opt/Structs/structpop2.csproj new file mode 100644 index 000000000000..37cc1ade115f --- /dev/null +++ b/tests/src/JIT/opt/Structs/structpop2.csproj @@ -0,0 +1,39 @@ + + + + + Debug + AnyCPU + $(MSBuildProjectName) + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + Properties + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(ProgramFiles)\Common Files\microsoft shared\VSTT .0\UITestExtensionPackages + ..\..\ + 7a9bfb7d + + + + + + + False + + + + None + True + True + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/TestWrappersConfig/TestWrappersConfig.csproj b/tests/src/TestWrappersConfig/TestWrappersConfig.csproj deleted file mode 100644 index 76128421d2c9..000000000000 --- a/tests/src/TestWrappersConfig/TestWrappersConfig.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Debug - AnyCPU - BuildOnly - false - - - - $(MicrosoftNETCorePlatformsPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - $(XunitPackageVersion) - - - - netcoreapp1.1;net45 - .NETCoreApp - $(PackageTargetFallback);dnxcore50;portable-net45+win8 - $(TargetRid) - true - false - - - - \ No newline at end of file diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs index b7c1da2d7634..f3710a950537 100644 --- a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs +++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange1_cti.cs @@ -49,9 +49,6 @@ public bool PosTest1() threadA.Start(); // Block calling thread until spawned Thread A completes threadA.Join(); - // Once Thread A completes, block - // calling thread until Thread B completes as well - threadB.Join(); // now, the final value of globalValue and state should be -0.1 if (globalValue != -0.1 && state != -0.1) { @@ -131,10 +128,10 @@ public void TestComChange() if (i == 10) { threadB.Start(); + threadB.Join(); } state = Interlocked.CompareExchange(ref globalValue, -0.1, 10.0); i++; - Thread.Sleep(10); } } public void changeGlobal() diff --git a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs index f703ab948b50..30feaa38daa0 100644 --- a/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs +++ b/tests/src/baseservices/threading/interlocked/compareexchange/compareexchange5_cti.cs @@ -51,9 +51,6 @@ public bool PosTest1() threadA.Start(); // Block spawning thread until Thread A completes threadA.Join(); - // Once Thread A completes, block spawning thread - // until Thread B completes as well - threadB.Join(); // now, the final values of // globalValue and state should be "changedValue" if (globalValue.ToString() != "changedValue" && state != (object)("changedValue")) @@ -88,9 +85,6 @@ public bool PosTest2() threadA.Start(); // Block spawning thread until Thread A completes threadA.Join(); - // Once Thread A completes, block spawning thread - // until Thread B completes as well - threadB.Join(); // now, the final values of // globalValue and state should NOT be -100 if (((myClass)globalValue).a != -100 && ((myClass)state).a != -100) @@ -183,6 +177,7 @@ public void TestComChange() if (i == 10) { threadB.Start(); + threadB.Join(); } // first ten iterations, globalValue does not // equal comparand, so it keeps returning @@ -196,7 +191,6 @@ public void TestComChange() // here we use the object overload state = Interlocked.CompareExchange(ref globalValue, value, comparand); i++; - Thread.Sleep(10); } } public void changeGlobal() @@ -221,6 +215,7 @@ public void TestComChange2() if (i == 10) { threadB.Start(); + threadB.Join(); } // first ten iterations, globalValue does not // equal comparand, so it keeps returning @@ -234,7 +229,6 @@ public void TestComChange2() // here we use the object overload state = Interlocked.CompareExchange(ref globalValue, value, comparand); i++; - Thread.Sleep(10); } } public void changeGlobal2() @@ -249,4 +243,4 @@ public myClass(int value) { a = value; } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString.csproj b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString.csproj index c0b5b0487441..4445ef808959 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString.csproj +++ b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString.csproj @@ -11,6 +11,7 @@ ..\..\ true 1 + true diff --git a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_1.csproj b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_1.csproj index 717ace21f3b4..5909d1c7b7d7 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_1.csproj +++ b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_1.csproj @@ -13,6 +13,7 @@ 1 ExchangeTString.csproj empty "This is a long string that I am trying to test to be sure that the Exchange can handle this long of a string. If it can not then that is bad and we will have to fix it." + true diff --git a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_2.csproj b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_2.csproj index 67935f2aa266..ede760b4a7a8 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_2.csproj +++ b/tests/src/baseservices/threading/interlocked/exchange/ExchangeTString_2.csproj @@ -13,6 +13,7 @@ 1 ExchangeTString.csproj null "This is a string" + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs index fb682e093b96..87b1520f31d0 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs +++ b/tests/src/baseservices/threading/interlocked/exchange/exchange1_cti.cs @@ -24,7 +24,6 @@ public class InterlockedExchange1 { private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn - private const int c_WAITTHREADSCOMPLETE = 3000; // how long main thread should sleep private static int resource = 10; // resources to be consumed private static double location = 0; // mutex being managed thru Exchange private static int entry = 0; // threads granted entry to the mutex @@ -83,10 +82,11 @@ public bool PosTest1() threads[i].Start(); } - // after all threads are spawned, put the spawining thread - // to sleep for long enough that the spawned threads have - // time to complete - Thread.Sleep(c_WAITTHREADSCOMPLETE); + // Wait for all threads to complete + for (int i = 0; i < threads.Length; i++) + { + threads[i].Join(); + } // entries + denials should equal original value of resource (10) if (entry + deny == 10) diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs index ba38b07ad279..bbbc54afcdf1 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs +++ b/tests/src/baseservices/threading/interlocked/exchange/exchange4_cti.cs @@ -24,7 +24,6 @@ public class InterlockedExchange4 { private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn - private const int c_WAITTHREADSCOMPLETE = 2000; // how long main thread should sleep private static int resource = 10; // resources to be consumed private static Int64 location = 0; // mutex being managed thru Exchange private static int entry = 0; // threads granted entry to the mutex @@ -83,10 +82,11 @@ public bool PosTest1() threads[i].Start(); } - // after all threads are spawned, put the spawining thread - // to sleep for long enough that the spawned threads have - // time to complete - Thread.Sleep(c_WAITTHREADSCOMPLETE); + // Wait for all threads to complete + for (int i = 0; i < threads.Length; i++) + { + threads[i].Join(); + } // entries + denials should equal original value of resource (10) if (entry + deny == 10) diff --git a/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs index af0da2a532e7..1a3b6c9fcba1 100644 --- a/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs +++ b/tests/src/baseservices/threading/interlocked/exchange/exchange5_cti.cs @@ -24,7 +24,6 @@ public class InterlockedExchange5 { private const int c_THREADARRAT_SIZE = 10; // how many threads to spawn - private const int c_WAITTHREADSCOMPLETE = 2000; // how long main thread should sleep private static int resource = 10; // resources to be consumed private static Object location = 0; // mutex being managed thru Exchange private static int entry = 0; // threads granted entry to the mutex @@ -83,10 +82,11 @@ public bool PosTest1() threads[i].Start(); } - // after all threads are spawned, put the spawining thread - // to sleep for long enough that the spawned threads have - // time to complete - Thread.Sleep(c_WAITTHREADSCOMPLETE); + // Wait for all threads to complete + for (int i = 0; i < threads.Length; i++) + { + threads[i].Join(); + } // entries + denials should equal original value of resource (10) if (entry + deny == 10) diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj index 305c6b2cfa38..21663a78069e 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am01waitallneg.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj index 2732314edb80..97c2396dae28 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am02waitoneneg.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj index c2ddb9c6cf9f..5b221edb1aea 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am04waitany.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:10 /pos:0 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj index 0455a88fe844..1ee5aac44258 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am05waitanymutex.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:63 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj index 7de4bb2c4e7b..f439180bea3e 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am06abandonall.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj index e7b5a577b9ec..2456bb8e45d2 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am07abandonmultiplemutex.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj index 46f140fa3460..804b758c690d 100644 --- a/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj +++ b/tests/src/baseservices/threading/mutex/abandonedmutex/am08mixedarray.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/mutex/misc/waitone1.cs b/tests/src/baseservices/threading/mutex/misc/waitone1.cs index d5a0c5cdb1e7..549e1ec90b04 100644 --- a/tests/src/baseservices/threading/mutex/misc/waitone1.cs +++ b/tests/src/baseservices/threading/mutex/misc/waitone1.cs @@ -193,12 +193,10 @@ private void SignalMutex() private void NeverReleaseMutex() { m_Mutex.WaitOne(); - // Thread.Sleep(c_DEFAULT_SLEEP_TIME); } private void DisposeMutex() { - // Thread.Sleep(c_DEFAULT_SLEEP_TIME); ((IDisposable)m_Mutex).Dispose(); } #endregion diff --git a/tests/src/baseservices/threading/mutex/misc/waitone2.csproj b/tests/src/baseservices/threading/mutex/misc/waitone2.csproj index f0fb07922bee..11dcff3f059f 100644 --- a/tests/src/baseservices/threading/mutex/misc/waitone2.csproj +++ b/tests/src/baseservices/threading/mutex/misc/waitone2.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -37,4 +38,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj index 02e7d6c679dc..2d5f103bc32a 100644 --- a/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj +++ b/tests/src/baseservices/threading/paramthreadstart/threadstartarray.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/regressions/576463/576463.csproj b/tests/src/baseservices/threading/regressions/576463/576463.csproj index d82edd7e9801..35ecbaf8ce70 100644 --- a/tests/src/baseservices/threading/regressions/576463/576463.csproj +++ b/tests/src/baseservices/threading/regressions/576463/576463.csproj @@ -12,6 +12,7 @@ true BuildAndRun 1 + true @@ -37,4 +38,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj b/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj index 2cb3338d98dd..8cfe61425987 100644 --- a/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj +++ b/tests/src/baseservices/threading/threadpool/unregister/unregister01.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj b/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj index adc805abd94a..e89a72a31cc3 100644 --- a/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj +++ b/tests/src/baseservices/threading/threadpool/unregister/unregister03.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj index 2d5f7de0955f..b9e9150e947a 100644 --- a/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj +++ b/tests/src/baseservices/threading/waithandle/misc/waithandlewaitone1.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -37,4 +38,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj index e07e5a258c78..64bc02b7c179 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj index f6792782c347..1afd2ab08ff9 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:63 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj index 1bdf249bf2cd..25b30f2bda0a 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex10a.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:0 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj index ddeb93614af5..271b2a750628 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex1a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj index ec201627004c..2402f87dd88e 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj index a4bcca690c1f..c299badb8a23 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex2a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj index f349a21e2cc7..96103d0a3b6d 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj index bab948d0d902..0f2db8e5688d 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex3a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj index b9f38688edc7..3384e91a202e 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj index f1c250eaff0f..792c19566513 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex4a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj index 475586093031..64c39d767a06 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj index 0335cc770075..f0adb55fab80 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex5a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj index eb60a22a9d62..8fe852d35805 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:2 /pos:0 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj index ec0e3050f7e6..810bc161fc71 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex6a.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:30 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj index 70cd75e9843c..98af403de8d8 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj index e1d55f413d9d..821c2d36b6ec 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex7a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj index 0a2329ab4f52..f871aa6ee885 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj index d433e4d7f1ad..96cc5ebf500a 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex8a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj index 4d704a00969d..f1de7e9d9f40 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:63 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj index 16685fefede2..014e4d0360db 100644 --- a/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitall/waitallex9a.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:0 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs index b55f8a0fde82..46d43a85b62e 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.cs @@ -35,7 +35,7 @@ private int Run() Console.WriteLine("Waiting..."); int i = WaitHandle.WaitAny( new WaitHandle[]{myMutex, - new ManualResetEvent(false)}, 10000); + new ManualResetEvent(false)}, 30000); Console.WriteLine("WaitAny did not throw an " + "exception, i = " + i); } diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj index 95748a570c10..ebbfc6f9f1af 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs index bb13264d4c50..48e344f5c952 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.cs @@ -78,10 +78,9 @@ private int Run(int iNumElements, int iPos) private void AbandonAllMutexesWait() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); else ((ManualResetEvent)w).Set(); @@ -101,4 +100,4 @@ private void CreateOneMutexArray(int numElements, int iPos) wh[i] = new ManualResetEvent(false); } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj index e223849ff420..0ce38e97359e 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:2 /pos:1 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs index b92f81985e27..c3157d7e8ad8 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.cs @@ -78,10 +78,9 @@ private int Run(int iNumElements, int iPos) private void AbandonAllMutexesWait() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); else ((ManualResetEvent)w).Set(); @@ -101,4 +100,4 @@ private void CreateOneMutexArray(int numElements, int iPos) wh[i] = new ManualResetEvent(false); } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj index a3a139a02e71..2944a8b0cbf9 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex10a.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:2 /pos:1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj index 3b2f75911a67..ee05cb16b2ef 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex1a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs index e1160c5e73ed..fe81733a27ab 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.cs @@ -29,7 +29,7 @@ private int Run() try { Console.WriteLine("Waiting..."); - int i = WaitHandle.WaitAny(wh, 10000); + int i = WaitHandle.WaitAny(wh, 30000); Console.WriteLine("WaitAny did not throw an " + "exception, i = " + i); } @@ -49,10 +49,9 @@ private int Run() private void AbandonAllMutexes() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj index b00ea8c0cbec..f5d085809a43 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs index f79cfa5cbf3e..da03f085c771 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.cs @@ -49,10 +49,9 @@ private int Run() private void AbandonAllMutexes() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); @@ -78,4 +77,4 @@ private void CreateArray(int numElements) } } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj index d99c135b6af3..f30bdf5c256e 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex3a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs index cdd75e5f1913..6d73ec6836af 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5.cs @@ -30,8 +30,8 @@ private int Run() try { Console.WriteLine("Waiting..."); - i = WaitHandle.WaitAny(wh, 5000); - Console.WriteLine("WaitAny did not throw AbandonedMutexExcpetion"); + i = WaitHandle.WaitAny(wh, 30000); + Console.WriteLine("WaitAny did not throw AbandonedMutexException. Result: {0}", i); } catch(AbandonedMutexException) { @@ -49,11 +49,10 @@ private int Run() private void AbandonOneAndRelease() { - Mutex m = new Mutex(); bool bSet = false; foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) { w.WaitOne(); if(bSet) diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs index 16c4e50e617d..b3d29fb1e6bb 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex5a.cs @@ -31,7 +31,7 @@ private int Run() { Console.WriteLine("Waiting..."); i = WaitHandle.WaitAny(wh); - Console.WriteLine("WaitAny did not throw AbandonedMutexExcpetion"); + Console.WriteLine("WaitAny did not throw AbandonedMutexException. Result: {0}", i); } catch(AbandonedMutexException) { @@ -49,11 +49,10 @@ private int Run() private void AbandonOneAndRelease() { - Mutex m = new Mutex(); bool bSet = false; foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) { w.WaitOne(); if(bSet) diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs index 0f5b58658b07..181e0c53ef29 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex6.cs @@ -55,13 +55,17 @@ private int Run(int iArraySize, int iPosToAbandon) try { Console.WriteLine("Waiting..."); - i = WaitHandle.WaitAny(wh, 5000); if(0 == iPosToAbandon) - Console.WriteLine("WaitAny didn't return an " + - "AbandonedMutexException"); + { + i = WaitHandle.WaitAny(wh, 30000); + Console.WriteLine("WaitAny did not throw AbandonedMutexException. Result: {0}", i); + } else + { + i = WaitHandle.WaitAny(wh, 10000); // Expected to pass iRet = 100; + } } catch(AbandonedMutexException) { @@ -94,4 +98,4 @@ private void CreateMutexArray(int numElements) wh[i] = new Mutex(false, Common.GetUniqueName()); } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs index cc3108d0f288..74e56be14641 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.cs @@ -28,7 +28,7 @@ private int Run() try { Console.WriteLine("Waiting..."); - int i = WaitHandle.WaitAny(wh, 10000); + int i = WaitHandle.WaitAny(wh, 30000); Console.WriteLine("WaitAny did not throw an " + "exception, i = " + i); } @@ -48,10 +48,9 @@ private int Run() private void AbandonAllMutexes() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj index 7bd9eef6a6ad..de9c88c44dff 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs index 903b83c372dc..736ce14fca53 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.cs @@ -48,10 +48,9 @@ private int Run() private void AbandonAllMutexes() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj index 69937cff6b48..ec2cb5251be1 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex7a.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -31,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs index 358ae5162b49..22398358ce1c 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex8.cs @@ -34,7 +34,7 @@ private int Run() try { Console.WriteLine("Waiting..."); - int i = WaitHandle.WaitAny(wh, 5000); + int i = WaitHandle.WaitAny(wh, 30000); Console.WriteLine("WaitAny did not throw an " + "exception, i = " + i); } diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs index 76b30068296e..7af91355a412 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.cs @@ -58,7 +58,7 @@ private int Run(int iNumElements, int iPos) try { Console.WriteLine("Waiting..."); - int i = WaitHandle.WaitAny(wh, 10000); + int i = WaitHandle.WaitAny(wh, 30000); Console.WriteLine("WaitAny did not throw an " + "exception, i = " + i); } @@ -78,10 +78,9 @@ private int Run(int iNumElements, int iPos) private void AbandonAllMutexesWait() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); @@ -99,4 +98,4 @@ private void CreateOneMutexArray(int numElements, int iPos) wh[i] = new ManualResetEvent(false); } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj index 4cb70cbf51ef..9f17ad6e2364 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:2 /pos:1 + true @@ -33,4 +34,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs index 1c5817f9e099..38637a977943 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.cs @@ -78,10 +78,9 @@ private int Run(int iNumElements, int iPos) private void AbandonAllMutexesWait() { - Mutex m = new Mutex(); foreach(WaitHandle w in wh) { - if(w.GetType() == m.GetType()) + if(w is Mutex) w.WaitOne(); } myMRE.Set(); @@ -99,4 +98,4 @@ private void CreateOneMutexArray(int numElements, int iPos) wh[i] = new ManualResetEvent(false); } } -} \ No newline at end of file +} diff --git a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj index 4939c2e07590..81b64effd3d0 100644 --- a/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj +++ b/tests/src/baseservices/threading/waithandle/waitany/waitanyex9a.csproj @@ -11,6 +11,7 @@ ..\..\ 1 /size:64 /pos:30 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj index e0c574f8a3e8..071412e0bd5f 100644 --- a/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj +++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex1.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj index 5f8a271c5fa8..79649b48977b 100644 --- a/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj +++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex2.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj index 5ec416d05064..176e3f5a65de 100644 --- a/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj +++ b/tests/src/baseservices/threading/waithandle/waitone/waitoneex3.csproj @@ -10,6 +10,7 @@ {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ 1 + true @@ -32,4 +33,4 @@ - \ No newline at end of file + diff --git a/tests/src/dir.common.props b/tests/src/dir.common.props deleted file mode 100644 index dda175574c91..000000000000 --- a/tests/src/dir.common.props +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - <__BuildArch Condition="'$(__BuildArch)' == ''">x64 - <__BuildType Condition="'$(__BuildType)' == ''">Debug - <__BuildOS Condition="'$(__BuildOS)' == ''">Windows_NT - $(__BuildArch) - $(__BuildType) - $(__BuildOS) - $(BuildType) - $(BuildArch) - - - - - true - false - full - $(DefineConstants);DEBUG;TRACE;XUNIT_PERF - - - true - true - pdbonly - $(DefineConstants);TRACE;XUNIT_PERF - - - true - true - full - $(DefineConstants);DEBUG;TRACE;XUNIT_PERF - - - - - 64 - 64 - 32 - 32 - - - - - $(BuildOS).$(Platform).$(Configuration) - $(ProjectDir)\..\bin\tests - $(__TestRootDir) - $(BaseOutputPath)\$(OSPlatformConfig)\ - $(BaseOutputPathWithConfig) - $(ProjectDir)\..\bin\tests\obj\$(OSPlatformConfig)\Managed\ - $(__ManagedTestIntermediatesDir)\ - <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\obj\$(BuildOS).$(Platform).$(Configuration)\Native\)) - $(MSBuildProjectName)\ - $([System.String]::Copy('$(MSBuildProjectDirectory)').Replace($(SourceDir),''))\$(MSBuildProjectName) - $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir)\ - $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\ - $(BaseOutputPath)\testStagingDir\ - $(TestWorkingDir)$(OSPlatformConfig)\$(MSBuildProjectName)/ - - - - diff --git a/tests/src/dir.props b/tests/src/dir.props index abdb7cc0f574..f3f229de9abe 100644 --- a/tests/src/dir.props +++ b/tests/src/dir.props @@ -1,5 +1,52 @@ - + + + + + + + true + false + full + $(DefineConstants);DEBUG;TRACE;XUNIT_PERF + + + true + true + pdbonly + $(DefineConstants);TRACE;XUNIT_PERF + + + true + true + full + $(DefineConstants);DEBUG;TRACE;XUNIT_PERF + + + + + 64 + 64 + 32 + 32 + + + + + $(ProjectDir)\..\bin\tests + $(__TestRootDir) + $(BaseOutputPath)\$(OSPlatformConfig)\ + $(BaseOutputPathWithConfig) + $(ProjectDir)\..\bin\tests\obj\$(OSPlatformConfig)\Managed\ + $(__ManagedTestIntermediatesDir)\ + <__NativeTestIntermediatesDir Condition="'$(__NativeTestIntermediatesDir)' == ''">$([System.IO.Path]::GetFullPath($(BaseOutputPathWithConfig)..\obj\$(BuildOS).$(Platform).$(Configuration)\Native\)) + $(MSBuildProjectName)\ + $([System.String]::Copy('$(MSBuildProjectDirectory)').Replace($(SourceDir),''))\$(MSBuildProjectName) + $(BaseIntermediateOutputPath)$(BuildProjectRelativeDir)\ + $(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\ + $(BaseOutputPath)\testStagingDir\ + $(TestWorkingDir)$(OSPlatformConfig)\$(MSBuildProjectName)/ + @@ -11,8 +58,6 @@ 78,162,164,168,169,219,251,252,414,429,642,649,652,675,1691,1717,1718,3001,3002,3003,3005,3008 false true - - $(MSBuildThisFileDirectory)TestWrappersConfig\ Test @@ -95,8 +140,8 @@ $(MSBuildProjectDirectory)\obj - .NETCoreApp,Version=v2.2 - netcoreapp2.2 + .NETCoreApp,Version=v3.0 + netcoreapp3.0 true diff --git a/tests/src/dirs.proj b/tests/src/dirs.proj index 6009e2ed080e..785a05859bba 100644 --- a/tests/src/dirs.proj +++ b/tests/src/dirs.proj @@ -16,10 +16,10 @@ - - + + diff --git a/tests/src/performance/performance.csproj b/tests/src/performance/performance.csproj index 94caf35ac235..c6c0b5c98dd1 100644 --- a/tests/src/performance/performance.csproj +++ b/tests/src/performance/performance.csproj @@ -94,8 +94,8 @@ $(XunitPackageVersion) - - $(XunitConsoleNetcorePackageVersion) + + $(XunitPackageVersion) $(XunitPackageVersion) diff --git a/tests/src/readytorun/r2rdump/BasicTests.cs b/tests/src/readytorun/r2rdump/BasicTests.cs new file mode 100644 index 000000000000..2acdeee040ee --- /dev/null +++ b/tests/src/readytorun/r2rdump/BasicTests.cs @@ -0,0 +1,24 @@ +// 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 R2RDumpTest +{ + public class BasicTests + { + static int Main(string[] args) + { + Console.WriteLine("Starting the test"); + + TestHelpers.RunTest("HelloWorld"); + TestHelpers.RunTest("MultipleRuntimeFunctions"); + TestHelpers.RunTest("GenericFunctions"); + TestHelpers.RunTest("GcInfoTransitions"); + + Console.WriteLine("PASSED"); + return 100; + } + } +} diff --git a/tests/src/readytorun/r2rdump/R2RDumpTest.csproj b/tests/src/readytorun/r2rdump/R2RDumpTest.csproj new file mode 100644 index 000000000000..d885ff88fb26 --- /dev/null +++ b/tests/src/readytorun/r2rdump/R2RDumpTest.csproj @@ -0,0 +1,64 @@ + + + + + Debug + AnyCPU + R2RDumpTest + 2.0 + Exe + false + ..\..\ + ..\..\..\..\..\..\ + $(CoreClrDir)bin\Product\$(BuildOS).$(BuildArch).$(BuildType)\netcoreapp2.0\R2RDump.dll + $(CoreClrDir)Tools\dotnetcli\dotnet + ../../../../../../ + $(BashCoreClrDir)bin/Product/$(BuildOS).$(BuildArch).$(BuildType)/netcoreapp2.0/R2RDump.dll + $(BashCoreClrDir)Tools/dotnetcli/dotnet + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/src/readytorun/r2rdump/TestHelpers.cs b/tests/src/readytorun/r2rdump/TestHelpers.cs new file mode 100644 index 000000000000..8e89f8d3960e --- /dev/null +++ b/tests/src/readytorun/r2rdump/TestHelpers.cs @@ -0,0 +1,116 @@ +// 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.Collections.Generic; +using System.Linq; +using System.Xml; +using Xunit.Abstractions; +using System.Text; +using Xunit; + +namespace R2RDumpTest +{ + class TestHelpers + { + public static void RunTest(string name) + { + List testXmlNodes = ReadXmlNodes($"{name}-test.xml", true).Cast().ToList(); + List expectedXmlNodes = ReadXmlNodes($"{name}.xml", true).Cast().ToList(); + bool identical = XmlDiff(testXmlNodes, expectedXmlNodes); + Assert.True(identical); + } + + public static bool XmlDiff(List testXmlNodes, List expectedXmlNodes) + { + testXmlNodes.RemoveAll(node => !IsLeaf(node)); + expectedXmlNodes.RemoveAll(node => !IsLeaf(node)); + + Dictionary allTest = testXmlNodes.ToDictionary(node => XmlNodeFullName(node)); + Dictionary allExpected = expectedXmlNodes.ToDictionary(node => XmlNodeFullName(node)); + Dictionary diffTest = testXmlNodes.Except(expectedXmlNodes, new XElementEqualityComparer()).ToDictionary(node => XmlNodeFullName(node)); + Dictionary diffExpected = expectedXmlNodes.Except(testXmlNodes, new XElementEqualityComparer()).ToDictionary(node => XmlNodeFullName(node)); + + foreach (KeyValuePair diff in diffExpected) + { + XmlNode expectedNode = diff.Value; + Console.WriteLine("Expected:"); + Console.WriteLine("\t" + XmlNodeFullName(expectedNode) + ": " + expectedNode.InnerText); + if (allTest.ContainsKey(diff.Key)) + { + XmlNode testNode = allTest[diff.Key]; + Console.WriteLine("Test:"); + Console.WriteLine("\t" + XmlNodeFullName(testNode) + ": " + testNode.InnerText); + } + else + { + Console.WriteLine("Test:"); + Console.WriteLine("\tnone"); + } + Console.WriteLine(""); + } + foreach (KeyValuePair diff in diffTest) + { + if (!allExpected.ContainsKey(diff.Key)) + { + Console.WriteLine("Expected:"); + Console.WriteLine("\tnone"); + Console.WriteLine("Test:"); + Console.WriteLine("\t" + XmlNodeFullName(diff.Value) + ": " + diff.Value.InnerText); + } + Console.WriteLine(""); + } + + return diffExpected.Count == 0 && diffTest.Count == 0; + } + + private class XElementEqualityComparer : IEqualityComparer + { + public bool Equals(XmlNode x, XmlNode y) + { + return XmlNodeFullName(x).Equals(XmlNodeFullName(y)) && x.InnerText.Equals(y.InnerText); + } + public int GetHashCode(XmlNode obj) + { + return 0; + } + } + + private static bool IsLeaf(XmlNode node) + { + return !node.HasChildNodes || node.FirstChild.NodeType == XmlNodeType.Text; + } + + private static string XmlNodeFullName(XmlNode node) + { + string fullName = ""; + XmlNode n = node; + while (node != null && node.NodeType != XmlNodeType.Document) + { + string index = ""; + XmlAttribute indexAttribute = node.Attributes["Index"]; + if (indexAttribute != null) { + index = indexAttribute.Value; + } + fullName = node.Name + index + "." + fullName; + node = node.ParentNode; + } + return fullName; + } + + public static XmlNodeList ReadXmlNodes(string filenameOrXmlString, bool fromFile) + { + XmlDocument expectedXml = new XmlDocument(); + if (fromFile) + { + expectedXml.Load(filenameOrXmlString); + } + else + { + expectedXml.LoadXml(filenameOrXmlString); + } + return expectedXml.SelectNodes("//*"); + } + } +} \ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/GcInfoTransitions.cs b/tests/src/readytorun/r2rdump/files/GcInfoTransitions.cs new file mode 100644 index 000000000000..8fb283bc6d78 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/GcInfoTransitions.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. + +namespace GcInfoTransitions +{ + class GcInfoTransitions + { + static void abc(string a) + { + + } + + static void Main(string[] args) + { + abc(new string('1',1)); + abc(new string('2', 1)); + abc(new string('3', 1)); + abc(new string('4', 1)); + abc(new string('5', 1)); + abc(new string('6', 1)); + abc(new string('7', 1)); + abc(new string('8', 1)); + } + } +} diff --git a/tests/src/readytorun/r2rdump/files/GcInfoTransitions.csproj b/tests/src/readytorun/r2rdump/files/GcInfoTransitions.csproj new file mode 100644 index 000000000000..8aaa695cc7a8 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/GcInfoTransitions.csproj @@ -0,0 +1,22 @@ + + + + + Debug + AnyCPU + 2.0 + library + ..\..\..\ + $(DefineConstants);STATIC;CORECLR + SharedLibrary + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/GenericFunctions.cs b/tests/src/readytorun/r2rdump/files/GenericFunctions.cs new file mode 100644 index 000000000000..52679bbfdd9d --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/GenericFunctions.cs @@ -0,0 +1,43 @@ +// 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. + +namespace GenericFunctions +{ + struct UserDefinedStruct + { + int n; + public UserDefinedStruct(int num) + { + n = num; + } + } + + class UserDefinedClass + { + int n; + public UserDefinedClass(int num) + { + n = num; + } + } + + class GenericFunctions + { + static T GenericFunction(T t, S s) + { + return t; + } + + static void Main(string[] args) + { + string str = "hello"; + UserDefinedStruct userDefinedStruct = new UserDefinedStruct(2); + GenericFunction(userDefinedStruct, str); + + int integer = 1; + UserDefinedClass userDefinedClass = new UserDefinedClass(2); + GenericFunction(integer, userDefinedClass); + } + } +} diff --git a/tests/src/readytorun/r2rdump/files/GenericFunctions.csproj b/tests/src/readytorun/r2rdump/files/GenericFunctions.csproj new file mode 100644 index 000000000000..34f8d12e4919 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/GenericFunctions.csproj @@ -0,0 +1,22 @@ + + + + + Debug + AnyCPU + 2.0 + library + ..\..\..\ + $(DefineConstants);STATIC;CORECLR + SharedLibrary + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/HelloWorld.cs b/tests/src/readytorun/r2rdump/files/HelloWorld.cs new file mode 100644 index 000000000000..5f02049d9c94 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/HelloWorld.cs @@ -0,0 +1,16 @@ +// 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 HelloWorld +{ + class HelloWorld + { + static void Main(string[] args) + { + Console.WriteLine("Hello World!"); + } + } +} diff --git a/tests/src/readytorun/r2rdump/files/HelloWorld.csproj b/tests/src/readytorun/r2rdump/files/HelloWorld.csproj new file mode 100644 index 000000000000..9659cad279f9 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/HelloWorld.csproj @@ -0,0 +1,22 @@ + + + + + Debug + AnyCPU + 2.0 + library + ..\..\..\ + $(DefineConstants);STATIC;CORECLR + SharedLibrary + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.cs b/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.cs new file mode 100644 index 000000000000..a0ec5bfde082 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.cs @@ -0,0 +1,21 @@ +// 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. + +namespace MultipleRuntimeFunctions +{ + class MultipleRuntimeFunctions + { + static void Main(string[] args) + { + try + { + + } + finally + { + + } + } + } +} diff --git a/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.csproj b/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.csproj new file mode 100644 index 000000000000..42d3ce5284e3 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/MultipleRuntimeFunctions.csproj @@ -0,0 +1,22 @@ + + + + + Debug + AnyCPU + 2.0 + library + ..\..\..\ + $(DefineConstants);STATIC;CORECLR + SharedLibrary + + + + + + + + + + + \ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GcInfoTransitions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GcInfoTransitions.xml new file mode 100644 index 000000000000..b9d550b45f9b --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GcInfoTransitions.xml @@ -0,0 +1,399 @@ + + + + GcInfoTransitions.ni.dll + true + Amd64 + 6891812028416 + +
+ + 8984 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9108 + 40 + + + + 24 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEagPAaCP8= +
+
+ 0 +
+ + 0 +
0
+ GgEagPAaCP8= +
+ + 8 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 8 + 9360 + + + 0 +
6891812037717
+ FQQAAAAAAAA= +
+
+ 10528 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3360 + +
+ + 0 +
6891812037717
+ FQQAAAAAAAA= +
+
+
+
+ + 9320 + 36 + + + 0x00002810 + 0x00002816 + 0x000028FC + 0x00002820 + 0x000028C3 + 0x00002908 + 0x000028D0 + 0x000028D6 + 0x000028FC + +
+
+ + 10456 + 10 + + +
+
+ + 10544 + 63 + + +
+
+ + 9301 + 16 + + +
+
+ + 10480 + 9 + + + GcInfoTransitions.GcInfoTransitions + .<Module> + +
+
+ + 10466 + 3 + + +
+
+ + 10608 + 22 + + +
+
+ + 3 + + + abc + GcInfoTransitions.GcInfoTransitions.abc(String) + false + GcInfoTransitions.GcInfoTransitions + 100663297 + 0 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3332 + + + + + 1 + + 10256 + 6 + 10492 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9295 + 8 + + + + + + + + Main + GcInfoTransitions.GcInfoTransitions.Main(String[]) + false + GcInfoTransitions.GcInfoTransitions + 100663298 + 1 + + + + 2 + 163 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 8 + 0 + + + 23 + + + 42 + + + 61 + + + 80 + + + 99 + + + 118 + + + 137 + + + 156 + + + + + 0 + 0 + 0 + 0 + + + 153 + 3348 + + + + + 2 + + 10272 + 163 + 10504 + 0 + + + + 1 + 3 + 4 + 1 + EAX + 0 + + + 4 + UWOP_ALLOC_SMALL + 4 + 4 + 4 + 16900 + + + 609157120 + 12 + + + + + + + + .ctor + GcInfoTransitions.GcInfoTransitions..ctor() + false + GcInfoTransitions.GcInfoTransitions + 100663299 + 2 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3332 + + + + + 3 + + 10448 + 6 + 10492 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9295 + 8 + + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GenericFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GenericFunctions.xml new file mode 100644 index 000000000000..90856348ebd3 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/GenericFunctions.xml @@ -0,0 +1,494 @@ + + + + GenericFunctions.ni.dll + true + Amd64 + 6891812028416 + +
+ + 8984 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9156 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9096 + 60 + + + + 24 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9284 + + + 0 +
0
+ GgEagPAaEP8= +
+
+ 0 +
+ + 0 +
0
+ GgEagPAaEP8= +
+ + 8 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 8 + 9392 + + + 0 +
6891812037725
+ HBIMEBEIAAA= +
+
+ 0 +
+ + 0 +
6891812037725
+ HBIMEBEIAAA= +
+ + 8 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 10672 + + 0 + +
+
+
+ + 9328 + 60 + + + 0x000028E0 + 0x000028E8 + 0x00002970 + 0x000028F0 + 0x000028F9 + 0x0000297C + 0x00002900 + 0x00002909 + 0x00002988 + 0x00002910 + 0x0000292F + 0x00002994 + 0x00002930 + 0x00002936 + 0x000029A4 + +
+
+ + 10552 + 14 + + +
+
+ + 10688 + 87 + + +
+
+ + 10592 + 15 + + + GenericFunctions.GenericFunctions + .<Module> + GenericFunctions.UserDefinedStruct + GenericFunctions.UserDefinedClass + +
+
+ + 10566 + 11 + + +
+
+ + 10776 + 41 + + +
+
+ + 5 + + + .ctor + GenericFunctions.UserDefinedStruct..ctor(Int32) + false + GenericFunctions.UserDefinedStruct + 100663297 + 0 + + + + 2 + 8 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3448 + + + + + 1 + + 10464 + 8 + 10608 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9303 + 8 + + + + + + + + .ctor + GenericFunctions.UserDefinedClass..ctor(Int32) + false + GenericFunctions.UserDefinedClass + 100663298 + 1 + + + + 2 + 9 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3460 + + + + + 2 + + 10480 + 9 + 10620 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9303 + 8 + + + + + + + + Main + GenericFunctions.GenericFunctions.Main(String[]) + false + GenericFunctions.GenericFunctions + 100663300 + 3 + + + 2 + 0 + + + + + + 2 + 31 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 1 + 0 + + + 18 + + + + + 0 + 0 + 0 + 0 + + + 32 + 3488 + + + + + 4 + + 10512 + 31 + 10644 + 0 + + + + 1 + 3 + 4 + 1 + EAX + 0 + + + 4 + UWOP_ALLOC_SMALL + 4 + 4 + 4 + 16900 + + + 609681408 + 12 + + + + + + + + .ctor + GenericFunctions.GenericFunctions..ctor() + false + GenericFunctions.GenericFunctions + 100663301 + 4 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3500 + + + + + 5 + + 10544 + 6 + 10660 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9303 + 8 + + + + + + + + GenericFunction + GenericFunctions.GenericFunctions.GenericFunction<__Canon, __Canon>(__Canon, __Canon) + true + GenericFunctions.GenericFunctions + 100663299 + 2 + + + + 2 + 9 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3472 + + + + + 3 + + 10496 + 9 + 10632 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9303 + 8 + + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/HelloWorld.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/HelloWorld.xml new file mode 100644 index 000000000000..a5f7d4d0168a --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/HelloWorld.xml @@ -0,0 +1,326 @@ + + + + HelloWorld.ni.dll + true + Amd64 + 6891812028416 + +
+ + 8952 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9136 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9076 + 60 + + + + 24 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9264 + + + 0 +
0
+ GgEagPAaCP8= +
+
+ 0 +
+ + 0 +
0
+ GgEagPAaCP8= +
+ + 8 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_STRING_HANDLE + 8 + 10256 + + 0 + + + 8 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 8 + 9336 + + + 0 +
6891812037705
+ FQQQAQICAn4= +
+
+ 10248 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3080 + +
+ + 0 +
6891812037705
+ FQQQAQICAn4= +
+
+
+
+ + 9308 + 24 + + + 0x000027A0 + 0x000027BB + 0x000027EC + 0x000027C0 + 0x000027C6 + 0x000027FC + +
+
+ + 10184 + 10 + + +
+
+ + 10264 + 31 + + +
+
+ + 9289 + 16 + + +
+
+ + 10208 + 9 + + + HelloWorld.HelloWorld + .<Module> + +
+
+ + 10194 + 3 + + +
+
+ + 10296 + 13 + + +
+
+ + 2 + + + Main + HelloWorld.HelloWorld.Main(String[]) + false + HelloWorld.HelloWorld + 100663297 + 0 + + + 1 + 0 + + + + + + 2 + 27 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 1 + 0 + + + 20 + + + + + 0 + 0 + 0 + 0 + + + 32 + 3064 + + + + + 1 + + 10144 + 27 + 10220 + 0 + + + + 1 + 3 + 4 + 1 + EAX + 0 + + + 4 + UWOP_ALLOC_SMALL + 4 + 4 + 4 + 16900 + + + 608370688 + 12 + + + + + + + + .ctor + HelloWorld.HelloWorld..ctor() + false + HelloWorld.HelloWorld + 100663298 + 1 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3076 + + + + + 2 + + 10176 + 6 + 10236 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9283 + 8 + + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/MultipleRuntimeFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/MultipleRuntimeFunctions.xml new file mode 100644 index 000000000000..2161efead0a3 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x64.Checked/MultipleRuntimeFunctions.xml @@ -0,0 +1,243 @@ + + + + MultipleRuntimeFunctions.ni.dll + true + Amd64 + 6891812028416 + +
+ + 9016 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9128 + 20 + + + + 16 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEagPD/Jbk= +
+
+ 0 +
+ + 0 +
0
+ GgEagPD/Jbk= +
+
+
+
+ + 9296 + 24 + + + 0x00002750 + 0x00002756 + 0x0000278C + 0x00002760 + 0x00002766 + 0x0000278C + +
+
+ + 10088 + 8 + + +
+
+ + 10136 + 27 + + +
+
+ + 10112 + 9 + + + MultipleRuntimeFunctions.MultipleRuntimeFunctions + .<Module> + +
+
+ + 10096 + 3 + + +
+
+ + 10164 + 13 + + +
+
+ + 2 + + + Main + MultipleRuntimeFunctions.MultipleRuntimeFunctions.Main(String[]) + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663297 + 0 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 2964 + + + + + 1 + + 10064 + 6 + 10124 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9289 + 8 + + + + + + + + .ctor + MultipleRuntimeFunctions.MultipleRuntimeFunctions..ctor() + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663298 + 1 + + + + 2 + 6 + RT_Scalar + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 2964 + + + + + 2 + + 10080 + 6 + 10124 + 0 + + + + 1 + 3 + 0 + 0 + EAX + 0 + + 9289 + 8 + + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml new file mode 100644 index 000000000000..a9ede3175eaa --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GcInfoTransitions.xml @@ -0,0 +1,233 @@ + + + + GcInfoTransitions.ni.dll + true + I386 + 268500992 + +
+ + 8984 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9108 + 40 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEaCDPAagE= +
+
+ 0 +
+ + 0 +
0
+ GgEaCDPAagE= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 4 + 9304 + + + 0 +
268510280
+ FQQAAP////8= +
+
+ 10412 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3244 + +
+ + 0 +
268510280
+ FQQAAP////8= +
+
+
+
+ + 10344 + 24 + + + 0x000027D8 + 0x000028B4 + 0x000027E0 + 0x000028B8 + 0x00002860 + 0x000028B4 + +
+
+ + 10372 + 10 + + +
+
+ + 10440 + 63 + + +
+
+ + 9288 + 16 + + +
+
+ + 10400 + 9 + + + GcInfoTransitions.GcInfoTransitions + .<Module> + +
+
+ + 10382 + 3 + + +
+
+ + 10504 + 22 + + +
+
+ + 3 + + + abc + GcInfoTransitions.GcInfoTransitions.abc(String) + false + GcInfoTransitions.GcInfoTransitions + 100663297 + 0 + + + + 1 + + 10200 + 0 + 10420 + 0 + + + + + + + Main + GcInfoTransitions.GcInfoTransitions.Main(String[]) + false + GcInfoTransitions.GcInfoTransitions + 100663298 + 1 + + + + 2 + + 10208 + 0 + 10424 + 0 + + + + + + + .ctor + GcInfoTransitions.GcInfoTransitions..ctor() + false + GcInfoTransitions.GcInfoTransitions + 100663299 + 2 + + + + 3 + + 10336 + 0 + 10420 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml new file mode 100644 index 000000000000..4e37c5b60aff --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/GenericFunctions.xml @@ -0,0 +1,261 @@ + + + + GenericFunctions.ni.dll + true + I386 + 268500992 + +
+ + 8984 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9156 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9096 + 60 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9284 + + + 0 +
0
+ GgEaEDPAagE= +
+
+ 0 +
+ + 0 +
0
+ GgEaEDPAagE= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 4 + 9312 + + + 0 +
268510288
+ HBIMEBEIAAA= +
+
+ 0 +
+ + 0 +
268510288
+ HBIMEBEIAAA= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 10552 + + 0 + +
+
+
+ + 10440 + 40 + + + 0x0000288C + 0x00002920 + 0x00002894 + 0x00002924 + 0x000028A0 + 0x00002928 + 0x000028AC + 0x0000292E + 0x000028C0 + 0x00002932 + +
+
+ + 10484 + 14 + + +
+
+ + 10568 + 84 + + +
+
+ + 10512 + 15 + + + GenericFunctions.GenericFunctions + .<Module> + GenericFunctions.UserDefinedStruct + GenericFunctions.UserDefinedClass + +
+
+ + 10498 + 11 + + +
+
+ + 10652 + 41 + + +
+
+ + 5 + + + .ctor + GenericFunctions.UserDefinedStruct..ctor(Int32) + false + GenericFunctions.UserDefinedStruct + 100663297 + 0 + + + + 1 + + 10380 + 0 + 10528 + 0 + + + + + + + .ctor + GenericFunctions.UserDefinedClass..ctor(Int32) + false + GenericFunctions.UserDefinedClass + 100663298 + 1 + + + + 2 + + 10388 + 0 + 10532 + 0 + + + + + + + Main + GenericFunctions.GenericFunctions.Main(String[]) + false + GenericFunctions.GenericFunctions + 100663300 + 3 + + + 2 + 0 + + + + + + 4 + + 10412 + 0 + 10542 + 0 + + + + + + + .ctor + GenericFunctions.GenericFunctions..ctor() + false + GenericFunctions.GenericFunctions + 100663301 + 4 + + + + 5 + + 10432 + 0 + 10546 + 0 + + + + + + + GenericFunction + GenericFunctions.GenericFunctions.GenericFunction<__Canon, __Canon>(__Canon, __Canon) + true + GenericFunctions.GenericFunctions + 100663299 + 2 + + + + 3 + + 10400 + 0 + 10536 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml new file mode 100644 index 000000000000..2f9bbef1a421 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/HelloWorld.xml @@ -0,0 +1,225 @@ + + + + HelloWorld.ni.dll + true + I386 + 268500992 + +
+ + 8952 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9136 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9076 + 60 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9264 + + + 0 +
0
+ GgEaCDPAagI= +
+
+ 0 +
+ + 0 +
0
+ GgEaCDPAagI= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_STRING_HANDLE + 4 + 10188 + + 0 + + + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 4 + 9292 + + + 0 +
268510268
+ FQT/////EAE= +
+
+ 10172 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3004 + +
+ + 0 +
268510268
+ FQT/////EAE= +
+
+
+
+ + 10124 + 16 + + + 0x00002770 + 0x000027C4 + 0x00002784 + 0x000027C8 + +
+
+ + 10144 + 10 + + +
+
+ + 10200 + 31 + + +
+
+ + 9276 + 16 + + +
+
+ + 10160 + 9 + + + HelloWorld.HelloWorld + .<Module> + +
+
+ + 10154 + 3 + + +
+
+ + 10232 + 13 + + +
+
+ + 2 + + + Main + HelloWorld.HelloWorld.Main(String[]) + false + HelloWorld.HelloWorld + 100663297 + 0 + + + 1 + 0 + + + + + + 1 + + 10096 + 0 + 10180 + 0 + + + + + + + .ctor + HelloWorld.HelloWorld..ctor() + false + HelloWorld.HelloWorld + 100663298 + 1 + + + + 2 + + 10116 + 0 + 10184 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml new file mode 100644 index 000000000000..64ae247527a5 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Checked/MultipleRuntimeFunctions.xml @@ -0,0 +1,155 @@ + + + + MultipleRuntimeFunctions.ni.dll + true + I386 + 268500992 + +
+ + 9016 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9128 + 20 + + + + 4 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEAAP////8= +
+
+ 0 +
+ + 0 +
0
+ GgEAAP////8= +
+
+
+
+ + 10032 + 16 + + + 0x00002720 + 0x0000275C + 0x00002728 + 0x0000275C + +
+
+ + 10052 + 8 + + +
+
+ + 10084 + 27 + + +
+
+ + 10064 + 9 + + + MultipleRuntimeFunctions.MultipleRuntimeFunctions + .<Module> + +
+
+ + 10060 + 3 + + +
+
+ + 10112 + 13 + + +
+
+ + 2 + + + Main + MultipleRuntimeFunctions.MultipleRuntimeFunctions.Main(String[]) + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663297 + 0 + + + + 1 + + 10016 + 0 + 10076 + 0 + + + + + + + .ctor + MultipleRuntimeFunctions.MultipleRuntimeFunctions..ctor() + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663298 + 1 + + + + 2 + + 10024 + 0 + 10076 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml new file mode 100644 index 000000000000..a9ede3175eaa --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GcInfoTransitions.xml @@ -0,0 +1,233 @@ + + + + GcInfoTransitions.ni.dll + true + I386 + 268500992 + +
+ + 8984 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9108 + 40 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEaCDPAagE= +
+
+ 0 +
+ + 0 +
0
+ GgEaCDPAagE= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 4 + 9304 + + + 0 +
268510280
+ FQQAAP////8= +
+
+ 10412 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3244 + +
+ + 0 +
268510280
+ FQQAAP////8= +
+
+
+
+ + 10344 + 24 + + + 0x000027D8 + 0x000028B4 + 0x000027E0 + 0x000028B8 + 0x00002860 + 0x000028B4 + +
+
+ + 10372 + 10 + + +
+
+ + 10440 + 63 + + +
+
+ + 9288 + 16 + + +
+
+ + 10400 + 9 + + + GcInfoTransitions.GcInfoTransitions + .<Module> + +
+
+ + 10382 + 3 + + +
+
+ + 10504 + 22 + + +
+
+ + 3 + + + abc + GcInfoTransitions.GcInfoTransitions.abc(String) + false + GcInfoTransitions.GcInfoTransitions + 100663297 + 0 + + + + 1 + + 10200 + 0 + 10420 + 0 + + + + + + + Main + GcInfoTransitions.GcInfoTransitions.Main(String[]) + false + GcInfoTransitions.GcInfoTransitions + 100663298 + 1 + + + + 2 + + 10208 + 0 + 10424 + 0 + + + + + + + .ctor + GcInfoTransitions.GcInfoTransitions..ctor() + false + GcInfoTransitions.GcInfoTransitions + 100663299 + 2 + + + + 3 + + 10336 + 0 + 10420 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml new file mode 100644 index 000000000000..4e37c5b60aff --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/GenericFunctions.xml @@ -0,0 +1,261 @@ + + + + GenericFunctions.ni.dll + true + I386 + 268500992 + +
+ + 8984 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9156 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9096 + 60 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9284 + + + 0 +
0
+ GgEaEDPAagE= +
+
+ 0 +
+ + 0 +
0
+ GgEaEDPAagE= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 4 + 9312 + + + 0 +
268510288
+ HBIMEBEIAAA= +
+
+ 0 +
+ + 0 +
268510288
+ HBIMEBEIAAA= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 10552 + + 0 + +
+
+
+ + 10440 + 40 + + + 0x0000288C + 0x00002920 + 0x00002894 + 0x00002924 + 0x000028A0 + 0x00002928 + 0x000028AC + 0x0000292E + 0x000028C0 + 0x00002932 + +
+
+ + 10484 + 14 + + +
+
+ + 10568 + 84 + + +
+
+ + 10512 + 15 + + + GenericFunctions.GenericFunctions + .<Module> + GenericFunctions.UserDefinedStruct + GenericFunctions.UserDefinedClass + +
+
+ + 10498 + 11 + + +
+
+ + 10652 + 41 + + +
+
+ + 5 + + + .ctor + GenericFunctions.UserDefinedStruct..ctor(Int32) + false + GenericFunctions.UserDefinedStruct + 100663297 + 0 + + + + 1 + + 10380 + 0 + 10528 + 0 + + + + + + + .ctor + GenericFunctions.UserDefinedClass..ctor(Int32) + false + GenericFunctions.UserDefinedClass + 100663298 + 1 + + + + 2 + + 10388 + 0 + 10532 + 0 + + + + + + + Main + GenericFunctions.GenericFunctions.Main(String[]) + false + GenericFunctions.GenericFunctions + 100663300 + 3 + + + 2 + 0 + + + + + + 4 + + 10412 + 0 + 10542 + 0 + + + + + + + .ctor + GenericFunctions.GenericFunctions..ctor() + false + GenericFunctions.GenericFunctions + 100663301 + 4 + + + + 5 + + 10432 + 0 + 10546 + 0 + + + + + + + GenericFunction + GenericFunctions.GenericFunctions.GenericFunction<__Canon, __Canon>(__Canon, __Canon) + true + GenericFunctions.GenericFunctions + 100663299 + 2 + + + + 3 + + 10400 + 0 + 10536 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml new file mode 100644 index 000000000000..2f9bbef1a421 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/HelloWorld.xml @@ -0,0 +1,225 @@ + + + + HelloWorld.ni.dll + true + I386 + 268500992 + +
+ + 8952 + 124 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 9 +
+ + 9136 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9076 + 60 + + + + 8 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9264 + + + 0 +
0
+ GgEaCDPAagI= +
+
+ 0 +
+ + 0 +
0
+ GgEaCDPAagI= +
+ + 4 + CORCOMPILE_IMPORT_FLAGS_UNKNOWN + CORCOMPILE_IMPORT_TYPE_STRING_HANDLE + 4 + 10188 + + 0 + + + 4 + CORCOMPILE_IMPORT_FLAGS_PCODE + CORCOMPILE_IMPORT_TYPE_STUB_DISPATCH + 4 + 9292 + + + 0 +
268510268
+ FQT/////EAE= +
+
+ 10172 + + 2 + 0 + RT_Object + 0 + 0 + -1 + -1 + -1 + -1 + 4294967295 + 4294967295 + -1 + 0 + 0 + 0 + + + + 0 + 0 + 0 + 0 + + + 22 + 3004 + +
+ + 0 +
268510268
+ FQT/////EAE= +
+
+
+
+ + 10124 + 16 + + + 0x00002770 + 0x000027C4 + 0x00002784 + 0x000027C8 + +
+
+ + 10144 + 10 + + +
+
+ + 10200 + 31 + + +
+
+ + 9276 + 16 + + +
+
+ + 10160 + 9 + + + HelloWorld.HelloWorld + .<Module> + +
+
+ + 10154 + 3 + + +
+
+ + 10232 + 13 + + +
+
+ + 2 + + + Main + HelloWorld.HelloWorld.Main(String[]) + false + HelloWorld.HelloWorld + 100663297 + 0 + + + 1 + 0 + + + + + + 1 + + 10096 + 0 + 10180 + 0 + + + + + + + .ctor + HelloWorld.HelloWorld..ctor() + false + HelloWorld.HelloWorld + 100663298 + 1 + + + + 2 + + 10116 + 0 + 10184 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml new file mode 100644 index 000000000000..64ae247527a5 --- /dev/null +++ b/tests/src/readytorun/r2rdump/files/Windows_NT.x86.Release/MultipleRuntimeFunctions.xml @@ -0,0 +1,155 @@ + + + + MultipleRuntimeFunctions.ni.dll + true + I386 + 268500992 + +
+ + 9016 + 112 + RTR + 5395538 + 2 + 2 + 3 + +
+ + 8 +
+ + 9148 + 37 + + + CoreCLR 4.5.30319.0 __BUILDMACHINE__ + +
+
+ + 9128 + 20 + + + + 4 + CORCOMPILE_IMPORT_FLAGS_EAGER + CORCOMPILE_IMPORT_TYPE_UNKNOWN + 0 + 9276 + + + 0 +
0
+ GgEAAP////8= +
+
+ 0 +
+ + 0 +
0
+ GgEAAP////8= +
+
+
+
+ + 10032 + 16 + + + 0x00002720 + 0x0000275C + 0x00002728 + 0x0000275C + +
+
+ + 10052 + 8 + + +
+
+ + 10084 + 27 + + +
+
+ + 10064 + 9 + + + MultipleRuntimeFunctions.MultipleRuntimeFunctions + .<Module> + +
+
+ + 10060 + 3 + + +
+
+ + 10112 + 13 + + +
+
+ + 2 + + + Main + MultipleRuntimeFunctions.MultipleRuntimeFunctions.Main(String[]) + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663297 + 0 + + + + 1 + + 10016 + 0 + 10076 + 0 + + + + + + + .ctor + MultipleRuntimeFunctions.MultipleRuntimeFunctions..ctor() + false + MultipleRuntimeFunctions.MultipleRuntimeFunctions + 100663298 + 1 + + + + 2 + + 10024 + 0 + 10076 + 0 + + + + + +
\ No newline at end of file diff --git a/tests/src/tracing/common/RuntimeEventSource.cs b/tests/src/tracing/common/RuntimeEventSource.cs new file mode 100644 index 000000000000..8518187d9e0e --- /dev/null +++ b/tests/src/tracing/common/RuntimeEventSource.cs @@ -0,0 +1,52 @@ +using System; +using System.Diagnostics.Tracing; +using System.Reflection; + +namespace Tracing.Tests.Common +{ + public static class RuntimeEventSource + { + private static FieldInfo m_staticLogField; + + public static EventSource Log + { + get + { + return (EventSource) m_staticLogField.GetValue(null); + } + } + + static RuntimeEventSource() + { + if(!Initialize()) + { + throw new InvalidOperationException("Reflection failed."); + } + } + + private static bool Initialize() + { + Assembly SPC = typeof(System.Diagnostics.Tracing.EventSource).Assembly; + if(SPC == null) + { + Console.WriteLine("System.Private.CoreLib assembly == null"); + return false; + } + Type runtimeEventSourceType = SPC.GetType("System.Diagnostics.Tracing.RuntimeEventSource"); + if(runtimeEventSourceType == null) + { + Console.WriteLine("System.Diagnostics.Tracing.RuntimeEventSource type == null"); + return false; + } + m_staticLogField = runtimeEventSourceType.GetField("Log", BindingFlags.NonPublic | BindingFlags.Static); + if(m_staticLogField == null) + { + Console.WriteLine("RuntimeEventSource.Log field == null"); + return false; + } + + return true; + } + + } +} diff --git a/tests/src/tracing/common/common.csproj b/tests/src/tracing/common/common.csproj index 32a210882cbc..3fb7cc1b9dd5 100644 --- a/tests/src/tracing/common/common.csproj +++ b/tests/src/tracing/common/common.csproj @@ -28,6 +28,7 @@ +
diff --git a/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs b/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs new file mode 100644 index 000000000000..94d358515fb2 --- /dev/null +++ b/tests/src/tracing/runtimeeventsource/RuntimeEventSourceTest.cs @@ -0,0 +1,91 @@ +using System; +using System.IO; +using System.Diagnostics.Tracing; +using System.Runtime.CompilerServices; +using System.Threading; +using Tracing.Tests.Common; + +namespace Tracing.Tests +{ + public sealed class RuntimeEventSourceTest + { + static int Main(string[] args) + { + // Get the RuntimeEventSource. + EventSource eventSource = RuntimeEventSource.Log; + + using (SimpleEventListener noEventsListener = new SimpleEventListener("NoEvents")) + { + // Enable the provider, but not any keywords, so we should get no events as long as no rundown occurs. + noEventsListener.EnableEvents(eventSource, EventLevel.Critical, (EventKeywords)(0)); + + // Create an EventListener. + using (SimpleEventListener listener = new SimpleEventListener("Simple")) + { + // Trigger the allocator task. + System.Threading.Tasks.Task.Run(new Action(Allocator)); + + // Enable events. + listener.EnableEvents(eventSource, EventLevel.Verbose, (EventKeywords)(0x4c14fccbd)); + + // Wait for events. + Thread.Sleep(1000); + + // Generate some GC events. + GC.Collect(2, GCCollectionMode.Forced); + + // Wait for more events. + Thread.Sleep(1000); + + // Ensure that we've seen some events. + Assert.True("listener.EventCount > 0", listener.EventCount > 0); + } + + // Generate some more GC events. + GC.Collect(2, GCCollectionMode.Forced); + + // Ensure that we've seen no events. + Assert.True("noEventsListener.EventCount == 0", noEventsListener.EventCount == 0); + } + + return 100; + } + + private static void Allocator() + { + while (true) + { + for(int i=0; i<1000; i++) + GC.KeepAlive(new object()); + + Thread.Sleep(10); + } + } + } + + internal sealed class SimpleEventListener : EventListener + { + private string m_name; + + public SimpleEventListener(string name) + { + m_name = name; + } + + public int EventCount { get; private set; } = 0; + + protected override void OnEventWritten(EventWrittenEventArgs eventData) + { + Console.WriteLine($"[{m_name}] ID = {eventData.EventId} Name = {eventData.EventName}"); + for (int i = 0; i < eventData.Payload.Count; i++) + { + string payloadString = eventData.Payload[i] != null ? eventData.Payload[i].ToString() : string.Empty; + Console.WriteLine($"\tName = \"{eventData.PayloadNames[i]}\" Value = \"{payloadString}\""); + } + Console.WriteLine("\n"); + + + EventCount++; + } + } +} diff --git a/tests/src/Interop/ClassicCOM/COMLib.csproj b/tests/src/tracing/runtimeeventsource/runtimeeventsource.csproj similarity index 70% rename from tests/src/Interop/ClassicCOM/COMLib.csproj rename to tests/src/tracing/runtimeeventsource/runtimeeventsource.csproj index 1f289d672991..08da1e84e00a 100644 --- a/tests/src/Interop/ClassicCOM/COMLib.csproj +++ b/tests/src/tracing/runtimeeventsource/runtimeeventsource.csproj @@ -1,16 +1,19 @@ - + Debug AnyCPU - COMLib 2.0 - {5FEE5C46-8DD9-49FA-BDC1-AF22867A0704} - library - {CDC3DF7E-04B4-4464-9A02-7E2B0FAB586A};{68EC03EE-C9EE-47FD-AA08-A954EB2D9816} + {8E3244CB-407F-4142-BAAB-E7A55901A5FA} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} ..\..\ + BuildAndRun $(DefineConstants);STATIC + true + 0 + true @@ -23,10 +26,8 @@ - - - - + + diff --git a/tests/src/tracing/tracevalidation/jittingstarted/JittingStarted.csproj b/tests/src/tracing/tracevalidation/jittingstarted/JittingStarted.csproj index 36f962356684..a2bb4c49df0c 100644 --- a/tests/src/tracing/tracevalidation/jittingstarted/JittingStarted.csproj +++ b/tests/src/tracing/tracevalidation/jittingstarted/JittingStarted.csproj @@ -12,6 +12,7 @@ BuildAndRun $(DefineConstants);STATIC 0 + true @@ -26,4 +27,4 @@ - \ No newline at end of file + diff --git a/tests/src/tracing/tracevalidation/rundown/rundown.csproj b/tests/src/tracing/tracevalidation/rundown/rundown.csproj index c7314c86a81e..58563897c59b 100644 --- a/tests/src/tracing/tracevalidation/rundown/rundown.csproj +++ b/tests/src/tracing/tracevalidation/rundown/rundown.csproj @@ -12,6 +12,7 @@ BuildAndRun $(DefineConstants);STATIC 0 + true @@ -26,4 +27,4 @@ - \ No newline at end of file + diff --git a/tests/tests.targets b/tests/tests.targets index 8f00fd749956..9a16cb0e0bd2 100644 --- a/tests/tests.targets +++ b/tests/tests.targets @@ -1,8 +1,6 @@ - - <_SkipTestAssemblies Include="$(SkipTestAssemblies)" /> @@ -26,10 +24,6 @@ - - @@ -37,20 +31,28 @@ category=outerloop;category=failing - true + all - + + + $(CORE_ROOT)\xunit.console.dll + + -parallel $(ParallelRun) + $(XunitArgs) -html $(__TestRunHtmlLog) + $(XunitArgs) -xml $(__TestRunXmlLog) + $(XunitArgs) @(IncludeTraitsItems->'-trait %(Identity)', ' ') + $(XunitArgs) @(ExcludeTraitsItems->'-notrait %(Identity)', ' ') + + $(CORE_ROOT)\corerun + $(CORE_ROOT)\corerun.exe + $(CorerunExecutable) $(XunitConsoleRunner) @(TestAssemblies->'%(Identity)', ' ') $(XunitArgs) + + diff --git a/tests/testsFailing.arm.txt b/tests/testsFailing.arm.txt index 1843b0a7e9f2..b8d8e80b0419 100644 --- a/tests/testsFailing.arm.txt +++ b/tests/testsFailing.arm.txt @@ -1,3 +1,5 @@ GC/API/GC/GetAllocatedBytesForCurrentThread/GetAllocatedBytesForCurrentThread.sh GC/Scenarios/LeakWheel/leakwheel/leakwheel.sh -CoreMangLib/system/span/SlowTailCallArgs/SlowTailCallArgs.sh \ No newline at end of file +CoreMangLib/system/span/SlowTailCallArgs/SlowTailCallArgs.sh +# b65423 tracking bug: https://github.com/dotnet/coreclr/issues/18441 +JIT/Regression/CLR-x86-JIT/V1-M12-Beta2/b65423/b65423/b65423.sh diff --git a/tests/testsFailingOutsideWindows.txt b/tests/testsFailingOutsideWindows.txt index 4be1aea8c45b..72e6eb8539f9 100644 --- a/tests/testsFailingOutsideWindows.txt +++ b/tests/testsFailingOutsideWindows.txt @@ -1,7 +1,6 @@ baseservices/threading/paramthreadstart/ThreadStartString_1/ThreadStartString_1.sh CoreMangLib/cti/system/multicastdelegate/MulticastDelegateCtor/MulticastDelegateCtor.sh CoreMangLib/cti/system/runtime/interopservices/marshal/MarshalGetLastWin32Error_PSC/MarshalGetLastWin32Error_PSC.sh -JIT/Directed/StructABI/StructABI/StructABI.sh JIT/Directed/UnrollLoop/loop6_cs_d/loop6_cs_d.sh JIT/Directed/UnrollLoop/loop6_cs_do/loop6_cs_do.sh JIT/Directed/UnrollLoop/loop6_cs_r/loop6_cs_r.sh diff --git a/tests/testsUnsupportedOutsideWindows.txt b/tests/testsUnsupportedOutsideWindows.txt index e9a7c6632b3b..d4928b20aae3 100644 --- a/tests/testsUnsupportedOutsideWindows.txt +++ b/tests/testsUnsupportedOutsideWindows.txt @@ -123,10 +123,12 @@ CoreMangLib/cti/system/reflection/emit/DynMethodJumpStubTests/DynMethodJumpStubT CoreMangLib/system/collections/generic/hashset/Regression_Dev10_609271/Regression_Dev10_609271.sh CoreMangLib/system/collections/generic/hashset/Regression_Dev10_624201/Regression_Dev10_624201.sh GC/Coverage/smalloom/smalloom.sh +Interop/COM/NETClients/Primitives/NETClientPrimitives/NETClientPrimitives.sh Interop/MarshalAPI/GetNativeVariantForObject/GetNativeVariantForObject/GetNativeVariantForObject.sh Interop/MarshalAPI/GetObjectForNativeVariant/GetObjectForNativeVariant/GetObjectForNativeVariant.sh Interop/MarshalAPI/GetObjectsForNativeVariants/GetObjectsForNativeVariants/GetObjectsForNativeVariants.sh Interop/MarshalAPI/IUnknown/IUnknownTest/IUnknownTest.sh +Interop/SizeConst/SizeConstTest/SizeConstTest.sh JIT/Directed/coverage/oldtests/callipinvoke/callipinvoke.sh JIT/Directed/coverage/oldtests/Desktop/callipinvoke_il_d/callipinvoke_il_d.sh JIT/Directed/coverage/oldtests/Desktop/callipinvoke_il_r/callipinvoke_il_r.sh @@ -338,6 +340,6 @@ JIT/Regression/VS-ia64-JIT/V1.2-M02/b12011/b12011/b12011.sh JIT/Regression/VS-ia64-JIT/V2.0-Beta2/b410474/b410474/b410474.sh JIT/Regression/VS-ia64-JIT/V2.0-RTM/b286991/b286991/b286991.sh managed/Compilation/Compilation/Compilation.sh +readytorun/r2rdump/R2RDumpTest/R2RDumpTest.sh Regressions/coreclr/0584/Test584/Test584.sh -Interop/SizeConst/SizeConstTest/SizeConstTest.sh tracing/eventsource/eventpipeandetw/eventpipeandetw/eventpipeandetw.sh diff --git a/tests/xunitwrapper.targets b/tests/xunitwrapper.targets deleted file mode 100644 index a0ff7f59fa2d..000000000000 --- a/tests/xunitwrapper.targets +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - - - - - - <_ProjectReferenceFilenames Include="@(_ResolvedProjectReferencePaths->'%(FileName)%(Extension)')"> - %(Identity) - - - <_ReferencesFileNames Include="@(Reference->'%(FileName)%(Extension)')"> - %(Identity) - - - <_CopyLocalFileNames Include="@(CopyLocal->'%(FileName)%(Extension)')"> - %(Identity) - - - - <_ReferenceFileNamesToRemove Include="@(_ReferencesFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_ReferencesFileNames)' and '%(Identity)' != ''"/> - <_CopyLocalFileNamesToRemove Include="@(_CopyLocalFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_CopyLocalFileNames)' and '%(Identity)' != ''"/> - - - - - - - - - - - - - -